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
j-carpentier/nova
nova/tests/unit/cells/test_cells_weights.py
17
9058
# Copyright (c) 2012 OpenStack Foundation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ Unit Tests for testing the cells weight algorithms. Cells with higher weights should be given priority for new builds. """ import datetime from oslo_utils import timeutils from nova.cells import state from nova.cells import weights from nova import test class FakeCellState(state.CellState): def __init__(self, cell_name): super(FakeCellState, self).__init__(cell_name) self.capacities['ram_free'] = {'total_mb': 0, 'units_by_mb': {}} self.db_info = {} def _update_ram_free(self, *args): ram_free = self.capacities['ram_free'] for ram_size, units in args: ram_free['total_mb'] += units * ram_size ram_free['units_by_mb'][str(ram_size)] = units def _get_fake_cells(): cell1 = FakeCellState('cell1') cell1._update_ram_free((512, 1), (1024, 4), (2048, 3)) cell1.db_info['weight_offset'] = -200.0 cell2 = FakeCellState('cell2') cell2._update_ram_free((512, 2), (1024, 3), (2048, 4)) cell2.db_info['weight_offset'] = -200.1 cell3 = FakeCellState('cell3') cell3._update_ram_free((512, 3), (1024, 2), (2048, 1)) cell3.db_info['weight_offset'] = 400.0 cell4 = FakeCellState('cell4') cell4._update_ram_free((512, 4), (1024, 1), (2048, 2)) cell4.db_info['weight_offset'] = 300.0 return [cell1, cell2, cell3, cell4] class CellsWeightsTestCase(test.NoDBTestCase): """Makes sure the proper weighers are in the directory.""" def test_all_weighers(self): weighers = weights.all_weighers() # Check at least a couple that we expect are there self.assertTrue(len(weighers) >= 2) class_names = [cls.__name__ for cls in weighers] self.assertIn('WeightOffsetWeigher', class_names) self.assertIn('RamByInstanceTypeWeigher', class_names) class _WeigherTestClass(test.NoDBTestCase): """Base class for testing individual weigher plugins.""" weigher_cls_name = None def setUp(self): super(_WeigherTestClass, self).setUp() self.weight_handler = weights.CellWeightHandler() weigher_classes = self.weight_handler.get_matching_classes( [self.weigher_cls_name]) self.weighers = [cls() for cls in weigher_classes] def _get_weighed_cells(self, cells, weight_properties): return self.weight_handler.get_weighed_objects(self.weighers, cells, weight_properties) class RAMByInstanceTypeWeigherTestClass(_WeigherTestClass): weigher_cls_name = ('nova.cells.weights.ram_by_instance_type.' 'RamByInstanceTypeWeigher') def test_default_spreading(self): """Test that cells with more ram available return a higher weight.""" cells = _get_fake_cells() # Simulate building a new 512MB instance. instance_type = {'memory_mb': 512} weight_properties = {'request_spec': {'instance_type': instance_type}} weighed_cells = self._get_weighed_cells(cells, weight_properties) self.assertEqual(4, len(weighed_cells)) resulting_cells = [weighed_cell.obj for weighed_cell in weighed_cells] expected_cells = [cells[3], cells[2], cells[1], cells[0]] self.assertEqual(expected_cells, resulting_cells) # Simulate building a new 1024MB instance. instance_type = {'memory_mb': 1024} weight_properties = {'request_spec': {'instance_type': instance_type}} weighed_cells = self._get_weighed_cells(cells, weight_properties) self.assertEqual(4, len(weighed_cells)) resulting_cells = [weighed_cell.obj for weighed_cell in weighed_cells] expected_cells = [cells[0], cells[1], cells[2], cells[3]] self.assertEqual(expected_cells, resulting_cells) # Simulate building a new 2048MB instance. instance_type = {'memory_mb': 2048} weight_properties = {'request_spec': {'instance_type': instance_type}} weighed_cells = self._get_weighed_cells(cells, weight_properties) self.assertEqual(4, len(weighed_cells)) resulting_cells = [weighed_cell.obj for weighed_cell in weighed_cells] expected_cells = [cells[1], cells[0], cells[3], cells[2]] self.assertEqual(expected_cells, resulting_cells) def test_negative_multiplier(self): """Test that cells with less ram available return a higher weight.""" self.flags(ram_weight_multiplier=-1.0, group='cells') cells = _get_fake_cells() # Simulate building a new 512MB instance. instance_type = {'memory_mb': 512} weight_properties = {'request_spec': {'instance_type': instance_type}} weighed_cells = self._get_weighed_cells(cells, weight_properties) self.assertEqual(4, len(weighed_cells)) resulting_cells = [weighed_cell.obj for weighed_cell in weighed_cells] expected_cells = [cells[0], cells[1], cells[2], cells[3]] self.assertEqual(expected_cells, resulting_cells) # Simulate building a new 1024MB instance. instance_type = {'memory_mb': 1024} weight_properties = {'request_spec': {'instance_type': instance_type}} weighed_cells = self._get_weighed_cells(cells, weight_properties) self.assertEqual(4, len(weighed_cells)) resulting_cells = [weighed_cell.obj for weighed_cell in weighed_cells] expected_cells = [cells[3], cells[2], cells[1], cells[0]] self.assertEqual(expected_cells, resulting_cells) # Simulate building a new 2048MB instance. instance_type = {'memory_mb': 2048} weight_properties = {'request_spec': {'instance_type': instance_type}} weighed_cells = self._get_weighed_cells(cells, weight_properties) self.assertEqual(4, len(weighed_cells)) resulting_cells = [weighed_cell.obj for weighed_cell in weighed_cells] expected_cells = [cells[2], cells[3], cells[0], cells[1]] self.assertEqual(expected_cells, resulting_cells) class WeightOffsetWeigherTestClass(_WeigherTestClass): """Test the RAMWeigher class.""" weigher_cls_name = 'nova.cells.weights.weight_offset.WeightOffsetWeigher' def test_weight_offset(self): """Test that cells with higher weight_offsets return higher weights. """ cells = _get_fake_cells() weighed_cells = self._get_weighed_cells(cells, {}) self.assertEqual(4, len(weighed_cells)) expected_cells = [cells[2], cells[3], cells[0], cells[1]] resulting_cells = [weighed_cell.obj for weighed_cell in weighed_cells] self.assertEqual(expected_cells, resulting_cells) class MuteWeigherTestClass(_WeigherTestClass): weigher_cls_name = 'nova.cells.weights.mute_child.MuteChildWeigher' def setUp(self): super(MuteWeigherTestClass, self).setUp() self.flags(mute_weight_multiplier=-10.0, mute_child_interval=100, group='cells') self.now = timeutils.utcnow() timeutils.set_time_override(self.now) self.cells = _get_fake_cells() for cell in self.cells: cell.last_seen = self.now def tearDown(self): super(MuteWeigherTestClass, self).tearDown() timeutils.clear_time_override() def test_non_mute(self): weight_properties = {} weighed_cells = self._get_weighed_cells(self.cells, weight_properties) self.assertEqual(4, len(weighed_cells)) for weighed_cell in weighed_cells: self.assertEqual(0, weighed_cell.weight) def test_mutes(self): # make 2 of them mute: self.cells[0].last_seen = (self.cells[0].last_seen - datetime.timedelta(seconds=200)) self.cells[1].last_seen = (self.cells[1].last_seen - datetime.timedelta(seconds=200)) weight_properties = {} weighed_cells = self._get_weighed_cells(self.cells, weight_properties) self.assertEqual(4, len(weighed_cells)) for i in range(2): weighed_cell = weighed_cells.pop(0) self.assertEqual(0, weighed_cell.weight) self.assertIn(weighed_cell.obj.name, ['cell3', 'cell4']) for i in range(2): weighed_cell = weighed_cells.pop(0) self.assertEqual(-10.0, weighed_cell.weight) self.assertIn(weighed_cell.obj.name, ['cell1', 'cell2'])
apache-2.0
[ 3, 1898, 334, 67, 9, 6029, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 624, 199, 5072, 6496, 367, 5343, 314, 10106, 5401, 18036, 14, 199, 199, 16852, 543, 10948, 4931, 1077, 506, 1627, 7464, 367, 892, 14723, 14, 199, 624, 199, 199, 646, 2197, 199, 199, 504, 11258, 63, 1208, 492, 23011, 199, 199, 504, 5913, 14, 9041, 492, 1174, 199, 504, 5913, 14, 9041, 492, 4931, 199, 504, 5913, 492, 511, 421, 199, 533, 7777, 8108, 2223, 8, 929, 14, 8108, 2223, 304, 272, 347, 636, 826, 721, 277, 12, 4917, 63, 354, 304, 267, 1613, 8, 8249, 8108, 2223, 12, 291, 2843, 826, 721, 3890, 63, 354, 9, 267, 291, 14, 18182, 18207, 459, 5975, 63, 4624, 418, 275, 791, 2923, 63, 887, 356, 378, 12, 4318, 283, 5260, 63, 991, 63, 887, 356, 24312, 267, 291, 14, 697, 63, 815, 275, 1052, 339, 347, 485, 873, 63, 5975, 63, 4624, 8, 277, 12, 627, 589, 304, 267, 21394, 63, 4624, 275, 291, 14, 18182, 18207, 459, 5975, 63, 4624, 418, 267, 367, 21394, 63, 890, 12, 6204, 315, 1249, 26, 288, 21394, 63, 4624, 459, 2923, 63, 887, 418, 847, 6204, 627, 21394, 63, 890, 288, 21394, 63, 4624, 459, 5260, 63, 991, 63, 887, 3488, 495, 8, 5975, 63, 890, 1874, 275, 6204, 421, 199, 318, 485, 362, 63, 3183, 63, 9041, 837, 339, 4917, 17, 275, 7777, 8108, 2223, 360, 3890, 17, 358, 272, 4917, 17, 423, 873, 63, 5975, 63, 4624, 1332, 7736, 12, 413, 395, 334, 7727, 12, 841, 395, 334, 18343, 12, 650, 430, 272, 4917, 17, 14, 697, 63, 815, 459, 3463, 63, 2743, 418, 275, 446, 1840, 14, 16, 272, 4917, 18, 275, 7777, 8108, 2223, 360, 3890, 18, 358, 272, 4917, 18, 423, 873, 63, 5975, 63, 4624, 1332, 7736, 12, 499, 395, 334, 7727, 12, 650, 395, 334, 18343, 12, 841, 430, 272, 4917, 18, 14, 697, 63, 815, 459, 3463, 63, 2743, 418, 275, 446, 1840, 14, 17, 272, 4917, 19, 275, 7777, 8108, 2223, 360, 3890, 19, 358, 272, 4917, 19, 423, 873, 63, 5975, 63, 4624, 1332, 7736, 12, 650, 395, 334, 7727, 12, 499, 395, 334, 18343, 12, 413, 430, 272, 4917, 19, 14, 697, 63, 815, 459, 3463, 63, 2743, 418, 275, 8290, 14, 16, 272, 4917, 20, 275, 7777, 8108, 2223, 360, 3890, 20, 358, 272, 4917, 20, 423, 873, 63, 5975, 63, 4624, 1332, 7736, 12, 841, 395, 334, 7727, 12, 413, 395, 334, 18343, 12, 499, 430, 272, 4917, 20, 14, 697, 63, 815, 459, 3463, 63, 2743, 418, 275, 9601, 14, 16, 339, 372, 359, 3890, 17, 12, 4917, 18, 12, 4917, 19, 12, 4917, 20, 61, 421, 199, 533, 445, 6840, 23885, 1746, 8, 396, 14, 32437, 304, 272, 408, 27142, 3238, 314, 5576, 781, 2056, 1192, 787, 315, 314, 2082, 1041, 339, 347, 511, 63, 452, 63, 1129, 2056, 1192, 8, 277, 304, 267, 781, 2056, 1192, 275, 4931, 14, 452, 63, 1129, 2056, 1192, 342, 267, 327, 2670, 737, 5210, 282, 17535, 626, 781, 4282, 787, 2337, 267, 291, 14, 1815, 8, 552, 8, 1129, 2056, 1192, 9, 2356, 499, 9, 267, 1021, 63, 1247, 275, 359, 1886, 855, 354, 363, 367, 843, 315, 781, 2056, 1192, 61, 267, 291, 14, 4080, 360, 16359, 6397, 6004, 2056, 281, 297, 1021, 63, 1247, 9, 267, 291, 14, 4080, 360, 50, 455, 2175, 3244, 804, 6004, 2056, 281, 297, 1021, 63, 1247, 9, 421, 199, 533, 485, 6004, 2056, 281, 22009, 8, 396, 14, 32437, 304, 272, 408, 1563, 1021, 367, 5343, 8212, 781, 2056, 281, 8963, 1041, 272, 781, 2056, 281, 63, 1886, 63, 354, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 1613, 1547, 6004, 2056, 281, 22009, 12, 291, 680, 5996, 342, 267, 291, 14, 3463, 63, 2232, 275, 4931, 14, 8108, 16359, 2461, 342, 267, 781, 2056, 281, 63, 2888, 275, 291, 14, 3463, 63, 2232, 14, 362, 63, 9467, 63, 2888, 8, 355, 359, 277, 14, 1129, 2056, 281, 63, 1886, 63, 354, 566, 267, 291, 14, 1129, 2056, 1192, 275, 359, 1886, 342, 367, 843, 315, 781, 2056, 281, 63, 2888, 61, 339, 347, 485, 362, 63, 1129, 2056, 379, 63, 9041, 8, 277, 12, 10106, 12, 5401, 63, 3282, 304, 267, 372, 291, 14, 3463, 63, 2232, 14, 362, 63, 1129, 2056, 379, 63, 1462, 8, 277, 14, 1129, 2056, 1192, 12, 355, 10106, 12, 5401, 63, 3282, 9, 421, 199, 533, 30207, 2175, 3244, 804, 6004, 2056, 281, 22009, 1547, 6004, 2056, 281, 22009, 304, 339, 781, 2056, 281, 63, 1886, 63, 354, 275, 661, 6765, 14, 9041, 14, 4916, 14, 5975, 63, 991, 63, 842, 63, 466, 3530, 717, 283, 50, 455, 2175, 3244, 804, 6004, 2056, 281, 358, 339, 347, 511, 63, 885, 63, 83, 657, 5384, 8, 277, 304, 267, 408, 774, 626, 10106, 543, 1655, 21394, 2808, 372, 282, 10948, 5401, 1041, 267, 10106, 275, 485, 362, 63, 3183, 63, 9041, 342, 267, 327, 10751, 5434, 10015, 282, 892, 10574, 4567, 1256, 14, 267, 1256, 63, 466, 275, 791, 4844, 63, 887, 356, 10574, 93, 267, 5401, 63, 3282, 275, 791, 1069, 63, 1650, 356, 791, 842, 63, 466, 356, 1256, 63, 466, 4863, 267, 781, 2056, 379, 63, 9041, 275, 291, 423, 362, 63, 1129, 2056, 379 ]
[ 1898, 334, 67, 9, 6029, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 624, 199, 5072, 6496, 367, 5343, 314, 10106, 5401, 18036, 14, 199, 199, 16852, 543, 10948, 4931, 1077, 506, 1627, 7464, 367, 892, 14723, 14, 199, 624, 199, 199, 646, 2197, 199, 199, 504, 11258, 63, 1208, 492, 23011, 199, 199, 504, 5913, 14, 9041, 492, 1174, 199, 504, 5913, 14, 9041, 492, 4931, 199, 504, 5913, 492, 511, 421, 199, 533, 7777, 8108, 2223, 8, 929, 14, 8108, 2223, 304, 272, 347, 636, 826, 721, 277, 12, 4917, 63, 354, 304, 267, 1613, 8, 8249, 8108, 2223, 12, 291, 2843, 826, 721, 3890, 63, 354, 9, 267, 291, 14, 18182, 18207, 459, 5975, 63, 4624, 418, 275, 791, 2923, 63, 887, 356, 378, 12, 4318, 283, 5260, 63, 991, 63, 887, 356, 24312, 267, 291, 14, 697, 63, 815, 275, 1052, 339, 347, 485, 873, 63, 5975, 63, 4624, 8, 277, 12, 627, 589, 304, 267, 21394, 63, 4624, 275, 291, 14, 18182, 18207, 459, 5975, 63, 4624, 418, 267, 367, 21394, 63, 890, 12, 6204, 315, 1249, 26, 288, 21394, 63, 4624, 459, 2923, 63, 887, 418, 847, 6204, 627, 21394, 63, 890, 288, 21394, 63, 4624, 459, 5260, 63, 991, 63, 887, 3488, 495, 8, 5975, 63, 890, 1874, 275, 6204, 421, 199, 318, 485, 362, 63, 3183, 63, 9041, 837, 339, 4917, 17, 275, 7777, 8108, 2223, 360, 3890, 17, 358, 272, 4917, 17, 423, 873, 63, 5975, 63, 4624, 1332, 7736, 12, 413, 395, 334, 7727, 12, 841, 395, 334, 18343, 12, 650, 430, 272, 4917, 17, 14, 697, 63, 815, 459, 3463, 63, 2743, 418, 275, 446, 1840, 14, 16, 272, 4917, 18, 275, 7777, 8108, 2223, 360, 3890, 18, 358, 272, 4917, 18, 423, 873, 63, 5975, 63, 4624, 1332, 7736, 12, 499, 395, 334, 7727, 12, 650, 395, 334, 18343, 12, 841, 430, 272, 4917, 18, 14, 697, 63, 815, 459, 3463, 63, 2743, 418, 275, 446, 1840, 14, 17, 272, 4917, 19, 275, 7777, 8108, 2223, 360, 3890, 19, 358, 272, 4917, 19, 423, 873, 63, 5975, 63, 4624, 1332, 7736, 12, 650, 395, 334, 7727, 12, 499, 395, 334, 18343, 12, 413, 430, 272, 4917, 19, 14, 697, 63, 815, 459, 3463, 63, 2743, 418, 275, 8290, 14, 16, 272, 4917, 20, 275, 7777, 8108, 2223, 360, 3890, 20, 358, 272, 4917, 20, 423, 873, 63, 5975, 63, 4624, 1332, 7736, 12, 841, 395, 334, 7727, 12, 413, 395, 334, 18343, 12, 499, 430, 272, 4917, 20, 14, 697, 63, 815, 459, 3463, 63, 2743, 418, 275, 9601, 14, 16, 339, 372, 359, 3890, 17, 12, 4917, 18, 12, 4917, 19, 12, 4917, 20, 61, 421, 199, 533, 445, 6840, 23885, 1746, 8, 396, 14, 32437, 304, 272, 408, 27142, 3238, 314, 5576, 781, 2056, 1192, 787, 315, 314, 2082, 1041, 339, 347, 511, 63, 452, 63, 1129, 2056, 1192, 8, 277, 304, 267, 781, 2056, 1192, 275, 4931, 14, 452, 63, 1129, 2056, 1192, 342, 267, 327, 2670, 737, 5210, 282, 17535, 626, 781, 4282, 787, 2337, 267, 291, 14, 1815, 8, 552, 8, 1129, 2056, 1192, 9, 2356, 499, 9, 267, 1021, 63, 1247, 275, 359, 1886, 855, 354, 363, 367, 843, 315, 781, 2056, 1192, 61, 267, 291, 14, 4080, 360, 16359, 6397, 6004, 2056, 281, 297, 1021, 63, 1247, 9, 267, 291, 14, 4080, 360, 50, 455, 2175, 3244, 804, 6004, 2056, 281, 297, 1021, 63, 1247, 9, 421, 199, 533, 485, 6004, 2056, 281, 22009, 8, 396, 14, 32437, 304, 272, 408, 1563, 1021, 367, 5343, 8212, 781, 2056, 281, 8963, 1041, 272, 781, 2056, 281, 63, 1886, 63, 354, 275, 488, 339, 347, 3613, 8, 277, 304, 267, 1613, 1547, 6004, 2056, 281, 22009, 12, 291, 680, 5996, 342, 267, 291, 14, 3463, 63, 2232, 275, 4931, 14, 8108, 16359, 2461, 342, 267, 781, 2056, 281, 63, 2888, 275, 291, 14, 3463, 63, 2232, 14, 362, 63, 9467, 63, 2888, 8, 355, 359, 277, 14, 1129, 2056, 281, 63, 1886, 63, 354, 566, 267, 291, 14, 1129, 2056, 1192, 275, 359, 1886, 342, 367, 843, 315, 781, 2056, 281, 63, 2888, 61, 339, 347, 485, 362, 63, 1129, 2056, 379, 63, 9041, 8, 277, 12, 10106, 12, 5401, 63, 3282, 304, 267, 372, 291, 14, 3463, 63, 2232, 14, 362, 63, 1129, 2056, 379, 63, 1462, 8, 277, 14, 1129, 2056, 1192, 12, 355, 10106, 12, 5401, 63, 3282, 9, 421, 199, 533, 30207, 2175, 3244, 804, 6004, 2056, 281, 22009, 1547, 6004, 2056, 281, 22009, 304, 339, 781, 2056, 281, 63, 1886, 63, 354, 275, 661, 6765, 14, 9041, 14, 4916, 14, 5975, 63, 991, 63, 842, 63, 466, 3530, 717, 283, 50, 455, 2175, 3244, 804, 6004, 2056, 281, 358, 339, 347, 511, 63, 885, 63, 83, 657, 5384, 8, 277, 304, 267, 408, 774, 626, 10106, 543, 1655, 21394, 2808, 372, 282, 10948, 5401, 1041, 267, 10106, 275, 485, 362, 63, 3183, 63, 9041, 342, 267, 327, 10751, 5434, 10015, 282, 892, 10574, 4567, 1256, 14, 267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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 ]
cfelton/pymtl
pymtl/tools/translation/cpp.py
8
33436
#======================================================================= # cpp.py #======================================================================= # Tool to translate PyMTL Models into a C simulation object. from pymtl import * from cpp_helpers import gen_cheader, gen_cdef, gen_pywrapper from ..ast_helpers import get_method_ast, print_simple_ast, print_ast from ...datatypes.SignalValue import SignalValueWrapper from ..simulation import sim_utils import sys import ast, _ast import collections import StringIO import re compiler = "g++ -O3 -fPIC -shared -o {libname} {csource}" #----------------------------------------------------------------------- # CLogicTransl #----------------------------------------------------------------------- # TODO: same as Verilog, reduce code dup def CLogicTransl( model, o=sys.stdout ): c_functions = StringIO.StringIO() c_variables = StringIO.StringIO() signals = sim_utils.collect_signals( model ) nets, _ = sim_utils.signals_to_nets( signals ) seq_blocks = sim_utils.register_seq_blocks( model ) # TODO: update translation so that this is unneeded? sim_utils.insert_signal_values( None, nets ) # Visit tick functions, save register information ast_next = [] localvars = {} for func in seq_blocks: r, l = translate_func( func, c_functions ) ast_next.extend( r ) localvars.update( l ) # Print signal declarations, use reg information top_ports, all_ports, shadows = declare_signals(nets, ast_next, c_variables) inport_names = ['top_'+mangle_name(x.name) for x in model.get_inports() ] outport_names = ['top_'+mangle_name(x.name) for x in model.get_outports()] top_inports = [] top_outports = [] for x in model.get_ports(): x.cpp_name = 'top_'+mangle_name( x.name ) # Separate input and output ports for port in top_ports: name = port[0] if name in inport_names: top_inports.append( port ) elif name in outport_names: top_outports.append( port ) #else: # raise Exception("Unknown port detected!") # print locals print >> c_variables print >> c_variables, '/* LOCALS ' + '-'*60 + '*/' for var, obj in localvars.items(): rvar = var.replace('.','_') if rvar not in all_ports: if isinstance( obj, int ): var_type = get_type( obj, o ) print >> c_variables, "{} {} = {};".format( var_type, rvar, obj ) # TODO: super hacky handling of lists elif isinstance( obj, list ): var_type = get_type( obj[0], o ) split = var.split('.') pfx = '_'.join( split[0:2] ) sfx = '_'+'_'.join( split[2:] ) if split[2:] else '' vx = [ '&{}_IDX{:03}{}'.format(pfx,i,sfx) for i in range(len(obj)) ] # Declare the variables if they don't exist yet for x in vx: if x[1:] not in all_ports: print >> c_variables, "{} {};".format( var_type, x[1:]) print >> c_variables, "{} * {}[] = {{ {} }};".format( var_type, rvar, ', '.join(vx ) ) else: var_type = get_type( obj, o ) print >> c_variables, "{} {};".format( var_type, rvar ) # Declare parameters params = [] for name, net, type_ in top_inports[:2]: params.append( ' {} _{}'.format( type_, name ) ) params .append( ' iface_t * top') params = ',\n'.join( params ) # Create the C header print >> o, '#include <stdio.h>' print >> o, '#include <assert.h>' print >> o, '#include <queue>' print >> o, '#define True true' print >> o, '#define False false' print >> o print >> o, gen_cheader( params, top_ports[2:] ) print >> o, c_variables.getvalue() print >> o, c_functions.getvalue() print >> o, 'unsigned int ncycles;\n\n' # Create the cycle function print >> o, '/* cycle */' print >> o, 'void cycle({}) {{'.format( '\n'+params+'\n' ) # Set input ports from params print >> o print >> o, ' /* Set inports */' print >> o, ' top_clk = _top_clk;' print >> o, ' top_reset = _top_reset;' for name, _, _ in top_inports[2:]: print >> o, ' {} = top->{};'.format( name, name[4:] ) # Execute all ticks print >> o print >> o, ' /* Execute all ticks */' for x in seq_blocks: print >> o, ' {}_{}();'.format( mangle_idxs(x._model.name), x.func_name) print >> o, ' ncycles++;' # Update all registers print >> o print >> o, ' /* Update all registers */' for s in shadows: print >> o, ' {0} = {0}_next;'.format( s ) # Update params from output ports print >> o print >> o, ' /* Assign all outputs */' for name, _, _ in top_outports: print >> o, ' top->{} = {};'.format( name[4:], name ) print >> o, '}' print >> o # Create the cdef and Python wrapper cdef = gen_cdef( params, top_ports[2:] ) CSimWrapper = gen_pywrapper( top_inports, top_outports ) return cdef, CSimWrapper #----------------------------------------------------------------------- # declare_signals #----------------------------------------------------------------------- def declare_signals( nets, ast_next, o ): clk_port = None reset_port = None top_ports = [] all_ports = [] shadows = [] for id_, n in enumerate( nets ): # each net is a set, convert it to a list net = list( n ) # returns the type, if it is an object/class generate the C def type_ = get_type( net[0].dtype(), o ) # TODO: add obj decl to extern # declare the net cname = 'net_{:05}'.format( id_ ) print >>o, '{} {} = 0;'.format( type_, cname); # create references for each signal connected to the net for signal in net: name = mangle_name( signal.fullname ) print >>o, '{} &{} = {};' .format( type_, name, cname ); # only create "next" if this signal was written to in @tick # NOTE: this will declare "net_next" twice if two different signals # attached to the net write next; this is okay because that is # invalid code! sig = re.sub('\[[0-9]*\]', '', signal.name) mod = mangle_idxs( signal.parent.name ) fullname = mod + '.' + sig if fullname in ast_next: print >>o, '{} {}_next = 0;' .format( type_, cname ); print >>o, '{} &{}_next = {}_next;'.format( type_, name, cname ); shadows.append( name ) all_ports.append( name+'_next' ) all_ports.append( name ) # ports attached to top will be exposed in the CSim wrapper # special case clock/reset, since they won't be exposed, want them # to be known locations in the cycle(...) function call if name == 'top_clk': clk_port = (name, cname, type_) elif name == 'top_reset': reset_port = (name, cname, type_) elif name.startswith('top'): print >>o, '{} * _{} = &{};'.format( type_, name[4:], cname ); top_ports.append( (name, cname, type_) ); top_ports = [clk_port, reset_port] + sorted(top_ports) return top_ports, all_ports, shadows #----------------------------------------------------------------------- # get_type #----------------------------------------------------------------------- def get_type( signal, o=None ): import pclib.cl.queues if isinstance( signal, bool ): return 'bool' elif isinstance( signal, int ): return 'unsigned int' elif isinstance( signal, Bits ): assert not isinstance( signal, BitStruct ) return 'unsigned int' # TODO: make a setbitwidth object elif isinstance( signal, SignalValueWrapper ): if not o: raise Exception( "NESTED TYPES NOT ALLOWED" ) return declare_class( signal, o ) elif isinstance( signal, list ): return get_type( signal[0], o ) + ' *' elif signal == None: return 'void *' # TODO: super hacky handling of generics elif isinstance( signal, pclib.cl.queues.Queue ): return 'std::queue<'+ get_type( signal._kind )+ '>' else: raise Exception( "UNTRANSLATABLE TYPE!") #print( "UNTRANSLATABLE TYPE!") #----------------------------------------------------------------------- # declare_class #----------------------------------------------------------------------- classes = set() def declare_class( signal, o ): class_name = signal._data.__class__.__name__ if class_name in classes: return class_name classes.add( class_name ) print >> o, "class {} {{".format( class_name ) print >> o, " public:" for name, value in signal._data.__dict__.items(): print >> o, " {} {};".format( get_type(value), name ); print >> o, "};" return class_name #----------------------------------------------------------------------- # translate_func #----------------------------------------------------------------------- def translate_func( func, o, model=None ): import StringIO behavioral_code = StringIO.StringIO() # Type Check the AST tree, src = get_method_ast( func ) if not model: model = func._model tree = RemoveCopy().visit( tree ) tree = ReorderSubscriptNext().visit( tree ) #print_simple_ast( tree ) # DEBUG InferTypes( model, func ).visit( tree ) #print_simple_ast( tree ) # DEBUG #print src # DEBUG #new_tree = TypeAST( model, func ).visit( tree ) # DEBUG #print_simple_ast( new_tree ) # DEBUG # Store the PyMTL source inline with the behavioral code print >> behavioral_code, " // PYMTL SOURCE:" for line in src.splitlines(): print >> behavioral_code, " // " + line # Print the Verilog translation visitor = TranslateLogic( model, func, behavioral_code ) #visitor.visit( new_tree ) visitor.visit( tree ) regs = [] localvars = {} for f in visitor.funcs: x, y = translate_func( f, o, model ) regs.extend( x ) localvars.update( y ) # print behavioral code to passed in print >> o print >> o, behavioral_code.getvalue() # return regs regs.extend( visitor.regs ) localvars.update( visitor.localvars ) return regs, localvars #----------------------------------------------------------------------- # opmap #----------------------------------------------------------------------- opmap = { ast.Add : '+', ast.Sub : '-', ast.Mult : '*', ast.Div : '/', ast.Mod : '%', ast.Pow : '**', ast.LShift : '<<', #ast.RShift : '>>>', ast.RShift : '>>', ast.BitOr : '|', ast.BitAnd : '&', ast.BitXor : '^', ast.FloorDiv : '/', ast.Invert : '~', ast.Not : '!', ast.UAdd : '+', ast.USub : '-', ast.Eq : '==', ast.Gt : '>', ast.GtE : '>=', ast.Lt : '<', ast.LtE : '<=', ast.NotEq : '!=', ast.And : '&&', ast.Or : '||', } #----------------------------------------------------------------------- # TranslateLogic #----------------------------------------------------------------------- class TranslateLogic( ast.NodeVisitor ): def __init__( self, model, func, o ): self.model = model self.func = func self.o = o self.ident = 0 self.elseif = False self.regs = [] self.localvars = {} self.arrays = [] self.funcs = set() self.assign = '=' #--------------------------------------------------------------------- # visit_FunctionDef #--------------------------------------------------------------------- def visit_FunctionDef(self, node): assert node.args.vararg == None assert node.args.kwarg == None # TODO: hacky typing: first argument should be self=<returntype> # following args should have default value if node.args.args: rtype = 'int' args = [] stash = self.o self.o = StringIO.StringIO() for x, y in zip(node.args.defaults, node.args.args[1:]): self.visit( x ) args.append( "{} {}".format( 'int', y.id ) ) self.o = stash else: rtype = 'void' args = [] print >> self.o print >> self.o, ' // logic for {}_{}()'.format( self.model.name, node.name ) print >> self.o, ' {} {}_{}( {} ) {{'.format( rtype, mangle_idxs(self.model.name), node.name, ', '.join(args) ) #print >> self.o, ' printf("EXECUTING {}_{}\\n");'.format( # self.model.name, node.name ) # Visit each line in the function, translate one at a time. self.ident += 2 for x in node.body: self.visit(x) self.ident -= 2 print >> self.o, ' }\n' #--------------------------------------------------------------------- # visit_Assign #--------------------------------------------------------------------- def visit_Assign(self, node): # TODO: implement multiple left hand targets? assert len(node.targets) == 1 #if debug: print >> self.o, (self.ident+2)*" ", self.visit( node.targets[0] ) print >> self.o, "{}".format( self.assign ), self.visit( node.value ) print >> self.o, ';' #--------------------------------------------------------------------- # visit_AugAssign #--------------------------------------------------------------------- def visit_AugAssign(self, node): # TODO: implement multiple left hand targets? print >> self.o, (self.ident+2)*" ", self.visit( node.target ) print >> self.o, self.assign, self.visit( node.target ) print >> self.o, opmap[type(node.op)], self.visit(node.value) print >> self.o, ';' #--------------------------------------------------------------------- # visit_BinOp #--------------------------------------------------------------------- def visit_BinOp(self, node): print >> self.o, '(', self.visit(node.left) print >> self.o, opmap[type(node.op)], self.visit(node.right) print >> self.o, ')', #---------------------------------------------------------------------- # visit_BoolOp #--------------------------------------------------------------------- def visit_BoolOp(self, node): print >> self.o, '(', num_nodes = len(node.values) for i in range( num_nodes - 1 ): self.visit( node.values[i] ) print >> self.o, opmap[type(node.op)], self.visit( node.values[ num_nodes - 1 ] ) print >> self.o, ')', #--------------------------------------------------------------------- # visit_UnaryOp #--------------------------------------------------------------------- def visit_UnaryOp(self, node): print >> self.o, opmap[type(node.op)], self.visit(node.operand) #--------------------------------------------------------------------- # visit_IfExp #--------------------------------------------------------------------- # Ternary operators (w = x if y else z). def visit_IfExp(self, node): # TODO: verify this works self.visit(node.test) print >> self.o, '?', self.visit(node.body) print >> self.o, ':', self.visit(node.orelse) #--------------------------------------------------------------------- # visit_Compare #--------------------------------------------------------------------- def visit_Compare(self, node): assert len(node.ops) == 1 # TODO: add debug check print >> self.o, "(", self.visit(node.left) op_symbol = opmap[type(node.ops[0])] print >> self.o, op_symbol, self.visit(node.comparators[0]) print >> self.o, ")", #--------------------------------------------------------------------- # visit_Attribute #--------------------------------------------------------------------- def visit_Attribute( self, node ): name = mangle_idxs( VariableName( self ).visit( node ) ) # TODO: SUPER HACKY if name.endswith('.n'): name = name[:-2]+'.next' elif name.endswith('.v'): name = name[:-2] elif name.endswith('.value'): name = name[:-6] # TODO: SUPER HACKY if name.endswith('.next'): self.regs.append( name[:-5] ) # TODO: more super hacky if name not in self.localvars: #TypeAST( self.model, self.func ).visit( node ) self.localvars[name] = node._object print >> self.o, name.replace('.','_'), #--------------------------------------------------------------------- # visit_Name #--------------------------------------------------------------------- def visit_Name( self, node ): name = VariableName( self ).visit( node ).replace('.', '_') print >> self.o, name, #--------------------------------------------------------------------- # visit_Subscript #--------------------------------------------------------------------- def visit_Subscript( self, node ): print >> self.o, '(*', self.visit( node.value ) print >> self.o, '[', self.visit( node.slice ) print >> self.o, '])', ## #--------------------------------------------------------------------- ## # visit_ArrayIndex ## #--------------------------------------------------------------------- ## def visit_ArrayIndex(self, node): ## ## # We don't support ArrayIndexes being slices ## assert not isinstance( node.slice, _ast.Slice ) ## ## # TODO: need to set ArrayIndex to point to list object ## # Ugly, by creating portlist? ## if node.value._object not in self.array: ## self.array.append( node.value._object ) ## ## # Translate ## self.visit(node.value) ## print >> self.o, "[", ## self.visit(node.slice) ## print >> self.o, "]", ## ## #--------------------------------------------------------------------- ## # visit_BitSlice ## #--------------------------------------------------------------------- ## def visit_BitSlice(self, node): ## ## # Writes to slices need to add the signal as a reg ## if isinstance( node.ctx, _ast.Store ): ## self.regs.add( node.value._object ) ## ## # TODO: add support for ranges! ## self.visit(node.value) ## print >> self.o, "[", ## self.visit(node.slice) ## print >> self.o, "]", ## ## #--------------------------------------------------------------------- ## # visit_Slice ## #--------------------------------------------------------------------- ## def visit_Slice(self, node): ## assert node.step == None ## upper = node.upper ## lower = node.lower ## if isinstance( upper, _ast.Num) and isinstance( lower, _ast.Num ): ## self.visit( node.upper ) ## print >> self.o, '-1:', ## self.visit( node.lower ) ## # TODO: Hacky attempt at implementing variable part-selects, as ## # described here: ## # http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-884-complex-digital-systems-spring-2005/related-resources/verilog_2k1paper.pdf ## elif isinstance( upper, _ast.BinOp ): ## assert isinstance( upper.op, (_ast.Add, _ast.Sub) ) ## self.visit( node.lower ) ## print >> self.o, '{}:'.format( opmap[type(node.upper.op)] ), ## self.visit( node.upper.right ) ## else: ## self.visit( node.upper ) ## print >> self.o, "-1:", ## self.visit( node.lower ) ## #raise Exception( "Cannot translate this slice!" ) ## #--------------------------------------------------------------------- # visit_Num #--------------------------------------------------------------------- def visit_Num(self, node): node._object = int( node.n ) print >> self.o, node.n, # #--------------------------------------------------------------------- # # visit_Self # #--------------------------------------------------------------------- # # TODO: handle names properly # #def visit_Self(self, node): # # self.this_obj = ThisObject( '', self.model ) # # self.visit( node.value ) # # print >> self.o, self.this_obj.name, # # #--------------------------------------------------------------------- # # visit_Local # #--------------------------------------------------------------------- # # TODO: handle names properly # #def visit_Local(self, node): # # obj = getattr( self.model, node.attr ) # # self.this_obj = ThisObject( node.attr, obj ) # # self.visit( node.value ) # # print >> self.o, self.this_obj.name, # # #--------------------------------------------------------------------- # # visit_Attribute # #--------------------------------------------------------------------- # # TODO: currently assuming all attributes are bits objects, # # need to fix for PortBundles and BitStructs # def visit_Attribute(self, node): # if isinstance( node.ctx, _ast.Store ): # self.regs.add( node._object ) # # # TODO: hacky # if isinstance( node._object, list ): # print >> self.o, node._object[0].name.split('[')[0], # # TODO:convert int attributes into contant nodes! # elif isinstance( node._object, int ): # print >> self.o, node._object, # else: # print >> self.o, signal_to_str( node._object, None, self.model ), # # #--------------------------------------------------------------------- # # visit_Temp # #--------------------------------------------------------------------- # def visit_Temp(self, node): # self.temps.add( node.id ) # print >> self.o, node.id, # #--------------------------------------------------------------------- # visit_For #--------------------------------------------------------------------- # TODO: does this work? def visit_For(self, node): #try: if node.iter.func.id != 'range': raise AttributeError() args = node.iter.args lower = args[0] if len( args ) > 1 else _ast.Num(0) upper = args[1] if len( args ) > 1 else args[0] step = args[2] if len( args ) > 2 else _ast.Num(1) i = node.target.id print >> self.o, (self.ident+2)*" " + "for (int {}=".format(i), self.visit( lower ) print >> self.o, "; {}<".format(i), self.visit( upper ) print >> self.o, "; {0}={0}+".format(i), self.visit( step ) print >> self.o, ") { " for x in node.body: self.visit(x) print >> self.o, (self.ident+2)*" " + "}" #except AttributeError as e: # raise Exception("For can only loop over range()! " + e.message) #--------------------------------------------------------------------- # visit_If #--------------------------------------------------------------------- # TODO: cleanup def visit_If(self, node): # Write out the if block if not self.elseif: print >> self.o print >> self.o, self.ident*" " + " if (", else: print >> self.o, self.ident*" " + " else if (", self.elseif = False self.visit(node.test) print >> self.o, " ) {" # Write out the body for body in node.body: self.ident += 2 self.visit(body) print >> self.o, ';' self.ident -= 2 print >> self.o, self.ident*" " + " }" # Write out an an elif block if len(node.orelse) == 1 and isinstance(node.orelse[0], _ast.If): self.elseif = True self.visit(node.orelse[0]) # Write out an else block elif node.orelse: print >> self.o, self.ident*" " + " else {" for orelse in node.orelse: self.ident += 2 self.visit(orelse) print >> self.o, ';' self.ident -= 2 print >> self.o, self.ident*" " + " }" #------------------------------------------------------------------ # visit_While #--------------------------------------------------------------------- # TODO: does this work? def visit_While(self, node): print >> self.o, self.ident*" " + " while( ", self.visit( node.test ) print >> self.o, ") {" self.ident += 2 for line in node.body: self.visit( line ) self.ident -= 2 print >> self.o, self.ident*" " + " }" #--------------------------------------------------------------------- # visit_Break #--------------------------------------------------------------------- def visit_Break(self, node): print >> self.o, self.ident*" " + " break;" #--------------------------------------------------------------------- # visit_Assert #--------------------------------------------------------------------- def visit_Assert(self, node): print >> self.o, self.ident*' ' + ' assert(', self.visit( node.test ) print >> self.o, ')', #--------------------------------------------------------------------- # visit_Return #--------------------------------------------------------------------- def visit_Return(self, node): print >> self.o, self.ident*' ' + ' return ', if node.value: self.visit( node.value ) print >> self.o, ';' #--------------------------------------------------------------------- # visit_Call #--------------------------------------------------------------------- def visit_Call(self, node): # Free function calls if isinstance( node.func, _ast.Name ): if node.func.id == 'zext': self.visit( node.args[0] ) elif node.func.id == 'hex': self.visit( node.args[0] ) elif node.func.id == 'len': print >> self.o, "(", self.visit( node.args[0] ) print >> self.o, ".size())", else: raise Exception('Unsupported free function: {}'.format(node.func.id)) # Method Calls elif isinstance( node.func, _ast.Attribute ): if hasattr( self.model, node.func.attr ): self.funcs.add( getattr( self.model, node.func.attr ) ) fname = node.func.attr print >> self.o, "{}_{}(".format( mangle_idxs(self.model.name), fname ), for i, arg in enumerate( node.args ): if i != 0: print >> self.o, ",", self.visit( node.args[i] ) print >> self.o, ")", return print >> self.o, "(", self.visit( node.func.value ) # TODO # print "METHODCALL", node.func.attr, # node.func.value._object.__class__.__name__ if node.func.attr == 'popleft': print >> self.o, ".pop()", elif node.func.attr == 'append': print >> self.o, ".push(" self.visit( node.args[0] ) print >> self.o, ")", # Queue elif node.func.attr == 'is_full': maxlen = node.func.value._object.data.maxlen print >> self.o, ".size() == {}".format(maxlen), elif node.func.attr == 'is_empty': print >> self.o, ".empty()", elif node.func.attr == 'peek': print >> self.o, ".front()", elif node.func.attr == 'deq': print >> self.o, ".pop()", elif node.func.attr == 'enq': print >> self.o, ".push(", self.visit( node.args[0] ) if isinstance( node.func.value._object, list ): for i in node.func.value._object: i._kind = node.args[0]._object else: node.func.value._object._kind = node.args[0]._object print >> self.o, ")", elif node.func.attr == 'uint': pass else: raise Exception('Unsupported method: {}'.format(node.func.attr)) print >> self.o, ")", else: raise Exception('Attempting to call a non-name! {}\n' .format(node.func)) #--------------------------------------------------------------------- # visit_Print #--------------------------------------------------------------------- def visit_Print( self, node ): print >> self.o, self.ident*' ' + 'printf("', print >> self.o, '%x '*len( node.values ) + '\\n"', for v in node.values: print >> self.o, ', ', self.visit( v ) print >> self.o, ' );' class VariableName( ast.NodeVisitor ): def __init__( self, parent ): self.parent = parent self.model = self.parent.model def visit_Attribute( self, node ): return self.visit( node.value ) + '.' + node.attr def visit_Subscript( self, node ): stash = self.parent.o import StringIO self.parent.o = StringIO.StringIO() self.parent.visit( node ) val = self.parent.o.getvalue() self.parent.o = stash return val def visit_Self( self, node ): return self.model.name def visit_Name( self, node ): if node.id in ['s', 'self']: return self.model.name else: return node.id #----------------------------------------------------------------------- # ReorderSubscriptNext #----------------------------------------------------------------------- class ReorderSubscriptNext( ast.NodeTransformer ): def __init__( self ): self.call = False def visit_Call( self, node ): # TODO: specially handle self.visit( node.func ) if attr # currently not visiting at all! args = [self.visit(x) for x in node.args] keywords = [self.visit(x) for x in node.keywords] if node.starargs: starargs = [self.visit(x) for x in node.starargs] else: starargs = None if node.kwargs: kwargs = [self.visit(x) for x in node.kwargs] else: kwargs = None return _ast.Call(func=node.func, args=args, keyword=keywords, starargs=starargs, kwargs=kwargs) def visit_Attribute( self, node ): self.generic_visit( node ) if isinstance(node.value, _ast.Subscript): subscript = node.value node.value = subscript.value subscript.value = node return ast.copy_location( subscript, node ) return node class RemoveCopy( ast.NodeTransformer ): def visit_Call( self, node ): self.generic_visit( node ) if isinstance(node.func, _ast.Name) and node.func.id == "copy": return ast.copy_location( node.args[0], node ) return node #----------------------------------------------------------------------- # InferTypes #----------------------------------------------------------------------- class InferTypes( ast.NodeVisitor ): def __init__( self, model, func ): self.model = model self.func = func self.closed_vars = get_closure_dict( func ) self.current_obj = None if not self.closed_vars: self.closed_vars['s'] = model def visit_Subscript( self, node ): self.visit( node.slice ) self.visit( node.value ) node._object = node.value._object[0] return node def visit_Attribute( self, node ): # First visit all children self.generic_visit( node ) # TODO: temporary, only handle objects that are live assert self.current_obj != None # Try to get the object by loading it try: x = self.current_obj.getattr( node.attr ) self.current_obj.update( node.attr, x ) except AttributeError: if node.attr not in ['next', 'value', 'n', 'v']: raise Exception("Error: Unknown attribute for this object: {}" .format( node.attr ) ) node._object = self.current_obj.inst if self.current_obj else None return node def visit_Name( self, node ): # TODO: temporary, don't handle local temporaries if node.id in self.closed_vars: new_node = node new_obj = PyObj( node.id, self.closed_vars[ node.id ] ) else: print "WARNING: variable {} type is unknown".format( node.id ) new_obj = None self.current_obj = new_obj node._object = self.current_obj.inst if self.current_obj else None class PyObj( object ): def __init__( self, name, inst ): self.name = name self.inst = inst def update( self, name, inst ): self.name += name self.inst = inst def getattr( self, name ): if isinstance( self.inst, list ): # TODO: super hacky, not sure why this works for forloop if name not in ['next', 'value', 'n', 'v']: return [getattr( x, name ) for x in self.inst] return getattr( self.inst, name ) return getattr( self.inst, name ) def __repr__( self ): return "PyObj( name={} inst={} )".format( self.name, type(self.inst) ) #---------------------------------------------------------------------- # get_closure_dict #---------------------------------------------------------------------- # http://stackoverflow.com/a/19416942 def get_closure_dict( fn ): if fn.func_closure: closure_objects = [c.cell_contents for c in fn.func_closure] return dict( zip( fn.func_code.co_freevars, closure_objects )) else: return dict() #---------------------------------------------------------------------- # mangle_idxs #---------------------------------------------------------------------- indexing = re.compile("(\[)(?P<idx>.*?)(\])") def mangle_idxs( name ): def replacement_string( m ): return "_IDX{:03d}".format( int(m.group('idx')) ) # Return the mangled name return re.sub( indexing, replacement_string, name ) #----------------------------------------------------------------------- # mangle_name #----------------------------------------------------------------------- def mangle_name( name ): # Utility function def replacement_string( m ): return "_IDX{:03d}".format( int(m.group('idx')) ) # Return the mangled name return re.sub( indexing, replacement_string, name.replace('.','_') ) # Regex to match list indexing indexing = re.compile("(\[)(?P<idx>.*?)(\])")
bsd-3-clause
[ 14813, 18673, 199, 3, 7246, 14, 647, 199, 14813, 18673, 199, 3, 15650, 370, 9028, 1611, 5747, 44, 29941, 1901, 282, 445, 17625, 909, 14, 199, 199, 504, 1134, 2037, 76, 7861, 492, 627, 199, 504, 7246, 63, 7546, 3777, 492, 3805, 63, 595, 669, 12, 3805, 63, 31875, 12, 3805, 63, 647, 5029, 199, 504, 2508, 1810, 63, 7546, 3698, 492, 664, 63, 765, 63, 1810, 12, 870, 63, 4129, 63, 1810, 12, 870, 63, 1810, 199, 504, 2263, 14184, 83, 14, 11274, 1110, 492, 18288, 1110, 4590, 199, 504, 2508, 22930, 3322, 492, 4389, 63, 1208, 199, 199, 646, 984, 199, 646, 6073, 12, 485, 1810, 199, 646, 5055, 199, 646, 5228, 199, 646, 295, 199, 199, 5772, 275, 298, 71, 4176, 446, 47, 19, 446, 70, 26769, 446, 5555, 446, 79, 469, 773, 354, 93, 469, 1259, 616, 7063, 199, 199, 7656, 12797, 199, 3, 445, 32140, 3188, 76, 199, 7656, 12797, 199, 3, 3254, 26, 2011, 465, 5444, 73, 793, 12, 7114, 1233, 11866, 199, 318, 445, 32140, 3188, 76, 8, 1402, 12, 312, 29, 1274, 14, 2703, 3461, 339, 286, 63, 5777, 275, 5228, 14, 6424, 342, 272, 286, 63, 3669, 275, 5228, 14, 6424, 342, 339, 10166, 259, 275, 4389, 63, 1208, 14, 7112, 63, 10458, 8, 1402, 776, 272, 1851, 83, 12, 485, 259, 275, 4389, 63, 1208, 14, 10458, 63, 475, 63, 20490, 8, 10166, 776, 272, 5412, 63, 4166, 275, 4389, 63, 1208, 14, 2683, 63, 3610, 63, 4166, 8, 1402, 776, 272, 327, 3254, 26, 1678, 7761, 880, 626, 642, 365, 625, 11368, 31, 272, 4389, 63, 1208, 14, 3176, 63, 4653, 63, 1459, 8, 488, 12, 1851, 83, 776, 339, 327, 29614, 11748, 3423, 12, 3354, 2274, 2556, 272, 6073, 63, 2184, 221, 275, 942, 272, 2257, 2936, 275, 1052, 272, 367, 2562, 315, 5412, 63, 4166, 26, 489, 519, 12, 634, 275, 9028, 63, 1532, 8, 2562, 12, 286, 63, 5777, 776, 489, 6073, 63, 2184, 14, 2880, 8, 519, 776, 489, 2257, 2936, 14, 873, 8, 634, 776, 339, 327, 9101, 4673, 18707, 12, 675, 1295, 2556, 272, 2746, 63, 5203, 12, 1006, 63, 5203, 12, 15084, 83, 275, 20771, 63, 10458, 8, 20490, 12, 6073, 63, 2184, 12, 286, 63, 3669, 9, 339, 315, 719, 63, 1247, 257, 275, 788, 2119, 20013, 29602, 63, 354, 8, 88, 14, 354, 9, 367, 671, 315, 1402, 14, 362, 63, 262, 5203, 342, 1622, 272, 734, 719, 63, 1247, 221, 275, 788, 2119, 20013, 29602, 63, 354, 8, 88, 14, 354, 9, 367, 671, 315, 1402, 14, 362, 63, 548, 5203, 5106, 272, 2746, 63, 262, 5203, 259, 275, 942, 272, 2746, 63, 548, 5203, 257, 275, 942, 339, 367, 671, 315, 1402, 14, 362, 63, 5203, 837, 489, 671, 14, 5910, 63, 354, 275, 283, 2119, 20013, 29602, 63, 354, 8, 671, 14, 354, 776, 339, 327, 27504, 323, 1324, 436, 1072, 8873, 272, 367, 1844, 315, 2746, 63, 5203, 26, 489, 536, 275, 1844, 59, 16, 61, 489, 340, 257, 536, 315, 315, 719, 63, 1247, 26, 267, 2746, 63, 262, 5203, 14, 740, 8, 1844, 776, 489, 916, 536, 315, 734, 719, 63, 1247, 26, 267, 2746, 63, 548, 5203, 14, 740, 8, 1844, 776, 489, 327, 2836, 26, 489, 327, 259, 746, 2186, 480, 5912, 1844, 10501, 9124, 339, 327, 870, 9480, 272, 870, 4331, 286, 63, 3669, 272, 870, 4331, 286, 63, 3669, 12, 1994, 10, 20639, 51, 283, 435, 10791, 10, 2259, 435, 6438, 4805, 272, 367, 2729, 12, 1559, 315, 2257, 2936, 14, 1744, 837, 489, 519, 1391, 275, 2729, 14, 1814, 5175, 1673, 15452, 489, 340, 519, 1391, 440, 315, 1006, 63, 5203, 26, 267, 340, 257, 1228, 8, 1559, 12, 1109, 3461, 881, 2729, 63, 466, 275, 664, 63, 466, 8, 1559, 12, 312, 776, 881, 870, 4331, 286, 63, 3669, 12, 11491, 1052, 275, 27978, 1674, 908, 8, 2729, 63, 466, 12, 519, 1391, 12, 1559, 776, 267, 327, 3254, 26, 1613, 11176, 89, 7252, 402, 5548, 267, 916, 1228, 8, 1559, 12, 769, 3461, 881, 2729, 63, 466, 275, 664, 63, 466, 8, 1559, 59, 16, 467, 312, 776, 881, 3715, 275, 2729, 14, 1294, 7563, 881, 299, 12220, 275, 2513, 1370, 904, 8, 3715, 59, 16, 26, 18, 61, 776, 881, 308, 12220, 275, 14135, 28323, 1370, 904, 8, 3715, 59, 18, 2938, 221, 776, 340, 3715, 59, 18, 2938, 587, 2125, 881, 29922, 275, 359, 7673, 2440, 63, 20037, 28476, 1644, 93, 11123, 908, 8, 9928, 88, 12, 73, 12, 7646, 88, 9, 367, 284, 315, 1425, 8, 552, 8, 1113, 430, 1622, 881, 327, 13966, 29200, 314, 2860, 340, 2985, 2793, 1133, 2187, 5966, 881, 367, 671, 315, 29922, 26, 288, 340, 671, 59, 17, 2938, 440, 315, 1006, 63, 5203, 26, 1598, 870, 4331, 286, 63, 3669, 12, 11491, 27978, 1674, 908, 8, 2729, 63, 466, 12, 671, 59, 17, 5728, 881, 870, 4331, 286, 63, 3669, 12, 11491, 627, 1052, 8607, 275, 8448, 1052, 3586, 27, 1674, 908, 8, 1598, 2729, 63, 466, 12, 519, 1391, 12, 1656, 1987, 904, 8, 18843, 776, 776, 267, 587, 26, 881, 2729, 63, 466, 275, 664, 63, 466, 8, 1559, 12, 312, 776, 881, 870, 4331, 286, 63, 3669, 12, 11491, 27978, 1674, 908, 8, 2729, 63, 466, 12, 519, 1391, 776, 2378, 327, 13966, 29200, 2633, 272, 1862, 275, 942, 272, 367, 536, 12, 1851, 12, 730, 63, 315, 2746, 63, 262, 5203, 1491, 18, 2189, 489, 1862, 14, 740, 8, 283, 259, 1052, 257, 485, 11123, 908, 8, 730, 3131, 536, 776, 776, 272, 1862, 221, 1275, 740, 8, 283, 259, 13395, 63, 84, 627, 2746, 358, 5591, 1862, 275, 1656, 60, 78, 1370, 904, 8, 1862, 776, 339, 327, 2790, 314, 445, 1406, 272, 870, 4331, 312, 12, 3943, 2613, 665, 32011, 14, 72, 3524, 272, 870, 4331, 312, 12, 3943, 2613, 665, 479, 14, 72, 3524, 272, 870, 4331, 312, 12, 3943, 2613, 665, 1825, 3524, 272, 870, 4331, 312, 12, 3943, 4640, 221, 715, 221, 2549, 7, 272, 870, 4331, 312, 12, 3943, 4640, 221, 756, 3055, 7, 272, 870, 4331, 312, 339, 870, 4331 ]
[ 18673, 199, 3, 7246, 14, 647, 199, 14813, 18673, 199, 3, 15650, 370, 9028, 1611, 5747, 44, 29941, 1901, 282, 445, 17625, 909, 14, 199, 199, 504, 1134, 2037, 76, 7861, 492, 627, 199, 504, 7246, 63, 7546, 3777, 492, 3805, 63, 595, 669, 12, 3805, 63, 31875, 12, 3805, 63, 647, 5029, 199, 504, 2508, 1810, 63, 7546, 3698, 492, 664, 63, 765, 63, 1810, 12, 870, 63, 4129, 63, 1810, 12, 870, 63, 1810, 199, 504, 2263, 14184, 83, 14, 11274, 1110, 492, 18288, 1110, 4590, 199, 504, 2508, 22930, 3322, 492, 4389, 63, 1208, 199, 199, 646, 984, 199, 646, 6073, 12, 485, 1810, 199, 646, 5055, 199, 646, 5228, 199, 646, 295, 199, 199, 5772, 275, 298, 71, 4176, 446, 47, 19, 446, 70, 26769, 446, 5555, 446, 79, 469, 773, 354, 93, 469, 1259, 616, 7063, 199, 199, 7656, 12797, 199, 3, 445, 32140, 3188, 76, 199, 7656, 12797, 199, 3, 3254, 26, 2011, 465, 5444, 73, 793, 12, 7114, 1233, 11866, 199, 318, 445, 32140, 3188, 76, 8, 1402, 12, 312, 29, 1274, 14, 2703, 3461, 339, 286, 63, 5777, 275, 5228, 14, 6424, 342, 272, 286, 63, 3669, 275, 5228, 14, 6424, 342, 339, 10166, 259, 275, 4389, 63, 1208, 14, 7112, 63, 10458, 8, 1402, 776, 272, 1851, 83, 12, 485, 259, 275, 4389, 63, 1208, 14, 10458, 63, 475, 63, 20490, 8, 10166, 776, 272, 5412, 63, 4166, 275, 4389, 63, 1208, 14, 2683, 63, 3610, 63, 4166, 8, 1402, 776, 272, 327, 3254, 26, 1678, 7761, 880, 626, 642, 365, 625, 11368, 31, 272, 4389, 63, 1208, 14, 3176, 63, 4653, 63, 1459, 8, 488, 12, 1851, 83, 776, 339, 327, 29614, 11748, 3423, 12, 3354, 2274, 2556, 272, 6073, 63, 2184, 221, 275, 942, 272, 2257, 2936, 275, 1052, 272, 367, 2562, 315, 5412, 63, 4166, 26, 489, 519, 12, 634, 275, 9028, 63, 1532, 8, 2562, 12, 286, 63, 5777, 776, 489, 6073, 63, 2184, 14, 2880, 8, 519, 776, 489, 2257, 2936, 14, 873, 8, 634, 776, 339, 327, 9101, 4673, 18707, 12, 675, 1295, 2556, 272, 2746, 63, 5203, 12, 1006, 63, 5203, 12, 15084, 83, 275, 20771, 63, 10458, 8, 20490, 12, 6073, 63, 2184, 12, 286, 63, 3669, 9, 339, 315, 719, 63, 1247, 257, 275, 788, 2119, 20013, 29602, 63, 354, 8, 88, 14, 354, 9, 367, 671, 315, 1402, 14, 362, 63, 262, 5203, 342, 1622, 272, 734, 719, 63, 1247, 221, 275, 788, 2119, 20013, 29602, 63, 354, 8, 88, 14, 354, 9, 367, 671, 315, 1402, 14, 362, 63, 548, 5203, 5106, 272, 2746, 63, 262, 5203, 259, 275, 942, 272, 2746, 63, 548, 5203, 257, 275, 942, 339, 367, 671, 315, 1402, 14, 362, 63, 5203, 837, 489, 671, 14, 5910, 63, 354, 275, 283, 2119, 20013, 29602, 63, 354, 8, 671, 14, 354, 776, 339, 327, 27504, 323, 1324, 436, 1072, 8873, 272, 367, 1844, 315, 2746, 63, 5203, 26, 489, 536, 275, 1844, 59, 16, 61, 489, 340, 257, 536, 315, 315, 719, 63, 1247, 26, 267, 2746, 63, 262, 5203, 14, 740, 8, 1844, 776, 489, 916, 536, 315, 734, 719, 63, 1247, 26, 267, 2746, 63, 548, 5203, 14, 740, 8, 1844, 776, 489, 327, 2836, 26, 489, 327, 259, 746, 2186, 480, 5912, 1844, 10501, 9124, 339, 327, 870, 9480, 272, 870, 4331, 286, 63, 3669, 272, 870, 4331, 286, 63, 3669, 12, 1994, 10, 20639, 51, 283, 435, 10791, 10, 2259, 435, 6438, 4805, 272, 367, 2729, 12, 1559, 315, 2257, 2936, 14, 1744, 837, 489, 519, 1391, 275, 2729, 14, 1814, 5175, 1673, 15452, 489, 340, 519, 1391, 440, 315, 1006, 63, 5203, 26, 267, 340, 257, 1228, 8, 1559, 12, 1109, 3461, 881, 2729, 63, 466, 275, 664, 63, 466, 8, 1559, 12, 312, 776, 881, 870, 4331, 286, 63, 3669, 12, 11491, 1052, 275, 27978, 1674, 908, 8, 2729, 63, 466, 12, 519, 1391, 12, 1559, 776, 267, 327, 3254, 26, 1613, 11176, 89, 7252, 402, 5548, 267, 916, 1228, 8, 1559, 12, 769, 3461, 881, 2729, 63, 466, 275, 664, 63, 466, 8, 1559, 59, 16, 467, 312, 776, 881, 3715, 275, 2729, 14, 1294, 7563, 881, 299, 12220, 275, 2513, 1370, 904, 8, 3715, 59, 16, 26, 18, 61, 776, 881, 308, 12220, 275, 14135, 28323, 1370, 904, 8, 3715, 59, 18, 2938, 221, 776, 340, 3715, 59, 18, 2938, 587, 2125, 881, 29922, 275, 359, 7673, 2440, 63, 20037, 28476, 1644, 93, 11123, 908, 8, 9928, 88, 12, 73, 12, 7646, 88, 9, 367, 284, 315, 1425, 8, 552, 8, 1113, 430, 1622, 881, 327, 13966, 29200, 314, 2860, 340, 2985, 2793, 1133, 2187, 5966, 881, 367, 671, 315, 29922, 26, 288, 340, 671, 59, 17, 2938, 440, 315, 1006, 63, 5203, 26, 1598, 870, 4331, 286, 63, 3669, 12, 11491, 27978, 1674, 908, 8, 2729, 63, 466, 12, 671, 59, 17, 5728, 881, 870, 4331, 286, 63, 3669, 12, 11491, 627, 1052, 8607, 275, 8448, 1052, 3586, 27, 1674, 908, 8, 1598, 2729, 63, 466, 12, 519, 1391, 12, 1656, 1987, 904, 8, 18843, 776, 776, 267, 587, 26, 881, 2729, 63, 466, 275, 664, 63, 466, 8, 1559, 12, 312, 776, 881, 870, 4331, 286, 63, 3669, 12, 11491, 27978, 1674, 908, 8, 2729, 63, 466, 12, 519, 1391, 776, 2378, 327, 13966, 29200, 2633, 272, 1862, 275, 942, 272, 367, 536, 12, 1851, 12, 730, 63, 315, 2746, 63, 262, 5203, 1491, 18, 2189, 489, 1862, 14, 740, 8, 283, 259, 1052, 257, 485, 11123, 908, 8, 730, 3131, 536, 776, 776, 272, 1862, 221, 1275, 740, 8, 283, 259, 13395, 63, 84, 627, 2746, 358, 5591, 1862, 275, 1656, 60, 78, 1370, 904, 8, 1862, 776, 339, 327, 2790, 314, 445, 1406, 272, 870, 4331, 312, 12, 3943, 2613, 665, 32011, 14, 72, 3524, 272, 870, 4331, 312, 12, 3943, 2613, 665, 479, 14, 72, 3524, 272, 870, 4331, 312, 12, 3943, 2613, 665, 1825, 3524, 272, 870, 4331, 312, 12, 3943, 4640, 221, 715, 221, 2549, 7, 272, 870, 4331, 312, 12, 3943, 4640, 221, 756, 3055, 7, 272, 870, 4331, 312, 339, 870, 4331, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
london-python-project-nights/romaine
tests/test_parser_examples.py
1
11549
from copy import deepcopy import unittest from tests import common from romaine.parser.exceptions import ( MalformedTableError, ) class TestExamplesParser(unittest.TestCase): """ Test examples gherkin parser functionality of romaine's core. """ def setUp(self): """ Prepare the environment for testing. """ # We're doing a lot of long tests- don't limit the diff output length self.maxDiff = None def test_getting_example_no_input_modification(self): """ Test that getting example doesn't change the input var. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from examples/basic_input input_data = common.get_parser_input('examples/basic_input') expected_data = deepcopy(input_data) parser.section.get_example(input_data) # Then my input variable is not modified self.assertEqual( input_data, expected_data, ) def test_basic_examples_without_description(self): """ Check we can get examples with no description. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from examples/basic_input input_data = common.get_parser_input('examples/basic_input') result = parser.section.get_example(input_data) # Then I see the results from examples/basic_expected self.assertEqual( result, common.get_parser_output('examples/basic_expected'), ) def test_basic_examples_with_description(self): """ Check description can be extracted from an example when present. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from examples/description_input input_data = common.get_parser_input('examples/description_input') result = parser.section.get_example(input_data) # Then I see the results from examples/description_expected self.assertEqual( result, common.get_parser_output('examples/description_expected'), ) def test_malformed_examples_table_causes_exception(self): """ Check that a malformed table throws an exception. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from # examples/malformed_examples_table_input input_data = common.get_parser_input( 'examples/malformed_examples_table_input', ) # Then I see a MalformedTableError with self.assertRaises(MalformedTableError): parser.section.get_example(input_data) def test_examples_with_incomplete_table(self): """ Confirm we can retrieve example with just table headings. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from # examples/incomplete_table_input input_data = common.get_parser_input( 'examples/incomplete_table_input', ) result = parser.section.get_example(input_data) # Then I see the results from # examples/incomplete_table_expected self.assertEqual( result, common.get_parser_output('examples/incomplete_table_expected'), ) def test_examples_with_leading_comment_and_whitespace_can_be_parsed(self): """ Check that examples with leading comment and whitespace are valid. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from # examples/comment_and_whitespace_input input_data = common.get_parser_input( 'examples/comment_and_whitespace_input', ) result = parser.section.get_example(input_data) # Then I see the results from # examples/comment_and_whitespace_expected self.assertEqual( result, common.get_parser_output( 'examples/comment_and_whitespace_expected', ), ) def test_example_with_trailing_data_and_whitespace(self): """ Check that examples with trailing whitespace and data are valid. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from # examples/trailing_data_and_whitespace_input input_data = common.get_parser_input( 'examples/trailing_data_and_whitespace_input', ) result = parser.section.get_example(input_data) # Then I see the results from # examples/trailing_data_and_whitespace_expected self.assertEqual( result, common.get_parser_output( 'examples/trailing_data_and_whitespace_expected', ), ) def test_multiple_examples_sections(self): """ Check that a second example will be left alone. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from # examples/one_from_multiple_examples_input input_data = common.get_parser_input( 'examples/one_from_multiple_examples_input', ) result = parser.section.get_example(input_data) # Then I see the results from # examples/one_from_multiple_examples_expected self.assertEqual( result, common.get_parser_output( 'examples/one_from_multiple_examples_expected', ), ) def test_no_examples_sections_with_trailing_data(self): """ Check that no examples sections returns no examples. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from # examples/no_examples_input input_data = common.get_parser_input( 'examples/no_examples_input', ) result = parser.section.get_example(input_data) # Then I see the results from # examples/no_examples_expected self.assertEqual( result, common.get_parser_output('examples/no_examples_expected'), ) def test_no_examples_from_nothing(self): """ Check that we don't crash trying to get examples from nothing. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from # examples/empty_input input_data = common.get_parser_input( 'examples/empty_input', ) result = parser.section.get_example(input_data) # Then I see the results from # examples/empty_expected self.assertEqual( result, common.get_parser_output('examples/empty_expected'), ) def test_examples_divorced_from_table(self): """ Confirm we don't get examples when the table is not attached. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from # examples/missing_table_input input_data = common.get_parser_input( 'examples/missing_table_input', ) result = parser.section.get_example(input_data) # Then I see the results from # examples/missing_table_expected self.assertEqual( result, common.get_parser_output('examples/missing_table_expected'), ) def test_basic_single_examples_without_description(self): """ Check we can get a single example with no description. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from # examples/single_example_input input_data = common.get_parser_input( 'examples/single_example_input', ) result = parser.section.get_examples(input_data) # Then I see the results from # examples/single_example_expected self.assertEqual( result, common.get_parser_output('examples/single_example_expected'), ) def test_get_multiple_examples_sections(self): """ Check that we can retrieve two examples sections. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from # examples/multiple_examples_input input_data = common.get_parser_input( 'examples/multiple_examples_input', ) result = parser.section.get_examples(input_data) # Then I see the results from # examples/multiple_examples_expected self.assertEqual( result, common.get_parser_output('examples/multiple_examples_expected'), ) def test_get_one_example_with_example_following_other_data(self): """ Check that an example not immediately following is left alone. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_example with input from # examples/noise_between_examples_input input_data = common.get_parser_input( 'examples/noise_between_examples_input', ) result = parser.section.get_examples(input_data) # Then I see the results from # examples/noise_between_examples_expected self.assertEqual( result, common.get_parser_output( 'examples/noise_between_examples_expected', ), ) def test_do_not_get_multiple_examples_from_nothing(self): """ Check that we can't get many (any) examples from nothing. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_examples with input from # examples/empty_input input_data = common.get_parser_input( 'examples/empty_input', ) result = parser.section.get_examples(input_data) # Then I see the results from # examples/empty_examples_expected self.assertEqual( result, common.get_parser_output('examples/empty_examples_expected'), ) def test_get_examples_no_input_modification(self): """ Test that getting examples doesn't change the input var. """ # Given I have Romaine core's parser parser = common.get_romaine_parser() # When I call get_examples with input from examples/basic_input input_data = common.get_parser_input('examples/basic_input') expected_data = deepcopy(input_data) parser.section.get_examples(input_data) # Then my input variable is not modified self.assertEqual( input_data, expected_data, )
mit
[ 504, 1331, 492, 14800, 199, 646, 2882, 199, 504, 2295, 492, 2863, 199, 199, 504, 882, 973, 69, 14, 2087, 14, 3924, 492, 334, 272, 603, 24012, 3186, 547, 12, 199, 9, 421, 199, 533, 1379, 22787, 2842, 8, 2796, 14, 1746, 304, 272, 408, 267, 1379, 7251, 486, 2523, 19269, 1798, 9330, 402, 882, 973, 69, 1159, 6170, 14, 272, 408, 272, 347, 3613, 8, 277, 304, 267, 408, 288, 17008, 314, 3734, 367, 5343, 14, 267, 408, 267, 327, 2136, 3984, 9689, 282, 13918, 402, 1846, 2295, 13, 2793, 1133, 2304, 314, 3915, 1072, 2582, 267, 291, 14, 988, 10746, 275, 488, 339, 347, 511, 63, 362, 1337, 63, 2694, 63, 889, 63, 1210, 63, 20945, 8, 277, 304, 267, 408, 288, 1379, 626, 10232, 2893, 3181, 1133, 1570, 314, 1324, 2729, 14, 267, 408, 267, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 7251, 15, 4316, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 360, 8589, 15, 4316, 63, 1210, 358, 398, 1420, 63, 576, 275, 14800, 8, 1210, 63, 576, 9, 398, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 398, 327, 9442, 3002, 1324, 1750, 365, 440, 6042, 267, 291, 14, 629, 8, 288, 1324, 63, 576, 12, 288, 1420, 63, 576, 12, 267, 776, 339, 347, 511, 63, 4316, 63, 8589, 63, 7395, 63, 1802, 8, 277, 304, 267, 408, 288, 2670, 781, 883, 664, 7251, 543, 949, 1369, 14, 267, 408, 267, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 7251, 15, 4316, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 360, 8589, 15, 4316, 63, 1210, 358, 398, 754, 275, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 398, 327, 9442, 473, 1937, 314, 2058, 687, 7251, 15, 4316, 63, 2062, 267, 291, 14, 629, 8, 288, 754, 12, 288, 2863, 14, 362, 63, 2087, 63, 1199, 360, 8589, 15, 4316, 63, 2062, 659, 267, 776, 339, 347, 511, 63, 4316, 63, 8589, 63, 1045, 63, 1802, 8, 277, 304, 267, 408, 288, 2670, 1369, 883, 506, 12509, 687, 376, 2893, 1380, 3451, 14, 267, 408, 267, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 7251, 15, 1802, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 360, 8589, 15, 1802, 63, 1210, 358, 398, 754, 275, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 398, 327, 9442, 473, 1937, 314, 2058, 687, 7251, 15, 1802, 63, 2062, 267, 291, 14, 629, 8, 288, 754, 12, 288, 2863, 14, 362, 63, 2087, 63, 1199, 360, 8589, 15, 1802, 63, 2062, 659, 267, 776, 339, 347, 511, 63, 31029, 63, 8589, 63, 1224, 63, 696, 5589, 63, 1971, 8, 277, 304, 267, 408, 288, 2670, 626, 282, 24159, 1817, 24266, 376, 1919, 14, 267, 408, 398, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 267, 327, 7251, 15, 31029, 63, 8589, 63, 1224, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 8, 288, 283, 8589, 15, 31029, 63, 8589, 63, 1224, 63, 1210, 297, 267, 776, 267, 327, 9442, 473, 1937, 282, 603, 24012, 3186, 547, 267, 543, 291, 14, 1855, 8, 29513, 3186, 547, 304, 288, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 339, 347, 511, 63, 8589, 63, 1045, 63, 24575, 63, 1224, 8, 277, 304, 267, 408, 288, 32112, 781, 883, 8044, 2893, 543, 2951, 1817, 26967, 14, 267, 408, 267, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 267, 327, 7251, 15, 24575, 63, 1224, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 8, 288, 283, 8589, 15, 24575, 63, 1224, 63, 1210, 297, 267, 776, 398, 754, 275, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 398, 327, 9442, 473, 1937, 314, 2058, 687, 267, 327, 7251, 15, 24575, 63, 1224, 63, 2062, 267, 291, 14, 629, 8, 288, 754, 12, 288, 2863, 14, 362, 63, 2087, 63, 1199, 360, 8589, 15, 24575, 63, 1224, 63, 2062, 659, 267, 776, 339, 347, 511, 63, 8589, 63, 1045, 63, 16812, 63, 3349, 63, 460, 63, 8506, 63, 2425, 63, 1235, 63, 6751, 8, 277, 304, 267, 408, 288, 2670, 626, 7251, 543, 9186, 3721, 436, 8139, 787, 1686, 14, 267, 408, 267, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 267, 327, 7251, 15, 3349, 63, 460, 63, 8506, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 8, 288, 283, 8589, 15, 3349, 63, 460, 63, 8506, 63, 1210, 297, 267, 776, 398, 754, 275, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 398, 327, 9442, 473, 1937, 314, 2058, 687, 267, 327, 7251, 15, 3349, 63, 460, 63, 8506, 63, 2062, 267, 291, 14, 629, 8, 288, 754, 12, 288, 2863, 14, 362, 63, 2087, 63, 1199, 8, 355, 283, 8589, 15, 3349, 63, 460, 63, 8506, 63, 2062, 297, 288, 2318, 267, 776, 339, 347, 511, 63, 2694, 63, 1045, 63, 15910, 63, 576, 63, 460, 63, 8506, 8, 277, 304, 267, 408, 288, 2670 ]
[ 1331, 492, 14800, 199, 646, 2882, 199, 504, 2295, 492, 2863, 199, 199, 504, 882, 973, 69, 14, 2087, 14, 3924, 492, 334, 272, 603, 24012, 3186, 547, 12, 199, 9, 421, 199, 533, 1379, 22787, 2842, 8, 2796, 14, 1746, 304, 272, 408, 267, 1379, 7251, 486, 2523, 19269, 1798, 9330, 402, 882, 973, 69, 1159, 6170, 14, 272, 408, 272, 347, 3613, 8, 277, 304, 267, 408, 288, 17008, 314, 3734, 367, 5343, 14, 267, 408, 267, 327, 2136, 3984, 9689, 282, 13918, 402, 1846, 2295, 13, 2793, 1133, 2304, 314, 3915, 1072, 2582, 267, 291, 14, 988, 10746, 275, 488, 339, 347, 511, 63, 362, 1337, 63, 2694, 63, 889, 63, 1210, 63, 20945, 8, 277, 304, 267, 408, 288, 1379, 626, 10232, 2893, 3181, 1133, 1570, 314, 1324, 2729, 14, 267, 408, 267, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 7251, 15, 4316, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 360, 8589, 15, 4316, 63, 1210, 358, 398, 1420, 63, 576, 275, 14800, 8, 1210, 63, 576, 9, 398, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 398, 327, 9442, 3002, 1324, 1750, 365, 440, 6042, 267, 291, 14, 629, 8, 288, 1324, 63, 576, 12, 288, 1420, 63, 576, 12, 267, 776, 339, 347, 511, 63, 4316, 63, 8589, 63, 7395, 63, 1802, 8, 277, 304, 267, 408, 288, 2670, 781, 883, 664, 7251, 543, 949, 1369, 14, 267, 408, 267, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 7251, 15, 4316, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 360, 8589, 15, 4316, 63, 1210, 358, 398, 754, 275, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 398, 327, 9442, 473, 1937, 314, 2058, 687, 7251, 15, 4316, 63, 2062, 267, 291, 14, 629, 8, 288, 754, 12, 288, 2863, 14, 362, 63, 2087, 63, 1199, 360, 8589, 15, 4316, 63, 2062, 659, 267, 776, 339, 347, 511, 63, 4316, 63, 8589, 63, 1045, 63, 1802, 8, 277, 304, 267, 408, 288, 2670, 1369, 883, 506, 12509, 687, 376, 2893, 1380, 3451, 14, 267, 408, 267, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 7251, 15, 1802, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 360, 8589, 15, 1802, 63, 1210, 358, 398, 754, 275, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 398, 327, 9442, 473, 1937, 314, 2058, 687, 7251, 15, 1802, 63, 2062, 267, 291, 14, 629, 8, 288, 754, 12, 288, 2863, 14, 362, 63, 2087, 63, 1199, 360, 8589, 15, 1802, 63, 2062, 659, 267, 776, 339, 347, 511, 63, 31029, 63, 8589, 63, 1224, 63, 696, 5589, 63, 1971, 8, 277, 304, 267, 408, 288, 2670, 626, 282, 24159, 1817, 24266, 376, 1919, 14, 267, 408, 398, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 267, 327, 7251, 15, 31029, 63, 8589, 63, 1224, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 8, 288, 283, 8589, 15, 31029, 63, 8589, 63, 1224, 63, 1210, 297, 267, 776, 267, 327, 9442, 473, 1937, 282, 603, 24012, 3186, 547, 267, 543, 291, 14, 1855, 8, 29513, 3186, 547, 304, 288, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 339, 347, 511, 63, 8589, 63, 1045, 63, 24575, 63, 1224, 8, 277, 304, 267, 408, 288, 32112, 781, 883, 8044, 2893, 543, 2951, 1817, 26967, 14, 267, 408, 267, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 267, 327, 7251, 15, 24575, 63, 1224, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 8, 288, 283, 8589, 15, 24575, 63, 1224, 63, 1210, 297, 267, 776, 398, 754, 275, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 398, 327, 9442, 473, 1937, 314, 2058, 687, 267, 327, 7251, 15, 24575, 63, 1224, 63, 2062, 267, 291, 14, 629, 8, 288, 754, 12, 288, 2863, 14, 362, 63, 2087, 63, 1199, 360, 8589, 15, 24575, 63, 1224, 63, 2062, 659, 267, 776, 339, 347, 511, 63, 8589, 63, 1045, 63, 16812, 63, 3349, 63, 460, 63, 8506, 63, 2425, 63, 1235, 63, 6751, 8, 277, 304, 267, 408, 288, 2670, 626, 7251, 543, 9186, 3721, 436, 8139, 787, 1686, 14, 267, 408, 267, 327, 9138, 473, 1172, 6848, 973, 69, 6170, 1159, 1798, 267, 1798, 275, 2863, 14, 362, 63, 293, 973, 69, 63, 2087, 342, 398, 327, 3979, 473, 1240, 664, 63, 2694, 543, 1324, 687, 267, 327, 7251, 15, 3349, 63, 460, 63, 8506, 63, 1210, 267, 1324, 63, 576, 275, 2863, 14, 362, 63, 2087, 63, 1210, 8, 288, 283, 8589, 15, 3349, 63, 460, 63, 8506, 63, 1210, 297, 267, 776, 398, 754, 275, 1798, 14, 2792, 14, 362, 63, 2694, 8, 1210, 63, 576, 9, 398, 327, 9442, 473, 1937, 314, 2058, 687, 267, 327, 7251, 15, 3349, 63, 460, 63, 8506, 63, 2062, 267, 291, 14, 629, 8, 288, 754, 12, 288, 2863, 14, 362, 63, 2087, 63, 1199, 8, 355, 283, 8589, 15, 3349, 63, 460, 63, 8506, 63, 2062, 297, 288, 2318, 267, 776, 339, 347, 511, 63, 2694, 63, 1045, 63, 15910, 63, 576, 63, 460, 63, 8506, 8, 277, 304, 267, 408, 288, 2670, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gptech/ansible
lib/ansible/modules/cloud/ovirt/ovirt_datacenters.py
1
7378
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (c) 2016 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/>. # ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: ovirt_datacenters short_description: Module to manage data centers in oVirt/RHV version_added: "2.3" author: "Ondra Machacek (@machacekondra)" description: - "Module to manage data centers in oVirt/RHV" options: name: description: - "Name of the the data center to manage." required: true state: description: - "Should the data center be present or absent" choices: ['present', 'absent'] default: present description: description: - "Description of the data center." comment: description: - "Comment of the data center." local: description: - "I(True) if the data center should be local, I(False) if should be shared." - "Default value is set by engine." compatibility_version: description: - "Compatibility version of the data center." quota_mode: description: - "Quota mode of the data center. One of I(disabled), I(audit) or I(enabled)" choices: ['disabled', 'audit', 'enabled'] mac_pool: description: - "MAC pool to be used by this datacenter." - "IMPORTANT: This option is deprecated in oVirt/RHV 4.1. You should use C(mac_pool) in C(ovirt_clusters) module, as MAC pools are set per cluster since 4.1." extends_documentation_fragment: ovirt ''' EXAMPLES = ''' # Examples don't contain auth parameter for simplicity, # look at ovirt_auth module to see how to reuse authentication: # Create datacenter - ovirt_datacenters: name: mydatacenter local: True compatibility_version: 4.0 quota_mode: enabled # Remove datacenter - ovirt_datacenters: state: absent name: mydatacenter ''' RETURN = ''' id: description: "ID of the managed datacenter" returned: "On success if datacenter is found." type: str sample: 7de90f31-222c-436c-a1ca-7e655bd5b60c data_center: description: "Dictionary of all the datacenter attributes. Datacenter attributes can be found on your oVirt/RHV instance at following url: https://ovirt.example.com/ovirt-engine/api/model#types/datacenter." returned: "On success if datacenter is found." type: dict ''' import traceback try: import ovirtsdk4.types as otypes except ImportError: pass from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.ovirt import ( BaseModule, check_sdk, check_params, create_connection, equal, ovirt_full_argument_spec, search_by_name, ) class DatacentersModule(BaseModule): def __get_major(self, full_version): if full_version is None: return None if isinstance(full_version, otypes.Version): return full_version.major return int(full_version.split('.')[0]) def __get_minor(self, full_version): if full_version is None: return None if isinstance(full_version, otypes.Version): return full_version.minor return int(full_version.split('.')[1]) def _get_mac_pool(self): mac_pool = None if self._module.params.get('mac_pool'): mac_pool = search_by_name( self._connection.system_service().mac_pools_service(), self._module.params.get('mac_pool'), ) return mac_pool def build_entity(self): return otypes.DataCenter( name=self._module.params['name'], comment=self._module.params['comment'], description=self._module.params['description'], mac_pool=otypes.MacPool( id=getattr(self._get_mac_pool(), 'id', None), ) if self._module.params.get('mac_pool') else None, quota_mode=otypes.QuotaModeType( self._module.params['quota_mode'] ) if self._module.params['quota_mode'] else None, local=self._module.params['local'], version=otypes.Version( major=self.__get_major(self._module.params['compatibility_version']), minor=self.__get_minor(self._module.params['compatibility_version']), ) if self._module.params['compatibility_version'] else None, ) def update_check(self, entity): minor = self.__get_minor(self._module.params.get('compatibility_version')) major = self.__get_major(self._module.params.get('compatibility_version')) return ( equal(getattr(self._get_mac_pool(), 'id', None), getattr(entity.mac_pool, 'id', None)) and equal(self._module.params.get('comment'), entity.comment) and equal(self._module.params.get('description'), entity.description) and equal(self._module.params.get('quota_mode'), str(entity.quota_mode)) and equal(self._module.params.get('local'), entity.local) and equal(minor, self.__get_minor(entity.version)) and equal(major, self.__get_major(entity.version)) ) def main(): argument_spec = ovirt_full_argument_spec( state=dict( choices=['present', 'absent'], default='present', ), name=dict(default=None, required=True), description=dict(default=None), local=dict(type='bool'), compatibility_version=dict(default=None), quota_mode=dict(choices=['disabled', 'audit', 'enabled']), comment=dict(default=None), mac_pool=dict(default=None), ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, ) check_sdk(module) check_params(module) try: auth = module.params.pop('auth') connection = create_connection(auth) data_centers_service = connection.system_service().data_centers_service() clusters_module = DatacentersModule( connection=connection, module=module, service=data_centers_service, ) state = module.params['state'] if state == 'present': ret = clusters_module.create() elif state == 'absent': ret = clusters_module.remove() module.exit_json(**ret) except Exception as e: module.fail_json(msg=str(e), exception=traceback.format_exc()) finally: connection.close(logout=auth.get('token') is None) if __name__ == "__main__": main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 7800, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 21353, 63, 576, 15660, 199, 3612, 63, 1802, 26, 5673, 370, 9635, 666, 19190, 315, 312, 17146, 15, 50, 16566, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 298, 47, 977, 345, 30611, 7984, 75, 8593, 14121, 7984, 75, 7835, 345, 2924, 199, 1802, 26, 272, 446, 298, 2377, 370, 9635, 666, 19190, 315, 312, 17146, 15, 50, 16566, 2, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 298, 985, 402, 314, 314, 666, 8126, 370, 9635, 2122, 267, 1415, 26, 2549, 272, 1174, 26, 267, 1369, 26, 288, 446, 298, 11408, 314, 666, 8126, 506, 3451, 503, 9552, 2, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 3451, 272, 1369, 26, 267, 1369, 26, 288, 446, 298, 5831, 402, 314, 666, 8126, 2122, 272, 3721, 26, 267, 1369, 26, 288, 446, 298, 7488, 402, 314, 666, 8126, 2122, 272, 2257, 26, 267, 1369, 26, 288, 446, 298, 41, 8, 549, 9, 340, 314, 666, 8126, 1077, 506, 2257, 12, 473, 8, 797, 9, 340, 1077, 506, 5709, 2122, 288, 446, 298, 2698, 574, 365, 663, 701, 6869, 2122, 272, 7163, 63, 1023, 26, 267, 1369, 26, 288, 446, 298, 2404, 5880, 1015, 402, 314, 666, 8126, 2122, 272, 12132, 63, 632, 26, 267, 1369, 26, 288, 446, 298, 17610, 818, 402, 314, 666, 8126, 14, 7309, 402, 473, 8, 7011, 395, 473, 8, 14274, 9, 503, 473, 8, 3827, 2924, 267, 3415, 26, 788, 7011, 297, 283, 14274, 297, 283, 3827, 418, 272, 4497, 63, 2293, 26, 267, 1369, 26, 288, 446, 298, 9410, 4203, 370, 506, 1202, 701, 642, 16606, 2122, 288, 446, 298, 17576, 1441, 26, 961, 945, 365, 5906, 315, 312, 17146, 15, 50, 16566, 841, 14, 17, 14, 2047, 1077, 2049, 675, 445, 8, 3088, 63, 2293, 9, 315, 445, 8, 23334, 63, 9170, 9, 859, 12, 465, 13347, 20092, 787, 2049, 663, 1126, 4350, 3967, 841, 14, 17, 2122, 199, 11036, 63, 9970, 63, 7677, 26, 21353, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 6058, 2793, 1133, 1395, 1790, 2725, 367, 17553, 3690, 12, 199, 3, 3648, 737, 21353, 63, 1178, 859, 370, 1937, 4212, 370, 12598, 6299, 26, 199, 199, 3, 2790, 16606, 199, 13, 21353, 63, 576, 15660, 26, 272, 536, 26, 3002, 17770, 272, 2257, 26, 715, 272, 7163, 63, 1023, 26, 841, 14, 16, 272, 12132, 63, 632, 26, 5223, 199, 199, 3, 5852, 16606, 199, 13, 21353, 63, 576, 15660, 26, 272, 1174, 26, 9552, 272, 536, 26, 3002, 17770, 199, 2344, 199, 199, 9677, 275, 1449, 199, 344, 26, 272, 1369, 26, 298, 998, 402, 314, 12883, 16606, 2, 272, 2138, 26, 298, 3314, 3182, 340, 16606, 365, 1911, 2122, 272, 730, 26, 620, 272, 2690, 26, 1520, 271, 2710, 70, 2192, 13, 9485, 67, 13, 26319, 67, 13, 65, 17, 696, 13, 23, 69, 10027, 3691, 21, 66, 2259, 67, 199, 576, 63, 4218, 26, 272, 1369, 26, 298, 11728, 402, 1006, 314, 16606, 3004, 14, 3918, 4218, 3004, 883, 506, 1911, 641, 2195, 312, 17146, 15, 50, 16566, 1256, 2116, 737, 2569, 1166, 26, 4178, 921, 23334, 14, 2694, 14, 957, 15, 23334, 13, 3908, 15, 1246, 15, 1238, 3, 1313, 15, 17770, 2122, 272, 2138, 26, 298, 3314, 3182, 340, 16606, 365, 1911, 2122, 272, 730, 26, 1211, 199, 2344, 199, 199, 646, 5190, 199, 199, 893, 26, 272, 492, 312, 1042, 1086, 6341, 20, 14, 1313, 465, 312, 1313, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 23334, 492, 334, 272, 3523, 2377, 12, 272, 1104, 63, 9277, 12, 272, 1104, 63, 1162, 12, 272, 1218, 63, 2105, 12, 272, 4472, 12, 272, 21353, 63, 2861, 63, 2094, 63, 1650, 12, 272, 2754, 63, 991, 63, 354, 12, 199, 9, 421, 199, 533, 3918, 15660, 2377, 8, 1563, 2377, 304, 339, 347, 636, 362, 63, 8452, 8, 277, 12, 2615, 63, 1023, 304, 267, 340, 2615, 63, 1023, 365, 488, 26, 288, 372, 488, 267, 340, 1228, 8, 2861, 63, 1023, 12, 312, 1313, 14, 3353, 304, 288, 372, 2615, 63, 1023, 14, 8452, 267, 372, 1109, 8, 2861, 63, 1023, 14, 1294, 19237, 16, 566, 339, 347, 636, 362, 63, 11067, 8, 277, 12, 2615, 63, 1023, 304, 267, 340, 2615, 63, 1023, 365, 488, 26, 288, 372, 488, 267, 340, 1228, 8, 2861, 63, 1023, 12, 312, 1313, 14, 3353, 304, 288, 372, 2615, 63, 1023, 14, 11067, 267, 372, 1109, 8, 2861, 63, 1023, 14, 1294, 19237, 17, 566, 339, 347, 485, 362, 63, 3088, 63, 2293, 8, 277, 304, 267, 4497, 63, 2293, 275, 488, 267, 340, 291, 423, 578, 14 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 7800, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 21353, 63, 576, 15660, 199, 3612, 63, 1802, 26, 5673, 370, 9635, 666, 19190, 315, 312, 17146, 15, 50, 16566, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2502, 26, 298, 47, 977, 345, 30611, 7984, 75, 8593, 14121, 7984, 75, 7835, 345, 2924, 199, 1802, 26, 272, 446, 298, 2377, 370, 9635, 666, 19190, 315, 312, 17146, 15, 50, 16566, 2, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 298, 985, 402, 314, 314, 666, 8126, 370, 9635, 2122, 267, 1415, 26, 2549, 272, 1174, 26, 267, 1369, 26, 288, 446, 298, 11408, 314, 666, 8126, 506, 3451, 503, 9552, 2, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 267, 849, 26, 3451, 272, 1369, 26, 267, 1369, 26, 288, 446, 298, 5831, 402, 314, 666, 8126, 2122, 272, 3721, 26, 267, 1369, 26, 288, 446, 298, 7488, 402, 314, 666, 8126, 2122, 272, 2257, 26, 267, 1369, 26, 288, 446, 298, 41, 8, 549, 9, 340, 314, 666, 8126, 1077, 506, 2257, 12, 473, 8, 797, 9, 340, 1077, 506, 5709, 2122, 288, 446, 298, 2698, 574, 365, 663, 701, 6869, 2122, 272, 7163, 63, 1023, 26, 267, 1369, 26, 288, 446, 298, 2404, 5880, 1015, 402, 314, 666, 8126, 2122, 272, 12132, 63, 632, 26, 267, 1369, 26, 288, 446, 298, 17610, 818, 402, 314, 666, 8126, 14, 7309, 402, 473, 8, 7011, 395, 473, 8, 14274, 9, 503, 473, 8, 3827, 2924, 267, 3415, 26, 788, 7011, 297, 283, 14274, 297, 283, 3827, 418, 272, 4497, 63, 2293, 26, 267, 1369, 26, 288, 446, 298, 9410, 4203, 370, 506, 1202, 701, 642, 16606, 2122, 288, 446, 298, 17576, 1441, 26, 961, 945, 365, 5906, 315, 312, 17146, 15, 50, 16566, 841, 14, 17, 14, 2047, 1077, 2049, 675, 445, 8, 3088, 63, 2293, 9, 315, 445, 8, 23334, 63, 9170, 9, 859, 12, 465, 13347, 20092, 787, 2049, 663, 1126, 4350, 3967, 841, 14, 17, 2122, 199, 11036, 63, 9970, 63, 7677, 26, 21353, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 6058, 2793, 1133, 1395, 1790, 2725, 367, 17553, 3690, 12, 199, 3, 3648, 737, 21353, 63, 1178, 859, 370, 1937, 4212, 370, 12598, 6299, 26, 199, 199, 3, 2790, 16606, 199, 13, 21353, 63, 576, 15660, 26, 272, 536, 26, 3002, 17770, 272, 2257, 26, 715, 272, 7163, 63, 1023, 26, 841, 14, 16, 272, 12132, 63, 632, 26, 5223, 199, 199, 3, 5852, 16606, 199, 13, 21353, 63, 576, 15660, 26, 272, 1174, 26, 9552, 272, 536, 26, 3002, 17770, 199, 2344, 199, 199, 9677, 275, 1449, 199, 344, 26, 272, 1369, 26, 298, 998, 402, 314, 12883, 16606, 2, 272, 2138, 26, 298, 3314, 3182, 340, 16606, 365, 1911, 2122, 272, 730, 26, 620, 272, 2690, 26, 1520, 271, 2710, 70, 2192, 13, 9485, 67, 13, 26319, 67, 13, 65, 17, 696, 13, 23, 69, 10027, 3691, 21, 66, 2259, 67, 199, 576, 63, 4218, 26, 272, 1369, 26, 298, 11728, 402, 1006, 314, 16606, 3004, 14, 3918, 4218, 3004, 883, 506, 1911, 641, 2195, 312, 17146, 15, 50, 16566, 1256, 2116, 737, 2569, 1166, 26, 4178, 921, 23334, 14, 2694, 14, 957, 15, 23334, 13, 3908, 15, 1246, 15, 1238, 3, 1313, 15, 17770, 2122, 272, 2138, 26, 298, 3314, 3182, 340, 16606, 365, 1911, 2122, 272, 730, 26, 1211, 199, 2344, 199, 199, 646, 5190, 199, 199, 893, 26, 272, 492, 312, 1042, 1086, 6341, 20, 14, 1313, 465, 312, 1313, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 23334, 492, 334, 272, 3523, 2377, 12, 272, 1104, 63, 9277, 12, 272, 1104, 63, 1162, 12, 272, 1218, 63, 2105, 12, 272, 4472, 12, 272, 21353, 63, 2861, 63, 2094, 63, 1650, 12, 272, 2754, 63, 991, 63, 354, 12, 199, 9, 421, 199, 533, 3918, 15660, 2377, 8, 1563, 2377, 304, 339, 347, 636, 362, 63, 8452, 8, 277, 12, 2615, 63, 1023, 304, 267, 340, 2615, 63, 1023, 365, 488, 26, 288, 372, 488, 267, 340, 1228, 8, 2861, 63, 1023, 12, 312, 1313, 14, 3353, 304, 288, 372, 2615, 63, 1023, 14, 8452, 267, 372, 1109, 8, 2861, 63, 1023, 14, 1294, 19237, 16, 566, 339, 347, 636, 362, 63, 11067, 8, 277, 12, 2615, 63, 1023, 304, 267, 340, 2615, 63, 1023, 365, 488, 26, 288, 372, 488, 267, 340, 1228, 8, 2861, 63, 1023, 12, 312, 1313, 14, 3353, 304, 288, 372, 2615, 63, 1023, 14, 11067, 267, 372, 1109, 8, 2861, 63, 1023, 14, 1294, 19237, 17, 566, 339, 347, 485, 362, 63, 3088, 63, 2293, 8, 277, 304, 267, 4497, 63, 2293, 275, 488, 267, 340, 291, 423, 578, 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, 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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 ]
AnthonyBroadCrawford/servo
tests/wpt/web-platform-tests/tools/pywebsocket/src/mod_pywebsocket/dispatch.py
652
14786
# Copyright 2012, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Dispatch WebSocket request. """ import logging import os import re from mod_pywebsocket import common from mod_pywebsocket import handshake from mod_pywebsocket import msgutil from mod_pywebsocket import mux from mod_pywebsocket import stream from mod_pywebsocket import util _SOURCE_PATH_PATTERN = re.compile(r'(?i)_wsh\.py$') _SOURCE_SUFFIX = '_wsh.py' _DO_EXTRA_HANDSHAKE_HANDLER_NAME = 'web_socket_do_extra_handshake' _TRANSFER_DATA_HANDLER_NAME = 'web_socket_transfer_data' _PASSIVE_CLOSING_HANDSHAKE_HANDLER_NAME = ( 'web_socket_passive_closing_handshake') class DispatchException(Exception): """Exception in dispatching WebSocket request.""" def __init__(self, name, status=common.HTTP_STATUS_NOT_FOUND): super(DispatchException, self).__init__(name) self.status = status def _default_passive_closing_handshake_handler(request): """Default web_socket_passive_closing_handshake handler.""" return common.STATUS_NORMAL_CLOSURE, '' def _normalize_path(path): """Normalize path. Args: path: the path to normalize. Path is converted to the absolute path. The input path can use either '\\' or '/' as the separator. The normalized path always uses '/' regardless of the platform. """ path = path.replace('\\', os.path.sep) path = os.path.realpath(path) path = path.replace('\\', '/') return path def _create_path_to_resource_converter(base_dir): """Returns a function that converts the path of a WebSocket handler source file to a resource string by removing the path to the base directory from its head, removing _SOURCE_SUFFIX from its tail, and replacing path separators in it with '/'. Args: base_dir: the path to the base directory. """ base_dir = _normalize_path(base_dir) base_len = len(base_dir) suffix_len = len(_SOURCE_SUFFIX) def converter(path): if not path.endswith(_SOURCE_SUFFIX): return None # _normalize_path must not be used because resolving symlink breaks # following path check. path = path.replace('\\', '/') if not path.startswith(base_dir): return None return path[base_len:-suffix_len] return converter def _enumerate_handler_file_paths(directory): """Returns a generator that enumerates WebSocket Handler source file names in the given directory. """ for root, unused_dirs, files in os.walk(directory): for base in files: path = os.path.join(root, base) if _SOURCE_PATH_PATTERN.search(path): yield path class _HandlerSuite(object): """A handler suite holder class.""" def __init__(self, do_extra_handshake, transfer_data, passive_closing_handshake): self.do_extra_handshake = do_extra_handshake self.transfer_data = transfer_data self.passive_closing_handshake = passive_closing_handshake def _source_handler_file(handler_definition): """Source a handler definition string. Args: handler_definition: a string containing Python statements that define handler functions. """ global_dic = {} try: exec handler_definition in global_dic except Exception: raise DispatchException('Error in sourcing handler:' + util.get_stack_trace()) passive_closing_handshake_handler = None try: passive_closing_handshake_handler = _extract_handler( global_dic, _PASSIVE_CLOSING_HANDSHAKE_HANDLER_NAME) except Exception: passive_closing_handshake_handler = ( _default_passive_closing_handshake_handler) return _HandlerSuite( _extract_handler(global_dic, _DO_EXTRA_HANDSHAKE_HANDLER_NAME), _extract_handler(global_dic, _TRANSFER_DATA_HANDLER_NAME), passive_closing_handshake_handler) def _extract_handler(dic, name): """Extracts a callable with the specified name from the given dictionary dic. """ if name not in dic: raise DispatchException('%s is not defined.' % name) handler = dic[name] if not callable(handler): raise DispatchException('%s is not callable.' % name) return handler class Dispatcher(object): """Dispatches WebSocket requests. This class maintains a map from resource name to handlers. """ def __init__( self, root_dir, scan_dir=None, allow_handlers_outside_root_dir=True): """Construct an instance. Args: root_dir: The directory where handler definition files are placed. scan_dir: The directory where handler definition files are searched. scan_dir must be a directory under root_dir, including root_dir itself. If scan_dir is None, root_dir is used as scan_dir. scan_dir can be useful in saving scan time when root_dir contains many subdirectories. allow_handlers_outside_root_dir: Scans handler files even if their canonical path is not under root_dir. """ self._logger = util.get_class_logger(self) self._handler_suite_map = {} self._source_warnings = [] if scan_dir is None: scan_dir = root_dir if not os.path.realpath(scan_dir).startswith( os.path.realpath(root_dir)): raise DispatchException('scan_dir:%s must be a directory under ' 'root_dir:%s.' % (scan_dir, root_dir)) self._source_handler_files_in_dir( root_dir, scan_dir, allow_handlers_outside_root_dir) def add_resource_path_alias(self, alias_resource_path, existing_resource_path): """Add resource path alias. Once added, request to alias_resource_path would be handled by handler registered for existing_resource_path. Args: alias_resource_path: alias resource path existing_resource_path: existing resource path """ try: handler_suite = self._handler_suite_map[existing_resource_path] self._handler_suite_map[alias_resource_path] = handler_suite except KeyError: raise DispatchException('No handler for: %r' % existing_resource_path) def source_warnings(self): """Return warnings in sourcing handlers.""" return self._source_warnings def do_extra_handshake(self, request): """Do extra checking in WebSocket handshake. Select a handler based on request.uri and call its web_socket_do_extra_handshake function. Args: request: mod_python request. Raises: DispatchException: when handler was not found AbortedByUserException: when user handler abort connection HandshakeException: when opening handshake failed """ handler_suite = self.get_handler_suite(request.ws_resource) if handler_suite is None: raise DispatchException('No handler for: %r' % request.ws_resource) do_extra_handshake_ = handler_suite.do_extra_handshake try: do_extra_handshake_(request) except handshake.AbortedByUserException, e: # Re-raise to tell the caller of this function to finish this # connection without sending any error. self._logger.debug('%s', util.get_stack_trace()) raise except Exception, e: util.prepend_message_to_exception( '%s raised exception for %s: ' % ( _DO_EXTRA_HANDSHAKE_HANDLER_NAME, request.ws_resource), e) raise handshake.HandshakeException(e, common.HTTP_STATUS_FORBIDDEN) def transfer_data(self, request): """Let a handler transfer_data with a WebSocket client. Select a handler based on request.ws_resource and call its web_socket_transfer_data function. Args: request: mod_python request. Raises: DispatchException: when handler was not found AbortedByUserException: when user handler abort connection """ # TODO(tyoshino): Terminate underlying TCP connection if possible. try: if mux.use_mux(request): mux.start(request, self) else: handler_suite = self.get_handler_suite(request.ws_resource) if handler_suite is None: raise DispatchException('No handler for: %r' % request.ws_resource) transfer_data_ = handler_suite.transfer_data transfer_data_(request) if not request.server_terminated: request.ws_stream.close_connection() # Catch non-critical exceptions the handler didn't handle. except handshake.AbortedByUserException, e: self._logger.debug('%s', util.get_stack_trace()) raise except msgutil.BadOperationException, e: self._logger.debug('%s', e) request.ws_stream.close_connection( common.STATUS_INTERNAL_ENDPOINT_ERROR) except msgutil.InvalidFrameException, e: # InvalidFrameException must be caught before # ConnectionTerminatedException that catches InvalidFrameException. self._logger.debug('%s', e) request.ws_stream.close_connection(common.STATUS_PROTOCOL_ERROR) except msgutil.UnsupportedFrameException, e: self._logger.debug('%s', e) request.ws_stream.close_connection(common.STATUS_UNSUPPORTED_DATA) except stream.InvalidUTF8Exception, e: self._logger.debug('%s', e) request.ws_stream.close_connection( common.STATUS_INVALID_FRAME_PAYLOAD_DATA) except msgutil.ConnectionTerminatedException, e: self._logger.debug('%s', e) except Exception, e: # Any other exceptions are forwarded to the caller of this # function. util.prepend_message_to_exception( '%s raised exception for %s: ' % ( _TRANSFER_DATA_HANDLER_NAME, request.ws_resource), e) raise def passive_closing_handshake(self, request): """Prepare code and reason for responding client initiated closing handshake. """ handler_suite = self.get_handler_suite(request.ws_resource) if handler_suite is None: return _default_passive_closing_handshake_handler(request) return handler_suite.passive_closing_handshake(request) def get_handler_suite(self, resource): """Retrieves two handlers (one for extra handshake processing, and one for data transfer) for the given request as a HandlerSuite object. """ fragment = None if '#' in resource: resource, fragment = resource.split('#', 1) if '?' in resource: resource = resource.split('?', 1)[0] handler_suite = self._handler_suite_map.get(resource) if handler_suite and fragment: raise DispatchException('Fragment identifiers MUST NOT be used on ' 'WebSocket URIs', common.HTTP_STATUS_BAD_REQUEST) return handler_suite def _source_handler_files_in_dir( self, root_dir, scan_dir, allow_handlers_outside_root_dir): """Source all the handler source files in the scan_dir directory. The resource path is determined relative to root_dir. """ # We build a map from resource to handler code assuming that there's # only one path from root_dir to scan_dir and it can be obtained by # comparing realpath of them. # Here we cannot use abspath. See # https://bugs.webkit.org/show_bug.cgi?id=31603 convert = _create_path_to_resource_converter(root_dir) scan_realpath = os.path.realpath(scan_dir) root_realpath = os.path.realpath(root_dir) for path in _enumerate_handler_file_paths(scan_realpath): if (not allow_handlers_outside_root_dir and (not os.path.realpath(path).startswith(root_realpath))): self._logger.debug( 'Canonical path of %s is not under root directory' % path) continue try: handler_suite = _source_handler_file(open(path).read()) except DispatchException, e: self._source_warnings.append('%s: %s' % (path, e)) continue resource = convert(path) if resource is None: self._logger.debug( 'Path to resource conversion on %s failed' % path) else: self._handler_suite_map[convert(path)] = handler_suite # vi:sts=4 sw=4 et
mpl-2.0
[ 3, 1898, 6029, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 624, 20628, 18846, 1056, 14, 199, 624, 421, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 199, 504, 3413, 63, 21387, 492, 2863, 199, 504, 3413, 63, 21387, 492, 14305, 199, 504, 3413, 63, 21387, 492, 1499, 1974, 199, 504, 3413, 63, 21387, 492, 22343, 199, 504, 3413, 63, 21387, 492, 2547, 199, 504, 3413, 63, 21387, 492, 4884, 421, 199, 63, 10187, 63, 3243, 63, 10764, 275, 295, 14, 2014, 8, 82, 10120, 73, 9, 63, 87, 609, 4537, 647, 9988, 199, 63, 10187, 63, 12273, 275, 2513, 87, 609, 14, 647, 7, 199, 63, 1649, 63, 18555, 63, 40, 20033, 6294, 2430, 63, 30872, 63, 2339, 275, 283, 2520, 63, 3450, 63, 1117, 63, 2911, 63, 11913, 7, 199, 63, 12191, 15849, 63, 3998, 63, 30872, 63, 2339, 275, 283, 2520, 63, 3450, 63, 9609, 63, 576, 7, 199, 63, 29634, 63, 10353, 12567, 63, 40, 20033, 6294, 2430, 63, 30872, 63, 2339, 275, 334, 272, 283, 2520, 63, 3450, 63, 25166, 63, 11707, 63, 11913, 358, 421, 199, 533, 28626, 1726, 8, 1726, 304, 272, 408, 1726, 315, 7634, 316, 18846, 1056, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2004, 29, 2330, 14, 2856, 63, 6305, 63, 4609, 63, 13945, 304, 267, 1613, 8, 20628, 1726, 12, 291, 2843, 826, 721, 354, 9, 267, 291, 14, 1205, 275, 2004, 421, 199, 318, 485, 885, 63, 25166, 63, 11707, 63, 11913, 63, 2232, 8, 1069, 304, 272, 408, 2698, 3330, 63, 3450, 63, 25166, 63, 11707, 63, 11913, 3016, 1041, 339, 372, 2863, 14, 6305, 63, 10765, 63, 10353, 51, 3942, 12, 2125, 421, 199, 318, 485, 7721, 63, 515, 8, 515, 304, 272, 408, 22580, 931, 14, 339, 3033, 26, 267, 931, 26, 314, 931, 370, 7666, 14, 339, 6912, 365, 6702, 370, 314, 3679, 931, 14, 272, 710, 1324, 931, 883, 675, 1902, 22548, 503, 7324, 465, 314, 9432, 14, 272, 710, 9657, 931, 3544, 4440, 7324, 15270, 402, 314, 4298, 14, 272, 408, 339, 931, 275, 931, 14, 1814, 20786, 747, 14, 515, 14, 4127, 9, 272, 931, 275, 747, 14, 515, 14, 11091, 8, 515, 9, 272, 931, 275, 931, 14, 1814, 20786, 15107, 272, 372, 931, 421, 199, 318, 485, 981, 63, 515, 63, 475, 63, 1927, 63, 11256, 8, 1095, 63, 694, 304, 272, 408, 3407, 282, 805, 626, 15373, 314, 931, 402, 282, 18846, 3016, 1350, 272, 570, 370, 282, 2073, 1059, 701, 12881, 314, 931, 370, 314, 1300, 2082, 687, 272, 2399, 4854, 12, 12881, 485, 10187, 63, 12273, 687, 2399, 9483, 12, 436, 15810, 931, 272, 17658, 315, 652, 543, 20538, 339, 3033, 26, 267, 1300, 63, 694, 26, 314, 931, 370, 314, 1300, 2082, 14, 272, 408, 339, 1300, 63, 694, 275, 485, 7721, 63, 515, 8, 1095, 63, 694, 9, 339, 1300, 63, 552, 275, 822, 8, 1095, 63, 694, 9, 272, 4739, 63, 552, 275, 822, 1547, 10187, 63, 12273, 9, 339, 347, 11109, 8, 515, 304, 267, 340, 440, 931, 14, 4130, 1547, 10187, 63, 12273, 304, 288, 372, 488, 267, 327, 485, 7721, 63, 515, 1471, 440, 506, 1202, 2952, 30685, 15296, 18277, 267, 327, 2569, 931, 1104, 14, 267, 931, 275, 931, 14, 1814, 20786, 15107, 267, 340, 440, 931, 14, 2460, 8, 1095, 63, 694, 304, 288, 372, 488, 267, 372, 931, 59, 1095, 63, 552, 6809, 4511, 63, 552, 61, 339, 372, 11109, 421, 199, 318, 485, 26318, 63, 2232, 63, 493, 63, 3771, 8, 3619, 304, 272, 408, 3407, 282, 4306, 626, 3874, 83, 18846, 18599, 1350, 570, 1561, 272, 315, 314, 1627, 2082, 14, 272, 408, 339, 367, 1738, 12, 9563, 63, 3220, 12, 1584, 315, 747, 14, 7757, 8, 3619, 304, 267, 367, 1300, 315, 1584, 26, 288, 931, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 1300, 9, 288, 340, 485, 10187, 63, 3243, 63, 10764, 14, 1733, 8, 515, 304, 355, 1995, 931, 421, 199, 533, 485, 2461, 6207, 8, 785, 304, 272, 408, 33, 3016, 5241, 16712, 1021, 1041, 339, 347, 636, 826, 721, 277, 12, 886, 63, 2911, 63, 11913, 12, 9307, 63, 576, 12, 326, 21010, 63, 11707, 63, 11913, 304, 267, 291, 14, 1117, 63, 2911, 63, 11913 ]
[ 1898, 6029, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 624, 20628, 18846, 1056, 14, 199, 624, 421, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 199, 504, 3413, 63, 21387, 492, 2863, 199, 504, 3413, 63, 21387, 492, 14305, 199, 504, 3413, 63, 21387, 492, 1499, 1974, 199, 504, 3413, 63, 21387, 492, 22343, 199, 504, 3413, 63, 21387, 492, 2547, 199, 504, 3413, 63, 21387, 492, 4884, 421, 199, 63, 10187, 63, 3243, 63, 10764, 275, 295, 14, 2014, 8, 82, 10120, 73, 9, 63, 87, 609, 4537, 647, 9988, 199, 63, 10187, 63, 12273, 275, 2513, 87, 609, 14, 647, 7, 199, 63, 1649, 63, 18555, 63, 40, 20033, 6294, 2430, 63, 30872, 63, 2339, 275, 283, 2520, 63, 3450, 63, 1117, 63, 2911, 63, 11913, 7, 199, 63, 12191, 15849, 63, 3998, 63, 30872, 63, 2339, 275, 283, 2520, 63, 3450, 63, 9609, 63, 576, 7, 199, 63, 29634, 63, 10353, 12567, 63, 40, 20033, 6294, 2430, 63, 30872, 63, 2339, 275, 334, 272, 283, 2520, 63, 3450, 63, 25166, 63, 11707, 63, 11913, 358, 421, 199, 533, 28626, 1726, 8, 1726, 304, 272, 408, 1726, 315, 7634, 316, 18846, 1056, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 12, 2004, 29, 2330, 14, 2856, 63, 6305, 63, 4609, 63, 13945, 304, 267, 1613, 8, 20628, 1726, 12, 291, 2843, 826, 721, 354, 9, 267, 291, 14, 1205, 275, 2004, 421, 199, 318, 485, 885, 63, 25166, 63, 11707, 63, 11913, 63, 2232, 8, 1069, 304, 272, 408, 2698, 3330, 63, 3450, 63, 25166, 63, 11707, 63, 11913, 3016, 1041, 339, 372, 2863, 14, 6305, 63, 10765, 63, 10353, 51, 3942, 12, 2125, 421, 199, 318, 485, 7721, 63, 515, 8, 515, 304, 272, 408, 22580, 931, 14, 339, 3033, 26, 267, 931, 26, 314, 931, 370, 7666, 14, 339, 6912, 365, 6702, 370, 314, 3679, 931, 14, 272, 710, 1324, 931, 883, 675, 1902, 22548, 503, 7324, 465, 314, 9432, 14, 272, 710, 9657, 931, 3544, 4440, 7324, 15270, 402, 314, 4298, 14, 272, 408, 339, 931, 275, 931, 14, 1814, 20786, 747, 14, 515, 14, 4127, 9, 272, 931, 275, 747, 14, 515, 14, 11091, 8, 515, 9, 272, 931, 275, 931, 14, 1814, 20786, 15107, 272, 372, 931, 421, 199, 318, 485, 981, 63, 515, 63, 475, 63, 1927, 63, 11256, 8, 1095, 63, 694, 304, 272, 408, 3407, 282, 805, 626, 15373, 314, 931, 402, 282, 18846, 3016, 1350, 272, 570, 370, 282, 2073, 1059, 701, 12881, 314, 931, 370, 314, 1300, 2082, 687, 272, 2399, 4854, 12, 12881, 485, 10187, 63, 12273, 687, 2399, 9483, 12, 436, 15810, 931, 272, 17658, 315, 652, 543, 20538, 339, 3033, 26, 267, 1300, 63, 694, 26, 314, 931, 370, 314, 1300, 2082, 14, 272, 408, 339, 1300, 63, 694, 275, 485, 7721, 63, 515, 8, 1095, 63, 694, 9, 339, 1300, 63, 552, 275, 822, 8, 1095, 63, 694, 9, 272, 4739, 63, 552, 275, 822, 1547, 10187, 63, 12273, 9, 339, 347, 11109, 8, 515, 304, 267, 340, 440, 931, 14, 4130, 1547, 10187, 63, 12273, 304, 288, 372, 488, 267, 327, 485, 7721, 63, 515, 1471, 440, 506, 1202, 2952, 30685, 15296, 18277, 267, 327, 2569, 931, 1104, 14, 267, 931, 275, 931, 14, 1814, 20786, 15107, 267, 340, 440, 931, 14, 2460, 8, 1095, 63, 694, 304, 288, 372, 488, 267, 372, 931, 59, 1095, 63, 552, 6809, 4511, 63, 552, 61, 339, 372, 11109, 421, 199, 318, 485, 26318, 63, 2232, 63, 493, 63, 3771, 8, 3619, 304, 272, 408, 3407, 282, 4306, 626, 3874, 83, 18846, 18599, 1350, 570, 1561, 272, 315, 314, 1627, 2082, 14, 272, 408, 339, 367, 1738, 12, 9563, 63, 3220, 12, 1584, 315, 747, 14, 7757, 8, 3619, 304, 267, 367, 1300, 315, 1584, 26, 288, 931, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 1300, 9, 288, 340, 485, 10187, 63, 3243, 63, 10764, 14, 1733, 8, 515, 304, 355, 1995, 931, 421, 199, 533, 485, 2461, 6207, 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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 ]
mimecine/mongrel2
examples/ws/python/echo.py
55
3488
import simplejson as json from mongrel2 import handler import wsutil import sys import time import re sender_id = "82209006-86FF-4982-B5EA-D1E29E55D480" conn = handler.Connection(sender_id, "tcp://127.0.0.1:9990", "tcp://127.0.0.1:9989") CONNECTION_TIMEOUT=5 closingMessages={} badUnicode=re.compile(u'[\ud800-\udfff]') logf=open('echo.log','wb') #logf=open('/dev/null','wb') #logf=sys.stdout def abortConnection(conn,req,reason='none',code=None): #print 'abort',conn,req,reason,code if code is not None: #print "Closing cleanly\n" conn.reply_websocket(req,code+reason,opcode=wsutil.OP_CLOSE) closingMessages[req.conn_id]=(time.time(),req.sender) else: conn.reply(req,'') print >>logf,'abort',code,reason while True: now=time.time() logf.flush() for k,(t,uuid) in closingMessages.items(): if now > t+CONNECTION_TIMEOUT: conn.send(uuid,k,'') try: req = conn.recv() except: print "FAILED RECV" continue if req.is_disconnect(): #print "DISCONNECTED", req.conn_id continue if req.headers.get('METHOD') == 'WEBSOCKET_HANDSHAKE': #print "HANDSHAKE" conn.reply(req, '\r\n'.join([ "HTTP/1.1 101 Switching Protocols", "Upgrade: websocket", "Connection: Upgrade", "Sec-WebSocket-Accept: %s\r\n\r\n"])%req.body) continue if req.headers.get('METHOD') != 'WEBSOCKET': print 'METHOD is Not WEBSOCKET:',req.headers#,req.body conn.reply(req,'') continue try: #print 'headers',req.headers flags = int(req.headers.get('FLAGS'),16) fin = flags&0x80==0x80 rsvd=flags & 0x70 opcode=flags & 0xf wsdata = req.body #print fin,rsvd,opcode,len(wsdata),wsdata #logf.write('\n') except: #print "Unable to decode FLAGS" abortConnection(conn,req,'WS decode failed') #continue if rsvd != 0: abortConnection(conn,req,'reserved non-zero', wsutil.CLOSE_PROTOCOL_ERROR) continue if opcode == wsutil.OP_CLOSE: if req.conn_id in closingMessages: del closingMessages[req.conn_id] conn.reply(req,'') else: conn.reply_websocket(req,wsdata,opcode) conn.reply(req,'') continue if req.conn_id in closingMessages: continue if opcode not in wsutil.opcodes: abortConnection(conn,req,'Unknown opcode', wsutil.CLOSE_PROTOCOL_ERROR) continue if (opcode & 0x8) != 0: if opcode ==wsutil.OP_PING: opcode = wsutil.OP_PONG conn.reply_websocket(req,wsdata,opcode) continue if opcode == wsutil.OP_PONG: continue # We don't send pings, so ignore pongs if(opcode == wsutil.OP_TEXT): try: x=wsdata.decode('utf-8') #Thank you for not fixing python issue8271 in 2.x :( if badUnicode.search(x): raise UnicodeError('Surrogates not allowed') #for c in x: #if (0xd800 <= ord(c) <= 0xdfff): #raise UnicodeError('Surrogates not allowed') except: abortConnection(conn,req,'invalid UTF', wsutil.CLOSE_BAD_DATA) continue conn.reply_websocket(req,wsdata,opcode)
bsd-3-clause
[ 646, 13804, 465, 2022, 199, 504, 32315, 3369, 18, 492, 3016, 199, 646, 10900, 1974, 199, 646, 984, 199, 646, 900, 199, 646, 295, 199, 199, 8114, 63, 344, 275, 298, 10228, 1643, 8010, 13, 1184, 1665, 13, 1887, 2564, 13, 34, 21, 11765, 13, 36, 17, 37, 1398, 37, 1229, 36, 21853, 2, 199, 199, 1631, 275, 3016, 14, 3225, 8, 8114, 63, 344, 12, 298, 8815, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 1020, 2710, 401, 2079, 298, 8815, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 1020, 1407, 531, 199, 199, 18389, 63, 8899, 29, 21, 199, 199, 11707, 14508, 7622, 199, 199, 4087, 7087, 29, 264, 14, 2014, 8, 85, 22123, 1181, 6718, 2696, 1181, 18190, 10374, 199, 199, 793, 70, 29, 1490, 360, 7878, 14, 793, 1673, 6603, 358, 199, 3, 793, 70, 29, 1490, 2336, 2374, 15, 2307, 1673, 6603, 358, 199, 3, 793, 70, 29, 1274, 14, 2703, 199, 199, 318, 12004, 3225, 8, 1631, 12, 2103, 12, 5764, 534, 3592, 297, 600, 29, 403, 304, 272, 327, 1361, 283, 13845, 297, 1631, 12, 2103, 12, 5764, 12, 600, 272, 340, 1233, 365, 440, 488, 26, 267, 327, 1361, 298, 18433, 3633, 590, 60, 78, 2, 267, 2557, 14, 8102, 63, 13508, 8, 2103, 12, 600, 11, 5764, 12, 14325, 29, 3569, 1974, 14, 1938, 63, 18219, 9, 267, 11261, 14508, 59, 2103, 14, 1631, 63, 344, 61, 2687, 521, 14, 521, 1062, 2103, 14, 8114, 9, 272, 587, 26, 267, 2557, 14, 8102, 8, 2103, 2584, 358, 272, 870, 4331, 793, 70, 2584, 13845, 297, 600, 12, 5764, 199, 199, 6710, 715, 26, 272, 3063, 29, 521, 14, 521, 342, 272, 943, 70, 14, 4939, 342, 272, 367, 1022, 12803, 84, 12, 2580, 9, 315, 11261, 14508, 14, 1744, 837, 267, 340, 3063, 690, 307, 11, 18389, 63, 8899, 26, 288, 2557, 14, 2254, 8, 2580, 12, 75, 2584, 358, 272, 862, 26, 267, 2648, 275, 2557, 14, 7637, 342, 272, 871, 26, 267, 870, 298, 12299, 19461, 54, 2, 267, 1980, 2378, 340, 2648, 14, 374, 63, 10673, 837, 267, 327, 1361, 298, 6178, 14657, 1149, 401, 2648, 14, 1631, 63, 344, 267, 1980, 339, 340, 2648, 14, 2139, 14, 362, 360, 9977, 358, 508, 283, 13166, 17462, 63, 40, 20033, 6294, 2430, 356, 267, 327, 1361, 298, 40, 20033, 6294, 2430, 2, 267, 2557, 14, 8102, 8, 2103, 12, 355, 1557, 82, 60, 78, 1370, 904, 779, 490, 298, 2856, 15, 17, 14, 17, 14313, 17711, 316, 2165, 475, 4574, 401, 490, 298, 19217, 26, 24897, 401, 490, 298, 3225, 26, 4949, 4523, 401, 490, 298, 4933, 13, 18477, 13, 8422, 26, 450, 83, 60, 82, 60, 78, 60, 82, 60, 78, 3135, 5, 2103, 14, 2030, 9, 267, 1980, 339, 340, 2648, 14, 2139, 14, 362, 360, 9977, 358, 1137, 283, 13166, 17462, 356, 267, 870, 283, 9977, 365, 2832, 644, 14138, 17462, 6536, 2103, 14, 2139, 3, 12, 2103, 14, 2030, 267, 2557, 14, 8102, 8, 2103, 2584, 358, 267, 1980, 339, 862, 26, 267, 327, 1361, 283, 2139, 297, 2103, 14, 2139, 267, 3285, 275, 1109, 8, 2103, 14, 2139, 14, 362, 360, 4831, 659, 975, 9, 267, 2583, 275, 3285, 6, 16, 88, 1257, 389, 16, 88, 1257, 267, 519, 18675, 29, 2469, 1253, 378, 88, 2760, 267, 10508, 29, 2469, 1253, 378, 1949, 267, 10900, 576, 275, 2648, 14, 2030, 267, 327, 1361, 2583, 12, 2393, 11549, 12, 14325, 12, 552, 8, 3569, 576, 395, 3569, 576, 267, 327, 793, 70, 14, 952, 2258, 78, 358, 272, 871, 26, 267, 327, 1361, 298, 6005, 370, 4849, 12846, 2, 267, 12004, 3225, 8, 1631, 12, 2103, 2584, 5035, 4849, 3405, 358, 267, 327, 6958, 339, 340, 519, 18675, 1137, 378, 26, 267, 12004, 3225, 8, 1631, 12, 2103, 2584, 10421, 2222, 13, 4262, 297, 355, 10900, 1974, 14, 18219, 63, 9583, 63, 3170, 9, 267, 1980, 339, 340, 10508, 508, 10900, 1974, 14, 1938, 63, 18219, 26, 267, 340, 2648, 14, 1631, 63, 344, 315, 11261, 14508, 26, 288, 2150, 11261, 14508, 59, 2103, 14, 1631, 63, 344, 61, 288, 2557, 14, 8102, 8, 2103, 2584, 358, 267, 587, 26, 288, 2557, 14, 8102, 63, 13508, 8, 2103, 12, 3569, 576, 12, 14325, 9, 288, 2557, 14, 8102, 8, 2103, 2584, 358, 267, 1980, 272, 340, 2648, 14, 1631, 63, 344, 315, 11261, 14508, 26, 267, 1980, 339, 340, 10508, 440, 315, 10900, 1974, 14, 22022, 26, 267, 12004, 3225, 8, 1631, 12, 2103, 2584, 5912, 10508, 297, 355, 10900, 1974, 14, 18219, 63, 9583, 63, 3170, 9, 267, 1980, 5493, 340, 334, 14325, 1253, 378, 88, 24, 9, 1137, 378, 26, 267, 340, 10508, 508, 3569, 1974, 14, 1938, 63, 15675, 26, 288, 10508, 275, 10900, 1974, 14, 1938, 63, 48, 7770, 288, 2557, 14, 8102, 63, 13508, 8, 2103, 12, 3569, 576, 12, 14325, 9, 398, 1980, 339, 340, 10508, 508, 10900, 1974, 14, 1938, 63, 48, 7770, 26, 267, 1980, 327, 2136, 2793, 1133, 3222, 299, 780, 12, 880, 3686, 299, 12358, 272, 340, 8, 14325, 508, 10900, 1974, 14, 1938, 63, 3876, 304, 267, 862, 26, 288, 671, 29, 3569, 576, 14, 2708, 360, 1624, 13, 24, 358, 288, 327, 2719, 3580, 1265, 367, 440, 5325, 316, 2366, 4976, 24, 16344, 315, 499, 14, 88, 520, 8, 288, 340, 4875, 7087, 14, 1733, 8, 88, 304, 355, 746, 20872, 360, 11762, 19029, 2335, 440, 4370, 358, 288, 327, 509, 286, 315, 671, 26, 355, 327, 692, 334, 16, 2207, 6718, 2695, 6206, 8, 67, 9, 2695, 378, 2207, 18190, 304, 490, 327, 3730, 20872, 360, 11762, 19029, 2335, 440, 4370, 358, 267, 871, 26, 288, 12004, 3225, 8, 1631, 12, 2103, 2584, 3197, 9094, 297, 10900, 1974, 14, 18219, 63, 9439, 63, 3998, 9, 288, 1980, 272, 2557, 14, 8102, 63, 13508, 8, 2103, 12, 3569, 576, 12, 14325, 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 ]
[ 13804, 465, 2022, 199, 504, 32315, 3369, 18, 492, 3016, 199, 646, 10900, 1974, 199, 646, 984, 199, 646, 900, 199, 646, 295, 199, 199, 8114, 63, 344, 275, 298, 10228, 1643, 8010, 13, 1184, 1665, 13, 1887, 2564, 13, 34, 21, 11765, 13, 36, 17, 37, 1398, 37, 1229, 36, 21853, 2, 199, 199, 1631, 275, 3016, 14, 3225, 8, 8114, 63, 344, 12, 298, 8815, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 1020, 2710, 401, 2079, 298, 8815, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 1020, 1407, 531, 199, 199, 18389, 63, 8899, 29, 21, 199, 199, 11707, 14508, 7622, 199, 199, 4087, 7087, 29, 264, 14, 2014, 8, 85, 22123, 1181, 6718, 2696, 1181, 18190, 10374, 199, 199, 793, 70, 29, 1490, 360, 7878, 14, 793, 1673, 6603, 358, 199, 3, 793, 70, 29, 1490, 2336, 2374, 15, 2307, 1673, 6603, 358, 199, 3, 793, 70, 29, 1274, 14, 2703, 199, 199, 318, 12004, 3225, 8, 1631, 12, 2103, 12, 5764, 534, 3592, 297, 600, 29, 403, 304, 272, 327, 1361, 283, 13845, 297, 1631, 12, 2103, 12, 5764, 12, 600, 272, 340, 1233, 365, 440, 488, 26, 267, 327, 1361, 298, 18433, 3633, 590, 60, 78, 2, 267, 2557, 14, 8102, 63, 13508, 8, 2103, 12, 600, 11, 5764, 12, 14325, 29, 3569, 1974, 14, 1938, 63, 18219, 9, 267, 11261, 14508, 59, 2103, 14, 1631, 63, 344, 61, 2687, 521, 14, 521, 1062, 2103, 14, 8114, 9, 272, 587, 26, 267, 2557, 14, 8102, 8, 2103, 2584, 358, 272, 870, 4331, 793, 70, 2584, 13845, 297, 600, 12, 5764, 199, 199, 6710, 715, 26, 272, 3063, 29, 521, 14, 521, 342, 272, 943, 70, 14, 4939, 342, 272, 367, 1022, 12803, 84, 12, 2580, 9, 315, 11261, 14508, 14, 1744, 837, 267, 340, 3063, 690, 307, 11, 18389, 63, 8899, 26, 288, 2557, 14, 2254, 8, 2580, 12, 75, 2584, 358, 272, 862, 26, 267, 2648, 275, 2557, 14, 7637, 342, 272, 871, 26, 267, 870, 298, 12299, 19461, 54, 2, 267, 1980, 2378, 340, 2648, 14, 374, 63, 10673, 837, 267, 327, 1361, 298, 6178, 14657, 1149, 401, 2648, 14, 1631, 63, 344, 267, 1980, 339, 340, 2648, 14, 2139, 14, 362, 360, 9977, 358, 508, 283, 13166, 17462, 63, 40, 20033, 6294, 2430, 356, 267, 327, 1361, 298, 40, 20033, 6294, 2430, 2, 267, 2557, 14, 8102, 8, 2103, 12, 355, 1557, 82, 60, 78, 1370, 904, 779, 490, 298, 2856, 15, 17, 14, 17, 14313, 17711, 316, 2165, 475, 4574, 401, 490, 298, 19217, 26, 24897, 401, 490, 298, 3225, 26, 4949, 4523, 401, 490, 298, 4933, 13, 18477, 13, 8422, 26, 450, 83, 60, 82, 60, 78, 60, 82, 60, 78, 3135, 5, 2103, 14, 2030, 9, 267, 1980, 339, 340, 2648, 14, 2139, 14, 362, 360, 9977, 358, 1137, 283, 13166, 17462, 356, 267, 870, 283, 9977, 365, 2832, 644, 14138, 17462, 6536, 2103, 14, 2139, 3, 12, 2103, 14, 2030, 267, 2557, 14, 8102, 8, 2103, 2584, 358, 267, 1980, 339, 862, 26, 267, 327, 1361, 283, 2139, 297, 2103, 14, 2139, 267, 3285, 275, 1109, 8, 2103, 14, 2139, 14, 362, 360, 4831, 659, 975, 9, 267, 2583, 275, 3285, 6, 16, 88, 1257, 389, 16, 88, 1257, 267, 519, 18675, 29, 2469, 1253, 378, 88, 2760, 267, 10508, 29, 2469, 1253, 378, 1949, 267, 10900, 576, 275, 2648, 14, 2030, 267, 327, 1361, 2583, 12, 2393, 11549, 12, 14325, 12, 552, 8, 3569, 576, 395, 3569, 576, 267, 327, 793, 70, 14, 952, 2258, 78, 358, 272, 871, 26, 267, 327, 1361, 298, 6005, 370, 4849, 12846, 2, 267, 12004, 3225, 8, 1631, 12, 2103, 2584, 5035, 4849, 3405, 358, 267, 327, 6958, 339, 340, 519, 18675, 1137, 378, 26, 267, 12004, 3225, 8, 1631, 12, 2103, 2584, 10421, 2222, 13, 4262, 297, 355, 10900, 1974, 14, 18219, 63, 9583, 63, 3170, 9, 267, 1980, 339, 340, 10508, 508, 10900, 1974, 14, 1938, 63, 18219, 26, 267, 340, 2648, 14, 1631, 63, 344, 315, 11261, 14508, 26, 288, 2150, 11261, 14508, 59, 2103, 14, 1631, 63, 344, 61, 288, 2557, 14, 8102, 8, 2103, 2584, 358, 267, 587, 26, 288, 2557, 14, 8102, 63, 13508, 8, 2103, 12, 3569, 576, 12, 14325, 9, 288, 2557, 14, 8102, 8, 2103, 2584, 358, 267, 1980, 272, 340, 2648, 14, 1631, 63, 344, 315, 11261, 14508, 26, 267, 1980, 339, 340, 10508, 440, 315, 10900, 1974, 14, 22022, 26, 267, 12004, 3225, 8, 1631, 12, 2103, 2584, 5912, 10508, 297, 355, 10900, 1974, 14, 18219, 63, 9583, 63, 3170, 9, 267, 1980, 5493, 340, 334, 14325, 1253, 378, 88, 24, 9, 1137, 378, 26, 267, 340, 10508, 508, 3569, 1974, 14, 1938, 63, 15675, 26, 288, 10508, 275, 10900, 1974, 14, 1938, 63, 48, 7770, 288, 2557, 14, 8102, 63, 13508, 8, 2103, 12, 3569, 576, 12, 14325, 9, 398, 1980, 339, 340, 10508, 508, 10900, 1974, 14, 1938, 63, 48, 7770, 26, 267, 1980, 327, 2136, 2793, 1133, 3222, 299, 780, 12, 880, 3686, 299, 12358, 272, 340, 8, 14325, 508, 10900, 1974, 14, 1938, 63, 3876, 304, 267, 862, 26, 288, 671, 29, 3569, 576, 14, 2708, 360, 1624, 13, 24, 358, 288, 327, 2719, 3580, 1265, 367, 440, 5325, 316, 2366, 4976, 24, 16344, 315, 499, 14, 88, 520, 8, 288, 340, 4875, 7087, 14, 1733, 8, 88, 304, 355, 746, 20872, 360, 11762, 19029, 2335, 440, 4370, 358, 288, 327, 509, 286, 315, 671, 26, 355, 327, 692, 334, 16, 2207, 6718, 2695, 6206, 8, 67, 9, 2695, 378, 2207, 18190, 304, 490, 327, 3730, 20872, 360, 11762, 19029, 2335, 440, 4370, 358, 267, 871, 26, 288, 12004, 3225, 8, 1631, 12, 2103, 2584, 3197, 9094, 297, 10900, 1974, 14, 18219, 63, 9439, 63, 3998, 9, 288, 1980, 272, 2557, 14, 8102, 63, 13508, 8, 2103, 12, 3569, 576, 12, 14325, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Sorsly/subtle
google-cloud-sdk/lib/third_party/google/protobuf/internal/wire_format_test.py
126
10930
#! /usr/bin/env python # # Protocol Buffers - Google's data interchange format # Copyright 2008 Google Inc. All rights reserved. # https://developers.google.com/protocol-buffers/ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Test for google.protobuf.internal.wire_format.""" __author__ = 'robinson@google.com (Will Robinson)' try: import unittest2 as unittest #PY26 except ImportError: import unittest from google.protobuf import message from google.protobuf.internal import wire_format class WireFormatTest(unittest.TestCase): def testPackTag(self): field_number = 0xabc tag_type = 2 self.assertEqual((field_number << 3) | tag_type, wire_format.PackTag(field_number, tag_type)) PackTag = wire_format.PackTag # Number too high. self.assertRaises(message.EncodeError, PackTag, field_number, 6) # Number too low. self.assertRaises(message.EncodeError, PackTag, field_number, -1) def testUnpackTag(self): # Test field numbers that will require various varint sizes. for expected_field_number in (1, 15, 16, 2047, 2048): for expected_wire_type in range(6): # Highest-numbered wiretype is 5. field_number, wire_type = wire_format.UnpackTag( wire_format.PackTag(expected_field_number, expected_wire_type)) self.assertEqual(expected_field_number, field_number) self.assertEqual(expected_wire_type, wire_type) self.assertRaises(TypeError, wire_format.UnpackTag, None) self.assertRaises(TypeError, wire_format.UnpackTag, 'abc') self.assertRaises(TypeError, wire_format.UnpackTag, 0.0) self.assertRaises(TypeError, wire_format.UnpackTag, object()) def testZigZagEncode(self): Z = wire_format.ZigZagEncode self.assertEqual(0, Z(0)) self.assertEqual(1, Z(-1)) self.assertEqual(2, Z(1)) self.assertEqual(3, Z(-2)) self.assertEqual(4, Z(2)) self.assertEqual(0xfffffffe, Z(0x7fffffff)) self.assertEqual(0xffffffff, Z(-0x80000000)) self.assertEqual(0xfffffffffffffffe, Z(0x7fffffffffffffff)) self.assertEqual(0xffffffffffffffff, Z(-0x8000000000000000)) self.assertRaises(TypeError, Z, None) self.assertRaises(TypeError, Z, 'abcd') self.assertRaises(TypeError, Z, 0.0) self.assertRaises(TypeError, Z, object()) def testZigZagDecode(self): Z = wire_format.ZigZagDecode self.assertEqual(0, Z(0)) self.assertEqual(-1, Z(1)) self.assertEqual(1, Z(2)) self.assertEqual(-2, Z(3)) self.assertEqual(2, Z(4)) self.assertEqual(0x7fffffff, Z(0xfffffffe)) self.assertEqual(-0x80000000, Z(0xffffffff)) self.assertEqual(0x7fffffffffffffff, Z(0xfffffffffffffffe)) self.assertEqual(-0x8000000000000000, Z(0xffffffffffffffff)) self.assertRaises(TypeError, Z, None) self.assertRaises(TypeError, Z, 'abcd') self.assertRaises(TypeError, Z, 0.0) self.assertRaises(TypeError, Z, object()) def NumericByteSizeTestHelper(self, byte_size_fn, value, expected_value_size): # Use field numbers that cause various byte sizes for the tag information. for field_number, tag_bytes in ((15, 1), (16, 2), (2047, 2), (2048, 3)): expected_size = expected_value_size + tag_bytes actual_size = byte_size_fn(field_number, value) self.assertEqual(expected_size, actual_size, 'byte_size_fn: %s, field_number: %d, value: %r\n' 'Expected: %d, Actual: %d'% ( byte_size_fn, field_number, value, expected_size, actual_size)) def testByteSizeFunctions(self): # Test all numeric *ByteSize() functions. NUMERIC_ARGS = [ # Int32ByteSize(). [wire_format.Int32ByteSize, 0, 1], [wire_format.Int32ByteSize, 127, 1], [wire_format.Int32ByteSize, 128, 2], [wire_format.Int32ByteSize, -1, 10], # Int64ByteSize(). [wire_format.Int64ByteSize, 0, 1], [wire_format.Int64ByteSize, 127, 1], [wire_format.Int64ByteSize, 128, 2], [wire_format.Int64ByteSize, -1, 10], # UInt32ByteSize(). [wire_format.UInt32ByteSize, 0, 1], [wire_format.UInt32ByteSize, 127, 1], [wire_format.UInt32ByteSize, 128, 2], [wire_format.UInt32ByteSize, wire_format.UINT32_MAX, 5], # UInt64ByteSize(). [wire_format.UInt64ByteSize, 0, 1], [wire_format.UInt64ByteSize, 127, 1], [wire_format.UInt64ByteSize, 128, 2], [wire_format.UInt64ByteSize, wire_format.UINT64_MAX, 10], # SInt32ByteSize(). [wire_format.SInt32ByteSize, 0, 1], [wire_format.SInt32ByteSize, -1, 1], [wire_format.SInt32ByteSize, 1, 1], [wire_format.SInt32ByteSize, -63, 1], [wire_format.SInt32ByteSize, 63, 1], [wire_format.SInt32ByteSize, -64, 1], [wire_format.SInt32ByteSize, 64, 2], # SInt64ByteSize(). [wire_format.SInt64ByteSize, 0, 1], [wire_format.SInt64ByteSize, -1, 1], [wire_format.SInt64ByteSize, 1, 1], [wire_format.SInt64ByteSize, -63, 1], [wire_format.SInt64ByteSize, 63, 1], [wire_format.SInt64ByteSize, -64, 1], [wire_format.SInt64ByteSize, 64, 2], # Fixed32ByteSize(). [wire_format.Fixed32ByteSize, 0, 4], [wire_format.Fixed32ByteSize, wire_format.UINT32_MAX, 4], # Fixed64ByteSize(). [wire_format.Fixed64ByteSize, 0, 8], [wire_format.Fixed64ByteSize, wire_format.UINT64_MAX, 8], # SFixed32ByteSize(). [wire_format.SFixed32ByteSize, 0, 4], [wire_format.SFixed32ByteSize, wire_format.INT32_MIN, 4], [wire_format.SFixed32ByteSize, wire_format.INT32_MAX, 4], # SFixed64ByteSize(). [wire_format.SFixed64ByteSize, 0, 8], [wire_format.SFixed64ByteSize, wire_format.INT64_MIN, 8], [wire_format.SFixed64ByteSize, wire_format.INT64_MAX, 8], # FloatByteSize(). [wire_format.FloatByteSize, 0.0, 4], [wire_format.FloatByteSize, 1000000000.0, 4], [wire_format.FloatByteSize, -1000000000.0, 4], # DoubleByteSize(). [wire_format.DoubleByteSize, 0.0, 8], [wire_format.DoubleByteSize, 1000000000.0, 8], [wire_format.DoubleByteSize, -1000000000.0, 8], # BoolByteSize(). [wire_format.BoolByteSize, False, 1], [wire_format.BoolByteSize, True, 1], # EnumByteSize(). [wire_format.EnumByteSize, 0, 1], [wire_format.EnumByteSize, 127, 1], [wire_format.EnumByteSize, 128, 2], [wire_format.EnumByteSize, wire_format.UINT32_MAX, 5], ] for args in NUMERIC_ARGS: self.NumericByteSizeTestHelper(*args) # Test strings and bytes. for byte_size_fn in (wire_format.StringByteSize, wire_format.BytesByteSize): # 1 byte for tag, 1 byte for length, 3 bytes for contents. self.assertEqual(5, byte_size_fn(10, 'abc')) # 2 bytes for tag, 1 byte for length, 3 bytes for contents. self.assertEqual(6, byte_size_fn(16, 'abc')) # 2 bytes for tag, 2 bytes for length, 128 bytes for contents. self.assertEqual(132, byte_size_fn(16, 'a' * 128)) # Test UTF-8 string byte size calculation. # 1 byte for tag, 1 byte for length, 8 bytes for content. self.assertEqual(10, wire_format.StringByteSize( 5, b'\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82'.decode('utf-8'))) class MockMessage(object): def __init__(self, byte_size): self.byte_size = byte_size def ByteSize(self): return self.byte_size message_byte_size = 10 mock_message = MockMessage(byte_size=message_byte_size) # Test groups. # (2 * 1) bytes for begin and end tags, plus message_byte_size. self.assertEqual(2 + message_byte_size, wire_format.GroupByteSize(1, mock_message)) # (2 * 2) bytes for begin and end tags, plus message_byte_size. self.assertEqual(4 + message_byte_size, wire_format.GroupByteSize(16, mock_message)) # Test messages. # 1 byte for tag, plus 1 byte for length, plus contents. self.assertEqual(2 + mock_message.byte_size, wire_format.MessageByteSize(1, mock_message)) # 2 bytes for tag, plus 1 byte for length, plus contents. self.assertEqual(3 + mock_message.byte_size, wire_format.MessageByteSize(16, mock_message)) # 2 bytes for tag, plus 2 bytes for length, plus contents. mock_message.byte_size = 128 self.assertEqual(4 + mock_message.byte_size, wire_format.MessageByteSize(16, mock_message)) # Test message set item byte size. # 4 bytes for tags, plus 1 byte for length, plus 1 byte for type_id, # plus contents. mock_message.byte_size = 10 self.assertEqual(mock_message.byte_size + 6, wire_format.MessageSetItemByteSize(1, mock_message)) # 4 bytes for tags, plus 2 bytes for length, plus 1 byte for type_id, # plus contents. mock_message.byte_size = 128 self.assertEqual(mock_message.byte_size + 7, wire_format.MessageSetItemByteSize(1, mock_message)) # 4 bytes for tags, plus 2 bytes for length, plus 2 byte for type_id, # plus contents. self.assertEqual(mock_message.byte_size + 8, wire_format.MessageSetItemByteSize(128, mock_message)) # Too-long varint. self.assertRaises(message.EncodeError, wire_format.UInt64ByteSize, 1, 1 << 128) if __name__ == '__main__': unittest.main()
mit
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 11557, 699, 3043, 1192, 446, 4475, 1159, 666, 1640, 1461, 1475, 199, 3, 1898, 9079, 4475, 3277, 14, 221, 2900, 4481, 4644, 14, 199, 3, 4178, 921, 23826, 14, 3098, 14, 957, 15, 3922, 13, 17389, 15, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 774, 367, 6233, 14, 7204, 14, 4672, 14, 11239, 63, 908, 1041, 199, 199, 363, 2502, 363, 275, 283, 28191, 834, 32, 3098, 14, 957, 334, 20326, 6848, 1393, 834, 3171, 199, 199, 893, 26, 523, 492, 2882, 18, 465, 2882, 221, 327, 4521, 1479, 199, 2590, 3545, 26, 523, 492, 2882, 199, 199, 504, 6233, 14, 7204, 492, 1245, 199, 504, 6233, 14, 7204, 14, 4672, 492, 11799, 63, 908, 421, 199, 533, 644, 3621, 3484, 774, 8, 2796, 14, 1746, 304, 819, 347, 511, 2305, 1931, 8, 277, 304, 272, 901, 63, 1955, 275, 378, 88, 3175, 272, 1947, 63, 466, 275, 499, 272, 291, 14, 629, 1332, 698, 63, 1955, 5213, 650, 9, 1204, 1947, 63, 466, 12, 2151, 11799, 63, 908, 14, 2305, 1931, 8, 698, 63, 1955, 12, 1947, 63, 466, 430, 272, 9954, 1931, 275, 11799, 63, 908, 14, 2305, 1931, 272, 327, 4860, 4634, 4721, 14, 272, 291, 14, 1855, 8, 1188, 14, 19994, 12, 9954, 1931, 12, 901, 63, 1955, 12, 1227, 9, 272, 327, 4860, 4634, 6465, 14, 272, 291, 14, 1855, 8, 1188, 14, 19994, 12, 9954, 1931, 12, 901, 63, 1955, 12, 446, 17, 9, 819, 347, 511, 26472, 1931, 8, 277, 304, 272, 327, 1379, 901, 5579, 626, 911, 4409, 7750, 2729, 442, 10627, 14, 272, 367, 1420, 63, 698, 63, 1955, 315, 334, 17, 12, 4114, 12, 3193, 12, 499, 12931, 12, 18427, 304, 489, 367, 1420, 63, 11239, 63, 466, 315, 1425, 8, 22, 304, 221, 327, 869, 12527, 13, 1507, 18897, 11799, 466, 365, 959, 14, 267, 901, 63, 1955, 12, 11799, 63, 466, 275, 11799, 63, 908, 14, 26472, 1931, 8, 288, 11799, 63, 908, 14, 2305, 1931, 8, 2062, 63, 698, 63, 1955, 12, 1420, 63, 11239, 63, 466, 430, 267, 291, 14, 629, 8, 2062, 63, 698, 63, 1955, 12, 901, 63, 1955, 9, 267, 291, 14, 629, 8, 2062, 63, 11239, 63, 466, 12, 11799, 63, 466, 9, 339, 291, 14, 1855, 8, 4333, 12, 11799, 63, 908, 14, 26472, 1931, 12, 488, 9, 272, 291, 14, 1855, 8, 4333, 12, 11799, 63, 908, 14, 26472, 1931, 12, 283, 3175, 358, 272, 291, 14, 1855, 8, 4333, 12, 11799, 63, 908, 14, 26472, 1931, 12, 378, 14, 16, 9, 272, 291, 14, 1855, 8, 4333, 12, 11799, 63, 908, 14, 26472, 1931, 12, 909, 1012, 819, 347, 511, 58, 528, 58, 643, 9686, 8, 277, 304, 272, 3107, 275, 11799, 63, 908, 14, 58, 528, 58, 643, 9686, 272, 291, 14, 629, 8, 16, 12, 3107, 8, 16, 430, 272, 291, 14, 629, 8, 17, 12, 3107, 2801, 17, 430, 272, 291, 14, 629, 8, 18, 12, 3107, 8, 17, 430, 272, 291, 14, 629, 8, 19, 12, 3107, 2801, 18, 430, 272, 291, 14, 629, 8, 20, 12, 3107, 8, 18, 430, 272, 291, 14, 629, 8, 16, 3581, 4717, 771, 12, 3107, 8, 16, 88, 23, 12596, 70, 430, 272, 291, 14, 629, 8, 16, 21870, 12, 3107, 2801, 16, 88, 24, 9084, 430, 272, 291, 14, 629, 8, 16, 3581, 15798, 4717, 771, 12, 3107, 8, 16, 88, 23, 15798, 12596, 70, 430, 272, 291, 14, 629, 8, 16, 3581, 15798, 12596, 12, 3107, 2801, 16, 88, 24, 3607, 9084, 430, 339, 291, 14, 1855, 8, 4333, 12, 3107, 12, 488, 9, 272, 291, 14, 1855, 8, 4333, 12, 3107, 12, 283, 13591, 358, 272, 291, 14, 1855, 8, 4333, 12, 3107, 12, 378, 14, 16, 9, 272, 291, 14, 1855, 8, 4333, 12, 3107, 12, 909, 1012, 819, 347, 511, 58, 528, 58, 643, 9400, 8, 277, 304, 272, 3107, 275, 11799, 63, 908, 14, 58, 528, 58, 643, 9400, 272, 291, 14, 629, 8, 16, 12, 3107, 8, 16, 430, 272, 291, 14, 629, 2801, 17, 12, 3107, 8, 17, 430, 272, 291, 14, 629, 8, 17, 12, 3107, 8, 18, 430, 272, 291, 14, 629, 2801, 18, 12, 3107, 8, 19, 430, 272, 291, 14, 629, 8, 18, 12, 3107 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 11557, 699, 3043, 1192, 446, 4475, 1159, 666, 1640, 1461, 1475, 199, 3, 1898, 9079, 4475, 3277, 14, 221, 2900, 4481, 4644, 14, 199, 3, 4178, 921, 23826, 14, 3098, 14, 957, 15, 3922, 13, 17389, 15, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 774, 367, 6233, 14, 7204, 14, 4672, 14, 11239, 63, 908, 1041, 199, 199, 363, 2502, 363, 275, 283, 28191, 834, 32, 3098, 14, 957, 334, 20326, 6848, 1393, 834, 3171, 199, 199, 893, 26, 523, 492, 2882, 18, 465, 2882, 221, 327, 4521, 1479, 199, 2590, 3545, 26, 523, 492, 2882, 199, 199, 504, 6233, 14, 7204, 492, 1245, 199, 504, 6233, 14, 7204, 14, 4672, 492, 11799, 63, 908, 421, 199, 533, 644, 3621, 3484, 774, 8, 2796, 14, 1746, 304, 819, 347, 511, 2305, 1931, 8, 277, 304, 272, 901, 63, 1955, 275, 378, 88, 3175, 272, 1947, 63, 466, 275, 499, 272, 291, 14, 629, 1332, 698, 63, 1955, 5213, 650, 9, 1204, 1947, 63, 466, 12, 2151, 11799, 63, 908, 14, 2305, 1931, 8, 698, 63, 1955, 12, 1947, 63, 466, 430, 272, 9954, 1931, 275, 11799, 63, 908, 14, 2305, 1931, 272, 327, 4860, 4634, 4721, 14, 272, 291, 14, 1855, 8, 1188, 14, 19994, 12, 9954, 1931, 12, 901, 63, 1955, 12, 1227, 9, 272, 327, 4860, 4634, 6465, 14, 272, 291, 14, 1855, 8, 1188, 14, 19994, 12, 9954, 1931, 12, 901, 63, 1955, 12, 446, 17, 9, 819, 347, 511, 26472, 1931, 8, 277, 304, 272, 327, 1379, 901, 5579, 626, 911, 4409, 7750, 2729, 442, 10627, 14, 272, 367, 1420, 63, 698, 63, 1955, 315, 334, 17, 12, 4114, 12, 3193, 12, 499, 12931, 12, 18427, 304, 489, 367, 1420, 63, 11239, 63, 466, 315, 1425, 8, 22, 304, 221, 327, 869, 12527, 13, 1507, 18897, 11799, 466, 365, 959, 14, 267, 901, 63, 1955, 12, 11799, 63, 466, 275, 11799, 63, 908, 14, 26472, 1931, 8, 288, 11799, 63, 908, 14, 2305, 1931, 8, 2062, 63, 698, 63, 1955, 12, 1420, 63, 11239, 63, 466, 430, 267, 291, 14, 629, 8, 2062, 63, 698, 63, 1955, 12, 901, 63, 1955, 9, 267, 291, 14, 629, 8, 2062, 63, 11239, 63, 466, 12, 11799, 63, 466, 9, 339, 291, 14, 1855, 8, 4333, 12, 11799, 63, 908, 14, 26472, 1931, 12, 488, 9, 272, 291, 14, 1855, 8, 4333, 12, 11799, 63, 908, 14, 26472, 1931, 12, 283, 3175, 358, 272, 291, 14, 1855, 8, 4333, 12, 11799, 63, 908, 14, 26472, 1931, 12, 378, 14, 16, 9, 272, 291, 14, 1855, 8, 4333, 12, 11799, 63, 908, 14, 26472, 1931, 12, 909, 1012, 819, 347, 511, 58, 528, 58, 643, 9686, 8, 277, 304, 272, 3107, 275, 11799, 63, 908, 14, 58, 528, 58, 643, 9686, 272, 291, 14, 629, 8, 16, 12, 3107, 8, 16, 430, 272, 291, 14, 629, 8, 17, 12, 3107, 2801, 17, 430, 272, 291, 14, 629, 8, 18, 12, 3107, 8, 17, 430, 272, 291, 14, 629, 8, 19, 12, 3107, 2801, 18, 430, 272, 291, 14, 629, 8, 20, 12, 3107, 8, 18, 430, 272, 291, 14, 629, 8, 16, 3581, 4717, 771, 12, 3107, 8, 16, 88, 23, 12596, 70, 430, 272, 291, 14, 629, 8, 16, 21870, 12, 3107, 2801, 16, 88, 24, 9084, 430, 272, 291, 14, 629, 8, 16, 3581, 15798, 4717, 771, 12, 3107, 8, 16, 88, 23, 15798, 12596, 70, 430, 272, 291, 14, 629, 8, 16, 3581, 15798, 12596, 12, 3107, 2801, 16, 88, 24, 3607, 9084, 430, 339, 291, 14, 1855, 8, 4333, 12, 3107, 12, 488, 9, 272, 291, 14, 1855, 8, 4333, 12, 3107, 12, 283, 13591, 358, 272, 291, 14, 1855, 8, 4333, 12, 3107, 12, 378, 14, 16, 9, 272, 291, 14, 1855, 8, 4333, 12, 3107, 12, 909, 1012, 819, 347, 511, 58, 528, 58, 643, 9400, 8, 277, 304, 272, 3107, 275, 11799, 63, 908, 14, 58, 528, 58, 643, 9400, 272, 291, 14, 629, 8, 16, 12, 3107, 8, 16, 430, 272, 291, 14, 629, 2801, 17, 12, 3107, 8, 17, 430, 272, 291, 14, 629, 8, 17, 12, 3107, 8, 18, 430, 272, 291, 14, 629, 2801, 18, 12, 3107, 8, 19, 430, 272, 291, 14, 629, 8, 18, 12, 3107, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ymcagodme/Norwalk-Judo
django/contrib/localflavor/us/models.py
230
1294
from django.conf import settings from django.utils.translation import ugettext_lazy as _ from django.db.models.fields import CharField from django.contrib.localflavor.us.us_states import STATE_CHOICES from django.contrib.localflavor.us.us_states import USPS_CHOICES class USStateField(CharField): description = _("U.S. state (two uppercase letters)") def __init__(self, *args, **kwargs): kwargs['choices'] = STATE_CHOICES kwargs['max_length'] = 2 super(USStateField, self).__init__(*args, **kwargs) class USPostalCodeField(CharField): description = _("U.S. postal code (two uppercase letters)") def __init__(self, *args, **kwargs): kwargs['choices'] = USPS_CHOICES kwargs['max_length'] = 2 super(USPostalCodeField, self).__init__(*args, **kwargs) class PhoneNumberField(CharField): description = _("Phone number") def __init__(self, *args, **kwargs): kwargs['max_length'] = 20 super(PhoneNumberField, self).__init__(*args, **kwargs) def formfield(self, **kwargs): from django.contrib.localflavor.us.forms import USPhoneNumberField defaults = {'form_class': USPhoneNumberField} defaults.update(kwargs) return super(PhoneNumberField, self).formfield(**defaults)
bsd-3-clause
[ 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 12064, 199, 504, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 527, 14, 527, 63, 4981, 492, 11377, 63, 16236, 199, 504, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 527, 14, 527, 63, 4981, 492, 19635, 5067, 63, 16236, 199, 199, 533, 19635, 2223, 792, 8, 2183, 304, 339, 1369, 275, 3824, 53, 14, 51, 14, 1174, 334, 5601, 22681, 14435, 6320, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 2074, 459, 4577, 418, 275, 11377, 63, 16236, 267, 2074, 459, 988, 63, 1267, 418, 275, 499, 267, 1613, 8, 1668, 2223, 792, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 199, 199, 533, 738, 5763, 941, 279, 3034, 792, 8, 2183, 304, 339, 1369, 275, 3824, 53, 14, 51, 14, 2963, 279, 1233, 334, 5601, 22681, 14435, 6320, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 2074, 459, 4577, 418, 275, 19635, 5067, 63, 16236, 267, 2074, 459, 988, 63, 1267, 418, 275, 499, 267, 1613, 8, 1668, 6564, 279, 3034, 792, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 199, 199, 533, 27585, 3259, 792, 8, 2183, 304, 339, 1369, 275, 3824, 15199, 1329, 531, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 2074, 459, 988, 63, 1267, 418, 275, 3388, 267, 1613, 8, 25640, 792, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 21388, 8, 277, 12, 1011, 958, 304, 267, 687, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 527, 14, 3351, 492, 19635, 25640, 792, 267, 4243, 275, 791, 964, 63, 533, 356, 19635, 25640, 792, 93, 267, 4243, 14, 873, 8, 958, 9, 267, 372, 1613, 8, 25640, 792, 12, 291, 680, 20015, 3682, 4322, 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 ]
[ 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 492, 12064, 199, 504, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 527, 14, 527, 63, 4981, 492, 11377, 63, 16236, 199, 504, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 527, 14, 527, 63, 4981, 492, 19635, 5067, 63, 16236, 199, 199, 533, 19635, 2223, 792, 8, 2183, 304, 339, 1369, 275, 3824, 53, 14, 51, 14, 1174, 334, 5601, 22681, 14435, 6320, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 2074, 459, 4577, 418, 275, 11377, 63, 16236, 267, 2074, 459, 988, 63, 1267, 418, 275, 499, 267, 1613, 8, 1668, 2223, 792, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 199, 199, 533, 738, 5763, 941, 279, 3034, 792, 8, 2183, 304, 339, 1369, 275, 3824, 53, 14, 51, 14, 2963, 279, 1233, 334, 5601, 22681, 14435, 6320, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 2074, 459, 4577, 418, 275, 19635, 5067, 63, 16236, 267, 2074, 459, 988, 63, 1267, 418, 275, 499, 267, 1613, 8, 1668, 6564, 279, 3034, 792, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 199, 199, 533, 27585, 3259, 792, 8, 2183, 304, 339, 1369, 275, 3824, 15199, 1329, 531, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 2074, 459, 988, 63, 1267, 418, 275, 3388, 267, 1613, 8, 25640, 792, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 347, 21388, 8, 277, 12, 1011, 958, 304, 267, 687, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 527, 14, 3351, 492, 19635, 25640, 792, 267, 4243, 275, 791, 964, 63, 533, 356, 19635, 25640, 792, 93, 267, 4243, 14, 873, 8, 958, 9, 267, 372, 1613, 8, 25640, 792, 12, 291, 680, 20015, 3682, 4322, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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.utils.translation import ugettext_lazy as _ from oscar.core.loading import get_class ReportGenerator = get_class('dashboard.reports.reports', 'ReportGenerator') ReportCSVFormatter = get_class('dashboard.reports.reports', 'ReportCSVFormatter') ReportHTMLFormatter = get_class('dashboard.reports.reports', 'ReportHTMLFormatter') Order = get_model('order', 'Order') class OrderReportCSVFormatter(ReportCSVFormatter): filename_template = 'orders-%s-to-%s.csv' def generate_csv(self, response, orders): writer = self.get_csv_writer(response) header_row = [_('Order number'), _('Name'), _('Email'), _('Total incl. tax'), _('Date placed')] writer.writerow(header_row) for order in orders: row = [ order.number, '-' if order.is_anonymous else order.user.get_full_name(), order.email, order.total_incl_tax, self.format_datetime(order.date_placed)] writer.writerow(row) def filename(self, **kwargs): return self.filename_template % ( kwargs['start_date'], kwargs['end_date']) class OrderReportHTMLFormatter(ReportHTMLFormatter): filename_template = 'dashboard/reports/partials/order_report.html' class OrderReportGenerator(ReportGenerator): code = 'order_report' description = _("Orders placed") date_range_field_name = 'date_placed' formatters = { 'CSV_formatter': OrderReportCSVFormatter, 'HTML_formatter': OrderReportHTMLFormatter, } def generate(self): qs = Order._default_manager.all() if self.start_date: qs = qs.filter(date_placed__gte=self.start_date) if self.end_date: qs = qs.filter( date_placed__lt=self.end_date + datetime.timedelta(days=1)) additional_data = { 'start_date': self.start_date, 'end_date': self.end_date } return self.formatter.generate_response(qs, **additional_data) def is_available_to(self, user): return user.is_staff
bsd-3-clause
[ 646, 2197, 199, 199, 504, 312, 22707, 14, 1018, 14, 8786, 492, 664, 63, 1238, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 312, 22707, 14, 1018, 14, 8786, 492, 664, 63, 533, 199, 7457, 7599, 275, 664, 63, 533, 360, 9743, 14, 15629, 14, 15629, 297, 283, 7457, 7599, 358, 199, 7457, 19018, 7772, 275, 664, 63, 533, 360, 9743, 14, 15629, 14, 15629, 297, 3044, 283, 7457, 19018, 7772, 358, 199, 7457, 4943, 7772, 275, 664, 63, 533, 360, 9743, 14, 15629, 14, 15629, 297, 1816, 283, 7457, 4943, 7772, 358, 199, 4738, 275, 664, 63, 1238, 360, 1648, 297, 283, 4738, 358, 421, 199, 533, 9240, 7457, 19018, 7772, 8, 7457, 19018, 7772, 304, 272, 1788, 63, 1160, 275, 283, 14387, 3295, 83, 13, 475, 3295, 83, 14, 4737, 7, 339, 347, 3550, 63, 4737, 8, 277, 12, 1177, 12, 15460, 304, 267, 7060, 275, 291, 14, 362, 63, 4737, 63, 5491, 8, 1310, 9, 267, 1406, 63, 1143, 275, 359, 11252, 4738, 1329, 659, 1993, 4018, 985, 659, 1993, 4018, 7035, 659, 1993, 4018, 7316, 315, 429, 14, 9067, 659, 1993, 4018, 2506, 15090, 5440, 267, 7060, 14, 22686, 8, 1291, 63, 1143, 9, 267, 367, 1865, 315, 15460, 26, 288, 1962, 275, 359, 355, 1865, 14, 1955, 12, 355, 10791, 340, 1865, 14, 374, 63, 12628, 587, 1865, 14, 751, 14, 362, 63, 2861, 63, 354, 1062, 355, 1865, 14, 2123, 12, 355, 1865, 14, 2923, 63, 31941, 63, 5530, 12, 355, 291, 14, 908, 63, 2083, 8, 1648, 14, 602, 63, 2778, 68, 1874, 288, 7060, 14, 22686, 8, 1143, 9, 339, 347, 1788, 8, 277, 12, 1011, 958, 304, 267, 372, 291, 14, 1501, 63, 1160, 450, 334, 288, 2074, 459, 928, 63, 602, 995, 2074, 459, 500, 63, 602, 1105, 421, 199, 533, 9240, 7457, 4943, 7772, 8, 7457, 4943, 7772, 304, 272, 1788, 63, 1160, 275, 283, 9743, 15, 15629, 15, 6672, 83, 15, 1648, 63, 3070, 14, 1360, 7, 421, 199, 533, 9240, 7457, 7599, 8, 7457, 7599, 304, 272, 1233, 275, 283, 1648, 63, 3070, 7, 272, 1369, 275, 3824, 4738, 83, 15090, 531, 272, 1434, 63, 1842, 63, 698, 63, 354, 275, 283, 602, 63, 2778, 68, 7, 339, 30514, 275, 469, 267, 283, 19018, 63, 8911, 356, 9240, 7457, 19018, 7772, 12, 267, 283, 4943, 63, 8911, 356, 9240, 7457, 4943, 7772, 12, 272, 789, 339, 347, 3550, 8, 277, 304, 267, 6377, 275, 9240, 423, 885, 63, 2609, 14, 452, 342, 398, 340, 291, 14, 928, 63, 602, 26, 288, 6377, 275, 6377, 14, 1541, 8, 602, 63, 2778, 68, 363, 19586, 29, 277, 14, 928, 63, 602, 9, 267, 340, 291, 14, 500, 63, 602, 26, 288, 6377, 275, 6377, 14, 1541, 8, 355, 1434, 63, 2778, 68, 363, 4116, 29, 277, 14, 500, 63, 602, 435, 2197, 14, 7473, 8, 4899, 29, 17, 430, 398, 4722, 63, 576, 275, 469, 288, 283, 928, 63, 602, 356, 291, 14, 928, 63, 602, 12, 288, 283, 500, 63, 602, 356, 291, 14, 500, 63, 602, 267, 789, 398, 372, 291, 14, 8911, 14, 4208, 63, 1310, 8, 6177, 12, 1011, 8460, 63, 576, 9, 339, 347, 365, 63, 4561, 63, 475, 8, 277, 12, 922, 304, 267, 372, 922, 14, 374, 63, 7018, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2197, 199, 199, 504, 312, 22707, 14, 1018, 14, 8786, 492, 664, 63, 1238, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 312, 22707, 14, 1018, 14, 8786, 492, 664, 63, 533, 199, 7457, 7599, 275, 664, 63, 533, 360, 9743, 14, 15629, 14, 15629, 297, 283, 7457, 7599, 358, 199, 7457, 19018, 7772, 275, 664, 63, 533, 360, 9743, 14, 15629, 14, 15629, 297, 3044, 283, 7457, 19018, 7772, 358, 199, 7457, 4943, 7772, 275, 664, 63, 533, 360, 9743, 14, 15629, 14, 15629, 297, 1816, 283, 7457, 4943, 7772, 358, 199, 4738, 275, 664, 63, 1238, 360, 1648, 297, 283, 4738, 358, 421, 199, 533, 9240, 7457, 19018, 7772, 8, 7457, 19018, 7772, 304, 272, 1788, 63, 1160, 275, 283, 14387, 3295, 83, 13, 475, 3295, 83, 14, 4737, 7, 339, 347, 3550, 63, 4737, 8, 277, 12, 1177, 12, 15460, 304, 267, 7060, 275, 291, 14, 362, 63, 4737, 63, 5491, 8, 1310, 9, 267, 1406, 63, 1143, 275, 359, 11252, 4738, 1329, 659, 1993, 4018, 985, 659, 1993, 4018, 7035, 659, 1993, 4018, 7316, 315, 429, 14, 9067, 659, 1993, 4018, 2506, 15090, 5440, 267, 7060, 14, 22686, 8, 1291, 63, 1143, 9, 267, 367, 1865, 315, 15460, 26, 288, 1962, 275, 359, 355, 1865, 14, 1955, 12, 355, 10791, 340, 1865, 14, 374, 63, 12628, 587, 1865, 14, 751, 14, 362, 63, 2861, 63, 354, 1062, 355, 1865, 14, 2123, 12, 355, 1865, 14, 2923, 63, 31941, 63, 5530, 12, 355, 291, 14, 908, 63, 2083, 8, 1648, 14, 602, 63, 2778, 68, 1874, 288, 7060, 14, 22686, 8, 1143, 9, 339, 347, 1788, 8, 277, 12, 1011, 958, 304, 267, 372, 291, 14, 1501, 63, 1160, 450, 334, 288, 2074, 459, 928, 63, 602, 995, 2074, 459, 500, 63, 602, 1105, 421, 199, 533, 9240, 7457, 4943, 7772, 8, 7457, 4943, 7772, 304, 272, 1788, 63, 1160, 275, 283, 9743, 15, 15629, 15, 6672, 83, 15, 1648, 63, 3070, 14, 1360, 7, 421, 199, 533, 9240, 7457, 7599, 8, 7457, 7599, 304, 272, 1233, 275, 283, 1648, 63, 3070, 7, 272, 1369, 275, 3824, 4738, 83, 15090, 531, 272, 1434, 63, 1842, 63, 698, 63, 354, 275, 283, 602, 63, 2778, 68, 7, 339, 30514, 275, 469, 267, 283, 19018, 63, 8911, 356, 9240, 7457, 19018, 7772, 12, 267, 283, 4943, 63, 8911, 356, 9240, 7457, 4943, 7772, 12, 272, 789, 339, 347, 3550, 8, 277, 304, 267, 6377, 275, 9240, 423, 885, 63, 2609, 14, 452, 342, 398, 340, 291, 14, 928, 63, 602, 26, 288, 6377, 275, 6377, 14, 1541, 8, 602, 63, 2778, 68, 363, 19586, 29, 277, 14, 928, 63, 602, 9, 267, 340, 291, 14, 500, 63, 602, 26, 288, 6377, 275, 6377, 14, 1541, 8, 355, 1434, 63, 2778, 68, 363, 4116, 29, 277, 14, 500, 63, 602, 435, 2197, 14, 7473, 8, 4899, 29, 17, 430, 398, 4722, 63, 576, 275, 469, 288, 283, 928, 63, 602, 356, 291, 14, 928, 63, 602, 12, 288, 283, 500, 63, 602, 356, 291, 14, 500, 63, 602, 267, 789, 398, 372, 291, 14, 8911, 14, 4208, 63, 1310, 8, 6177, 12, 1011, 8460, 63, 576, 9, 339, 347, 365, 63, 4561, 63, 475, 8, 277, 12, 922, 304, 267, 372, 922, 14, 374, 63, 7018, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
nirs/vdsm
tests/network/unit/nmstate/bond_test.py
2
3216
# # Copyright 2020-2021 Red Hat, 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 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # Refer to the README and COPYING files for full details of the license # from vdsm.network import nmstate from .testlib import ( IFACE0, IFACE1, TESTBOND0, create_bond_iface_state, disable_iface_ip, ) class TestBond(object): def test_translate_new_bond_with_two_slaves(self): bondings = {TESTBOND0: {'nics': [IFACE0, IFACE1], 'switch': 'legacy'}} state = nmstate.generate_state(networks={}, bondings=bondings) bond0_state = create_bond_iface_state( TESTBOND0, 'balance-rr', [IFACE0, IFACE1], mtu=None ) disable_iface_ip(bond0_state) expected_state = {nmstate.Interface.KEY: [bond0_state]} assert expected_state == state def test_translate_edit_bond_with_slaves(self, rconfig_mock): bondings = {TESTBOND0: {'nics': [IFACE0, IFACE1], 'switch': 'legacy'}} rconfig_mock.bonds = bondings state = nmstate.generate_state(networks={}, bondings=bondings) bond0_state = create_bond_iface_state( TESTBOND0, 'balance-rr', [IFACE0, IFACE1], mtu=None ) expected_state = {nmstate.Interface.KEY: [bond0_state]} assert expected_state == state def test_translate_new_bond_with_two_slaves_and_options(self): bondings = { TESTBOND0: { 'nics': [IFACE0, IFACE1], 'options': 'mode=4 miimon=150', 'switch': 'legacy', } } state = nmstate.generate_state(networks={}, bondings=bondings) bond0_state = create_bond_iface_state( TESTBOND0, '802.3ad', [IFACE0, IFACE1], mtu=None, miimon='150' ) disable_iface_ip(bond0_state) expected_state = {nmstate.Interface.KEY: [bond0_state]} assert expected_state == state def test_translate_remove_bonds(self, rconfig_mock): rconfig_mock.bonds = { TESTBOND0: {'nics': [IFACE0, IFACE1], 'switch': 'legacy'} } bondings = {TESTBOND0: {'remove': True}} state = nmstate.generate_state(networks={}, bondings=bondings) expected_state = { nmstate.Interface.KEY: [ { nmstate.Interface.NAME: TESTBOND0, nmstate.Interface.TYPE: nmstate.InterfaceType.BOND, nmstate.Interface.STATE: nmstate.InterfaceState.ABSENT, } ] } assert expected_state == state
gpl-2.0
[ 3, 199, 3, 1898, 25455, 13, 22150, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 8217, 199, 3, 199, 3, 21751, 370, 314, 27781, 436, 9685, 1584, 367, 2615, 2436, 402, 314, 4190, 199, 3, 199, 199, 504, 373, 795, 77, 14, 1200, 492, 16751, 929, 199, 199, 504, 1275, 396, 773, 492, 334, 272, 8036, 4121, 16, 12, 272, 8036, 4121, 17, 12, 272, 7393, 34, 615, 36, 16, 12, 272, 1218, 63, 21410, 63, 11166, 63, 929, 12, 272, 3507, 63, 11166, 63, 711, 12, 199, 9, 421, 199, 533, 1379, 34, 7835, 8, 785, 304, 272, 347, 511, 63, 5275, 63, 1222, 63, 21410, 63, 1045, 63, 5601, 63, 32175, 8, 277, 304, 267, 23119, 780, 275, 469, 2864, 34, 615, 36, 16, 26, 791, 28004, 356, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 283, 5656, 356, 283, 10000, 18620, 267, 1174, 275, 16751, 929, 14, 4208, 63, 929, 8, 7642, 10324, 23119, 780, 29, 21410, 780, 9, 398, 23119, 16, 63, 929, 275, 1218, 63, 21410, 63, 11166, 63, 929, 8, 288, 7393, 34, 615, 36, 16, 12, 283, 7358, 13, 9734, 297, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 28270, 29, 403, 267, 776, 398, 3507, 63, 11166, 63, 711, 8, 21410, 16, 63, 929, 9, 398, 1420, 63, 929, 275, 469, 10756, 929, 14, 4267, 14, 3078, 26, 359, 21410, 16, 63, 929, 9420, 267, 702, 1420, 63, 929, 508, 1174, 339, 347, 511, 63, 5275, 63, 3773, 63, 21410, 63, 1045, 63, 32175, 8, 277, 12, 519, 888, 63, 1805, 304, 267, 23119, 780, 275, 469, 2864, 34, 615, 36, 16, 26, 791, 28004, 356, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 283, 5656, 356, 283, 10000, 18620, 267, 519, 888, 63, 1805, 14, 27816, 275, 23119, 780, 398, 1174, 275, 16751, 929, 14, 4208, 63, 929, 8, 7642, 10324, 23119, 780, 29, 21410, 780, 9, 398, 23119, 16, 63, 929, 275, 1218, 63, 21410, 63, 11166, 63, 929, 8, 288, 7393, 34, 615, 36, 16, 12, 283, 7358, 13, 9734, 297, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 28270, 29, 403, 267, 776, 398, 1420, 63, 929, 275, 469, 10756, 929, 14, 4267, 14, 3078, 26, 359, 21410, 16, 63, 929, 9420, 267, 702, 1420, 63, 929, 508, 1174, 339, 347, 511, 63, 5275, 63, 1222, 63, 21410, 63, 1045, 63, 5601, 63, 32175, 63, 460, 63, 1419, 8, 277, 304, 267, 23119, 780, 275, 469, 288, 7393, 34, 615, 36, 16, 26, 469, 355, 283, 28004, 356, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 355, 283, 1419, 356, 283, 632, 29, 20, 10684, 1017, 265, 29, 8251, 297, 355, 283, 5656, 356, 283, 10000, 297, 288, 789, 267, 789, 267, 1174, 275, 16751, 929, 14, 4208, 63, 929, 8, 7642, 10324, 23119, 780, 29, 21410, 780, 9, 398, 23119, 16, 63, 929, 275, 1218, 63, 21410, 63, 11166, 63, 929, 8, 288, 7393, 34, 615, 36, 16, 12, 283, 11366, 14, 19, 350, 297, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 28270, 29, 403, 12, 10684, 1017, 265, 534, 8251, 7, 267, 776, 398, 3507, 63, 11166, 63, 711, 8, 21410, 16, 63, 929, 9, 398, 1420, 63, 929, 275, 469, 10756, 929, 14, 4267, 14, 3078, 26, 359, 21410, 16, 63, 929, 9420, 267, 702, 1420, 63, 929, 508, 1174, 339, 347, 511, 63, 5275, 63, 2168, 63, 27816, 8, 277, 12, 519, 888, 63, 1805, 304, 267, 519, 888, 63, 1805, 14, 27816, 275, 469, 288, 7393, 34, 615, 36, 16, 26, 791, 28004, 356, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 283, 5656, 356, 283, 10000, 936, 267, 789, 267, 23119, 780, 275, 469, 2864, 34, 615, 36, 16, 26, 791, 2168, 356, 715, 4863, 398, 1174, 275, 16751, 929, 14, 4208, 63, 929, 8, 7642, 10324, 23119, 780, 29, 21410, 780, 9, 398, 1420, 63, 929, 275, 469, 288, 16751, 929, 14, 4267, 14, 3078, 26, 359, 355, 469, 490, 16751, 929, 14, 4267, 14, 2339, 26, 7393, 34, 615, 36, 16, 12, 490, 16751, 929, 14, 4267, 14, 2711, 26, 16751, 929, 14, 4267, 804, 14, 34, 615, 36, 12, 490, 16751, 929, 14, 4267, 14, 6689, 26, 16751, 929, 14, 4267, 2223, 14, 27851, 1309, 12, 355, 789, 288, 1622, 267, 789, 267, 702, 1420, 63, 929, 508, 1174, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 25455, 13, 22150, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 8217, 199, 3, 199, 3, 21751, 370, 314, 27781, 436, 9685, 1584, 367, 2615, 2436, 402, 314, 4190, 199, 3, 199, 199, 504, 373, 795, 77, 14, 1200, 492, 16751, 929, 199, 199, 504, 1275, 396, 773, 492, 334, 272, 8036, 4121, 16, 12, 272, 8036, 4121, 17, 12, 272, 7393, 34, 615, 36, 16, 12, 272, 1218, 63, 21410, 63, 11166, 63, 929, 12, 272, 3507, 63, 11166, 63, 711, 12, 199, 9, 421, 199, 533, 1379, 34, 7835, 8, 785, 304, 272, 347, 511, 63, 5275, 63, 1222, 63, 21410, 63, 1045, 63, 5601, 63, 32175, 8, 277, 304, 267, 23119, 780, 275, 469, 2864, 34, 615, 36, 16, 26, 791, 28004, 356, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 283, 5656, 356, 283, 10000, 18620, 267, 1174, 275, 16751, 929, 14, 4208, 63, 929, 8, 7642, 10324, 23119, 780, 29, 21410, 780, 9, 398, 23119, 16, 63, 929, 275, 1218, 63, 21410, 63, 11166, 63, 929, 8, 288, 7393, 34, 615, 36, 16, 12, 283, 7358, 13, 9734, 297, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 28270, 29, 403, 267, 776, 398, 3507, 63, 11166, 63, 711, 8, 21410, 16, 63, 929, 9, 398, 1420, 63, 929, 275, 469, 10756, 929, 14, 4267, 14, 3078, 26, 359, 21410, 16, 63, 929, 9420, 267, 702, 1420, 63, 929, 508, 1174, 339, 347, 511, 63, 5275, 63, 3773, 63, 21410, 63, 1045, 63, 32175, 8, 277, 12, 519, 888, 63, 1805, 304, 267, 23119, 780, 275, 469, 2864, 34, 615, 36, 16, 26, 791, 28004, 356, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 283, 5656, 356, 283, 10000, 18620, 267, 519, 888, 63, 1805, 14, 27816, 275, 23119, 780, 398, 1174, 275, 16751, 929, 14, 4208, 63, 929, 8, 7642, 10324, 23119, 780, 29, 21410, 780, 9, 398, 23119, 16, 63, 929, 275, 1218, 63, 21410, 63, 11166, 63, 929, 8, 288, 7393, 34, 615, 36, 16, 12, 283, 7358, 13, 9734, 297, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 28270, 29, 403, 267, 776, 398, 1420, 63, 929, 275, 469, 10756, 929, 14, 4267, 14, 3078, 26, 359, 21410, 16, 63, 929, 9420, 267, 702, 1420, 63, 929, 508, 1174, 339, 347, 511, 63, 5275, 63, 1222, 63, 21410, 63, 1045, 63, 5601, 63, 32175, 63, 460, 63, 1419, 8, 277, 304, 267, 23119, 780, 275, 469, 288, 7393, 34, 615, 36, 16, 26, 469, 355, 283, 28004, 356, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 355, 283, 1419, 356, 283, 632, 29, 20, 10684, 1017, 265, 29, 8251, 297, 355, 283, 5656, 356, 283, 10000, 297, 288, 789, 267, 789, 267, 1174, 275, 16751, 929, 14, 4208, 63, 929, 8, 7642, 10324, 23119, 780, 29, 21410, 780, 9, 398, 23119, 16, 63, 929, 275, 1218, 63, 21410, 63, 11166, 63, 929, 8, 288, 7393, 34, 615, 36, 16, 12, 283, 11366, 14, 19, 350, 297, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 28270, 29, 403, 12, 10684, 1017, 265, 534, 8251, 7, 267, 776, 398, 3507, 63, 11166, 63, 711, 8, 21410, 16, 63, 929, 9, 398, 1420, 63, 929, 275, 469, 10756, 929, 14, 4267, 14, 3078, 26, 359, 21410, 16, 63, 929, 9420, 267, 702, 1420, 63, 929, 508, 1174, 339, 347, 511, 63, 5275, 63, 2168, 63, 27816, 8, 277, 12, 519, 888, 63, 1805, 304, 267, 519, 888, 63, 1805, 14, 27816, 275, 469, 288, 7393, 34, 615, 36, 16, 26, 791, 28004, 356, 359, 4656, 4121, 16, 12, 8036, 4121, 17, 467, 283, 5656, 356, 283, 10000, 936, 267, 789, 267, 23119, 780, 275, 469, 2864, 34, 615, 36, 16, 26, 791, 2168, 356, 715, 4863, 398, 1174, 275, 16751, 929, 14, 4208, 63, 929, 8, 7642, 10324, 23119, 780, 29, 21410, 780, 9, 398, 1420, 63, 929, 275, 469, 288, 16751, 929, 14, 4267, 14, 3078, 26, 359, 355, 469, 490, 16751, 929, 14, 4267, 14, 2339, 26, 7393, 34, 615, 36, 16, 12, 490, 16751, 929, 14, 4267, 14, 2711, 26, 16751, 929, 14, 4267, 804, 14, 34, 615, 36, 12, 490, 16751, 929, 14, 4267, 14, 6689, 26, 16751, 929, 14, 4267, 2223, 14, 27851, 1309, 12, 355, 789, 288, 1622, 267, 789, 267, 702, 1420, 63, 929, 508, 1174, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
tavendo/txaio
txaio/with_asyncio.py
3
1328
############################################################################### # # The MIT License (MIT) # # Copyright (c) Crossbar.io Technologies GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # ############################################################################### import txaio txaio.use_asyncio()
mit
[ 11490, 199, 3, 199, 3, 710, 10697, 844, 334, 13965, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 28965, 1700, 14, 2308, 19215, 23428, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 3, 199, 11490, 199, 199, 646, 307, 1800, 2308, 199, 199, 84, 1800, 2308, 14, 1180, 63, 19343, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 199, 3, 710, 10697, 844, 334, 13965, 9, 199, 3, 199, 3, 1898, 334, 67, 9, 28965, 1700, 14, 2308, 19215, 23428, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 3, 199, 11490, 199, 199, 646, 307, 1800, 2308, 199, 199, 84, 1800, 2308, 14, 1180, 63, 19343, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
Weihonghao/ECM
Vpy34/lib/python3.5/site-packages/pandas/io/sql.py
7
58343
# -*- coding: utf-8 -*- """ Collection of query wrappers / abstractions to both facilitate data retrieval and to reduce dependency on DB-specific API. """ from __future__ import print_function, division from datetime import datetime, date, time import warnings import re import numpy as np import pandas._libs.lib as lib from pandas.core.dtypes.missing import isnull from pandas.core.dtypes.dtypes import DatetimeTZDtype from pandas.core.dtypes.common import ( is_list_like, is_dict_like, is_datetime64tz_dtype) from pandas.compat import (map, zip, raise_with_traceback, string_types, text_type) from pandas.core.api import DataFrame, Series from pandas.core.base import PandasObject from pandas.core.tools.datetimes import to_datetime from contextlib import contextmanager class SQLAlchemyRequired(ImportError): pass class DatabaseError(IOError): pass # ----------------------------------------------------------------------------- # -- Helper functions _SQLALCHEMY_INSTALLED = None def _validate_flavor_parameter(flavor): """ Checks whether a database 'flavor' was specified. If not None, produces FutureWarning if 'sqlite' and raises a ValueError if anything else. """ if flavor is not None: if flavor == 'sqlite': warnings.warn("the 'flavor' parameter is deprecated " "and will be removed in a future version, " "as 'sqlite' is the only supported option " "when SQLAlchemy is not installed.", FutureWarning, stacklevel=2) else: raise ValueError("database flavor {flavor} is not " "supported".format(flavor=flavor)) def _is_sqlalchemy_connectable(con): global _SQLALCHEMY_INSTALLED if _SQLALCHEMY_INSTALLED is None: try: import sqlalchemy _SQLALCHEMY_INSTALLED = True from distutils.version import LooseVersion ver = LooseVersion(sqlalchemy.__version__) # For sqlalchemy versions < 0.8.2, the BIGINT type is recognized # for a sqlite engine, which results in a warning when trying to # read/write a DataFrame with int64 values. (GH7433) if ver < '0.8.2': from sqlalchemy import BigInteger from sqlalchemy.ext.compiler import compiles @compiles(BigInteger, 'sqlite') def compile_big_int_sqlite(type_, compiler, **kw): return 'INTEGER' except ImportError: _SQLALCHEMY_INSTALLED = False if _SQLALCHEMY_INSTALLED: import sqlalchemy return isinstance(con, sqlalchemy.engine.Connectable) else: return False def _convert_params(sql, params): """convert sql and params args to DBAPI2.0 compliant format""" args = [sql] if params is not None: if hasattr(params, 'keys'): # test if params is a mapping args += [params] else: args += [list(params)] return args def _handle_date_column(col, format=None): if isinstance(format, dict): return to_datetime(col, errors='ignore', **format) else: if format in ['D', 's', 'ms', 'us', 'ns']: return to_datetime(col, errors='coerce', unit=format, utc=True) elif (issubclass(col.dtype.type, np.floating) or issubclass(col.dtype.type, np.integer)): # parse dates as timestamp format = 's' if format is None else format return to_datetime(col, errors='coerce', unit=format, utc=True) elif is_datetime64tz_dtype(col): # coerce to UTC timezone # GH11216 return (to_datetime(col, errors='coerce') .astype('datetime64[ns, UTC]')) else: return to_datetime(col, errors='coerce', format=format, utc=True) def _parse_date_columns(data_frame, parse_dates): """ Force non-datetime columns to be read as such. Supports both string formatted and integer timestamp columns """ # handle non-list entries for parse_dates gracefully if parse_dates is True or parse_dates is None or parse_dates is False: parse_dates = [] if not hasattr(parse_dates, '__iter__'): parse_dates = [parse_dates] for col_name in parse_dates: df_col = data_frame[col_name] try: fmt = parse_dates[col_name] except TypeError: fmt = None data_frame[col_name] = _handle_date_column(df_col, format=fmt) # we want to coerce datetime64_tz dtypes for now # we could in theory do a 'nice' conversion from a FixedOffset tz # GH11216 for col_name, df_col in data_frame.iteritems(): if is_datetime64tz_dtype(df_col): data_frame[col_name] = _handle_date_column(df_col) return data_frame def _wrap_result(data, columns, index_col=None, coerce_float=True, parse_dates=None): """Wrap result set of query in a DataFrame """ frame = DataFrame.from_records(data, columns=columns, coerce_float=coerce_float) _parse_date_columns(frame, parse_dates) if index_col is not None: frame.set_index(index_col, inplace=True) return frame def execute(sql, con, cur=None, params=None): """ Execute the given SQL query using the provided connection object. Parameters ---------- sql : string Query to be executed con : SQLAlchemy connectable(engine/connection) or sqlite3 connection Using SQLAlchemy makes it possible to use any DB supported by that library. If a DBAPI2 object, only sqlite3 is supported. cur : deprecated, cursor is obtained from connection, default: None params : list or tuple, optional, default: None List of parameters to pass to execute method. Returns ------- Results Iterable """ if cur is None: pandas_sql = pandasSQL_builder(con) else: pandas_sql = pandasSQL_builder(cur, is_cursor=True) args = _convert_params(sql, params) return pandas_sql.execute(*args) # ----------------------------------------------------------------------------- # -- Read and write to DataFrames def read_sql_table(table_name, con, schema=None, index_col=None, coerce_float=True, parse_dates=None, columns=None, chunksize=None): """Read SQL database table into a DataFrame. Given a table name and an SQLAlchemy connectable, returns a DataFrame. This function does not support DBAPI connections. Parameters ---------- table_name : string Name of SQL table in database con : SQLAlchemy connectable (or database string URI) Sqlite DBAPI connection mode not supported schema : string, default None Name of SQL schema in database to query (if database flavor supports this). If None, use default schema (default). index_col : string or list of strings, optional, default: None Column(s) to set as index(MultiIndex) coerce_float : boolean, default True Attempt to convert values of non-string, non-numeric objects (like decimal.Decimal) to floating point. Can result in loss of Precision. parse_dates : list or dict, default: None - List of column names to parse as dates - Dict of ``{column_name: format string}`` where format string is strftime compatible in case of parsing string times or is one of (D, s, ns, ms, us) in case of parsing integer timestamps - Dict of ``{column_name: arg dict}``, where the arg dict corresponds to the keyword arguments of :func:`pandas.to_datetime` Especially useful with databases without native Datetime support, such as SQLite columns : list, default: None List of column names to select from sql table chunksize : int, default None If specified, return an iterator where `chunksize` is the number of rows to include in each chunk. Returns ------- DataFrame Notes ----- Any datetime values with time zone information will be converted to UTC See also -------- read_sql_query : Read SQL query into a DataFrame. read_sql """ con = _engine_builder(con) if not _is_sqlalchemy_connectable(con): raise NotImplementedError("read_sql_table only supported for " "SQLAlchemy connectable.") import sqlalchemy from sqlalchemy.schema import MetaData meta = MetaData(con, schema=schema) try: meta.reflect(only=[table_name], views=True) except sqlalchemy.exc.InvalidRequestError: raise ValueError("Table %s not found" % table_name) pandas_sql = SQLDatabase(con, meta=meta) table = pandas_sql.read_table( table_name, index_col=index_col, coerce_float=coerce_float, parse_dates=parse_dates, columns=columns, chunksize=chunksize) if table is not None: return table else: raise ValueError("Table %s not found" % table_name, con) def read_sql_query(sql, con, index_col=None, coerce_float=True, params=None, parse_dates=None, chunksize=None): """Read SQL query into a DataFrame. Returns a DataFrame corresponding to the result set of the query string. Optionally provide an `index_col` parameter to use one of the columns as the index, otherwise default integer index will be used. Parameters ---------- sql : string SQL query or SQLAlchemy Selectable (select or text object) to be executed. con : SQLAlchemy connectable(engine/connection) or database string URI or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to use any DB supported by that library. If a DBAPI2 object, only sqlite3 is supported. index_col : string or list of strings, optional, default: None Column(s) to set as index(MultiIndex) coerce_float : boolean, default True Attempt to convert values of non-string, non-numeric objects (like decimal.Decimal) to floating point, useful for SQL result sets params : list, tuple or dict, optional, default: None List of parameters to pass to execute method. The syntax used to pass parameters is database driver dependent. Check your database driver documentation for which of the five syntax styles, described in PEP 249's paramstyle, is supported. Eg. for psycopg2, uses %(name)s so use params={'name' : 'value'} parse_dates : list or dict, default: None - List of column names to parse as dates - Dict of ``{column_name: format string}`` where format string is strftime compatible in case of parsing string times or is one of (D, s, ns, ms, us) in case of parsing integer timestamps - Dict of ``{column_name: arg dict}``, where the arg dict corresponds to the keyword arguments of :func:`pandas.to_datetime` Especially useful with databases without native Datetime support, such as SQLite chunksize : int, default None If specified, return an iterator where `chunksize` is the number of rows to include in each chunk. Returns ------- DataFrame Notes ----- Any datetime values with time zone information parsed via the `parse_dates` parameter will be converted to UTC See also -------- read_sql_table : Read SQL database table into a DataFrame read_sql """ pandas_sql = pandasSQL_builder(con) return pandas_sql.read_query( sql, index_col=index_col, params=params, coerce_float=coerce_float, parse_dates=parse_dates, chunksize=chunksize) def read_sql(sql, con, index_col=None, coerce_float=True, params=None, parse_dates=None, columns=None, chunksize=None): """ Read SQL query or database table into a DataFrame. Parameters ---------- sql : string SQL query or SQLAlchemy Selectable (select or text object) to be executed, or database table name. con : SQLAlchemy connectable(engine/connection) or database string URI or DBAPI2 connection (fallback mode) Using SQLAlchemy makes it possible to use any DB supported by that library. If a DBAPI2 object, only sqlite3 is supported. index_col : string or list of strings, optional, default: None Column(s) to set as index(MultiIndex) coerce_float : boolean, default True Attempt to convert values of non-string, non-numeric objects (like decimal.Decimal) to floating point, useful for SQL result sets params : list, tuple or dict, optional, default: None List of parameters to pass to execute method. The syntax used to pass parameters is database driver dependent. Check your database driver documentation for which of the five syntax styles, described in PEP 249's paramstyle, is supported. Eg. for psycopg2, uses %(name)s so use params={'name' : 'value'} parse_dates : list or dict, default: None - List of column names to parse as dates - Dict of ``{column_name: format string}`` where format string is strftime compatible in case of parsing string times or is one of (D, s, ns, ms, us) in case of parsing integer timestamps - Dict of ``{column_name: arg dict}``, where the arg dict corresponds to the keyword arguments of :func:`pandas.to_datetime` Especially useful with databases without native Datetime support, such as SQLite columns : list, default: None List of column names to select from sql table (only used when reading a table). chunksize : int, default None If specified, return an iterator where `chunksize` is the number of rows to include in each chunk. Returns ------- DataFrame Notes ----- This function is a convenience wrapper around ``read_sql_table`` and ``read_sql_query`` (and for backward compatibility) and will delegate to the specific function depending on the provided input (database table name or sql query). The delegated function might have more specific notes about their functionality not listed here. See also -------- read_sql_table : Read SQL database table into a DataFrame read_sql_query : Read SQL query into a DataFrame """ pandas_sql = pandasSQL_builder(con) if isinstance(pandas_sql, SQLiteDatabase): return pandas_sql.read_query( sql, index_col=index_col, params=params, coerce_float=coerce_float, parse_dates=parse_dates, chunksize=chunksize) try: _is_table_name = pandas_sql.has_table(sql) except: _is_table_name = False if _is_table_name: pandas_sql.meta.reflect(only=[sql]) return pandas_sql.read_table( sql, index_col=index_col, coerce_float=coerce_float, parse_dates=parse_dates, columns=columns, chunksize=chunksize) else: return pandas_sql.read_query( sql, index_col=index_col, params=params, coerce_float=coerce_float, parse_dates=parse_dates, chunksize=chunksize) def to_sql(frame, name, con, flavor=None, schema=None, if_exists='fail', index=True, index_label=None, chunksize=None, dtype=None): """ Write records stored in a DataFrame to a SQL database. Parameters ---------- frame : DataFrame name : string Name of SQL table con : SQLAlchemy connectable(engine/connection) or database string URI or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to use any DB supported by that library. If a DBAPI2 object, only sqlite3 is supported. flavor : 'sqlite', default None DEPRECATED: this parameter will be removed in a future version schema : string, default None Name of SQL schema in database to write to (if database flavor supports this). If None, use default schema (default). if_exists : {'fail', 'replace', 'append'}, default 'fail' - fail: If table exists, do nothing. - replace: If table exists, drop it, recreate it, and insert data. - append: If table exists, insert data. Create if does not exist. index : boolean, default True Write DataFrame index as a column index_label : string or sequence, default None Column label for index column(s). If None is given (default) and `index` is True, then the index names are used. A sequence should be given if the DataFrame uses MultiIndex. chunksize : int, default None If not None, then rows will be written in batches of this size at a time. If None, all rows will be written at once. dtype : single SQLtype or dict of column name to SQL type, default None Optional specifying the datatype for columns. The SQL type should be a SQLAlchemy type, or a string for sqlite3 fallback connection. If all columns are of the same type, one single value can be used. """ if if_exists not in ('fail', 'replace', 'append'): raise ValueError("'{0}' is not valid for if_exists".format(if_exists)) pandas_sql = pandasSQL_builder(con, schema=schema, flavor=flavor) if isinstance(frame, Series): frame = frame.to_frame() elif not isinstance(frame, DataFrame): raise NotImplementedError("'frame' argument should be either a " "Series or a DataFrame") pandas_sql.to_sql(frame, name, if_exists=if_exists, index=index, index_label=index_label, schema=schema, chunksize=chunksize, dtype=dtype) def has_table(table_name, con, flavor=None, schema=None): """ Check if DataBase has named table. Parameters ---------- table_name: string Name of SQL table con: SQLAlchemy connectable(engine/connection) or sqlite3 DBAPI2 connection Using SQLAlchemy makes it possible to use any DB supported by that library. If a DBAPI2 object, only sqlite3 is supported. flavor : 'sqlite', default None DEPRECATED: this parameter will be removed in a future version schema : string, default None Name of SQL schema in database to write to (if database flavor supports this). If None, use default schema (default). Returns ------- boolean """ pandas_sql = pandasSQL_builder(con, flavor=flavor, schema=schema) return pandas_sql.has_table(table_name) table_exists = has_table def _engine_builder(con): """ Returns a SQLAlchemy engine from a URI (if con is a string) else it just return con without modifying it """ global _SQLALCHEMY_INSTALLED if isinstance(con, string_types): try: import sqlalchemy except ImportError: _SQLALCHEMY_INSTALLED = False else: con = sqlalchemy.create_engine(con) return con return con def pandasSQL_builder(con, flavor=None, schema=None, meta=None, is_cursor=False): """ Convenience function to return the correct PandasSQL subclass based on the provided parameters """ _validate_flavor_parameter(flavor) # When support for DBAPI connections is removed, # is_cursor should not be necessary. con = _engine_builder(con) if _is_sqlalchemy_connectable(con): return SQLDatabase(con, schema=schema, meta=meta) elif isinstance(con, string_types): raise ImportError("Using URI string without sqlalchemy installed.") else: return SQLiteDatabase(con, is_cursor=is_cursor) class SQLTable(PandasObject): """ For mapping Pandas tables to SQL tables. Uses fact that table is reflected by SQLAlchemy to do better type convertions. Also holds various flags needed to avoid having to pass them between functions all the time. """ # TODO: support for multiIndex def __init__(self, name, pandas_sql_engine, frame=None, index=True, if_exists='fail', prefix='pandas', index_label=None, schema=None, keys=None, dtype=None): self.name = name self.pd_sql = pandas_sql_engine self.prefix = prefix self.frame = frame self.index = self._index_name(index, index_label) self.schema = schema self.if_exists = if_exists self.keys = keys self.dtype = dtype if frame is not None: # We want to initialize based on a dataframe self.table = self._create_table_setup() else: # no data provided, read-only mode self.table = self.pd_sql.get_table(self.name, self.schema) if self.table is None: raise ValueError("Could not init table '%s'" % name) def exists(self): return self.pd_sql.has_table(self.name, self.schema) def sql_schema(self): from sqlalchemy.schema import CreateTable return str(CreateTable(self.table).compile(self.pd_sql.connectable)) def _execute_create(self): # Inserting table into database, add to MetaData object self.table = self.table.tometadata(self.pd_sql.meta) self.table.create() def create(self): if self.exists(): if self.if_exists == 'fail': raise ValueError("Table '%s' already exists." % self.name) elif self.if_exists == 'replace': self.pd_sql.drop_table(self.name, self.schema) self._execute_create() elif self.if_exists == 'append': pass else: raise ValueError( "'{0}' is not valid for if_exists".format(self.if_exists)) else: self._execute_create() def insert_statement(self): return self.table.insert() def insert_data(self): if self.index is not None: temp = self.frame.copy() temp.index.names = self.index try: temp.reset_index(inplace=True) except ValueError as err: raise ValueError( "duplicate name in index/columns: {0}".format(err)) else: temp = self.frame column_names = list(map(text_type, temp.columns)) ncols = len(column_names) data_list = [None] * ncols blocks = temp._data.blocks for i in range(len(blocks)): b = blocks[i] if b.is_datetime: # convert to microsecond resolution so this yields # datetime.datetime d = b.values.astype('M8[us]').astype(object) else: d = np.array(b.get_values(), dtype=object) # replace NaN with None if b._can_hold_na: mask = isnull(d) d[mask] = None for col_loc, col in zip(b.mgr_locs, d): data_list[col_loc] = col return column_names, data_list def _execute_insert(self, conn, keys, data_iter): data = [dict((k, v) for k, v in zip(keys, row)) for row in data_iter] conn.execute(self.insert_statement(), data) def insert(self, chunksize=None): keys, data_list = self.insert_data() nrows = len(self.frame) if nrows == 0: return if chunksize is None: chunksize = nrows elif chunksize == 0: raise ValueError('chunksize argument should be non-zero') chunks = int(nrows / chunksize) + 1 with self.pd_sql.run_transaction() as conn: for i in range(chunks): start_i = i * chunksize end_i = min((i + 1) * chunksize, nrows) if start_i >= end_i: break chunk_iter = zip(*[arr[start_i:end_i] for arr in data_list]) self._execute_insert(conn, keys, chunk_iter) def _query_iterator(self, result, chunksize, columns, coerce_float=True, parse_dates=None): """Return generator through chunked result set""" while True: data = result.fetchmany(chunksize) if not data: break else: self.frame = DataFrame.from_records( data, columns=columns, coerce_float=coerce_float) self._harmonize_columns(parse_dates=parse_dates) if self.index is not None: self.frame.set_index(self.index, inplace=True) yield self.frame def read(self, coerce_float=True, parse_dates=None, columns=None, chunksize=None): if columns is not None and len(columns) > 0: from sqlalchemy import select cols = [self.table.c[n] for n in columns] if self.index is not None: [cols.insert(0, self.table.c[idx]) for idx in self.index[::-1]] sql_select = select(cols) else: sql_select = self.table.select() result = self.pd_sql.execute(sql_select) column_names = result.keys() if chunksize is not None: return self._query_iterator(result, chunksize, column_names, coerce_float=coerce_float, parse_dates=parse_dates) else: data = result.fetchall() self.frame = DataFrame.from_records( data, columns=column_names, coerce_float=coerce_float) self._harmonize_columns(parse_dates=parse_dates) if self.index is not None: self.frame.set_index(self.index, inplace=True) return self.frame def _index_name(self, index, index_label): # for writing: index=True to include index in sql table if index is True: nlevels = self.frame.index.nlevels # if index_label is specified, set this as index name(s) if index_label is not None: if not isinstance(index_label, list): index_label = [index_label] if len(index_label) != nlevels: raise ValueError( "Length of 'index_label' should match number of " "levels, which is {0}".format(nlevels)) else: return index_label # return the used column labels for the index columns if (nlevels == 1 and 'index' not in self.frame.columns and self.frame.index.name is None): return ['index'] else: return [l if l is not None else "level_{0}".format(i) for i, l in enumerate(self.frame.index.names)] # for reading: index=(list of) string to specify column to set as index elif isinstance(index, string_types): return [index] elif isinstance(index, list): return index else: return None def _get_column_names_and_types(self, dtype_mapper): column_names_and_types = [] if self.index is not None: for i, idx_label in enumerate(self.index): idx_type = dtype_mapper( self.frame.index._get_level_values(i)) column_names_and_types.append((text_type(idx_label), idx_type, True)) column_names_and_types += [ (text_type(self.frame.columns[i]), dtype_mapper(self.frame.iloc[:, i]), False) for i in range(len(self.frame.columns)) ] return column_names_and_types def _create_table_setup(self): from sqlalchemy import Table, Column, PrimaryKeyConstraint column_names_and_types = \ self._get_column_names_and_types(self._sqlalchemy_type) columns = [Column(name, typ, index=is_index) for name, typ, is_index in column_names_and_types] if self.keys is not None: if not is_list_like(self.keys): keys = [self.keys] else: keys = self.keys pkc = PrimaryKeyConstraint(*keys, name=self.name + '_pk') columns.append(pkc) schema = self.schema or self.pd_sql.meta.schema # At this point, attach to new metadata, only attach to self.meta # once table is created. from sqlalchemy.schema import MetaData meta = MetaData(self.pd_sql, schema=schema) return Table(self.name, meta, *columns, schema=schema) def _harmonize_columns(self, parse_dates=None): """ Make the DataFrame's column types align with the SQL table column types. Need to work around limited NA value support. Floats are always fine, ints must always be floats if there are Null values. Booleans are hard because converting bool column with None replaces all Nones with false. Therefore only convert bool if there are no NA values. Datetimes should already be converted to np.datetime64 if supported, but here we also force conversion if required """ # handle non-list entries for parse_dates gracefully if parse_dates is True or parse_dates is None or parse_dates is False: parse_dates = [] if not hasattr(parse_dates, '__iter__'): parse_dates = [parse_dates] for sql_col in self.table.columns: col_name = sql_col.name try: df_col = self.frame[col_name] # the type the dataframe column should have col_type = self._get_dtype(sql_col.type) if (col_type is datetime or col_type is date or col_type is DatetimeTZDtype): self.frame[col_name] = _handle_date_column(df_col) elif col_type is float: # floats support NA, can always convert! self.frame[col_name] = df_col.astype(col_type, copy=False) elif len(df_col) == df_col.count(): # No NA values, can convert ints and bools if col_type is np.dtype('int64') or col_type is bool: self.frame[col_name] = df_col.astype( col_type, copy=False) # Handle date parsing if col_name in parse_dates: try: fmt = parse_dates[col_name] except TypeError: fmt = None self.frame[col_name] = _handle_date_column( df_col, format=fmt) except KeyError: pass # this column not in results def _get_notnull_col_dtype(self, col): """ Infer datatype of the Series col. In case the dtype of col is 'object' and it contains NA values, this infers the datatype of the not-NA values. Needed for inserting typed data containing NULLs, GH8778. """ col_for_inference = col if col.dtype == 'object': notnulldata = col[~isnull(col)] if len(notnulldata): col_for_inference = notnulldata return lib.infer_dtype(col_for_inference) def _sqlalchemy_type(self, col): dtype = self.dtype or {} if col.name in dtype: return self.dtype[col.name] col_type = self._get_notnull_col_dtype(col) from sqlalchemy.types import (BigInteger, Integer, Float, Text, Boolean, DateTime, Date, Time) if col_type == 'datetime64' or col_type == 'datetime': try: tz = col.tzinfo # noqa return DateTime(timezone=True) except: return DateTime if col_type == 'timedelta64': warnings.warn("the 'timedelta' type is not supported, and will be " "written as integer values (ns frequency) to the " "database.", UserWarning, stacklevel=8) return BigInteger elif col_type == 'floating': if col.dtype == 'float32': return Float(precision=23) else: return Float(precision=53) elif col_type == 'integer': if col.dtype == 'int32': return Integer else: return BigInteger elif col_type == 'boolean': return Boolean elif col_type == 'date': return Date elif col_type == 'time': return Time elif col_type == 'complex': raise ValueError('Complex datatypes not supported') return Text def _get_dtype(self, sqltype): from sqlalchemy.types import (Integer, Float, Boolean, DateTime, Date, TIMESTAMP) if isinstance(sqltype, Float): return float elif isinstance(sqltype, Integer): # TODO: Refine integer size. return np.dtype('int64') elif isinstance(sqltype, TIMESTAMP): # we have a timezone capable type if not sqltype.timezone: return datetime return DatetimeTZDtype elif isinstance(sqltype, DateTime): # Caution: np.datetime64 is also a subclass of np.number. return datetime elif isinstance(sqltype, Date): return date elif isinstance(sqltype, Boolean): return bool return object class PandasSQL(PandasObject): """ Subclasses Should define read_sql and to_sql """ def read_sql(self, *args, **kwargs): raise ValueError("PandasSQL must be created with an SQLAlchemy " "connectable or sqlite connection") def to_sql(self, *args, **kwargs): raise ValueError("PandasSQL must be created with an SQLAlchemy " "connectable or sqlite connection") class SQLDatabase(PandasSQL): """ This class enables convertion between DataFrame and SQL databases using SQLAlchemy to handle DataBase abstraction Parameters ---------- engine : SQLAlchemy connectable Connectable to connect with the database. Using SQLAlchemy makes it possible to use any DB supported by that library. schema : string, default None Name of SQL schema in database to write to (if database flavor supports this). If None, use default schema (default). meta : SQLAlchemy MetaData object, default None If provided, this MetaData object is used instead of a newly created. This allows to specify database flavor specific arguments in the MetaData object. """ def __init__(self, engine, schema=None, meta=None): self.connectable = engine if not meta: from sqlalchemy.schema import MetaData meta = MetaData(self.connectable, schema=schema) self.meta = meta @contextmanager def run_transaction(self): with self.connectable.begin() as tx: if hasattr(tx, 'execute'): yield tx else: yield self.connectable def execute(self, *args, **kwargs): """Simple passthrough to SQLAlchemy connectable""" return self.connectable.execute(*args, **kwargs) def read_table(self, table_name, index_col=None, coerce_float=True, parse_dates=None, columns=None, schema=None, chunksize=None): """Read SQL database table into a DataFrame. Parameters ---------- table_name : string Name of SQL table in database index_col : string, optional, default: None Column to set as index coerce_float : boolean, default True Attempt to convert values of non-string, non-numeric objects (like decimal.Decimal) to floating point. This can result in loss of precision. parse_dates : list or dict, default: None - List of column names to parse as dates - Dict of ``{column_name: format string}`` where format string is strftime compatible in case of parsing string times or is one of (D, s, ns, ms, us) in case of parsing integer timestamps - Dict of ``{column_name: arg}``, where the arg corresponds to the keyword arguments of :func:`pandas.to_datetime`. Especially useful with databases without native Datetime support, such as SQLite columns : list, default: None List of column names to select from sql table schema : string, default None Name of SQL schema in database to query (if database flavor supports this). If specified, this overwrites the default schema of the SQLDatabase object. chunksize : int, default None If specified, return an iterator where `chunksize` is the number of rows to include in each chunk. Returns ------- DataFrame See also -------- pandas.read_sql_table SQLDatabase.read_query """ table = SQLTable(table_name, self, index=index_col, schema=schema) return table.read(coerce_float=coerce_float, parse_dates=parse_dates, columns=columns, chunksize=chunksize) @staticmethod def _query_iterator(result, chunksize, columns, index_col=None, coerce_float=True, parse_dates=None): """Return generator through chunked result set""" while True: data = result.fetchmany(chunksize) if not data: break else: yield _wrap_result(data, columns, index_col=index_col, coerce_float=coerce_float, parse_dates=parse_dates) def read_query(self, sql, index_col=None, coerce_float=True, parse_dates=None, params=None, chunksize=None): """Read SQL query into a DataFrame. Parameters ---------- sql : string SQL query to be executed index_col : string, optional, default: None Column name to use as index for the returned DataFrame object. coerce_float : boolean, default True Attempt to convert values of non-string, non-numeric objects (like decimal.Decimal) to floating point, useful for SQL result sets params : list, tuple or dict, optional, default: None List of parameters to pass to execute method. The syntax used to pass parameters is database driver dependent. Check your database driver documentation for which of the five syntax styles, described in PEP 249's paramstyle, is supported. Eg. for psycopg2, uses %(name)s so use params={'name' : 'value'} parse_dates : list or dict, default: None - List of column names to parse as dates - Dict of ``{column_name: format string}`` where format string is strftime compatible in case of parsing string times or is one of (D, s, ns, ms, us) in case of parsing integer timestamps - Dict of ``{column_name: arg dict}``, where the arg dict corresponds to the keyword arguments of :func:`pandas.to_datetime` Especially useful with databases without native Datetime support, such as SQLite chunksize : int, default None If specified, return an iterator where `chunksize` is the number of rows to include in each chunk. Returns ------- DataFrame See also -------- read_sql_table : Read SQL database table into a DataFrame read_sql """ args = _convert_params(sql, params) result = self.execute(*args) columns = result.keys() if chunksize is not None: return self._query_iterator(result, chunksize, columns, index_col=index_col, coerce_float=coerce_float, parse_dates=parse_dates) else: data = result.fetchall() frame = _wrap_result(data, columns, index_col=index_col, coerce_float=coerce_float, parse_dates=parse_dates) return frame read_sql = read_query def to_sql(self, frame, name, if_exists='fail', index=True, index_label=None, schema=None, chunksize=None, dtype=None): """ Write records stored in a DataFrame to a SQL database. Parameters ---------- frame : DataFrame name : string Name of SQL table if_exists : {'fail', 'replace', 'append'}, default 'fail' - fail: If table exists, do nothing. - replace: If table exists, drop it, recreate it, and insert data. - append: If table exists, insert data. Create if does not exist. index : boolean, default True Write DataFrame index as a column index_label : string or sequence, default None Column label for index column(s). If None is given (default) and `index` is True, then the index names are used. A sequence should be given if the DataFrame uses MultiIndex. schema : string, default None Name of SQL schema in database to write to (if database flavor supports this). If specified, this overwrites the default schema of the SQLDatabase object. chunksize : int, default None If not None, then rows will be written in batches of this size at a time. If None, all rows will be written at once. dtype : single type or dict of column name to SQL type, default None Optional specifying the datatype for columns. The SQL type should be a SQLAlchemy type. If all columns are of the same type, one single value can be used. """ if dtype and not is_dict_like(dtype): dtype = {col_name: dtype for col_name in frame} if dtype is not None: from sqlalchemy.types import to_instance, TypeEngine for col, my_type in dtype.items(): if not isinstance(to_instance(my_type), TypeEngine): raise ValueError('The type of %s is not a SQLAlchemy ' 'type ' % col) table = SQLTable(name, self, frame=frame, index=index, if_exists=if_exists, index_label=index_label, schema=schema, dtype=dtype) table.create() table.insert(chunksize) if (not name.isdigit() and not name.islower()): # check for potentially case sensitivity issues (GH7815) # Only check when name is not a number and name is not lower case engine = self.connectable.engine with self.connectable.connect() as conn: table_names = engine.table_names( schema=schema or self.meta.schema, connection=conn, ) if name not in table_names: msg = ( "The provided table name '{0}' is not found exactly as " "such in the database after writing the table, possibly " "due to case sensitivity issues. Consider using lower " "case table names." ).format(name) warnings.warn(msg, UserWarning) @property def tables(self): return self.meta.tables def has_table(self, name, schema=None): return self.connectable.run_callable( self.connectable.dialect.has_table, name, schema or self.meta.schema, ) def get_table(self, table_name, schema=None): schema = schema or self.meta.schema if schema: tbl = self.meta.tables.get('.'.join([schema, table_name])) else: tbl = self.meta.tables.get(table_name) # Avoid casting double-precision floats into decimals from sqlalchemy import Numeric for column in tbl.columns: if isinstance(column.type, Numeric): column.type.asdecimal = False return tbl def drop_table(self, table_name, schema=None): schema = schema or self.meta.schema if self.has_table(table_name, schema): self.meta.reflect(only=[table_name], schema=schema) self.get_table(table_name, schema).drop() self.meta.clear() def _create_sql_schema(self, frame, table_name, keys=None, dtype=None): table = SQLTable(table_name, self, frame=frame, index=False, keys=keys, dtype=dtype) return str(table.sql_schema()) # ---- SQL without SQLAlchemy --- # sqlite-specific sql strings and handler class # dictionary used for readability purposes _SQL_TYPES = { 'string': 'TEXT', 'floating': 'REAL', 'integer': 'INTEGER', 'datetime': 'TIMESTAMP', 'date': 'DATE', 'time': 'TIME', 'boolean': 'INTEGER', } def _get_unicode_name(name): try: uname = text_type(name).encode("utf-8", "strict").decode("utf-8") except UnicodeError: raise ValueError("Cannot convert identifier to UTF-8: '%s'" % name) return uname def _get_valid_sqlite_name(name): # See http://stackoverflow.com/questions/6514274/how-do-you-escape-strings\ # -for-sqlite-table-column-names-in-python # Ensure the string can be encoded as UTF-8. # Ensure the string does not include any NUL characters. # Replace all " with "". # Wrap the entire thing in double quotes. uname = _get_unicode_name(name) if not len(uname): raise ValueError("Empty table or column name specified") nul_index = uname.find("\x00") if nul_index >= 0: raise ValueError('SQLite identifier cannot contain NULs') return '"' + uname.replace('"', '""') + '"' _SAFE_NAMES_WARNING = ("The spaces in these column names will not be changed. " "In pandas versions < 0.14, spaces were converted to " "underscores.") class SQLiteTable(SQLTable): """ Patch the SQLTable for fallback support. Instead of a table variable just use the Create Table statement. """ def __init__(self, *args, **kwargs): # GH 8341 # register an adapter callable for datetime.time object import sqlite3 # this will transform time(12,34,56,789) into '12:34:56.000789' # (this is what sqlalchemy does) sqlite3.register_adapter(time, lambda _: _.strftime("%H:%M:%S.%f")) super(SQLiteTable, self).__init__(*args, **kwargs) def sql_schema(self): return str(";\n".join(self.table)) def _execute_create(self): with self.pd_sql.run_transaction() as conn: for stmt in self.table: conn.execute(stmt) def insert_statement(self): names = list(map(text_type, self.frame.columns)) wld = '?' # wildcard char escape = _get_valid_sqlite_name if self.index is not None: [names.insert(0, idx) for idx in self.index[::-1]] bracketed_names = [escape(column) for column in names] col_names = ','.join(bracketed_names) wildcards = ','.join([wld] * len(names)) insert_statement = 'INSERT INTO %s (%s) VALUES (%s)' % ( escape(self.name), col_names, wildcards) return insert_statement def _execute_insert(self, conn, keys, data_iter): data_list = list(data_iter) conn.executemany(self.insert_statement(), data_list) def _create_table_setup(self): """ Return a list of SQL statement that create a table reflecting the structure of a DataFrame. The first entry will be a CREATE TABLE statement while the rest will be CREATE INDEX statements """ column_names_and_types = \ self._get_column_names_and_types(self._sql_type_name) pat = re.compile('\s+') column_names = [col_name for col_name, _, _ in column_names_and_types] if any(map(pat.search, column_names)): warnings.warn(_SAFE_NAMES_WARNING, stacklevel=6) escape = _get_valid_sqlite_name create_tbl_stmts = [escape(cname) + ' ' + ctype for cname, ctype, _ in column_names_and_types] if self.keys is not None and len(self.keys): if not is_list_like(self.keys): keys = [self.keys] else: keys = self.keys cnames_br = ", ".join([escape(c) for c in keys]) create_tbl_stmts.append( "CONSTRAINT {tbl}_pk PRIMARY KEY ({cnames_br})".format( tbl=self.name, cnames_br=cnames_br)) create_stmts = ["CREATE TABLE " + escape(self.name) + " (\n" + ',\n '.join(create_tbl_stmts) + "\n)"] ix_cols = [cname for cname, _, is_index in column_names_and_types if is_index] if len(ix_cols): cnames = "_".join(ix_cols) cnames_br = ",".join([escape(c) for c in ix_cols]) create_stmts.append( "CREATE INDEX " + escape("ix_" + self.name + "_" + cnames) + "ON " + escape(self.name) + " (" + cnames_br + ")") return create_stmts def _sql_type_name(self, col): dtype = self.dtype or {} if col.name in dtype: return dtype[col.name] col_type = self._get_notnull_col_dtype(col) if col_type == 'timedelta64': warnings.warn("the 'timedelta' type is not supported, and will be " "written as integer values (ns frequency) to the " "database.", UserWarning, stacklevel=8) col_type = "integer" elif col_type == "datetime64": col_type = "datetime" elif col_type == "empty": col_type = "string" elif col_type == "complex": raise ValueError('Complex datatypes not supported') if col_type not in _SQL_TYPES: col_type = "string" return _SQL_TYPES[col_type] class SQLiteDatabase(PandasSQL): """ Version of SQLDatabase to support sqlite connections (fallback without sqlalchemy). This should only be used internally. Parameters ---------- con : sqlite connection object """ def __init__(self, con, flavor=None, is_cursor=False): _validate_flavor_parameter(flavor) self.is_cursor = is_cursor self.con = con @contextmanager def run_transaction(self): cur = self.con.cursor() try: yield cur self.con.commit() except: self.con.rollback() raise finally: cur.close() def execute(self, *args, **kwargs): if self.is_cursor: cur = self.con else: cur = self.con.cursor() try: if kwargs: cur.execute(*args, **kwargs) else: cur.execute(*args) return cur except Exception as exc: try: self.con.rollback() except Exception: # pragma: no cover ex = DatabaseError("Execution failed on sql: %s\n%s\nunable" " to rollback" % (args[0], exc)) raise_with_traceback(ex) ex = DatabaseError( "Execution failed on sql '%s': %s" % (args[0], exc)) raise_with_traceback(ex) @staticmethod def _query_iterator(cursor, chunksize, columns, index_col=None, coerce_float=True, parse_dates=None): """Return generator through chunked result set""" while True: data = cursor.fetchmany(chunksize) if type(data) == tuple: data = list(data) if not data: cursor.close() break else: yield _wrap_result(data, columns, index_col=index_col, coerce_float=coerce_float, parse_dates=parse_dates) def read_query(self, sql, index_col=None, coerce_float=True, params=None, parse_dates=None, chunksize=None): args = _convert_params(sql, params) cursor = self.execute(*args) columns = [col_desc[0] for col_desc in cursor.description] if chunksize is not None: return self._query_iterator(cursor, chunksize, columns, index_col=index_col, coerce_float=coerce_float, parse_dates=parse_dates) else: data = self._fetchall_as_list(cursor) cursor.close() frame = _wrap_result(data, columns, index_col=index_col, coerce_float=coerce_float, parse_dates=parse_dates) return frame def _fetchall_as_list(self, cur): result = cur.fetchall() if not isinstance(result, list): result = list(result) return result def to_sql(self, frame, name, if_exists='fail', index=True, index_label=None, schema=None, chunksize=None, dtype=None): """ Write records stored in a DataFrame to a SQL database. Parameters ---------- frame: DataFrame name: name of SQL table if_exists: {'fail', 'replace', 'append'}, default 'fail' fail: If table exists, do nothing. replace: If table exists, drop it, recreate it, and insert data. append: If table exists, insert data. Create if does not exist. index : boolean, default True Write DataFrame index as a column index_label : string or sequence, default None Column label for index column(s). If None is given (default) and `index` is True, then the index names are used. A sequence should be given if the DataFrame uses MultiIndex. schema : string, default None Ignored parameter included for compatability with SQLAlchemy version of ``to_sql``. chunksize : int, default None If not None, then rows will be written in batches of this size at a time. If None, all rows will be written at once. dtype : single type or dict of column name to SQL type, default None Optional specifying the datatype for columns. The SQL type should be a string. If all columns are of the same type, one single value can be used. """ if dtype and not is_dict_like(dtype): dtype = {col_name: dtype for col_name in frame} if dtype is not None: for col, my_type in dtype.items(): if not isinstance(my_type, str): raise ValueError('%s (%s) not a string' % ( col, str(my_type))) table = SQLiteTable(name, self, frame=frame, index=index, if_exists=if_exists, index_label=index_label, dtype=dtype) table.create() table.insert(chunksize) def has_table(self, name, schema=None): # TODO(wesm): unused? # escape = _get_valid_sqlite_name # esc_name = escape(name) wld = '?' query = ("SELECT name FROM sqlite_master " "WHERE type='table' AND name=%s;") % wld return len(self.execute(query, [name, ]).fetchall()) > 0 def get_table(self, table_name, schema=None): return None # not supported in fallback mode def drop_table(self, name, schema=None): drop_sql = "DROP TABLE %s" % _get_valid_sqlite_name(name) self.execute(drop_sql) def _create_sql_schema(self, frame, table_name, keys=None, dtype=None): table = SQLiteTable(table_name, self, frame=frame, index=False, keys=keys, dtype=dtype) return str(table.sql_schema()) def get_schema(frame, name, flavor=None, keys=None, con=None, dtype=None): """ Get the SQL db table schema for the given frame. Parameters ---------- frame : DataFrame name : string name of SQL table keys : string or sequence, default: None columns to use a primary key con: an open SQL database connection object or a SQLAlchemy connectable Using SQLAlchemy makes it possible to use any DB supported by that library, default: None If a DBAPI2 object, only sqlite3 is supported. flavor : 'sqlite', default None DEPRECATED: this parameter will be removed in a future version dtype : dict of column name to SQL type, default None Optional specifying the datatype for columns. The SQL type should be a SQLAlchemy type, or a string for sqlite3 fallback connection. """ pandas_sql = pandasSQL_builder(con=con, flavor=flavor) return pandas_sql._create_sql_schema(frame, name, keys=keys, dtype=dtype)
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 7768, 402, 1827, 17995, 1182, 2236, 14183, 2452, 370, 3865, 30242, 1051, 323, 666, 199, 11235, 2579, 436, 370, 7114, 5936, 641, 6249, 13, 6100, 3261, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 504, 2197, 492, 2197, 12, 1434, 12, 900, 199, 199, 646, 3598, 199, 646, 295, 199, 646, 2680, 465, 980, 199, 199, 646, 10634, 423, 8450, 14, 773, 465, 1973, 199, 504, 10634, 14, 1018, 14, 5717, 14, 4752, 492, 365, 2307, 199, 504, 10634, 14, 1018, 14, 5717, 14, 5717, 492, 29825, 14226, 36, 466, 199, 504, 10634, 14, 1018, 14, 5717, 14, 2330, 492, 334, 272, 365, 63, 513, 63, 2930, 12, 365, 63, 807, 63, 2930, 12, 272, 365, 63, 2083, 772, 3903, 63, 2271, 9, 199, 199, 504, 10634, 14, 5819, 492, 334, 1130, 12, 3482, 12, 746, 63, 1045, 63, 6894, 12, 2574, 1059, 63, 1313, 12, 1318, 63, 466, 9, 199, 504, 10634, 14, 1018, 14, 1246, 492, 10071, 12, 12403, 199, 504, 10634, 14, 1018, 14, 1095, 492, 510, 7683, 1692, 199, 504, 10634, 14, 1018, 14, 2537, 14, 31601, 492, 370, 63, 2083, 199, 199, 504, 15502, 492, 27608, 421, 199, 533, 14303, 8030, 8, 17825, 304, 272, 986, 421, 199, 533, 27728, 8, 13760, 304, 272, 986, 421, 199, 3, 13722, 199, 3, 1553, 11642, 3423, 199, 199, 63, 4657, 748, 1244, 2769, 57, 63, 15942, 275, 488, 421, 199, 318, 485, 3502, 63, 6081, 63, 5329, 8, 6081, 304, 272, 408, 272, 13813, 3775, 282, 3050, 283, 6081, 7, 1990, 2013, 14, 272, 982, 440, 488, 12, 16904, 20799, 3849, 340, 283, 10659, 7, 436, 272, 6534, 282, 1722, 340, 7003, 587, 14, 272, 408, 272, 340, 8541, 365, 440, 488, 26, 267, 340, 8541, 508, 283, 10659, 356, 288, 3598, 14, 4050, 480, 1589, 283, 6081, 7, 2725, 365, 5906, 298, 2079, 298, 460, 911, 506, 4829, 315, 282, 6466, 1015, 12, 298, 2079, 298, 305, 283, 10659, 7, 365, 314, 1454, 3748, 945, 298, 2079, 298, 6526, 14303, 365, 440, 4903, 4765, 2079, 20799, 3849, 12, 13232, 29, 18, 9, 267, 587, 26, 288, 746, 1722, 480, 4659, 8541, 469, 6081, 93, 365, 440, 298, 2490, 298, 4946, 1674, 908, 8, 6081, 29, 6081, 430, 421, 199, 318, 485, 374, 63, 14536, 63, 2242, 461, 8, 388, 304, 272, 2288, 485, 4657, 748, 1244, 2769, 57, 63, 15942, 272, 340, 485, 4657, 748, 1244, 2769, 57, 63, 15942, 365, 488, 26, 267, 862, 26, 288, 492, 8335, 288, 485, 4657, 748, 1244, 2769, 57, 63, 15942, 275, 715, 953, 687, 7065, 14, 1023, 492, 18462, 288, 809, 275, 18462, 8, 14536, 855, 1023, 3368, 288, 327, 2104, 8335, 5459, 665, 378, 14, 24, 14, 18, 12, 314, 16524, 2919, 730, 365, 18054, 288, 327, 367, 282, 11723, 6869, 12, 1314, 2058, 315, 282, 5721, 1380, 9936, 370, 288, 327, 1586, 15, 952, 282, 10071, 543, 1109, 772, 1338, 14, 334, 31916, 1342, 1153, 9, 288, 340, 809, 665, 283, 16, 14, 24, 14, 18, 356, 355, 687, 8335, 492, 13123, 2674, 355, 687, 8335, 14, 832, 14, 5772, 492, 6555, 83, 2234, 768, 2014, 83, 8, 7279, 2674, 12, 283, 10659, 358, 355, 347, 6555, 63, 5076, 63, 442, 63, 10659, 8, 466, 3131, 6365, 12, 1011, 829, 304, 490, 372, 283, 9596, 7, 267, 871, 3545, 26, 288, 485, 4657, 748, 1244, 2769, 57, 63, 15942, 275, 756, 339, 340, 485, 4657, 748, 1244, 2769, 57, 63, 15942, 26, 267, 492, 8335, 267, 372, 1228, 8, 388, 12, 8335, 14, 3908, 14, 8631, 461, 9, 272, 587, 26, 267, 372, 756, 421, 199, 318, 485, 3916, 63, 1162, 8, 3009, 12, 1862, 304, 272, 408, 3916, 3875, 436, 1862, 1249, 370, 27980, 18, 14, 16, 1013, 22676, 1475, 624, 272, 1249, 275, 359, 3009, 61, 272, 340, 1862, 365, 440, 488, 26, 267, 340, 2688, 8, 1162, 12, 283, 1612, 735, 221, 327, 511, 340, 1862, 365, 282, 4412, 288, 1249, 847, 359, 1162, 61, 267, 587, 26, 288, 1249, 847, 359, 513, 8, 1162, 1874, 272, 372, 1249, 421, 199, 318, 485, 2479, 63, 602, 63, 2301, 8, 761, 12, 1475, 29, 403, 304, 272, 340, 1228, 8, 908, 12, 1211, 304, 267, 372, 370, 63, 2083, 8, 761, 12, 2552, 534, 4247, 297, 1011, 908, 9, 272, 587, 26, 267, 340, 1475, 315, 788, 36, 297, 283, 83, 297, 283, 706, 297, 283, 527, 297, 283, 561, 2565, 288, 372, 370, 63, 2083, 8, 761, 12, 2552, 534, 14141, 297, 4137, 29, 908, 12, 19314, 29, 549, 9, 267, 916, 334, 20179, 8, 761, 14, 2271, 14, 466, 12, 980, 14, 7774, 9, 503, 1598, 11602, 8, 761, 14, 2271, 14, 466, 12, 980, 14, 4115, 2298, 288, 327, 2198, 10831, 465, 4913, 288, 1475, 275, 283, 83, 7, 340, 1475, 365, 488, 587, 1475, 288, 372, 370, 63, 2083, 8, 761, 12, 2552, 534, 14141, 297, 4137, 29, 908, 12, 19314, 29, 549, 9, 267, 916, 365, 63, 2083, 772, 3903, 63, 2271, 8, 761, 304, 288, 327, 19874, 370, 12174, 7137, 288, 327, 20321, 6094, 975, 288, 372, 334, 475, 63, 2083, 8, 761, 12, 2552, 534, 14141, 358, 490, 1275, 6041, 360, 2083, 772, 59, 561, 12, 12174, 28869, 267, 587, 26, 288, 372, 370, 63, 2083, 8, 761, 12, 2552, 534, 14141, 297, 1475, 29, 908, 12, 19314, 29, 549, 9, 421, 199, 318, 485, 1122, 63, 602, 63, 3406, 8, 576, 63, 1943, 12, 2198, 63, 9356, 304, 272, 408, 272, 18771, 2222, 13, 2083, 4362, 370, 506, 1586, 465, 4066, 14, 272, 32090, 3865, 1059, 7871, 436, 3000, 4913, 4362, 272, 408, 272, 327, 2429, 2222, 13, 513, 4811, 367, 2198, 63, 9356, 19756, 5836, 272, 340, 2198, 63, 9356, 365, 715, 503, 2198, 63, 9356, 365, 488, 503, 2198, 63, 9356, 365, 756, 26, 267, 2198, 63, 9356, 275, 942, 339, 340, 440, 2688, 8, 1122, 63, 9356, 12, 2560, 1661, 12168, 267, 2198, 63, 9356, 275, 359, 1122, 63, 9356, 61, 339, 367, 1048, 63, 354, 315, 2198 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 7768, 402, 1827, 17995, 1182, 2236, 14183, 2452, 370, 3865, 30242, 1051, 323, 666, 199, 11235, 2579, 436, 370, 7114, 5936, 641, 6249, 13, 6100, 3261, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 504, 2197, 492, 2197, 12, 1434, 12, 900, 199, 199, 646, 3598, 199, 646, 295, 199, 646, 2680, 465, 980, 199, 199, 646, 10634, 423, 8450, 14, 773, 465, 1973, 199, 504, 10634, 14, 1018, 14, 5717, 14, 4752, 492, 365, 2307, 199, 504, 10634, 14, 1018, 14, 5717, 14, 5717, 492, 29825, 14226, 36, 466, 199, 504, 10634, 14, 1018, 14, 5717, 14, 2330, 492, 334, 272, 365, 63, 513, 63, 2930, 12, 365, 63, 807, 63, 2930, 12, 272, 365, 63, 2083, 772, 3903, 63, 2271, 9, 199, 199, 504, 10634, 14, 5819, 492, 334, 1130, 12, 3482, 12, 746, 63, 1045, 63, 6894, 12, 2574, 1059, 63, 1313, 12, 1318, 63, 466, 9, 199, 504, 10634, 14, 1018, 14, 1246, 492, 10071, 12, 12403, 199, 504, 10634, 14, 1018, 14, 1095, 492, 510, 7683, 1692, 199, 504, 10634, 14, 1018, 14, 2537, 14, 31601, 492, 370, 63, 2083, 199, 199, 504, 15502, 492, 27608, 421, 199, 533, 14303, 8030, 8, 17825, 304, 272, 986, 421, 199, 533, 27728, 8, 13760, 304, 272, 986, 421, 199, 3, 13722, 199, 3, 1553, 11642, 3423, 199, 199, 63, 4657, 748, 1244, 2769, 57, 63, 15942, 275, 488, 421, 199, 318, 485, 3502, 63, 6081, 63, 5329, 8, 6081, 304, 272, 408, 272, 13813, 3775, 282, 3050, 283, 6081, 7, 1990, 2013, 14, 272, 982, 440, 488, 12, 16904, 20799, 3849, 340, 283, 10659, 7, 436, 272, 6534, 282, 1722, 340, 7003, 587, 14, 272, 408, 272, 340, 8541, 365, 440, 488, 26, 267, 340, 8541, 508, 283, 10659, 356, 288, 3598, 14, 4050, 480, 1589, 283, 6081, 7, 2725, 365, 5906, 298, 2079, 298, 460, 911, 506, 4829, 315, 282, 6466, 1015, 12, 298, 2079, 298, 305, 283, 10659, 7, 365, 314, 1454, 3748, 945, 298, 2079, 298, 6526, 14303, 365, 440, 4903, 4765, 2079, 20799, 3849, 12, 13232, 29, 18, 9, 267, 587, 26, 288, 746, 1722, 480, 4659, 8541, 469, 6081, 93, 365, 440, 298, 2490, 298, 4946, 1674, 908, 8, 6081, 29, 6081, 430, 421, 199, 318, 485, 374, 63, 14536, 63, 2242, 461, 8, 388, 304, 272, 2288, 485, 4657, 748, 1244, 2769, 57, 63, 15942, 272, 340, 485, 4657, 748, 1244, 2769, 57, 63, 15942, 365, 488, 26, 267, 862, 26, 288, 492, 8335, 288, 485, 4657, 748, 1244, 2769, 57, 63, 15942, 275, 715, 953, 687, 7065, 14, 1023, 492, 18462, 288, 809, 275, 18462, 8, 14536, 855, 1023, 3368, 288, 327, 2104, 8335, 5459, 665, 378, 14, 24, 14, 18, 12, 314, 16524, 2919, 730, 365, 18054, 288, 327, 367, 282, 11723, 6869, 12, 1314, 2058, 315, 282, 5721, 1380, 9936, 370, 288, 327, 1586, 15, 952, 282, 10071, 543, 1109, 772, 1338, 14, 334, 31916, 1342, 1153, 9, 288, 340, 809, 665, 283, 16, 14, 24, 14, 18, 356, 355, 687, 8335, 492, 13123, 2674, 355, 687, 8335, 14, 832, 14, 5772, 492, 6555, 83, 2234, 768, 2014, 83, 8, 7279, 2674, 12, 283, 10659, 358, 355, 347, 6555, 63, 5076, 63, 442, 63, 10659, 8, 466, 3131, 6365, 12, 1011, 829, 304, 490, 372, 283, 9596, 7, 267, 871, 3545, 26, 288, 485, 4657, 748, 1244, 2769, 57, 63, 15942, 275, 756, 339, 340, 485, 4657, 748, 1244, 2769, 57, 63, 15942, 26, 267, 492, 8335, 267, 372, 1228, 8, 388, 12, 8335, 14, 3908, 14, 8631, 461, 9, 272, 587, 26, 267, 372, 756, 421, 199, 318, 485, 3916, 63, 1162, 8, 3009, 12, 1862, 304, 272, 408, 3916, 3875, 436, 1862, 1249, 370, 27980, 18, 14, 16, 1013, 22676, 1475, 624, 272, 1249, 275, 359, 3009, 61, 272, 340, 1862, 365, 440, 488, 26, 267, 340, 2688, 8, 1162, 12, 283, 1612, 735, 221, 327, 511, 340, 1862, 365, 282, 4412, 288, 1249, 847, 359, 1162, 61, 267, 587, 26, 288, 1249, 847, 359, 513, 8, 1162, 1874, 272, 372, 1249, 421, 199, 318, 485, 2479, 63, 602, 63, 2301, 8, 761, 12, 1475, 29, 403, 304, 272, 340, 1228, 8, 908, 12, 1211, 304, 267, 372, 370, 63, 2083, 8, 761, 12, 2552, 534, 4247, 297, 1011, 908, 9, 272, 587, 26, 267, 340, 1475, 315, 788, 36, 297, 283, 83, 297, 283, 706, 297, 283, 527, 297, 283, 561, 2565, 288, 372, 370, 63, 2083, 8, 761, 12, 2552, 534, 14141, 297, 4137, 29, 908, 12, 19314, 29, 549, 9, 267, 916, 334, 20179, 8, 761, 14, 2271, 14, 466, 12, 980, 14, 7774, 9, 503, 1598, 11602, 8, 761, 14, 2271, 14, 466, 12, 980, 14, 4115, 2298, 288, 327, 2198, 10831, 465, 4913, 288, 1475, 275, 283, 83, 7, 340, 1475, 365, 488, 587, 1475, 288, 372, 370, 63, 2083, 8, 761, 12, 2552, 534, 14141, 297, 4137, 29, 908, 12, 19314, 29, 549, 9, 267, 916, 365, 63, 2083, 772, 3903, 63, 2271, 8, 761, 304, 288, 327, 19874, 370, 12174, 7137, 288, 327, 20321, 6094, 975, 288, 372, 334, 475, 63, 2083, 8, 761, 12, 2552, 534, 14141, 358, 490, 1275, 6041, 360, 2083, 772, 59, 561, 12, 12174, 28869, 267, 587, 26, 288, 372, 370, 63, 2083, 8, 761, 12, 2552, 534, 14141, 297, 1475, 29, 908, 12, 19314, 29, 549, 9, 421, 199, 318, 485, 1122, 63, 602, 63, 3406, 8, 576, 63, 1943, 12, 2198, 63, 9356, 304, 272, 408, 272, 18771, 2222, 13, 2083, 4362, 370, 506, 1586, 465, 4066, 14, 272, 32090, 3865, 1059, 7871, 436, 3000, 4913, 4362, 272, 408, 272, 327, 2429, 2222, 13, 513, 4811, 367, 2198, 63, 9356, 19756, 5836, 272, 340, 2198, 63, 9356, 365, 715, 503, 2198, 63, 9356, 365, 488, 503, 2198, 63, 9356, 365, 756, 26, 267, 2198, 63, 9356, 275, 942, 339, 340, 440, 2688, 8, 1122, 63, 9356, 12, 2560, 1661, 12168, 267, 2198, 63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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Spleen64/Sick-Beard
sickbeard/clients/requests/packages/charade/cp949prober.py
2801
1782
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is mozilla.org code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Mark Pilgrim - port to Python # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### from .mbcharsetprober import MultiByteCharSetProber from .codingstatemachine import CodingStateMachine from .chardistribution import EUCKRDistributionAnalysis from .mbcssm import CP949SMModel class CP949Prober(MultiByteCharSetProber): def __init__(self): MultiByteCharSetProber.__init__(self) self._mCodingSM = CodingStateMachine(CP949SMModel) # NOTE: CP949 is a superset of EUC-KR, so the distribution should be # not different. self._mDistributionAnalyzer = EUCKRDistributionAnalysis() self.reset() def get_charset_name(self): return "CP949"
gpl-3.0
[ 6565, 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 887, 6043, 19903, 492, 6879, 21312, 199, 504, 1275, 1523, 929, 6744, 492, 30539, 199, 504, 1275, 1560, 4972, 492, 26007, 27373, 24906, 199, 504, 1275, 887, 3919, 77, 492, 19701, 15674, 25335, 421, 199, 533, 19701, 15674, 8029, 8, 3947, 21312, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6879, 21312, 855, 826, 721, 277, 9, 267, 291, 423, 29633, 275, 30539, 8, 2890, 15674, 25335, 9, 267, 327, 6944, 26, 19701, 15674, 365, 282, 1613, 409, 402, 662, 13371, 13, 23063, 12, 880, 314, 4084, 1077, 506, 267, 327, 755, 440, 3365, 14, 267, 291, 423, 77, 8580, 17606, 275, 26007, 27373, 24906, 342, 267, 291, 14, 3958, 342, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 372, 298, 2890, 15674, 2, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 16427, 5113, 8068, 11945, 199, 3, 710, 12769, 5495, 365, 1303, 6956, 14, 1308, 1233, 14, 199, 3, 199, 3, 710, 6026, 9607, 402, 314, 12769, 5495, 365, 199, 3, 20433, 18686, 11098, 14, 199, 3, 20825, 2737, 701, 314, 6026, 9607, 787, 1898, 334, 35, 9, 19960, 199, 3, 314, 6026, 9607, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 257, 7173, 19641, 446, 1844, 370, 2018, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 3, 11315, 13, 10067, 221, 8217, 199, 19054, 7729, 5113, 8068, 21186, 199, 199, 504, 1275, 887, 6043, 19903, 492, 6879, 21312, 199, 504, 1275, 1523, 929, 6744, 492, 30539, 199, 504, 1275, 1560, 4972, 492, 26007, 27373, 24906, 199, 504, 1275, 887, 3919, 77, 492, 19701, 15674, 25335, 421, 199, 533, 19701, 15674, 8029, 8, 3947, 21312, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6879, 21312, 855, 826, 721, 277, 9, 267, 291, 423, 29633, 275, 30539, 8, 2890, 15674, 25335, 9, 267, 327, 6944, 26, 19701, 15674, 365, 282, 1613, 409, 402, 662, 13371, 13, 23063, 12, 880, 314, 4084, 1077, 506, 267, 327, 755, 440, 3365, 14, 267, 291, 423, 77, 8580, 17606, 275, 26007, 27373, 24906, 342, 267, 291, 14, 3958, 342, 339, 347, 664, 63, 6043, 63, 354, 8, 277, 304, 267, 372, 298, 2890, 15674, 2, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
leilihh/novaha
nova/api/openstack/compute/image_metadata.py
16
5056
# Copyright 2011 OpenStack Foundation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from webob import exc from nova.api.openstack import common from nova.api.openstack import wsgi from nova import exception from nova.image import glance from nova.openstack.common.gettextutils import _ class Controller(object): """The image metadata API controller for the OpenStack API.""" def __init__(self): self.image_service = glance.get_default_image_service() def _get_image(self, context, image_id): try: return self.image_service.show(context, image_id) except exception.NotFound: msg = _("Image not found.") raise exc.HTTPNotFound(explanation=msg) @wsgi.serializers(xml=common.MetadataTemplate) def index(self, req, image_id): """Returns the list of metadata for a given instance.""" context = req.environ['nova.context'] metadata = self._get_image(context, image_id)['properties'] return dict(metadata=metadata) @wsgi.serializers(xml=common.MetaItemTemplate) def show(self, req, image_id, id): context = req.environ['nova.context'] metadata = self._get_image(context, image_id)['properties'] if id in metadata: return {'meta': {id: metadata[id]}} else: raise exc.HTTPNotFound() @wsgi.serializers(xml=common.MetadataTemplate) @wsgi.deserializers(xml=common.MetadataDeserializer) def create(self, req, image_id, body): context = req.environ['nova.context'] image = self._get_image(context, image_id) if 'metadata' in body: for key, value in body['metadata'].iteritems(): image['properties'][key] = value common.check_img_metadata_properties_quota(context, image['properties']) try: image = self.image_service.update(context, image_id, image, None) except exception.ImageNotAuthorized as e: raise exc.HTTPForbidden(explanation=e.format_message()) return dict(metadata=image['properties']) @wsgi.serializers(xml=common.MetaItemTemplate) @wsgi.deserializers(xml=common.MetaItemDeserializer) def update(self, req, image_id, id, body): context = req.environ['nova.context'] try: meta = body['meta'] except KeyError: expl = _('Incorrect request body format') raise exc.HTTPBadRequest(explanation=expl) if id not in meta: expl = _('Request body and URI mismatch') raise exc.HTTPBadRequest(explanation=expl) if len(meta) > 1: expl = _('Request body contains too many items') raise exc.HTTPBadRequest(explanation=expl) image = self._get_image(context, image_id) image['properties'][id] = meta[id] common.check_img_metadata_properties_quota(context, image['properties']) try: self.image_service.update(context, image_id, image, None) except exception.ImageNotAuthorized as e: raise exc.HTTPForbidden(explanation=e.format_message()) return dict(meta=meta) @wsgi.serializers(xml=common.MetadataTemplate) @wsgi.deserializers(xml=common.MetadataDeserializer) def update_all(self, req, image_id, body): context = req.environ['nova.context'] image = self._get_image(context, image_id) metadata = body.get('metadata', {}) common.check_img_metadata_properties_quota(context, metadata) image['properties'] = metadata try: self.image_service.update(context, image_id, image, None) except exception.ImageNotAuthorized as e: raise exc.HTTPForbidden(explanation=e.format_message()) return dict(metadata=metadata) @wsgi.response(204) def delete(self, req, image_id, id): context = req.environ['nova.context'] image = self._get_image(context, image_id) if id not in image['properties']: msg = _("Invalid metadata key") raise exc.HTTPNotFound(explanation=msg) image['properties'].pop(id) try: self.image_service.update(context, image_id, image, None) except exception.ImageNotAuthorized as e: raise exc.HTTPForbidden(explanation=e.format_message()) def create_resource(): return wsgi.Resource(Controller())
apache-2.0
[ 3, 1898, 7760, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 14568, 492, 3178, 199, 199, 504, 5913, 14, 1246, 14, 8512, 492, 2863, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 1569, 492, 21785, 199, 504, 5913, 14, 8512, 14, 2330, 14, 5152, 1208, 492, 485, 421, 199, 533, 16282, 8, 785, 304, 272, 408, 1918, 1834, 3341, 3261, 7614, 367, 314, 14260, 3261, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1569, 63, 1364, 275, 21785, 14, 362, 63, 885, 63, 1569, 63, 1364, 342, 339, 347, 485, 362, 63, 1569, 8, 277, 12, 1067, 12, 1834, 63, 344, 304, 267, 862, 26, 288, 372, 291, 14, 1569, 63, 1364, 14, 2384, 8, 1100, 12, 1834, 63, 344, 9, 267, 871, 1919, 14, 4667, 26, 288, 1499, 275, 3824, 3491, 440, 1911, 2685, 288, 746, 3178, 14, 26553, 8, 15228, 29, 1328, 9, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 347, 1478, 8, 277, 12, 2648, 12, 1834, 63, 344, 304, 267, 408, 3407, 314, 769, 402, 3341, 367, 282, 1627, 1256, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 3341, 275, 291, 423, 362, 63, 1569, 8, 1100, 12, 1834, 63, 344, 11820, 3282, 418, 267, 372, 1211, 8, 2343, 29, 2343, 9, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 3396, 2081, 4231, 9, 272, 347, 2498, 8, 277, 12, 2648, 12, 1834, 63, 344, 12, 1305, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 3341, 275, 291, 423, 362, 63, 1569, 8, 1100, 12, 1834, 63, 344, 11820, 3282, 418, 267, 340, 1305, 315, 3341, 26, 288, 372, 791, 2024, 356, 469, 344, 26, 3341, 59, 344, 61, 4863, 267, 587, 26, 288, 746, 3178, 14, 26553, 342, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 5142, 872, 8349, 9, 272, 347, 1218, 8, 277, 12, 2648, 12, 1834, 63, 344, 12, 2396, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 1834, 275, 291, 423, 362, 63, 1569, 8, 1100, 12, 1834, 63, 344, 9, 267, 340, 283, 2343, 7, 315, 2396, 26, 288, 367, 790, 12, 574, 315, 2396, 459, 2343, 2278, 4611, 837, 355, 1834, 459, 3282, 3488, 498, 61, 275, 574, 267, 2863, 14, 1074, 63, 4060, 63, 2343, 63, 3282, 63, 8848, 8, 1100, 12, 8962, 1834, 459, 3282, 1105, 267, 862, 26, 288, 1834, 275, 291, 14, 1569, 63, 1364, 14, 873, 8, 1100, 12, 1834, 63, 344, 12, 1834, 12, 488, 9, 267, 871, 1919, 14, 3491, 1763, 29284, 465, 325, 26, 288, 746, 3178, 14, 2856, 17454, 8, 15228, 29, 69, 14, 908, 63, 1188, 1012, 267, 372, 1211, 8, 2343, 29, 1569, 459, 3282, 1105, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 3396, 2081, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 3396, 2081, 872, 8349, 9, 272, 347, 1678, 8, 277, 12, 2648, 12, 1834, 63, 344, 12, 1305, 12, 2396, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 398, 862, 26, 288, 3404, 275, 2396, 459, 2024, 418, 267, 871, 4067, 26, 288, 29278, 275, 4018, 18298, 1056, 2396, 1475, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 340, 1305, 440, 315, 3404, 26, 288, 29278, 275, 4018, 2017, 2396, 436, 9022, 15015, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 267, 340, 822, 8, 2024, 9, 690, 413, 26, 288, 29278, 275, 4018, 2017, 2396, 3509, 4634, 5002, 2974, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 1834, 275, 291, 423, 362, 63, 1569, 8, 1100, 12, 1834, 63, 344, 9, 267, 1834, 459, 3282, 3488, 344, 61, 275, 3404, 59, 344, 61, 267, 2863, 14, 1074, 63, 4060, 63, 2343, 63, 3282, 63, 8848, 8, 1100, 12, 8962, 1834, 459, 3282, 1105, 267, 862, 26, 288, 291, 14, 1569, 63, 1364, 14, 873, 8, 1100, 12, 1834, 63, 344, 12, 1834, 12, 488, 9, 267, 871, 1919, 14, 3491, 1763, 29284, 465, 325, 26, 288, 746, 3178, 14, 2856, 17454, 8, 15228, 29, 69, 14, 908, 63, 1188, 1012, 267, 372, 1211, 8, 2024, 29, 2024, 9, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 5142, 872, 8349, 9, 272, 347, 1678, 63, 452, 8, 277, 12, 2648, 12, 1834, 63, 344, 12, 2396, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 1834, 275, 291, 423, 362, 63, 1569, 8, 1100, 12, 1834, 63, 344, 9, 267, 3341, 275, 2396, 14, 362, 360, 2343, 297, 5009, 267, 2863, 14, 1074, 63, 4060, 63, 2343, 63, 3282, 63, 8848, 8, 1100, 12, 3341, 9, 267, 1834, 459, 3282, 418, 275, 3341, 267, 862, 26, 288, 291, 14, 1569, 63, 1364, 14, 873, 8, 1100, 12, 1834, 63, 344, 12, 1834, 12, 488, 9, 267, 871, 1919, 14, 3491, 1763, 29284, 465, 325, 26, 288, 746, 3178 ]
[ 1898, 7760, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 14568, 492, 3178, 199, 199, 504, 5913, 14, 1246, 14, 8512, 492, 2863, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 492, 1919, 199, 504, 5913, 14, 1569, 492, 21785, 199, 504, 5913, 14, 8512, 14, 2330, 14, 5152, 1208, 492, 485, 421, 199, 533, 16282, 8, 785, 304, 272, 408, 1918, 1834, 3341, 3261, 7614, 367, 314, 14260, 3261, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1569, 63, 1364, 275, 21785, 14, 362, 63, 885, 63, 1569, 63, 1364, 342, 339, 347, 485, 362, 63, 1569, 8, 277, 12, 1067, 12, 1834, 63, 344, 304, 267, 862, 26, 288, 372, 291, 14, 1569, 63, 1364, 14, 2384, 8, 1100, 12, 1834, 63, 344, 9, 267, 871, 1919, 14, 4667, 26, 288, 1499, 275, 3824, 3491, 440, 1911, 2685, 288, 746, 3178, 14, 26553, 8, 15228, 29, 1328, 9, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 347, 1478, 8, 277, 12, 2648, 12, 1834, 63, 344, 304, 267, 408, 3407, 314, 769, 402, 3341, 367, 282, 1627, 1256, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 3341, 275, 291, 423, 362, 63, 1569, 8, 1100, 12, 1834, 63, 344, 11820, 3282, 418, 267, 372, 1211, 8, 2343, 29, 2343, 9, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 3396, 2081, 4231, 9, 272, 347, 2498, 8, 277, 12, 2648, 12, 1834, 63, 344, 12, 1305, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 3341, 275, 291, 423, 362, 63, 1569, 8, 1100, 12, 1834, 63, 344, 11820, 3282, 418, 267, 340, 1305, 315, 3341, 26, 288, 372, 791, 2024, 356, 469, 344, 26, 3341, 59, 344, 61, 4863, 267, 587, 26, 288, 746, 3178, 14, 26553, 342, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 5142, 872, 8349, 9, 272, 347, 1218, 8, 277, 12, 2648, 12, 1834, 63, 344, 12, 2396, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 1834, 275, 291, 423, 362, 63, 1569, 8, 1100, 12, 1834, 63, 344, 9, 267, 340, 283, 2343, 7, 315, 2396, 26, 288, 367, 790, 12, 574, 315, 2396, 459, 2343, 2278, 4611, 837, 355, 1834, 459, 3282, 3488, 498, 61, 275, 574, 267, 2863, 14, 1074, 63, 4060, 63, 2343, 63, 3282, 63, 8848, 8, 1100, 12, 8962, 1834, 459, 3282, 1105, 267, 862, 26, 288, 1834, 275, 291, 14, 1569, 63, 1364, 14, 873, 8, 1100, 12, 1834, 63, 344, 12, 1834, 12, 488, 9, 267, 871, 1919, 14, 3491, 1763, 29284, 465, 325, 26, 288, 746, 3178, 14, 2856, 17454, 8, 15228, 29, 69, 14, 908, 63, 1188, 1012, 267, 372, 1211, 8, 2343, 29, 1569, 459, 3282, 1105, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 3396, 2081, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 3396, 2081, 872, 8349, 9, 272, 347, 1678, 8, 277, 12, 2648, 12, 1834, 63, 344, 12, 1305, 12, 2396, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 398, 862, 26, 288, 3404, 275, 2396, 459, 2024, 418, 267, 871, 4067, 26, 288, 29278, 275, 4018, 18298, 1056, 2396, 1475, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 340, 1305, 440, 315, 3404, 26, 288, 29278, 275, 4018, 2017, 2396, 436, 9022, 15015, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 267, 340, 822, 8, 2024, 9, 690, 413, 26, 288, 29278, 275, 4018, 2017, 2396, 3509, 4634, 5002, 2974, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 1834, 275, 291, 423, 362, 63, 1569, 8, 1100, 12, 1834, 63, 344, 9, 267, 1834, 459, 3282, 3488, 344, 61, 275, 3404, 59, 344, 61, 267, 2863, 14, 1074, 63, 4060, 63, 2343, 63, 3282, 63, 8848, 8, 1100, 12, 8962, 1834, 459, 3282, 1105, 267, 862, 26, 288, 291, 14, 1569, 63, 1364, 14, 873, 8, 1100, 12, 1834, 63, 344, 12, 1834, 12, 488, 9, 267, 871, 1919, 14, 3491, 1763, 29284, 465, 325, 26, 288, 746, 3178, 14, 2856, 17454, 8, 15228, 29, 69, 14, 908, 63, 1188, 1012, 267, 372, 1211, 8, 2024, 29, 2024, 9, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 5142, 872, 8349, 9, 272, 347, 1678, 63, 452, 8, 277, 12, 2648, 12, 1834, 63, 344, 12, 2396, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 1834, 275, 291, 423, 362, 63, 1569, 8, 1100, 12, 1834, 63, 344, 9, 267, 3341, 275, 2396, 14, 362, 360, 2343, 297, 5009, 267, 2863, 14, 1074, 63, 4060, 63, 2343, 63, 3282, 63, 8848, 8, 1100, 12, 3341, 9, 267, 1834, 459, 3282, 418, 275, 3341, 267, 862, 26, 288, 291, 14, 1569, 63, 1364, 14, 873, 8, 1100, 12, 1834, 63, 344, 12, 1834, 12, 488, 9, 267, 871, 1919, 14, 3491, 1763, 29284, 465, 325, 26, 288, 746, 3178, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
vshtanko/scikit-learn
sklearn/cluster/tests/test_birch.py
342
5603
""" Tests for the birch clustering algorithm. """ from scipy import sparse import numpy as np from sklearn.cluster.tests.common import generate_clustered_data from sklearn.cluster.birch import Birch from sklearn.cluster.hierarchical import AgglomerativeClustering from sklearn.datasets import make_blobs from sklearn.linear_model import ElasticNet from sklearn.metrics import pairwise_distances_argmin, v_measure_score from sklearn.utils.testing import assert_greater_equal from sklearn.utils.testing import assert_equal from sklearn.utils.testing import assert_greater from sklearn.utils.testing import assert_almost_equal from sklearn.utils.testing import assert_array_equal from sklearn.utils.testing import assert_raises from sklearn.utils.testing import assert_warns def test_n_samples_leaves_roots(): # Sanity check for the number of samples in leaves and roots X, y = make_blobs(n_samples=10) brc = Birch() brc.fit(X) n_samples_root = sum([sc.n_samples_ for sc in brc.root_.subclusters_]) n_samples_leaves = sum([sc.n_samples_ for leaf in brc._get_leaves() for sc in leaf.subclusters_]) assert_equal(n_samples_leaves, X.shape[0]) assert_equal(n_samples_root, X.shape[0]) def test_partial_fit(): # Test that fit is equivalent to calling partial_fit multiple times X, y = make_blobs(n_samples=100) brc = Birch(n_clusters=3) brc.fit(X) brc_partial = Birch(n_clusters=None) brc_partial.partial_fit(X[:50]) brc_partial.partial_fit(X[50:]) assert_array_equal(brc_partial.subcluster_centers_, brc.subcluster_centers_) # Test that same global labels are obtained after calling partial_fit # with None brc_partial.set_params(n_clusters=3) brc_partial.partial_fit(None) assert_array_equal(brc_partial.subcluster_labels_, brc.subcluster_labels_) def test_birch_predict(): # Test the predict method predicts the nearest centroid. rng = np.random.RandomState(0) X = generate_clustered_data(n_clusters=3, n_features=3, n_samples_per_cluster=10) # n_samples * n_samples_per_cluster shuffle_indices = np.arange(30) rng.shuffle(shuffle_indices) X_shuffle = X[shuffle_indices, :] brc = Birch(n_clusters=4, threshold=1.) brc.fit(X_shuffle) centroids = brc.subcluster_centers_ assert_array_equal(brc.labels_, brc.predict(X_shuffle)) nearest_centroid = pairwise_distances_argmin(X_shuffle, centroids) assert_almost_equal(v_measure_score(nearest_centroid, brc.labels_), 1.0) def test_n_clusters(): # Test that n_clusters param works properly X, y = make_blobs(n_samples=100, centers=10) brc1 = Birch(n_clusters=10) brc1.fit(X) assert_greater(len(brc1.subcluster_centers_), 10) assert_equal(len(np.unique(brc1.labels_)), 10) # Test that n_clusters = Agglomerative Clustering gives # the same results. gc = AgglomerativeClustering(n_clusters=10) brc2 = Birch(n_clusters=gc) brc2.fit(X) assert_array_equal(brc1.subcluster_labels_, brc2.subcluster_labels_) assert_array_equal(brc1.labels_, brc2.labels_) # Test that the wrong global clustering step raises an Error. clf = ElasticNet() brc3 = Birch(n_clusters=clf) assert_raises(ValueError, brc3.fit, X) # Test that a small number of clusters raises a warning. brc4 = Birch(threshold=10000.) assert_warns(UserWarning, brc4.fit, X) def test_sparse_X(): # Test that sparse and dense data give same results X, y = make_blobs(n_samples=100, centers=10) brc = Birch(n_clusters=10) brc.fit(X) csr = sparse.csr_matrix(X) brc_sparse = Birch(n_clusters=10) brc_sparse.fit(csr) assert_array_equal(brc.labels_, brc_sparse.labels_) assert_array_equal(brc.subcluster_centers_, brc_sparse.subcluster_centers_) def check_branching_factor(node, branching_factor): subclusters = node.subclusters_ assert_greater_equal(branching_factor, len(subclusters)) for cluster in subclusters: if cluster.child_: check_branching_factor(cluster.child_, branching_factor) def test_branching_factor(): # Test that nodes have at max branching_factor number of subclusters X, y = make_blobs() branching_factor = 9 # Purposefully set a low threshold to maximize the subclusters. brc = Birch(n_clusters=None, branching_factor=branching_factor, threshold=0.01) brc.fit(X) check_branching_factor(brc.root_, branching_factor) brc = Birch(n_clusters=3, branching_factor=branching_factor, threshold=0.01) brc.fit(X) check_branching_factor(brc.root_, branching_factor) # Raises error when branching_factor is set to one. brc = Birch(n_clusters=None, branching_factor=1, threshold=0.01) assert_raises(ValueError, brc.fit, X) def check_threshold(birch_instance, threshold): """Use the leaf linked list for traversal""" current_leaf = birch_instance.dummy_leaf_.next_leaf_ while current_leaf: subclusters = current_leaf.subclusters_ for sc in subclusters: assert_greater_equal(threshold, sc.radius) current_leaf = current_leaf.next_leaf_ def test_threshold(): # Test that the leaf subclusters have a threshold lesser than radius X, y = make_blobs(n_samples=80, centers=4) brc = Birch(threshold=0.5, n_clusters=None) brc.fit(X) check_threshold(brc, 0.5) brc = Birch(threshold=5.0, n_clusters=None) brc.fit(X) check_threshold(brc, 5.)
bsd-3-clause
[ 624, 199, 2925, 367, 314, 330, 723, 335, 19454, 5563, 14, 199, 624, 199, 199, 504, 7026, 492, 5178, 199, 646, 2680, 465, 980, 199, 199, 504, 6357, 14, 4201, 14, 2219, 14, 2330, 492, 3550, 63, 429, 527, 3014, 63, 576, 199, 504, 6357, 14, 4201, 14, 66, 723, 335, 492, 699, 723, 335, 199, 504, 6357, 14, 4201, 14, 72, 16437, 492, 18693, 320, 278, 30498, 31174, 199, 504, 6357, 14, 12281, 492, 1852, 63, 21893, 199, 504, 6357, 14, 6676, 63, 1238, 492, 19509, 2480, 199, 504, 6357, 14, 6759, 492, 24859, 63, 15482, 63, 26488, 12, 373, 63, 9580, 63, 3397, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 13154, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 13154, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3536, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 19811, 421, 199, 318, 511, 63, 78, 63, 3356, 63, 16554, 63, 12065, 837, 272, 327, 22111, 1104, 367, 314, 1329, 402, 5845, 315, 16733, 436, 14361, 272, 1323, 12, 612, 275, 1852, 63, 21893, 8, 78, 63, 3356, 29, 709, 9, 272, 330, 1195, 275, 699, 723, 335, 342, 272, 330, 1195, 14, 3269, 8, 56, 9, 272, 302, 63, 3356, 63, 1231, 275, 3089, 779, 551, 14, 78, 63, 3356, 63, 367, 4061, 315, 330, 1195, 14, 1231, 3754, 954, 9170, 63, 566, 272, 302, 63, 3356, 63, 16554, 275, 3089, 779, 551, 14, 78, 63, 3356, 63, 367, 11747, 315, 330, 1195, 423, 362, 63, 16554, 342, 1169, 367, 4061, 315, 11747, 14, 954, 9170, 63, 566, 272, 702, 63, 1452, 8, 78, 63, 3356, 63, 16554, 12, 1323, 14, 1392, 59, 16, 566, 272, 702, 63, 1452, 8, 78, 63, 3356, 63, 1231, 12, 1323, 14, 1392, 59, 16, 566, 421, 199, 318, 511, 63, 6672, 63, 3269, 837, 272, 327, 1379, 626, 5542, 365, 7353, 370, 6358, 7417, 63, 3269, 3663, 5431, 272, 1323, 12, 612, 275, 1852, 63, 21893, 8, 78, 63, 3356, 29, 1960, 9, 272, 330, 1195, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 19, 9, 272, 330, 1195, 14, 3269, 8, 56, 9, 272, 330, 1195, 63, 6672, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 403, 9, 272, 330, 1195, 63, 6672, 14, 6672, 63, 3269, 8, 56, 1491, 1400, 566, 272, 330, 1195, 63, 6672, 14, 6672, 63, 3269, 8, 56, 59, 1400, 5728, 272, 702, 63, 1144, 63, 1452, 8, 66, 1195, 63, 6672, 14, 954, 4201, 63, 15660, 3131, 2432, 330, 1195, 14, 954, 4201, 63, 15660, 4602, 339, 327, 1379, 626, 2011, 2288, 3628, 787, 15884, 2410, 6358, 7417, 63, 3269, 272, 327, 543, 488, 272, 330, 1195, 63, 6672, 14, 409, 63, 1162, 8, 78, 63, 9170, 29, 19, 9, 272, 330, 1195, 63, 6672, 14, 6672, 63, 3269, 8, 403, 9, 272, 702, 63, 1144, 63, 1452, 8, 66, 1195, 63, 6672, 14, 954, 4201, 63, 3512, 3131, 330, 1195, 14, 954, 4201, 63, 3512, 4602, 421, 199, 318, 511, 63, 66, 723, 335, 63, 6892, 837, 272, 327, 1379, 314, 12610, 1083, 876, 7892, 314, 17173, 27587, 14, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 275, 3550, 63, 429, 527, 3014, 63, 576, 8, 78, 63, 9170, 29, 19, 12, 302, 63, 3179, 29, 19, 12, 1816, 302, 63, 3356, 63, 529, 63, 4201, 29, 709, 9, 339, 327, 302, 63, 3356, 627, 302, 63, 3356, 63, 529, 63, 4201, 272, 13031, 63, 4108, 275, 980, 14, 5605, 8, 1216, 9, 272, 9038, 14, 11777, 8, 11777, 63, 4108, 9, 272, 1323, 63, 11777, 275, 1323, 59, 11777, 63, 4108, 12, 12228, 272, 330, 1195, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 20, 12, 8765, 29, 17, 4959, 272, 330, 1195, 14, 3269, 8, 56, 63, 11777, 9, 272, 13345, 26188, 275, 330, 1195, 14, 954, 4201, 63, 15660, 63, 272, 702, 63, 1144, 63, 1452, 8, 66, 1195, 14, 3512, 3131, 330, 1195, 14, 6892, 8, 56, 63, 11777, 430, 272, 17173, 63, 22098, 275, 24859, 63, 15482, 63, 26488, 8, 56, 63, 11777, 12, 13345, 26188, 9, 272, 702, 63, 4398, 63, 1452, 8, 86, 63, 9580, 63, 3397, 8, 16615, 63, 22098, 12, 330, 1195, 14, 3512, 29425, 413, 14, 16, 9, 421, 199, 318, 511, 63, 78, 63, 9170, 837, 272, 327, 1379, 626, 302, 63, 9170, 1215, 5419, 7684, 272, 1323, 12, 612, 275, 1852, 63, 21893, 8, 78, 63, 3356, 29, 1960, 12, 19190, 29, 709, 9, 272, 330, 1195, 17, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 709, 9, 272, 330, 1195, 17, 14, 3269, 8, 56, 9, 272, 702, 63, 13154, 8, 552, 8, 66, 1195, 17, 14, 954, 4201, 63, 15660, 29425, 1616, 9, 272, 702, 63, 1452, 8, 552, 8, 1590, 14, 3235, 8, 66, 1195, 17, 14, 3512, 63, 1826, 1616, 9, 339, 327, 1379, 626, 302, 63, 9170, 275, 18693, 320, 278, 30498, 16454, 316, 10557, 272, 327, 314, 2011, 2058, 14, 272, 9486, 275, 18693, 320, 278, 30498, 31174, 8, 78, 63, 9170, 29, 709, 9, 272, 330, 1195, 18, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 9493, 9, 272, 330, 1195, 18, 14, 3269, 8, 56, 9, 272, 702, 63, 1144, 63, 1452, 8, 66, 1195, 17, 14, 954, 4201, 63, 3512, 3131, 330, 1195, 18, 14, 954, 4201, 63, 3512, 4602, 272, 702, 63, 1144, 63, 1452, 8, 66, 1195, 17, 14, 3512, 3131, 330, 1195, 18, 14, 3512, 4602, 339, 327, 1379, 626, 314, 6835, 2288, 19454, 3650, 6534, 376, 4520, 14, 272, 6975, 275, 19509, 2480, 342, 272, 330, 1195, 19, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 9694, 9, 272, 702, 63, 3536, 8, 3393, 12, 330, 1195, 19, 14, 3269, 12, 1323, 9, 339, 327, 1379, 626, 282, 7425, 1329, 402, 13865, 6534 ]
[ 199, 2925, 367, 314, 330, 723, 335, 19454, 5563, 14, 199, 624, 199, 199, 504, 7026, 492, 5178, 199, 646, 2680, 465, 980, 199, 199, 504, 6357, 14, 4201, 14, 2219, 14, 2330, 492, 3550, 63, 429, 527, 3014, 63, 576, 199, 504, 6357, 14, 4201, 14, 66, 723, 335, 492, 699, 723, 335, 199, 504, 6357, 14, 4201, 14, 72, 16437, 492, 18693, 320, 278, 30498, 31174, 199, 504, 6357, 14, 12281, 492, 1852, 63, 21893, 199, 504, 6357, 14, 6676, 63, 1238, 492, 19509, 2480, 199, 504, 6357, 14, 6759, 492, 24859, 63, 15482, 63, 26488, 12, 373, 63, 9580, 63, 3397, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 13154, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 13154, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3536, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 19811, 421, 199, 318, 511, 63, 78, 63, 3356, 63, 16554, 63, 12065, 837, 272, 327, 22111, 1104, 367, 314, 1329, 402, 5845, 315, 16733, 436, 14361, 272, 1323, 12, 612, 275, 1852, 63, 21893, 8, 78, 63, 3356, 29, 709, 9, 272, 330, 1195, 275, 699, 723, 335, 342, 272, 330, 1195, 14, 3269, 8, 56, 9, 272, 302, 63, 3356, 63, 1231, 275, 3089, 779, 551, 14, 78, 63, 3356, 63, 367, 4061, 315, 330, 1195, 14, 1231, 3754, 954, 9170, 63, 566, 272, 302, 63, 3356, 63, 16554, 275, 3089, 779, 551, 14, 78, 63, 3356, 63, 367, 11747, 315, 330, 1195, 423, 362, 63, 16554, 342, 1169, 367, 4061, 315, 11747, 14, 954, 9170, 63, 566, 272, 702, 63, 1452, 8, 78, 63, 3356, 63, 16554, 12, 1323, 14, 1392, 59, 16, 566, 272, 702, 63, 1452, 8, 78, 63, 3356, 63, 1231, 12, 1323, 14, 1392, 59, 16, 566, 421, 199, 318, 511, 63, 6672, 63, 3269, 837, 272, 327, 1379, 626, 5542, 365, 7353, 370, 6358, 7417, 63, 3269, 3663, 5431, 272, 1323, 12, 612, 275, 1852, 63, 21893, 8, 78, 63, 3356, 29, 1960, 9, 272, 330, 1195, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 19, 9, 272, 330, 1195, 14, 3269, 8, 56, 9, 272, 330, 1195, 63, 6672, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 403, 9, 272, 330, 1195, 63, 6672, 14, 6672, 63, 3269, 8, 56, 1491, 1400, 566, 272, 330, 1195, 63, 6672, 14, 6672, 63, 3269, 8, 56, 59, 1400, 5728, 272, 702, 63, 1144, 63, 1452, 8, 66, 1195, 63, 6672, 14, 954, 4201, 63, 15660, 3131, 2432, 330, 1195, 14, 954, 4201, 63, 15660, 4602, 339, 327, 1379, 626, 2011, 2288, 3628, 787, 15884, 2410, 6358, 7417, 63, 3269, 272, 327, 543, 488, 272, 330, 1195, 63, 6672, 14, 409, 63, 1162, 8, 78, 63, 9170, 29, 19, 9, 272, 330, 1195, 63, 6672, 14, 6672, 63, 3269, 8, 403, 9, 272, 702, 63, 1144, 63, 1452, 8, 66, 1195, 63, 6672, 14, 954, 4201, 63, 3512, 3131, 330, 1195, 14, 954, 4201, 63, 3512, 4602, 421, 199, 318, 511, 63, 66, 723, 335, 63, 6892, 837, 272, 327, 1379, 314, 12610, 1083, 876, 7892, 314, 17173, 27587, 14, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 275, 3550, 63, 429, 527, 3014, 63, 576, 8, 78, 63, 9170, 29, 19, 12, 302, 63, 3179, 29, 19, 12, 1816, 302, 63, 3356, 63, 529, 63, 4201, 29, 709, 9, 339, 327, 302, 63, 3356, 627, 302, 63, 3356, 63, 529, 63, 4201, 272, 13031, 63, 4108, 275, 980, 14, 5605, 8, 1216, 9, 272, 9038, 14, 11777, 8, 11777, 63, 4108, 9, 272, 1323, 63, 11777, 275, 1323, 59, 11777, 63, 4108, 12, 12228, 272, 330, 1195, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 20, 12, 8765, 29, 17, 4959, 272, 330, 1195, 14, 3269, 8, 56, 63, 11777, 9, 272, 13345, 26188, 275, 330, 1195, 14, 954, 4201, 63, 15660, 63, 272, 702, 63, 1144, 63, 1452, 8, 66, 1195, 14, 3512, 3131, 330, 1195, 14, 6892, 8, 56, 63, 11777, 430, 272, 17173, 63, 22098, 275, 24859, 63, 15482, 63, 26488, 8, 56, 63, 11777, 12, 13345, 26188, 9, 272, 702, 63, 4398, 63, 1452, 8, 86, 63, 9580, 63, 3397, 8, 16615, 63, 22098, 12, 330, 1195, 14, 3512, 29425, 413, 14, 16, 9, 421, 199, 318, 511, 63, 78, 63, 9170, 837, 272, 327, 1379, 626, 302, 63, 9170, 1215, 5419, 7684, 272, 1323, 12, 612, 275, 1852, 63, 21893, 8, 78, 63, 3356, 29, 1960, 12, 19190, 29, 709, 9, 272, 330, 1195, 17, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 709, 9, 272, 330, 1195, 17, 14, 3269, 8, 56, 9, 272, 702, 63, 13154, 8, 552, 8, 66, 1195, 17, 14, 954, 4201, 63, 15660, 29425, 1616, 9, 272, 702, 63, 1452, 8, 552, 8, 1590, 14, 3235, 8, 66, 1195, 17, 14, 3512, 63, 1826, 1616, 9, 339, 327, 1379, 626, 302, 63, 9170, 275, 18693, 320, 278, 30498, 16454, 316, 10557, 272, 327, 314, 2011, 2058, 14, 272, 9486, 275, 18693, 320, 278, 30498, 31174, 8, 78, 63, 9170, 29, 709, 9, 272, 330, 1195, 18, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 9493, 9, 272, 330, 1195, 18, 14, 3269, 8, 56, 9, 272, 702, 63, 1144, 63, 1452, 8, 66, 1195, 17, 14, 954, 4201, 63, 3512, 3131, 330, 1195, 18, 14, 954, 4201, 63, 3512, 4602, 272, 702, 63, 1144, 63, 1452, 8, 66, 1195, 17, 14, 3512, 3131, 330, 1195, 18, 14, 3512, 4602, 339, 327, 1379, 626, 314, 6835, 2288, 19454, 3650, 6534, 376, 4520, 14, 272, 6975, 275, 19509, 2480, 342, 272, 330, 1195, 19, 275, 699, 723, 335, 8, 78, 63, 9170, 29, 9694, 9, 272, 702, 63, 3536, 8, 3393, 12, 330, 1195, 19, 14, 3269, 12, 1323, 9, 339, 327, 1379, 626, 282, 7425, 1329, 402, 13865, 6534, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tempbottle/rethinkdb
test/rql_test/connections/http_support/werkzeug/contrib/securecookie.py
294
12204
# -*- coding: utf-8 -*- r""" werkzeug.contrib.securecookie ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module implements a cookie that is not alterable from the client because it adds a checksum the server checks for. You can use it as session replacement if all you have is a user id or something to mark a logged in user. Keep in mind that the data is still readable from the client as a normal cookie is. However you don't have to store and flush the sessions you have at the server. Example usage: >>> from werkzeug.contrib.securecookie import SecureCookie >>> x = SecureCookie({"foo": 42, "baz": (1, 2, 3)}, "deadbeef") Dumping into a string so that one can store it in a cookie: >>> value = x.serialize() Loading from that string again: >>> x = SecureCookie.unserialize(value, "deadbeef") >>> x["baz"] (1, 2, 3) If someone modifies the cookie and the checksum is wrong the unserialize method will fail silently and return a new empty `SecureCookie` object. Keep in mind that the values will be visible in the cookie so do not store data in a cookie you don't want the user to see. Application Integration ======================= If you are using the werkzeug request objects you could integrate the secure cookie into your application like this:: from werkzeug.utils import cached_property from werkzeug.wrappers import BaseRequest from werkzeug.contrib.securecookie import SecureCookie # don't use this key but a different one; you could just use # os.urandom(20) to get something random SECRET_KEY = '\xfa\xdd\xb8z\xae\xe0}4\x8b\xea' class Request(BaseRequest): @cached_property def client_session(self): data = self.cookies.get('session_data') if not data: return SecureCookie(secret_key=SECRET_KEY) return SecureCookie.unserialize(data, SECRET_KEY) def application(environ, start_response): request = Request(environ, start_response) # get a response object here response = ... if request.client_session.should_save: session_data = request.client_session.serialize() response.set_cookie('session_data', session_data, httponly=True) return response(environ, start_response) A less verbose integration can be achieved by using shorthand methods:: class Request(BaseRequest): @cached_property def client_session(self): return SecureCookie.load_cookie(self, secret_key=COOKIE_SECRET) def application(environ, start_response): request = Request(environ, start_response) # get a response object here response = ... request.client_session.save_cookie(response) return response(environ, start_response) :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import pickle import base64 from hmac import new as hmac from time import time from hashlib import sha1 as _default_hash from werkzeug._compat import iteritems, text_type from werkzeug.urls import url_quote_plus, url_unquote_plus from werkzeug._internal import _date_to_unix from werkzeug.contrib.sessions import ModificationTrackingDict from werkzeug.security import safe_str_cmp from werkzeug._compat import to_native class UnquoteError(Exception): """Internal exception used to signal failures on quoting.""" class SecureCookie(ModificationTrackingDict): """Represents a secure cookie. You can subclass this class and provide an alternative mac method. The import thing is that the mac method is a function with a similar interface to the hashlib. Required methods are update() and digest(). Example usage: >>> x = SecureCookie({"foo": 42, "baz": (1, 2, 3)}, "deadbeef") >>> x["foo"] 42 >>> x["baz"] (1, 2, 3) >>> x["blafasel"] = 23 >>> x.should_save True :param data: the initial data. Either a dict, list of tuples or `None`. :param secret_key: the secret key. If not set `None` or not specified it has to be set before :meth:`serialize` is called. :param new: The initial value of the `new` flag. """ #: The hash method to use. This has to be a module with a new function #: or a function that creates a hashlib object. Such as `hashlib.md5` #: Subclasses can override this attribute. The default hash is sha1. #: Make sure to wrap this in staticmethod() if you store an arbitrary #: function there such as hashlib.sha1 which might be implemented #: as a function. hash_method = staticmethod(_default_hash) #: the module used for serialization. Unless overriden by subclasses #: the standard pickle module is used. serialization_method = pickle #: if the contents should be base64 quoted. This can be disabled if the #: serialization process returns cookie safe strings only. quote_base64 = True def __init__(self, data=None, secret_key=None, new=True): ModificationTrackingDict.__init__(self, data or ()) # explicitly convert it into a bytestring because python 2.6 # no longer performs an implicit string conversion on hmac if secret_key is not None: secret_key = bytes(secret_key) self.secret_key = secret_key self.new = new def __repr__(self): return '<%s %s%s>' % ( self.__class__.__name__, dict.__repr__(self), self.should_save and '*' or '' ) @property def should_save(self): """True if the session should be saved. By default this is only true for :attr:`modified` cookies, not :attr:`new`. """ return self.modified @classmethod def quote(cls, value): """Quote the value for the cookie. This can be any object supported by :attr:`serialization_method`. :param value: the value to quote. """ if cls.serialization_method is not None: value = cls.serialization_method.dumps(value) if cls.quote_base64: value = b''.join(base64.b64encode(value).splitlines()).strip() return value @classmethod def unquote(cls, value): """Unquote the value for the cookie. If unquoting does not work a :exc:`UnquoteError` is raised. :param value: the value to unquote. """ try: if cls.quote_base64: value = base64.b64decode(value) if cls.serialization_method is not None: value = cls.serialization_method.loads(value) return value except Exception: # unfortunately pickle and other serialization modules can # cause pretty every error here. if we get one we catch it # and convert it into an UnquoteError raise UnquoteError() def serialize(self, expires=None): """Serialize the secure cookie into a string. If expires is provided, the session will be automatically invalidated after expiration when you unseralize it. This provides better protection against session cookie theft. :param expires: an optional expiration date for the cookie (a :class:`datetime.datetime` object) """ if self.secret_key is None: raise RuntimeError('no secret key defined') if expires: self['_expires'] = _date_to_unix(expires) result = [] mac = hmac(self.secret_key, None, self.hash_method) for key, value in sorted(self.items()): result.append(('%s=%s' % ( url_quote_plus(key), self.quote(value).decode('ascii') )).encode('ascii')) mac.update(b'|' + result[-1]) return b'?'.join([ base64.b64encode(mac.digest()).strip(), b'&'.join(result) ]) @classmethod def unserialize(cls, string, secret_key): """Load the secure cookie from a serialized string. :param string: the cookie value to unserialize. :param secret_key: the secret key used to serialize the cookie. :return: a new :class:`SecureCookie`. """ if isinstance(string, text_type): string = string.encode('utf-8', 'replace') if isinstance(secret_key, text_type): secret_key = secret_key.encode('utf-8', 'replace') try: base64_hash, data = string.split(b'?', 1) except (ValueError, IndexError): items = () else: items = {} mac = hmac(secret_key, None, cls.hash_method) for item in data.split(b'&'): mac.update(b'|' + item) if not b'=' in item: items = None break key, value = item.split(b'=', 1) # try to make the key a string key = url_unquote_plus(key.decode('ascii')) try: key = to_native(key) except UnicodeError: pass items[key] = value # no parsing error and the mac looks okay, we can now # sercurely unpickle our cookie. try: client_hash = base64.b64decode(base64_hash) except TypeError: items = client_hash = None if items is not None and safe_str_cmp(client_hash, mac.digest()): try: for key, value in iteritems(items): items[key] = cls.unquote(value) except UnquoteError: items = () else: if '_expires' in items: if time() > items['_expires']: items = () else: del items['_expires'] else: items = () return cls(items, secret_key, False) @classmethod def load_cookie(cls, request, key='session', secret_key=None): """Loads a :class:`SecureCookie` from a cookie in request. If the cookie is not set, a new :class:`SecureCookie` instanced is returned. :param request: a request object that has a `cookies` attribute which is a dict of all cookie values. :param key: the name of the cookie. :param secret_key: the secret key used to unquote the cookie. Always provide the value even though it has no default! """ data = request.cookies.get(key) if not data: return cls(secret_key=secret_key) return cls.unserialize(data, secret_key) def save_cookie(self, response, key='session', expires=None, session_expires=None, max_age=None, path='/', domain=None, secure=None, httponly=False, force=False): """Saves the SecureCookie in a cookie on response object. All parameters that are not described here are forwarded directly to :meth:`~BaseResponse.set_cookie`. :param response: a response object that has a :meth:`~BaseResponse.set_cookie` method. :param key: the name of the cookie. :param session_expires: the expiration date of the secure cookie stored information. If this is not provided the cookie `expires` date is used instead. """ if force or self.should_save: data = self.serialize(session_expires or expires) response.set_cookie(key, data, expires=expires, max_age=max_age, path=path, domain=domain, secure=secure, httponly=httponly)
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 82, 624, 272, 10380, 14, 2828, 14, 7817, 5306, 272, 18294, 22935, 94, 339, 961, 859, 9031, 282, 5494, 626, 365, 440, 741, 13048, 687, 314, 1890, 272, 2952, 652, 9584, 282, 9040, 314, 1654, 5920, 367, 14, 221, 2047, 883, 675, 652, 465, 272, 2351, 8343, 340, 1006, 1265, 1172, 365, 282, 922, 1305, 503, 6020, 370, 2216, 272, 282, 10367, 315, 922, 14, 339, 14797, 315, 25169, 626, 314, 666, 365, 5139, 12701, 687, 314, 1890, 465, 282, 272, 3293, 5494, 365, 14, 221, 9738, 1265, 2793, 1133, 1172, 370, 3877, 436, 8976, 314, 272, 12184, 1265, 1172, 737, 314, 1654, 14, 339, 5679, 4503, 26, 339, 1306, 687, 10380, 14, 2828, 14, 7817, 5306, 492, 30894, 7810, 272, 1306, 671, 275, 30894, 7810, 6333, 1421, 582, 5685, 12, 298, 6185, 582, 334, 17, 12, 499, 12, 650, 16658, 298, 10957, 19446, 70, 531, 339, 19460, 316, 1901, 282, 1059, 880, 626, 1373, 883, 3877, 652, 315, 282, 5494, 26, 339, 1306, 574, 275, 671, 14, 3549, 342, 339, 3835, 5384, 687, 626, 1059, 4020, 26, 339, 1306, 671, 275, 30894, 7810, 14, 324, 3549, 8, 585, 12, 298, 10957, 19446, 70, 531, 272, 1306, 671, 905, 6185, 937, 272, 334, 17, 12, 499, 12, 650, 9, 339, 982, 17122, 26473, 314, 5494, 436, 314, 9040, 365, 6835, 314, 625, 3549, 272, 1083, 911, 2449, 18030, 436, 372, 282, 892, 2701, 658, 24117, 7810, 64, 909, 14, 339, 14797, 315, 25169, 626, 314, 1338, 911, 506, 8917, 315, 314, 5494, 880, 886, 440, 272, 3877, 666, 315, 282, 5494, 1265, 2793, 1133, 2934, 314, 922, 370, 1937, 14, 339, 13515, 27561, 272, 16248, 23476, 339, 982, 1265, 787, 1808, 314, 10380, 1056, 2251, 1265, 4293, 21494, 314, 272, 11153, 5494, 1901, 2195, 4223, 2839, 642, 447, 398, 687, 10380, 14, 1208, 492, 6328, 63, 1829, 267, 687, 10380, 14, 21148, 492, 3523, 2017, 267, 687, 10380, 14, 2828, 14, 7817, 5306, 492, 30894, 7810, 398, 327, 2793, 1133, 675, 642, 790, 1325, 282, 3365, 1373, 27, 1265, 4293, 2951, 675, 267, 327, 747, 14, 22776, 8, 1165, 9, 370, 664, 6020, 2196, 267, 5795, 11771, 63, 3078, 275, 1557, 10500, 60, 11110, 60, 1774, 24, 90, 60, 10183, 60, 1845, 16, 93, 20, 60, 88, 24, 66, 60, 10656, 7, 398, 1021, 4784, 8, 1563, 2017, 304, 953, 768, 5245, 63, 1829, 288, 347, 1890, 63, 1730, 8, 277, 304, 355, 666, 275, 291, 14, 7792, 14, 362, 360, 1730, 63, 576, 358, 355, 340, 440, 666, 26, 490, 372, 30894, 7810, 8, 4731, 63, 498, 29, 12961, 63, 3078, 9, 355, 372, 30894, 7810, 14, 324, 3549, 8, 576, 12, 5795, 11771, 63, 3078, 9, 398, 347, 4223, 8, 2314, 12, 1343, 63, 1310, 304, 288, 1056, 275, 4784, 8, 2314, 12, 1343, 63, 1310, 9, 953, 327, 664, 282, 1177, 909, 2348, 288, 1177, 275, 2263, 953, 340, 1056, 14, 1258, 63, 1730, 14, 5626, 63, 2117, 26, 355, 2351, 63, 576, 275, 1056, 14, 1258, 63, 1730, 14, 3549, 342, 355, 1177, 14, 409, 63, 5306, 360, 1730, 63, 576, 297, 2351, 63, 576, 12, 2511, 22768, 26960, 29, 549, 9, 288, 372, 1177, 8, 2314, 12, 1343, 63, 1310, 9, 339, 437, 6656, 3376, 13150, 883, 506, 22175, 1354, 701, 1808, 1033, 23999, 3102, 447, 398, 1021, 4784, 8, 1563, 2017, 304, 953, 768, 5245, 63, 1829, 288, 347, 1890, 63, 1730, 8, 277, 304, 355, 372, 30894, 7810, 14, 912, 63, 5306, 8, 277, 12, 7565, 63, 498, 29, 13665, 63, 12961, 9, 398, 347, 4223, 8, 2314, 12, 1343, 63, 1310, 304, 288, 1056, 275, 4784, 8, 2314, 12, 1343, 63, 1310, 9, 953, 327, 664, 282, 1177, 909, 2348, 288, 1177, 275, 2263, 953, 1056, 14, 1258, 63, 1730, 14, 2117, 63, 5306, 8, 1310, 9, 288, 372, 1177, 8, 2314, 12, 1343, 63, 1310, 9, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 5927, 199, 646, 1300, 772, 199, 504, 20330, 492, 892, 465, 20330, 199, 504, 900, 492, 900, 199, 504, 8337, 492, 7793, 17, 465, 485, 885, 63, 2227, 199, 199, 504, 10380, 423, 5819, 492, 10849, 12, 1318, 63, 466, 199, 504, 10380, 14, 3603, 492, 1166, 63, 3513, 63, 6666, 12, 1166, 63, 12240, 63, 6666, 199, 504, 10380, 423, 4672, 492, 485, 602, 63, 475, 63, 11864, 199, 504, 10380, 14, 2828, 14, 11676, 492, 12972, 3477, 23785, 2141, 199, 504, 10380, 14, 4416, 492, 5048, 63, 495, 63, 5730, 199, 504, 10380, 423, 5819, 492, 370, 63, 6106, 421, 199, 533, 1910, 3513, 547, 8, 1726, 304, 272, 408, 8405, 1919, 1202, 370, 4673, 9081, 641, 18593, 1041, 421, 199, 533, 30894, 7810, 8, 29188, 23785, 2141, 304, 272, 408, 18089, 282, 11153, 5494, 14, 221, 2047, 883, 5516, 642, 1021, 436, 5647, 272, 376, 13943, 4497, 1083, 14, 221, 710, 492, 8377, 365, 626, 314, 4497, 1083, 272, 365, 282, 805, 543, 282, 8545, 3217, 370, 314, 8337, 14, 221, 11105, 272, 3102, 787, 1678, 342, 436, 10017, 1252, 339, 5679, 4503, 26, 339, 1306, 671, 275, 30894, 7810, 6333, 1421, 582, 5685, 12, 298, 6185, 582, 334, 17, 12, 499, 12, 650, 16658, 298, 10957, 19446, 70, 531, 272, 1306, 671, 905, 1421, 937, 272, 5685, 272, 1306, 671, 905, 6185, 937, 272, 334, 17, 12, 499, 12, 650, 9, 272, 1306, 671, 905, 21244, 70, 482, 76, 937, 275, 6546, 272, 1306, 671, 14, 5626, 63, 2117, 272, 715, 339, 520, 635, 666, 26, 314, 2536, 666, 14, 221, 13083, 282, 1211, 12, 769, 402, 6346, 503, 658, 403, 2313, 272, 520, 635, 7565, 63, 498, 26, 314, 7565, 790, 14, 221, 982, 440, 663, 658, 403, 64, 503, 440, 2013, 2432, 652, 965, 370, 506, 663, 2544, 520, 5247, 1705, 3549, 64, 365, 2797, 14, 272, 520, 635, 892, 26, 710, 2536, 574, 402, 314, 658, 1222, 64, 3305, 14, 272, 408, 339, 6079, 710, 2631, 1083, 370 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 82, 624, 272, 10380, 14, 2828, 14, 7817, 5306, 272, 18294, 22935, 94, 339, 961, 859, 9031, 282, 5494, 626, 365, 440, 741, 13048, 687, 314, 1890, 272, 2952, 652, 9584, 282, 9040, 314, 1654, 5920, 367, 14, 221, 2047, 883, 675, 652, 465, 272, 2351, 8343, 340, 1006, 1265, 1172, 365, 282, 922, 1305, 503, 6020, 370, 2216, 272, 282, 10367, 315, 922, 14, 339, 14797, 315, 25169, 626, 314, 666, 365, 5139, 12701, 687, 314, 1890, 465, 282, 272, 3293, 5494, 365, 14, 221, 9738, 1265, 2793, 1133, 1172, 370, 3877, 436, 8976, 314, 272, 12184, 1265, 1172, 737, 314, 1654, 14, 339, 5679, 4503, 26, 339, 1306, 687, 10380, 14, 2828, 14, 7817, 5306, 492, 30894, 7810, 272, 1306, 671, 275, 30894, 7810, 6333, 1421, 582, 5685, 12, 298, 6185, 582, 334, 17, 12, 499, 12, 650, 16658, 298, 10957, 19446, 70, 531, 339, 19460, 316, 1901, 282, 1059, 880, 626, 1373, 883, 3877, 652, 315, 282, 5494, 26, 339, 1306, 574, 275, 671, 14, 3549, 342, 339, 3835, 5384, 687, 626, 1059, 4020, 26, 339, 1306, 671, 275, 30894, 7810, 14, 324, 3549, 8, 585, 12, 298, 10957, 19446, 70, 531, 272, 1306, 671, 905, 6185, 937, 272, 334, 17, 12, 499, 12, 650, 9, 339, 982, 17122, 26473, 314, 5494, 436, 314, 9040, 365, 6835, 314, 625, 3549, 272, 1083, 911, 2449, 18030, 436, 372, 282, 892, 2701, 658, 24117, 7810, 64, 909, 14, 339, 14797, 315, 25169, 626, 314, 1338, 911, 506, 8917, 315, 314, 5494, 880, 886, 440, 272, 3877, 666, 315, 282, 5494, 1265, 2793, 1133, 2934, 314, 922, 370, 1937, 14, 339, 13515, 27561, 272, 16248, 23476, 339, 982, 1265, 787, 1808, 314, 10380, 1056, 2251, 1265, 4293, 21494, 314, 272, 11153, 5494, 1901, 2195, 4223, 2839, 642, 447, 398, 687, 10380, 14, 1208, 492, 6328, 63, 1829, 267, 687, 10380, 14, 21148, 492, 3523, 2017, 267, 687, 10380, 14, 2828, 14, 7817, 5306, 492, 30894, 7810, 398, 327, 2793, 1133, 675, 642, 790, 1325, 282, 3365, 1373, 27, 1265, 4293, 2951, 675, 267, 327, 747, 14, 22776, 8, 1165, 9, 370, 664, 6020, 2196, 267, 5795, 11771, 63, 3078, 275, 1557, 10500, 60, 11110, 60, 1774, 24, 90, 60, 10183, 60, 1845, 16, 93, 20, 60, 88, 24, 66, 60, 10656, 7, 398, 1021, 4784, 8, 1563, 2017, 304, 953, 768, 5245, 63, 1829, 288, 347, 1890, 63, 1730, 8, 277, 304, 355, 666, 275, 291, 14, 7792, 14, 362, 360, 1730, 63, 576, 358, 355, 340, 440, 666, 26, 490, 372, 30894, 7810, 8, 4731, 63, 498, 29, 12961, 63, 3078, 9, 355, 372, 30894, 7810, 14, 324, 3549, 8, 576, 12, 5795, 11771, 63, 3078, 9, 398, 347, 4223, 8, 2314, 12, 1343, 63, 1310, 304, 288, 1056, 275, 4784, 8, 2314, 12, 1343, 63, 1310, 9, 953, 327, 664, 282, 1177, 909, 2348, 288, 1177, 275, 2263, 953, 340, 1056, 14, 1258, 63, 1730, 14, 5626, 63, 2117, 26, 355, 2351, 63, 576, 275, 1056, 14, 1258, 63, 1730, 14, 3549, 342, 355, 1177, 14, 409, 63, 5306, 360, 1730, 63, 576, 297, 2351, 63, 576, 12, 2511, 22768, 26960, 29, 549, 9, 288, 372, 1177, 8, 2314, 12, 1343, 63, 1310, 9, 339, 437, 6656, 3376, 13150, 883, 506, 22175, 1354, 701, 1808, 1033, 23999, 3102, 447, 398, 1021, 4784, 8, 1563, 2017, 304, 953, 768, 5245, 63, 1829, 288, 347, 1890, 63, 1730, 8, 277, 304, 355, 372, 30894, 7810, 14, 912, 63, 5306, 8, 277, 12, 7565, 63, 498, 29, 13665, 63, 12961, 9, 398, 347, 4223, 8, 2314, 12, 1343, 63, 1310, 304, 288, 1056, 275, 4784, 8, 2314, 12, 1343, 63, 1310, 9, 953, 327, 664, 282, 1177, 909, 2348, 288, 1177, 275, 2263, 953, 1056, 14, 1258, 63, 1730, 14, 2117, 63, 5306, 8, 1310, 9, 288, 372, 1177, 8, 2314, 12, 1343, 63, 1310, 9, 339, 520, 7307, 26, 334, 67, 9, 6927, 701, 314, 22798, 11682, 12, 1937, 10610, 367, 1655, 2436, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 5927, 199, 646, 1300, 772, 199, 504, 20330, 492, 892, 465, 20330, 199, 504, 900, 492, 900, 199, 504, 8337, 492, 7793, 17, 465, 485, 885, 63, 2227, 199, 199, 504, 10380, 423, 5819, 492, 10849, 12, 1318, 63, 466, 199, 504, 10380, 14, 3603, 492, 1166, 63, 3513, 63, 6666, 12, 1166, 63, 12240, 63, 6666, 199, 504, 10380, 423, 4672, 492, 485, 602, 63, 475, 63, 11864, 199, 504, 10380, 14, 2828, 14, 11676, 492, 12972, 3477, 23785, 2141, 199, 504, 10380, 14, 4416, 492, 5048, 63, 495, 63, 5730, 199, 504, 10380, 423, 5819, 492, 370, 63, 6106, 421, 199, 533, 1910, 3513, 547, 8, 1726, 304, 272, 408, 8405, 1919, 1202, 370, 4673, 9081, 641, 18593, 1041, 421, 199, 533, 30894, 7810, 8, 29188, 23785, 2141, 304, 272, 408, 18089, 282, 11153, 5494, 14, 221, 2047, 883, 5516, 642, 1021, 436, 5647, 272, 376, 13943, 4497, 1083, 14, 221, 710, 492, 8377, 365, 626, 314, 4497, 1083, 272, 365, 282, 805, 543, 282, 8545, 3217, 370, 314, 8337, 14, 221, 11105, 272, 3102, 787, 1678, 342, 436, 10017, 1252, 339, 5679, 4503, 26, 339, 1306, 671, 275, 30894, 7810, 6333, 1421, 582, 5685, 12, 298, 6185, 582, 334, 17, 12, 499, 12, 650, 16658, 298, 10957, 19446, 70, 531, 272, 1306, 671, 905, 1421, 937, 272, 5685, 272, 1306, 671, 905, 6185, 937, 272, 334, 17, 12, 499, 12, 650, 9, 272, 1306, 671, 905, 21244, 70, 482, 76, 937, 275, 6546, 272, 1306, 671, 14, 5626, 63, 2117, 272, 715, 339, 520, 635, 666, 26, 314, 2536, 666, 14, 221, 13083, 282, 1211, 12, 769, 402, 6346, 503, 658, 403, 2313, 272, 520, 635, 7565, 63, 498, 26, 314, 7565, 790, 14, 221, 982, 440, 663, 658, 403, 64, 503, 440, 2013, 2432, 652, 965, 370, 506, 663, 2544, 520, 5247, 1705, 3549, 64, 365, 2797, 14, 272, 520, 635, 892, 26, 710, 2536, 574, 402, 314, 658, 1222, 64, 3305, 14, 272, 408, 339, 6079, 710, 2631, 1083, 370, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lunafeng/django
tests/template_tests/syntax_tests/test_list_index.py
521
2694
from django.test import SimpleTestCase from ..utils import setup class ListIndexTests(SimpleTestCase): @setup({'list-index01': '{{ var.1 }}'}) def test_list_index01(self): """ List-index syntax allows a template to access a certain item of a subscriptable object. """ output = self.engine.render_to_string('list-index01', {'var': ['first item', 'second item']}) self.assertEqual(output, 'second item') @setup({'list-index02': '{{ var.5 }}'}) def test_list_index02(self): """ Fail silently when the list index is out of range. """ output = self.engine.render_to_string('list-index02', {'var': ['first item', 'second item']}) if self.engine.string_if_invalid: self.assertEqual(output, 'INVALID') else: self.assertEqual(output, '') @setup({'list-index03': '{{ var.1 }}'}) def test_list_index03(self): """ Fail silently when the list index is out of range. """ output = self.engine.render_to_string('list-index03', {'var': None}) if self.engine.string_if_invalid: self.assertEqual(output, 'INVALID') else: self.assertEqual(output, '') @setup({'list-index04': '{{ var.1 }}'}) def test_list_index04(self): """ Fail silently when variable is a dict without the specified key. """ output = self.engine.render_to_string('list-index04', {'var': {}}) if self.engine.string_if_invalid: self.assertEqual(output, 'INVALID') else: self.assertEqual(output, '') @setup({'list-index05': '{{ var.1 }}'}) def test_list_index05(self): """ Dictionary lookup wins out when dict's key is a string. """ output = self.engine.render_to_string('list-index05', {'var': {'1': "hello"}}) self.assertEqual(output, 'hello') @setup({'list-index06': '{{ var.1 }}'}) def test_list_index06(self): """ But list-index lookup wins out when dict's key is an int, which behind the scenes is really a dictionary lookup (for a dict) after converting the key to an int. """ output = self.engine.render_to_string('list-index06', {"var": {1: "hello"}}) self.assertEqual(output, 'hello') @setup({'list-index07': '{{ var.1 }}'}) def test_list_index07(self): """ Dictionary lookup wins out when there is a string and int version of the key. """ output = self.engine.render_to_string('list-index07', {"var": {'1': "hello", 1: "world"}}) self.assertEqual(output, 'hello')
bsd-3-clause
[ 504, 1639, 14, 396, 492, 24424, 199, 199, 504, 2508, 1208, 492, 3272, 421, 199, 533, 3820, 2681, 2925, 8, 17968, 304, 339, 768, 2758, 3252, 513, 13, 1080, 614, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 614, 8, 277, 304, 267, 408, 267, 3820, 13, 1080, 6302, 6127, 282, 1978, 370, 2879, 282, 9842, 1242, 402, 282, 267, 1007, 1579, 461, 909, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 614, 297, 791, 1391, 356, 788, 2246, 1242, 297, 283, 4375, 1242, 13678, 267, 291, 14, 629, 8, 1199, 12, 283, 4375, 1242, 358, 339, 768, 2758, 3252, 513, 13, 1080, 996, 356, 11400, 2729, 14, 21, 29281, 272, 347, 511, 63, 513, 63, 1080, 996, 8, 277, 304, 267, 408, 267, 12176, 18030, 1380, 314, 769, 1478, 365, 734, 402, 1425, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 996, 297, 791, 1391, 356, 788, 2246, 1242, 297, 283, 4375, 1242, 13678, 267, 340, 291, 14, 3908, 14, 875, 63, 692, 63, 3197, 26, 288, 291, 14, 629, 8, 1199, 12, 283, 9692, 358, 267, 587, 26, 288, 291, 14, 629, 8, 1199, 12, 4074, 339, 768, 2758, 3252, 513, 13, 1080, 1644, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 1644, 8, 277, 304, 267, 408, 267, 12176, 18030, 1380, 314, 769, 1478, 365, 734, 402, 1425, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 1644, 297, 791, 1391, 356, 488, 1552, 267, 340, 291, 14, 3908, 14, 875, 63, 692, 63, 3197, 26, 288, 291, 14, 629, 8, 1199, 12, 283, 9692, 358, 267, 587, 26, 288, 291, 14, 629, 8, 1199, 12, 4074, 339, 768, 2758, 3252, 513, 13, 1080, 966, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 966, 8, 277, 304, 267, 408, 267, 12176, 18030, 1380, 1750, 365, 282, 1211, 1928, 314, 2013, 790, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 966, 297, 791, 1391, 356, 1052, 1552, 267, 340, 291, 14, 3908, 14, 875, 63, 692, 63, 3197, 26, 288, 291, 14, 629, 8, 1199, 12, 283, 9692, 358, 267, 587, 26, 288, 291, 14, 629, 8, 1199, 12, 4074, 339, 768, 2758, 3252, 513, 13, 1080, 1717, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 1717, 8, 277, 304, 267, 408, 267, 11932, 4237, 29431, 734, 1380, 1211, 1159, 790, 365, 282, 1059, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 1717, 297, 791, 1391, 356, 791, 17, 356, 298, 5006, 3570, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 5006, 358, 339, 768, 2758, 3252, 513, 13, 1080, 1690, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 1690, 8, 277, 304, 267, 408, 267, 11017, 769, 13, 1080, 4237, 29431, 734, 1380, 1211, 1159, 790, 365, 376, 1109, 12, 1314, 267, 22172, 314, 8482, 397, 365, 7710, 282, 2600, 4237, 334, 509, 282, 1211, 9, 267, 2410, 13806, 314, 790, 370, 376, 1109, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 1690, 297, 2420, 1391, 582, 469, 17, 26, 298, 5006, 3570, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 5006, 358, 339, 768, 2758, 3252, 513, 13, 1080, 1780, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 1780, 8, 277, 304, 267, 408, 267, 11932, 4237, 29431, 734, 1380, 2337, 365, 282, 1059, 436, 1109, 1015, 267, 402, 314, 790, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 1780, 297, 2420, 1391, 582, 791, 17, 356, 298, 5006, 401, 413, 26, 298, 7617, 3570, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 5006, 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 ]
[ 1639, 14, 396, 492, 24424, 199, 199, 504, 2508, 1208, 492, 3272, 421, 199, 533, 3820, 2681, 2925, 8, 17968, 304, 339, 768, 2758, 3252, 513, 13, 1080, 614, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 614, 8, 277, 304, 267, 408, 267, 3820, 13, 1080, 6302, 6127, 282, 1978, 370, 2879, 282, 9842, 1242, 402, 282, 267, 1007, 1579, 461, 909, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 614, 297, 791, 1391, 356, 788, 2246, 1242, 297, 283, 4375, 1242, 13678, 267, 291, 14, 629, 8, 1199, 12, 283, 4375, 1242, 358, 339, 768, 2758, 3252, 513, 13, 1080, 996, 356, 11400, 2729, 14, 21, 29281, 272, 347, 511, 63, 513, 63, 1080, 996, 8, 277, 304, 267, 408, 267, 12176, 18030, 1380, 314, 769, 1478, 365, 734, 402, 1425, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 996, 297, 791, 1391, 356, 788, 2246, 1242, 297, 283, 4375, 1242, 13678, 267, 340, 291, 14, 3908, 14, 875, 63, 692, 63, 3197, 26, 288, 291, 14, 629, 8, 1199, 12, 283, 9692, 358, 267, 587, 26, 288, 291, 14, 629, 8, 1199, 12, 4074, 339, 768, 2758, 3252, 513, 13, 1080, 1644, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 1644, 8, 277, 304, 267, 408, 267, 12176, 18030, 1380, 314, 769, 1478, 365, 734, 402, 1425, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 1644, 297, 791, 1391, 356, 488, 1552, 267, 340, 291, 14, 3908, 14, 875, 63, 692, 63, 3197, 26, 288, 291, 14, 629, 8, 1199, 12, 283, 9692, 358, 267, 587, 26, 288, 291, 14, 629, 8, 1199, 12, 4074, 339, 768, 2758, 3252, 513, 13, 1080, 966, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 966, 8, 277, 304, 267, 408, 267, 12176, 18030, 1380, 1750, 365, 282, 1211, 1928, 314, 2013, 790, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 966, 297, 791, 1391, 356, 1052, 1552, 267, 340, 291, 14, 3908, 14, 875, 63, 692, 63, 3197, 26, 288, 291, 14, 629, 8, 1199, 12, 283, 9692, 358, 267, 587, 26, 288, 291, 14, 629, 8, 1199, 12, 4074, 339, 768, 2758, 3252, 513, 13, 1080, 1717, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 1717, 8, 277, 304, 267, 408, 267, 11932, 4237, 29431, 734, 1380, 1211, 1159, 790, 365, 282, 1059, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 1717, 297, 791, 1391, 356, 791, 17, 356, 298, 5006, 3570, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 5006, 358, 339, 768, 2758, 3252, 513, 13, 1080, 1690, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 1690, 8, 277, 304, 267, 408, 267, 11017, 769, 13, 1080, 4237, 29431, 734, 1380, 1211, 1159, 790, 365, 376, 1109, 12, 1314, 267, 22172, 314, 8482, 397, 365, 7710, 282, 2600, 4237, 334, 509, 282, 1211, 9, 267, 2410, 13806, 314, 790, 370, 376, 1109, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 1690, 297, 2420, 1391, 582, 469, 17, 26, 298, 5006, 3570, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 5006, 358, 339, 768, 2758, 3252, 513, 13, 1080, 1780, 356, 11400, 2729, 14, 17, 29281, 272, 347, 511, 63, 513, 63, 1080, 1780, 8, 277, 304, 267, 408, 267, 11932, 4237, 29431, 734, 1380, 2337, 365, 282, 1059, 436, 1109, 1015, 267, 402, 314, 790, 14, 267, 408, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 513, 13, 1080, 1780, 297, 2420, 1391, 582, 791, 17, 356, 298, 5006, 401, 413, 26, 298, 7617, 3570, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 5006, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kalahbrown/HueBigSQL
desktop/core/ext-py/tablib-0.10.0/tablib/packages/xlrd3/biffh.py
54
17755
# Support module for the xlrd3 package. # # Portions copyright (c) 2005-2008 Stephen John Machin, Lingfo Pty Ltd # This module is part of the xlrd package, which is released under a # BSD-style licence. # # 2010-12-08 mozman refactoring for python 3 # 2008-02-10 SJM BIFF2 BLANK record # 2008-02-08 SJM Preparation for Excel 2.0 support # 2008-02-02 SJM Added suffixes (_B2, _B2_ONLY, etc) on record names for # biff_dump & biff_count # 2007-12-04 SJM Added support for Excel 2.x (BIFF2) files. # 2007-09-08 SJM Avoid crash when zero-length Unicode string missing options byte. # 2007-04-22 SJM Remove experimental "trimming" facility. import sys from struct import unpack encoding_from_codepage = { 1200 : 'utf_16_le', 10000: 'mac_roman', 10006: 'mac_greek', # guess 10007: 'mac_cyrillic', # guess 10029: 'mac_latin2', # guess 10079: 'mac_iceland', # guess 10081: 'mac_turkish', # guess 32768: 'mac_roman', 32769: 'cp1252', } # some more guessing, for Indic scripts # codepage 57000 range: # 2 Devanagari [0] # 3 Bengali [1] # 4 Tamil [5] # 5 Telegu [6] # 6 Assamese [1] c.f. Bengali # 7 Oriya [4] # 8 Kannada [7] # 9 Malayalam [8] # 10 Gujarati [3] # 11 Gurmukhi [2] FUN = 0 # unknown FDT = 1 # date FNU = 2 # number FGE = 3 # general FTX = 4 # text DATEFORMAT = FDT NUMBERFORMAT = FNU XL_CELL_EMPTY = 0 XL_CELL_TEXT = 1 XL_CELL_NUMBER = 2 XL_CELL_DATE = 3 XL_CELL_BOOLEAN = 4 XL_CELL_ERROR = 5 XL_CELL_BLANK = 6 # for use in debugging, gathering stats, etc biff_text_from_num = { 0: "(not BIFF)", 20: "2.0", 21: "2.1", 30: "3", 40: "4S", 45: "4W", 50: "5", 70: "7", 80: "8", 85: "8X", } # This dictionary can be used to produce a text version of the internal codes # that Excel uses for error cells. Here are its contents: error_text_from_code = { 0x00: '#NULL!', # Intersection of two cell ranges is empty 0x07: '#DIV/0!', # Division by zero 0x0F: '#VALUE!', # Wrong type of operand 0x17: '#REF!', # Illegal or deleted cell reference 0x1D: '#NAME?', # Wrong function or range name 0x24: '#NUM!', # Value range overflow 0x2A: '#N/A!', # Argument or function not available } BIFF_FIRST_UNICODE = 80 XL_WORKBOOK_GLOBALS = WBKBLOBAL = 0x5 XL_WORKBOOK_GLOBALS_4W = 0x100 XL_WORKSHEET = WRKSHEET = 0x10 XL_BOUNDSHEET_WORKSHEET = 0x00 XL_BOUNDSHEET_CHART = 0x02 XL_BOUNDSHEET_VB_MODULE = 0x06 # XL_RK2 = 0x7e XL_ARRAY = 0x0221 XL_ARRAY2 = 0x0021 XL_BLANK = 0x0201 XL_BLANK_B2 = 0x01 XL_BOF = 0x809 XL_BOOLERR = 0x205 XL_BOOLERR_B2 = 0x5 XL_BOUNDSHEET = 0x85 XL_BUILTINFMTCOUNT = 0x56 XL_CF = 0x01B1 XL_CODEPAGE = 0x42 XL_COLINFO = 0x7D XL_COLUMNDEFAULT = 0x20 # BIFF2 only XL_COLWIDTH = 0x24 # BIFF2 only XL_CONDFMT = 0x01B0 XL_CONTINUE = 0x3c XL_COUNTRY = 0x8C XL_DATEMODE = 0x22 XL_DEFAULTROWHEIGHT = 0x0225 XL_DEFCOLWIDTH = 0x55 XL_DIMENSION = 0x200 XL_DIMENSION2 = 0x0 XL_EFONT = 0x45 XL_EOF = 0x0a XL_EXTERNNAME = 0x23 XL_EXTERNSHEET = 0x17 XL_EXTSST = 0xff XL_FEAT11 = 0x872 XL_FILEPASS = 0x2f XL_FONT = 0x31 XL_FONT_B3B4 = 0x231 XL_FORMAT = 0x41e XL_FORMAT2 = 0x1E # BIFF2, BIFF3 XL_FORMULA = 0x6 XL_FORMULA3 = 0x206 XL_FORMULA4 = 0x406 XL_GCW = 0xab XL_INDEX = 0x20b XL_INTEGER = 0x2 # BIFF2 only XL_IXFE = 0x44 # BIFF2 only XL_LABEL = 0x204 XL_LABEL_B2 = 0x04 XL_LABELRANGES = 0x15f XL_LABELSST = 0xfd XL_MERGEDCELLS = 0xE5 XL_MSO_DRAWING = 0x00EC XL_MSO_DRAWING_GROUP = 0x00EB XL_MSO_DRAWING_SELECTION = 0x00ED XL_MULRK = 0xbd XL_MULBLANK = 0xbe XL_NAME = 0x18 XL_NOTE = 0x1c XL_NUMBER = 0x203 XL_NUMBER_B2 = 0x3 XL_OBJ = 0x5D XL_PALETTE = 0x92 XL_RK = 0x27e XL_ROW = 0x208 XL_ROW_B2 = 0x08 XL_RSTRING = 0xd6 XL_SHEETHDR = 0x8F # BIFF4W only XL_SHEETSOFFSET = 0x8E # BIFF4W only XL_SHRFMLA = 0x04bc XL_SST = 0xfc XL_STANDARDWIDTH = 0x99 XL_STRING = 0x207 XL_STRING_B2 = 0x7 XL_STYLE = 0x293 XL_SUPBOOK = 0x1AE XL_TABLEOP = 0x236 XL_TABLEOP2 = 0x37 XL_TABLEOP_B2 = 0x36 XL_TXO = 0x1b6 XL_UNCALCED = 0x5e XL_UNKNOWN = 0xffff XL_WINDOW2 = 0x023E XL_WRITEACCESS = 0x5C XL_XF = 0xe0 XL_XF2 = 0x0043 # BIFF2 version of XF record XL_XF3 = 0x0243 # BIFF3 version of XF record XL_XF4 = 0x0443 # BIFF4 version of XF record boflen = { 0x0809: 8, 0x0409: 6, 0x0209: 6, 0x0009: 4, } bofcodes = (0x0809, 0x0409, 0x0209, 0x0009) XL_FORMULA_OPCODES = (0x0006, 0x0406, 0x0206) _cell_opcode_list = ( XL_BOOLERR, XL_FORMULA, XL_FORMULA3, XL_FORMULA4, XL_LABEL, XL_LABELSST, XL_MULRK, XL_NUMBER, XL_RK, XL_RSTRING, ) biff_rec_name_dict = { 0x0000: 'DIMENSIONS_B2', 0x0001: 'BLANK_B2', 0x0002: 'INTEGER_B2_ONLY', 0x0003: 'NUMBER_B2', 0x0004: 'LABEL_B2', 0x0005: 'BOOLERR_B2', 0x0006: 'FORMULA', 0x0007: 'STRING_B2', 0x0008: 'ROW_B2', 0x0009: 'BOF_B2', 0x000A: 'EOF', 0x000B: 'INDEX_B2_ONLY', 0x000C: 'CALCCOUNT', 0x000D: 'CALCMODE', 0x000E: 'PRECISION', 0x000F: 'REFMODE', 0x0010: 'DELTA', 0x0011: 'ITERATION', 0x0012: 'PROTECT', 0x0013: 'PASSWORD', 0x0014: 'HEADER', 0x0015: 'FOOTER', 0x0016: 'EXTERNCOUNT', 0x0017: 'EXTERNSHEET', 0x0018: 'NAME_B2,5+', 0x0019: 'WINDOWPROTECT', 0x001A: 'VERTICALPAGEBREAKS', 0x001B: 'HORIZONTALPAGEBREAKS', 0x001C: 'NOTE', 0x001D: 'SELECTION', 0x001E: 'FORMAT_B2-3', 0x001F: 'BUILTINFMTCOUNT_B2', 0x0020: 'COLUMNDEFAULT_B2_ONLY', 0x0021: 'ARRAY_B2_ONLY', 0x0022: 'DATEMODE', 0x0023: 'EXTERNNAME', 0x0024: 'COLWIDTH_B2_ONLY', 0x0025: 'DEFAULTROWHEIGHT_B2_ONLY', 0x0026: 'LEFTMARGIN', 0x0027: 'RIGHTMARGIN', 0x0028: 'TOPMARGIN', 0x0029: 'BOTTOMMARGIN', 0x002A: 'PRINTHEADERS', 0x002B: 'PRINTGRIDLINES', 0x002F: 'FILEPASS', 0x0031: 'FONT', 0x0032: 'FONT2_B2_ONLY', 0x0036: 'TABLEOP_B2', 0x0037: 'TABLEOP2_B2', 0x003C: 'CONTINUE', 0x003D: 'WINDOW1', 0x003E: 'WINDOW2_B2', 0x0040: 'BACKUP', 0x0041: 'PANE', 0x0042: 'CODEPAGE', 0x0043: 'XF_B2', 0x0044: 'IXFE_B2_ONLY', 0x0045: 'EFONT_B2_ONLY', 0x004D: 'PLS', 0x0051: 'DCONREF', 0x0055: 'DEFCOLWIDTH', 0x0056: 'BUILTINFMTCOUNT_B3-4', 0x0059: 'XCT', 0x005A: 'CRN', 0x005B: 'FILESHARING', 0x005C: 'WRITEACCESS', 0x005D: 'OBJECT', 0x005E: 'UNCALCED', 0x005F: 'SAVERECALC', 0x0063: 'OBJECTPROTECT', 0x007D: 'COLINFO', 0x007E: 'RK2_mythical_?', 0x0080: 'GUTS', 0x0081: 'WSBOOL', 0x0082: 'GRIDSET', 0x0083: 'HCENTER', 0x0084: 'VCENTER', 0x0085: 'BOUNDSHEET', 0x0086: 'WRITEPROT', 0x008C: 'COUNTRY', 0x008D: 'HIDEOBJ', 0x008E: 'SHEETSOFFSET', 0x008F: 'SHEETHDR', 0x0090: 'SORT', 0x0092: 'PALETTE', 0x0099: 'STANDARDWIDTH', 0x009B: 'FILTERMODE', 0x009C: 'FNGROUPCOUNT', 0x009D: 'AUTOFILTERINFO', 0x009E: 'AUTOFILTER', 0x00A0: 'SCL', 0x00A1: 'SETUP', 0x00AB: 'GCW', 0x00BD: 'MULRK', 0x00BE: 'MULBLANK', 0x00C1: 'MMS', 0x00D6: 'RSTRING', 0x00D7: 'DBCELL', 0x00DA: 'BOOKBOOL', 0x00DD: 'SCENPROTECT', 0x00E0: 'XF', 0x00E1: 'INTERFACEHDR', 0x00E2: 'INTERFACEEND', 0x00E5: 'MERGEDCELLS', 0x00E9: 'BITMAP', 0x00EB: 'MSO_DRAWING_GROUP', 0x00EC: 'MSO_DRAWING', 0x00ED: 'MSO_DRAWING_SELECTION', 0x00EF: 'PHONETIC', 0x00FC: 'SST', 0x00FD: 'LABELSST', 0x00FF: 'EXTSST', 0x013D: 'TABID', 0x015F: 'LABELRANGES', 0x0160: 'USESELFS', 0x0161: 'DSF', 0x01AE: 'SUPBOOK', 0x01AF: 'PROTECTIONREV4', 0x01B0: 'CONDFMT', 0x01B1: 'CF', 0x01B2: 'DVAL', 0x01B6: 'TXO', 0x01B7: 'REFRESHALL', 0x01B8: 'HLINK', 0x01BC: 'PASSWORDREV4', 0x01BE: 'DV', 0x01C0: 'XL9FILE', 0x01C1: 'RECALCID', 0x0200: 'DIMENSIONS', 0x0201: 'BLANK', 0x0203: 'NUMBER', 0x0204: 'LABEL', 0x0205: 'BOOLERR', 0x0206: 'FORMULA_B3', 0x0207: 'STRING', 0x0208: 'ROW', 0x0209: 'BOF', 0x020B: 'INDEX_B3+', 0x0218: 'NAME', 0x0221: 'ARRAY', 0x0223: 'EXTERNNAME_B3-4', 0x0225: 'DEFAULTROWHEIGHT', 0x0231: 'FONT_B3B4', 0x0236: 'TABLEOP', 0x023E: 'WINDOW2', 0x0243: 'XF_B3', 0x027E: 'RK', 0x0293: 'STYLE', 0x0406: 'FORMULA_B4', 0x0409: 'BOF', 0x041E: 'FORMAT', 0x0443: 'XF_B4', 0x04BC: 'SHRFMLA', 0x0800: 'QUICKTIP', 0x0809: 'BOF', 0x0862: 'SHEETLAYOUT', 0x0867: 'SHEETPROTECTION', 0x0868: 'RANGEPROTECTION', } class XLRDError(Exception): pass class BaseObject: """ Parent of almost all other classes in the package. Defines a common 'dump' method for debugging. """ _repr_these = [] def dump(self, f=None, header=None, footer=None, indent=0): """ :param f: open file object, to which the dump is written :param header: text to write before the dump :param footer: text to write after the dump :param indent: number of leading spaces (for recursive calls) """ if f is None: f = sys.stderr pad = " " * indent if header is not None: print(header, file=f) for attr, value in sorted(self.__dict__.items()): if getattr(value, 'dump', None) and attr != 'book': value.dump(f, header="%s%s (%s object):" % (pad, attr, value.__class__.__name__), indent=indent+4) elif attr not in self._repr_these and \ (isinstance(value, list) or isinstance(value, dict)): print("%s%s: %s, len = %d" % (pad, attr, type(value), len(value)), file=f) else: print("%s%s: %r" % (pad, attr, value), file=f) if footer is not None: print(footer, file=f) def fprintf(f, fmt, *vargs): print(fmt.rstrip('\n') % vargs, file=f) def upkbits(tgt_obj, src, manifest, local_setattr=setattr): for n, mask, attr in manifest: local_setattr(tgt_obj, attr, (src & mask) >> n) def upkbitsL(tgt_obj, src, manifest, local_setattr=setattr, local_int=int): for n, mask, attr in manifest: local_setattr(tgt_obj, attr, local_int((src & mask) >> n)) def unpack_string(data, pos, encoding, lenlen=1): nchars = unpack('<' + 'BH'[lenlen-1], data[pos:pos+lenlen])[0] pos += lenlen return str(data[pos:pos+nchars], encoding) def unpack_string_update_pos(data, pos, encoding, lenlen=1, known_len=None): if known_len is not None: # On a NAME record, the length byte is detached from the front of the string. nchars = known_len else: nchars = unpack('<' + 'BH'[lenlen-1], data[pos:pos+lenlen])[0] pos += lenlen newpos = pos + nchars return (str(data[pos:newpos], encoding), newpos) def unpack_unicode(data, pos, lenlen=2): """ Return unicode_strg """ nchars = unpack('<' + 'BH'[lenlen-1], data[pos:pos+lenlen])[0] if not nchars: # Ambiguous whether 0-length string should have an "options" byte. # Avoid crash if missing. return "" pos += lenlen options = data[pos] pos += 1 if options & 0x08: # richtext pos += 2 if options & 0x04: # phonetic pos += 4 if options & 0x01: # Uncompressed UTF-16-LE rawstrg = data[pos:pos+2*nchars] strg = str(rawstrg, 'utf_16_le') else: # Note: this is COMPRESSED (not ASCII!) encoding!!! # Merely returning the raw bytes would work OK 99.99% of the time # if the local codepage was cp1252 -- however this would rapidly go pear-shaped # for other codepages so we grit our Anglocentric teeth and return Unicode :-) strg = str(data[pos:pos+nchars], "latin_1") return strg def unpack_unicode_update_pos(data, pos, lenlen=2, known_len=None): """ Return (unicode_strg, updated value of pos) """ if known_len is not None: # On a NAME record, the length byte is detached from the front of the string. nchars = known_len else: nchars = unpack('<' + 'BH'[lenlen-1], data[pos:pos+lenlen])[0] pos += lenlen if not nchars and not data[pos:]: # Zero-length string with no options byte return ("", pos) options = data[pos] pos += 1 phonetic = options & 0x04 richtext = options & 0x08 if richtext: rt = unpack('<H', data[pos:pos+2])[0] pos += 2 if phonetic: sz = unpack('<i', data[pos:pos+4])[0] pos += 4 if options & 0x01: # Uncompressed UTF-16-LE strg = str(data[pos:pos+2*nchars], 'utf_16_le') pos += 2*nchars else: # Note: this is COMPRESSED (not ASCII!) encoding!!! strg = str(data[pos:pos+nchars], "latin_1") pos += nchars if richtext: pos += 4 * rt if phonetic: pos += sz return (strg, pos) def unpack_cell_range_address_list_update_pos( output_list, data, pos, biff_version, addr_size=6): # output_list is updated in situ if biff_version < 80: assert addr_size == 6 else: assert addr_size in (6, 8) n, = unpack("<H", data[pos:pos+2]) pos += 2 if n: fmt = "<HHBB" if addr_size == 6 else "<HHHH" for _unused in range(n): ra, rb, ca, cb = unpack(fmt, data[pos:pos+addr_size]) output_list.append((ra, rb+1, ca, cb+1)) pos += addr_size return pos def hex_char_dump(strg, ofs, dlen, base=0, fout=sys.stdout, unnumbered=False): endpos = min(ofs + dlen, len(strg)) pos = ofs numbered = not unnumbered num_prefix = '' while pos < endpos: endsub = min(pos + 16, endpos) substrg = strg[pos:endsub] lensub = endsub - pos if lensub <= 0 or lensub != len(substrg): fprintf( sys.stdout, '??? hex_char_dump: ofs=%d dlen=%d base=%d -> endpos=%d pos=%d endsub=%d substrg=%r\n', ofs, dlen, base, endpos, pos, endsub, substrg) break hexd = ''.join(["%02x " % c for c in substrg]) chard = '' for c in substrg: if c == ord('\0'): c = '~' elif not (' ' <= chr(c) <= '~'): c = '?' if isinstance(c, int): c = chr(c) chard += c if numbered: num_prefix = "%5d: " % (base+pos-ofs) fprintf(fout, "%s %-48s %s\n", num_prefix, hexd, chard) pos = endsub def biff_dump(mem, stream_offset, stream_len, base=0, fout=sys.stdout, unnumbered=False): pos = stream_offset stream_end = stream_offset + stream_len adj = base - stream_offset dummies = 0 numbered = not unnumbered num_prefix = '' while stream_end - pos >= 4: rc, length = unpack('<HH', mem[pos:pos+4]) if rc == 0 and length == 0: if mem[pos:] == '\0' * (stream_end - pos): dummies = stream_end - pos savpos = pos pos = stream_end break if dummies: dummies += 4 else: savpos = pos dummies = 4 pos += 4 else: if dummies: if numbered: num_prefix = "%5d: " % (adj + savpos) fprintf(fout, "%s---- %d zero bytes skipped ----\n", num_prefix, dummies) dummies = 0 recname = biff_rec_name_dict.get(rc, '<UNKNOWN>') if numbered: num_prefix = "%5d: " % (adj + pos) fprintf(fout, "%s%04x %s len = %04x (%d)\n", num_prefix, rc, recname, length, length) pos += 4 hex_char_dump(mem, pos, length, adj+pos, fout, unnumbered) pos += length if dummies: if numbered: num_prefix = "%5d: " % (adj + savpos) fprintf(fout, "%s---- %d zero bytes skipped ----\n", num_prefix, dummies) if pos < stream_end: if numbered: num_prefix = "%5d: " % (adj + pos) fprintf(fout, "%s---- Misc bytes at end ----\n", num_prefix) hex_char_dump(mem, pos, stream_end-pos, adj + pos, fout, unnumbered) elif pos > stream_end: fprintf(fout, "Last dumped record has length (%d) that is too large\n", length) def biff_count_records(mem, stream_offset, stream_len, fout=sys.stdout): pos = stream_offset stream_end = stream_offset + stream_len tally = {} while stream_end - pos >= 4: rc, length = unpack('<HH', mem[pos:pos+4]) if rc == 0 and length == 0: if mem[pos:] == '\0' * (stream_end - pos): break recname = "<Dummy (zero)>" else: recname = biff_rec_name_dict.get(rc, None) if recname is None: recname = "Unknown_0x%04X" % rc if recname in tally: tally[recname] += 1 else: tally[recname] = 1 pos += length + 4 for recname, count in sorted(tally.items()): fprintf(fout, "%8d %s", count, recname)
apache-2.0
[ 3, 12502, 859, 367, 314, 25077, 6883, 19, 2559, 14, 202, 199, 3, 202, 199, 3, 20825, 4248, 334, 67, 9, 11811, 13, 9300, 17854, 17579, 17815, 30611, 262, 12, 491, 316, 545, 510, 369, 12126, 202, 199, 3, 961, 859, 365, 1777, 402, 314, 25077, 6883, 2559, 12, 1314, 365, 14286, 1334, 282, 202, 199, 3, 6289, 13, 2487, 23854, 4894, 14, 202, 199, 3, 202, 199, 3, 7129, 13, 713, 13, 2036, 1303, 90, 1237, 24200, 316, 367, 2366, 650, 202, 199, 3, 9079, 13, 996, 13, 709, 428, 42, 45, 699, 24150, 18, 699, 10825, 43, 2777, 202, 199, 3, 9079, 13, 996, 13, 2036, 428, 42, 45, 5543, 462, 425, 367, 27832, 499, 14, 16, 2291, 202, 199, 3, 9079, 13, 996, 13, 996, 428, 42, 45, 16230, 19475, 6110, 34, 18, 12, 485, 34, 18, 63, 10452, 12, 5423, 9, 641, 2777, 1561, 367, 202, 199, 3, 4483, 12111, 556, 63, 2724, 1253, 12111, 556, 63, 835, 202, 199, 3, 10219, 13, 713, 13, 966, 428, 42, 45, 16230, 2291, 367, 27832, 499, 14, 88, 334, 19419, 1665, 18, 9, 1584, 14, 202, 199, 3, 10219, 13, 1643, 13, 2036, 428, 42, 45, 19503, 12420, 1380, 4697, 13, 1267, 6140, 1059, 4124, 1511, 3696, 14, 202, 199, 3, 10219, 13, 966, 13, 1081, 428, 42, 45, 5852, 22820, 298, 599, 596, 316, 2, 21395, 14, 2999, 199, 646, 984, 202, 199, 504, 2702, 492, 7787, 2999, 199, 2991, 63, 504, 63, 600, 1606, 275, 469, 1128, 413, 1840, 520, 283, 1624, 63, 975, 63, 274, 297, 1128, 11630, 26, 283, 3088, 63, 20971, 297, 1128, 5198, 22, 26, 283, 3088, 63, 32007, 297, 327, 9519, 1128, 5198, 23, 26, 283, 3088, 63, 17405, 297, 327, 9519, 1128, 2948, 1398, 26, 283, 3088, 63, 10378, 18, 297, 327, 9519, 1128, 2948, 1965, 26, 283, 3088, 63, 1885, 9688, 297, 327, 9519, 1128, 2948, 2835, 26, 283, 3088, 63, 16218, 75, 2453, 297, 327, 9519, 1128, 20939, 2333, 26, 283, 3088, 63, 20971, 297, 1128, 20939, 1876, 26, 283, 1850, 19364, 297, 1128, 789, 2999, 199, 3, 2005, 1655, 9519, 316, 12, 367, 1010, 5000, 10554, 202, 199, 3, 1233, 1606, 12699, 1493, 1425, 26, 202, 199, 3, 499, 1487, 20662, 643, 759, 359, 16, 61, 202, 199, 3, 650, 699, 22329, 359, 17, 61, 202, 199, 3, 841, 377, 455, 382, 359, 21, 61, 202, 199, 3, 959, 5773, 4170, 85, 359, 22, 61, 202, 199, 3, 1227, 10829, 313, 261, 359, 17, 61, 286, 14, 70, 14, 699, 22329, 202, 199, 3, 1520, 593, 322, 11552, 359, 20, 61, 202, 199, 3, 1695, 1804, 1189, 10641, 359, 23, 61, 202, 199, 3, 1749, 29936, 1187, 279, 455, 359, 24, 61, 202, 199, 3, 1616, 12436, 23757, 359, 19, 61, 202, 199, 3, 4119, 598, 24538, 359, 18, 61, 2999, 199, 9309, 275, 378, 327, 5809, 202, 199, 38, 7438, 275, 413, 327, 1434, 202, 199, 38, 1440, 275, 499, 327, 1329, 202, 199, 38, 4962, 275, 650, 327, 8605, 202, 199, 2161, 56, 275, 841, 327, 1318, 2999, 199, 5390, 4807, 275, 481, 7438, 202, 199, 9190, 4807, 275, 481, 1440, 2999, 199, 25774, 63, 26474, 63, 13993, 275, 378, 202, 199, 25774, 63, 26474, 63, 3876, 275, 413, 202, 199, 25774, 63, 26474, 63, 9190, 275, 499, 202, 199, 25774, 63, 26474, 63, 5390, 275, 650, 202, 199, 25774, 63, 26474, 63, 25312, 275, 841, 202, 199, 25774, 63, 26474, 63, 3170, 275, 959, 202, 199, 25774, 63, 26474, 63, 20438, 275, 1227, 327, 367, 675, 315, 10201, 12, 13082, 316, 5020, 12, 5423, 2999, 199, 4492, 556, 63, 505, 63, 504, 63, 1507, 275, 469, 1128, 378, 26, 221, 7340, 1397, 699, 24150, 4186, 1128, 3388, 26, 298, 18, 14, 16, 401, 1128, 7829, 26, 298, 18, 14, 17, 401, 1128, 4233, 26, 298, 19, 401, 1128, 6335, 26, 298, 20, 51, 401, 1128, 10416, 26, 298, 20, 55, 401, 1128, 5238, 26, 298, 21, 401, 1128, 10045, 26, 298, 23, 401, 1128, 5939, 26, 298, 24, 401, 1128, 16412, 26, 298, 24, 56, 401, 202, 199, 93, 2999, 199, 3, 961, 2600, 883, 506, 1202, 370, 7389, 282, 1318, 1015, 402, 314, 5007, 9479, 202, 199, 3, 626, 27832, 4440, 367, 1125, 10106, 14, 11842, 787, 2399, 4072, 26, 202, 199, 705, 63, 505, 63, 504, 63, 600, 275, 469, 1128, 378, 88, 383, 26, 3943, 8084, 12389, 221, 327, 6551, 2792, 402, 2877, 4917, 12271, 365, 2701, 1128, 378, 88, 1780, 26, 3943, 27051, 15, 16, 12389, 327, 3757, 2317, 701, 4697, 1128, 378, 88, 16, 38, 26, 3943, 7041, 12389, 327, 30801, 730, 402, 14888, 1128, 378, 88, 1196, 26, 3943, 8279, 12389, 257, 327, 473, 13486, 503, 5463, 4917, 3659, 1128, 378, 88, 17, 36, 26, 3943, 2339, 7044, 221, 327, 30801, 805, 503, 1425, 536, 1128, 378, 88, 1194, 26, 3943, 7125, 12389, 257, 327, 1594, 1425, 15784, 1128, 378, 88, 18, 33, 26, 3943, 46, 15, 33, 12389, 257, 327, 5886, 503, 805, 440, 2808, 202, 199, 93, 2999, 199, 19419, 1665, 63, 12903, 63, 12819, 275, 5939, 2999, 199, 25774, 63, 8406, 21155, 63, 13808, 51, 275, 644, 34, 12780, 12667, 275, 378, 88, 21, 202, 199, 25774, 63, 8406, 21155, 63, 13808, 51, 63, 20, 55, 275, 378, 88, 1960, 202, 199, 25774, 63, 8406, 20255, 775, 275, 16573, 19982, 1645, 775, 275, 378, 88, 709, 2999, 199, 25774, 63, 3973, 1734, 3177, 1645, 775, 63, 8406, 20255, 775, 275, 378, 88, 383, 202, 199, 25774, 63, 3973, 1734, 3177, 1645, 775, 63, 32110, 258, 275, 378, 88, 996, 202, 199, 25774, 63, 3973, 1734, 3177, 1645, 775, 63, 27966, 63, 10001, 275, 378, 88, 1690, 2999, 199, 3, 1323, 44, 63, 50, 43, 18, 275, 378, 88, 23, 69, 202, 199, 25774, 63, 12322, 221, 275, 378, 88, 996, 2025, 202, 199, 25774, 63, 12322, 18, 275, 378, 88, 383, 2025, 202, 199, 25774, 63, 20438, 275, 378, 88, 996, 614, 202, 199, 25774, 63, 20438, 63, 34, 18, 275, 378, 88, 614, 202, 199, 25774, 63, 34, 3359, 275, 378, 88, 11782, 202, 199, 25774, 63, 16026 ]
[ 12502, 859, 367, 314, 25077, 6883, 19, 2559, 14, 202, 199, 3, 202, 199, 3, 20825, 4248, 334, 67, 9, 11811, 13, 9300, 17854, 17579, 17815, 30611, 262, 12, 491, 316, 545, 510, 369, 12126, 202, 199, 3, 961, 859, 365, 1777, 402, 314, 25077, 6883, 2559, 12, 1314, 365, 14286, 1334, 282, 202, 199, 3, 6289, 13, 2487, 23854, 4894, 14, 202, 199, 3, 202, 199, 3, 7129, 13, 713, 13, 2036, 1303, 90, 1237, 24200, 316, 367, 2366, 650, 202, 199, 3, 9079, 13, 996, 13, 709, 428, 42, 45, 699, 24150, 18, 699, 10825, 43, 2777, 202, 199, 3, 9079, 13, 996, 13, 2036, 428, 42, 45, 5543, 462, 425, 367, 27832, 499, 14, 16, 2291, 202, 199, 3, 9079, 13, 996, 13, 996, 428, 42, 45, 16230, 19475, 6110, 34, 18, 12, 485, 34, 18, 63, 10452, 12, 5423, 9, 641, 2777, 1561, 367, 202, 199, 3, 4483, 12111, 556, 63, 2724, 1253, 12111, 556, 63, 835, 202, 199, 3, 10219, 13, 713, 13, 966, 428, 42, 45, 16230, 2291, 367, 27832, 499, 14, 88, 334, 19419, 1665, 18, 9, 1584, 14, 202, 199, 3, 10219, 13, 1643, 13, 2036, 428, 42, 45, 19503, 12420, 1380, 4697, 13, 1267, 6140, 1059, 4124, 1511, 3696, 14, 202, 199, 3, 10219, 13, 966, 13, 1081, 428, 42, 45, 5852, 22820, 298, 599, 596, 316, 2, 21395, 14, 2999, 199, 646, 984, 202, 199, 504, 2702, 492, 7787, 2999, 199, 2991, 63, 504, 63, 600, 1606, 275, 469, 1128, 413, 1840, 520, 283, 1624, 63, 975, 63, 274, 297, 1128, 11630, 26, 283, 3088, 63, 20971, 297, 1128, 5198, 22, 26, 283, 3088, 63, 32007, 297, 327, 9519, 1128, 5198, 23, 26, 283, 3088, 63, 17405, 297, 327, 9519, 1128, 2948, 1398, 26, 283, 3088, 63, 10378, 18, 297, 327, 9519, 1128, 2948, 1965, 26, 283, 3088, 63, 1885, 9688, 297, 327, 9519, 1128, 2948, 2835, 26, 283, 3088, 63, 16218, 75, 2453, 297, 327, 9519, 1128, 20939, 2333, 26, 283, 3088, 63, 20971, 297, 1128, 20939, 1876, 26, 283, 1850, 19364, 297, 1128, 789, 2999, 199, 3, 2005, 1655, 9519, 316, 12, 367, 1010, 5000, 10554, 202, 199, 3, 1233, 1606, 12699, 1493, 1425, 26, 202, 199, 3, 499, 1487, 20662, 643, 759, 359, 16, 61, 202, 199, 3, 650, 699, 22329, 359, 17, 61, 202, 199, 3, 841, 377, 455, 382, 359, 21, 61, 202, 199, 3, 959, 5773, 4170, 85, 359, 22, 61, 202, 199, 3, 1227, 10829, 313, 261, 359, 17, 61, 286, 14, 70, 14, 699, 22329, 202, 199, 3, 1520, 593, 322, 11552, 359, 20, 61, 202, 199, 3, 1695, 1804, 1189, 10641, 359, 23, 61, 202, 199, 3, 1749, 29936, 1187, 279, 455, 359, 24, 61, 202, 199, 3, 1616, 12436, 23757, 359, 19, 61, 202, 199, 3, 4119, 598, 24538, 359, 18, 61, 2999, 199, 9309, 275, 378, 327, 5809, 202, 199, 38, 7438, 275, 413, 327, 1434, 202, 199, 38, 1440, 275, 499, 327, 1329, 202, 199, 38, 4962, 275, 650, 327, 8605, 202, 199, 2161, 56, 275, 841, 327, 1318, 2999, 199, 5390, 4807, 275, 481, 7438, 202, 199, 9190, 4807, 275, 481, 1440, 2999, 199, 25774, 63, 26474, 63, 13993, 275, 378, 202, 199, 25774, 63, 26474, 63, 3876, 275, 413, 202, 199, 25774, 63, 26474, 63, 9190, 275, 499, 202, 199, 25774, 63, 26474, 63, 5390, 275, 650, 202, 199, 25774, 63, 26474, 63, 25312, 275, 841, 202, 199, 25774, 63, 26474, 63, 3170, 275, 959, 202, 199, 25774, 63, 26474, 63, 20438, 275, 1227, 327, 367, 675, 315, 10201, 12, 13082, 316, 5020, 12, 5423, 2999, 199, 4492, 556, 63, 505, 63, 504, 63, 1507, 275, 469, 1128, 378, 26, 221, 7340, 1397, 699, 24150, 4186, 1128, 3388, 26, 298, 18, 14, 16, 401, 1128, 7829, 26, 298, 18, 14, 17, 401, 1128, 4233, 26, 298, 19, 401, 1128, 6335, 26, 298, 20, 51, 401, 1128, 10416, 26, 298, 20, 55, 401, 1128, 5238, 26, 298, 21, 401, 1128, 10045, 26, 298, 23, 401, 1128, 5939, 26, 298, 24, 401, 1128, 16412, 26, 298, 24, 56, 401, 202, 199, 93, 2999, 199, 3, 961, 2600, 883, 506, 1202, 370, 7389, 282, 1318, 1015, 402, 314, 5007, 9479, 202, 199, 3, 626, 27832, 4440, 367, 1125, 10106, 14, 11842, 787, 2399, 4072, 26, 202, 199, 705, 63, 505, 63, 504, 63, 600, 275, 469, 1128, 378, 88, 383, 26, 3943, 8084, 12389, 221, 327, 6551, 2792, 402, 2877, 4917, 12271, 365, 2701, 1128, 378, 88, 1780, 26, 3943, 27051, 15, 16, 12389, 327, 3757, 2317, 701, 4697, 1128, 378, 88, 16, 38, 26, 3943, 7041, 12389, 327, 30801, 730, 402, 14888, 1128, 378, 88, 1196, 26, 3943, 8279, 12389, 257, 327, 473, 13486, 503, 5463, 4917, 3659, 1128, 378, 88, 17, 36, 26, 3943, 2339, 7044, 221, 327, 30801, 805, 503, 1425, 536, 1128, 378, 88, 1194, 26, 3943, 7125, 12389, 257, 327, 1594, 1425, 15784, 1128, 378, 88, 18, 33, 26, 3943, 46, 15, 33, 12389, 257, 327, 5886, 503, 805, 440, 2808, 202, 199, 93, 2999, 199, 19419, 1665, 63, 12903, 63, 12819, 275, 5939, 2999, 199, 25774, 63, 8406, 21155, 63, 13808, 51, 275, 644, 34, 12780, 12667, 275, 378, 88, 21, 202, 199, 25774, 63, 8406, 21155, 63, 13808, 51, 63, 20, 55, 275, 378, 88, 1960, 202, 199, 25774, 63, 8406, 20255, 775, 275, 16573, 19982, 1645, 775, 275, 378, 88, 709, 2999, 199, 25774, 63, 3973, 1734, 3177, 1645, 775, 63, 8406, 20255, 775, 275, 378, 88, 383, 202, 199, 25774, 63, 3973, 1734, 3177, 1645, 775, 63, 32110, 258, 275, 378, 88, 996, 202, 199, 25774, 63, 3973, 1734, 3177, 1645, 775, 63, 27966, 63, 10001, 275, 378, 88, 1690, 2999, 199, 3, 1323, 44, 63, 50, 43, 18, 275, 378, 88, 23, 69, 202, 199, 25774, 63, 12322, 221, 275, 378, 88, 996, 2025, 202, 199, 25774, 63, 12322, 18, 275, 378, 88, 383, 2025, 202, 199, 25774, 63, 20438, 275, 378, 88, 996, 614, 202, 199, 25774, 63, 20438, 63, 34, 18, 275, 378, 88, 614, 202, 199, 25774, 63, 34, 3359, 275, 378, 88, 11782, 202, 199, 25774, 63, 16026, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 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/google_account/controllers/main.py
350
1270
import simplejson import urllib import openerp from openerp import http from openerp.http import request import openerp.addons.web.controllers.main as webmain from openerp.addons.web.http import SessionExpiredException from werkzeug.exceptions import BadRequest import werkzeug.utils class google_auth(http.Controller): @http.route('/google_account/authentication', type='http', auth="none") def oauth2callback(self, **kw): """ This route/function is called by Google when user Accept/Refuse the consent of Google """ state = simplejson.loads(kw['state']) dbname = state.get('d') service = state.get('s') url_return = state.get('f') registry = openerp.modules.registry.RegistryManager.get(dbname) with registry.cursor() as cr: if kw.get('code',False): registry.get('google.%s' % service).set_all_tokens(cr,request.session.uid,kw['code']) return werkzeug.utils.redirect(url_return) elif kw.get('error'): return werkzeug.utils.redirect("%s%s%s" % (url_return ,"?error=" , kw.get('error'))) else: return werkzeug.utils.redirect("%s%s" % (url_return ,"?error=Unknown_error"))
agpl-3.0
[ 646, 13804, 199, 646, 4011, 199, 646, 5166, 199, 504, 5166, 492, 1455, 199, 504, 5166, 14, 1014, 492, 1056, 199, 646, 5166, 14, 10788, 14, 2520, 14, 20531, 14, 973, 465, 3330, 973, 199, 504, 5166, 14, 10788, 14, 2520, 14, 1014, 492, 8596, 20898, 1726, 199, 504, 10380, 14, 3924, 492, 8857, 2017, 199, 646, 10380, 14, 1208, 199, 199, 533, 6233, 63, 1178, 8, 1014, 14, 7506, 304, 2286, 768, 1014, 14, 4449, 2336, 3098, 63, 2048, 15, 11725, 297, 730, 534, 1014, 297, 1790, 628, 3592, 531, 272, 347, 9725, 18, 3058, 8, 277, 12, 1011, 829, 304, 267, 408, 961, 7475, 15, 1593, 365, 2797, 701, 4475, 1380, 922, 15506, 15, 2891, 1180, 314, 406, 1150, 402, 4475, 408, 2728, 1174, 275, 13804, 14, 3640, 8, 829, 459, 929, 1105, 267, 21842, 275, 1174, 14, 362, 360, 68, 358, 267, 2435, 275, 1174, 14, 362, 360, 83, 358, 267, 1166, 63, 1107, 275, 1174, 14, 362, 360, 70, 358, 2728, 7086, 275, 5166, 14, 3112, 14, 5189, 14, 10899, 2988, 14, 362, 8, 13238, 9, 267, 543, 7086, 14, 3937, 342, 465, 2467, 26, 288, 340, 4775, 14, 362, 360, 600, 297, 797, 304, 355, 7086, 14, 362, 360, 3098, 4111, 83, 7, 450, 2435, 680, 409, 63, 452, 63, 4504, 8, 1556, 12, 1069, 14, 1730, 14, 1535, 12, 829, 459, 600, 1105, 355, 372, 10380, 14, 1208, 14, 4876, 8, 633, 63, 1107, 9, 288, 916, 4775, 14, 362, 360, 705, 735, 355, 372, 10380, 14, 1208, 14, 4876, 3647, 83, 5, 83, 5, 83, 2, 450, 334, 633, 63, 1107, 2360, 14863, 705, 628, 2360, 4775, 14, 362, 360, 705, 7058, 288, 587, 26, 355, 372, 10380, 14, 1208, 14, 4876, 3647, 83, 5, 83, 2, 450, 334, 633, 63, 1107, 2360, 14863, 705, 29, 5912, 63, 705, 2237, 13359, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 13804, 199, 646, 4011, 199, 646, 5166, 199, 504, 5166, 492, 1455, 199, 504, 5166, 14, 1014, 492, 1056, 199, 646, 5166, 14, 10788, 14, 2520, 14, 20531, 14, 973, 465, 3330, 973, 199, 504, 5166, 14, 10788, 14, 2520, 14, 1014, 492, 8596, 20898, 1726, 199, 504, 10380, 14, 3924, 492, 8857, 2017, 199, 646, 10380, 14, 1208, 199, 199, 533, 6233, 63, 1178, 8, 1014, 14, 7506, 304, 2286, 768, 1014, 14, 4449, 2336, 3098, 63, 2048, 15, 11725, 297, 730, 534, 1014, 297, 1790, 628, 3592, 531, 272, 347, 9725, 18, 3058, 8, 277, 12, 1011, 829, 304, 267, 408, 961, 7475, 15, 1593, 365, 2797, 701, 4475, 1380, 922, 15506, 15, 2891, 1180, 314, 406, 1150, 402, 4475, 408, 2728, 1174, 275, 13804, 14, 3640, 8, 829, 459, 929, 1105, 267, 21842, 275, 1174, 14, 362, 360, 68, 358, 267, 2435, 275, 1174, 14, 362, 360, 83, 358, 267, 1166, 63, 1107, 275, 1174, 14, 362, 360, 70, 358, 2728, 7086, 275, 5166, 14, 3112, 14, 5189, 14, 10899, 2988, 14, 362, 8, 13238, 9, 267, 543, 7086, 14, 3937, 342, 465, 2467, 26, 288, 340, 4775, 14, 362, 360, 600, 297, 797, 304, 355, 7086, 14, 362, 360, 3098, 4111, 83, 7, 450, 2435, 680, 409, 63, 452, 63, 4504, 8, 1556, 12, 1069, 14, 1730, 14, 1535, 12, 829, 459, 600, 1105, 355, 372, 10380, 14, 1208, 14, 4876, 8, 633, 63, 1107, 9, 288, 916, 4775, 14, 362, 360, 705, 735, 355, 372, 10380, 14, 1208, 14, 4876, 3647, 83, 5, 83, 5, 83, 2, 450, 334, 633, 63, 1107, 2360, 14863, 705, 628, 2360, 4775, 14, 362, 360, 705, 7058, 288, 587, 26, 355, 372, 10380, 14, 1208, 14, 4876, 3647, 83, 5, 83, 2, 450, 334, 633, 63, 1107, 2360, 14863, 705, 29, 5912, 63, 705, 2237, 13359, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
petrutlucian94/nova
nova/api/openstack/compute/plugins/v3/services.py
13
5102
# Copyright 2012 IBM Corp. # # 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 webob.exc from nova.api.openstack.compute.schemas.v3 import services from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.api import validation from nova import compute from nova import exception from nova.i18n import _ from nova import servicegroup ALIAS = "os-services" authorize = extensions.os_compute_authorizer(ALIAS) class ServiceController(wsgi.Controller): def __init__(self): self.host_api = compute.HostAPI() self.servicegroup_api = servicegroup.API() def _get_services(self, req): context = req.environ['nova.context'] authorize(context) services = self.host_api.service_get_all( context, set_zones=True) host = '' if 'host' in req.GET: host = req.GET['host'] binary = '' if 'binary' in req.GET: binary = req.GET['binary'] if host: services = [s for s in services if s['host'] == host] if binary: services = [s for s in services if s['binary'] == binary] return services def _get_service_detail(self, svc): alive = self.servicegroup_api.service_is_up(svc) state = (alive and "up") or "down" active = 'enabled' if svc['disabled']: active = 'disabled' service_detail = {'binary': svc['binary'], 'host': svc['host'], 'id': svc['id'], 'zone': svc['availability_zone'], 'status': active, 'state': state, 'updated_at': svc['updated_at'], 'disabled_reason': svc['disabled_reason']} return service_detail def _get_services_list(self, req): services = self._get_services(req) svcs = [] for svc in services: svcs.append(self._get_service_detail(svc)) return svcs @wsgi.response(204) @extensions.expected_errors((400, 404)) def delete(self, req, id): """Deletes the specified service.""" context = req.environ['nova.context'] authorize(context) try: self.host_api.service_delete(context, id) except exception.ServiceNotFound: explanation = _("Service %s not found.") % id raise webob.exc.HTTPNotFound(explanation=explanation) @extensions.expected_errors(()) def index(self, req): """Return a list of all running services. Filter by host & service name """ services = self._get_services_list(req) return {'services': services} @extensions.expected_errors((400, 404)) @validation.schema(services.service_update) def update(self, req, id, body): """Enable/Disable scheduling for a service.""" context = req.environ['nova.context'] authorize(context) if id == "enable": disabled = False status = "enabled" elif id in ("disable", "disable-log-reason"): disabled = True status = "disabled" else: msg = _("Unknown action") raise webob.exc.HTTPNotFound(explanation=msg) host = body['host'] binary = body['binary'] ret_value = { 'service': { 'host': host, 'binary': binary, 'status': status, }, } status_detail = { 'disabled': disabled, 'disabled_reason': None, } if id == "disable-log-reason": try: reason = body['disabled_reason'] except (KeyError): msg = _('Missing disabled reason field') raise webob.exc.HTTPBadRequest(explanation=msg) status_detail['disabled_reason'] = reason ret_value['service']['disabled_reason'] = reason try: self.host_api.service_update(context, host, binary, status_detail) except exception.HostBinaryNotFound as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) return ret_value class Services(extensions.V3APIExtensionBase): """Services support.""" name = "Services" alias = ALIAS version = 1 def get_resources(self): resources = [extensions.ResourceExtension(ALIAS, ServiceController())] return resources def get_controller_extensions(self): return []
apache-2.0
[ 3, 1898, 6029, 26202, 22304, 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, 14568, 14, 2804, 199, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 9482, 14, 86, 19, 492, 8500, 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, 492, 1919, 199, 504, 5913, 14, 73, 1085, 78, 492, 485, 199, 504, 5913, 492, 2435, 923, 199, 199, 12644, 275, 298, 736, 13, 5950, 2, 199, 14204, 275, 5478, 14, 736, 63, 3357, 63, 2502, 1793, 8, 12644, 9, 421, 199, 533, 7591, 7506, 8, 6508, 14, 7506, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1102, 63, 1246, 275, 4526, 14, 4965, 3735, 342, 267, 291, 14, 29409, 63, 1246, 275, 2435, 923, 14, 3735, 342, 339, 347, 485, 362, 63, 5950, 8, 277, 12, 2648, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 9, 267, 8500, 275, 291, 14, 1102, 63, 1246, 14, 1364, 63, 362, 63, 452, 8, 288, 1067, 12, 663, 63, 13325, 29, 549, 9, 398, 1591, 275, 2125, 267, 340, 283, 1102, 7, 315, 2648, 14, 2970, 26, 288, 1591, 275, 2648, 14, 2970, 459, 1102, 418, 267, 3366, 275, 2125, 267, 340, 283, 3008, 7, 315, 2648, 14, 2970, 26, 288, 3366, 275, 2648, 14, 2970, 459, 3008, 418, 267, 340, 1591, 26, 288, 8500, 275, 359, 83, 367, 308, 315, 8500, 340, 308, 459, 1102, 418, 508, 1591, 61, 267, 340, 3366, 26, 288, 8500, 275, 359, 83, 367, 308, 315, 8500, 340, 308, 459, 3008, 418, 508, 3366, 61, 398, 372, 8500, 339, 347, 485, 362, 63, 1364, 63, 5506, 8, 277, 12, 19257, 304, 267, 19708, 275, 291, 14, 29409, 63, 1246, 14, 1364, 63, 374, 63, 384, 8, 10599, 9, 267, 1174, 275, 334, 9631, 436, 298, 384, 531, 503, 298, 2110, 2, 267, 4702, 275, 283, 3827, 7, 267, 340, 19257, 459, 7011, 2565, 288, 4702, 275, 283, 7011, 7, 267, 2435, 63, 5506, 275, 791, 3008, 356, 19257, 459, 3008, 995, 283, 1102, 356, 19257, 459, 1102, 995, 2151, 283, 344, 356, 19257, 459, 344, 995, 2151, 283, 2619, 356, 19257, 459, 11856, 63, 2619, 995, 2151, 283, 1205, 356, 4702, 12, 283, 929, 356, 1174, 12, 2151, 283, 5334, 63, 292, 356, 19257, 459, 5334, 63, 292, 995, 2151, 283, 7011, 63, 5764, 356, 19257, 459, 7011, 63, 5764, 12074, 398, 372, 2435, 63, 5506, 339, 347, 485, 362, 63, 5950, 63, 513, 8, 277, 12, 2648, 304, 267, 8500, 275, 291, 423, 362, 63, 5950, 8, 2103, 9, 267, 308, 15525, 275, 942, 267, 367, 19257, 315, 8500, 26, 288, 308, 15525, 14, 740, 8, 277, 423, 362, 63, 1364, 63, 5506, 8, 10599, 430, 398, 372, 308, 15525, 339, 768, 6508, 14, 1310, 8, 6686, 9, 272, 768, 5359, 14, 2062, 63, 2550, 1332, 5303, 12, 7901, 430, 272, 347, 3145, 8, 277, 12, 2648, 12, 1305, 304, 267, 408, 26372, 314, 2013, 2435, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 9, 398, 862, 26, 288, 291, 14, 1102, 63, 1246, 14, 1364, 63, 1807, 8, 1100, 12, 1305, 9, 267, 871, 1919, 14, 3167, 4667, 26, 288, 17531, 275, 3824, 3167, 450, 83, 440, 1911, 2685, 450, 1305, 288, 746, 14568, 14, 2804, 14, 26553, 8, 15228, 29, 15228, 9, 339, 768, 5359, 14, 2062, 63, 2550, 30812, 272, 347, 1478, 8, 277, 12, 2648, 304, 267, 408, 1767, 282, 769, 402, 1006, 3879, 8500, 14, 9388, 701, 1591, 1253, 2435, 267, 536, 267, 408, 267, 8500, 275, 291, 423, 362, 63, 5950, 63, 513, 8, 2103, 9, 398, 372, 791, 5950, 356, 8500, 93, 339, 768, 5359, 14, 2062, 63, 2550, 1332, 5303, 12, 7901, 430, 272, 768, 6136, 14, 3629, 8, 5950, 14, 1364, 63, 873, 9, 272, 347, 1678, 8, 277, 12, 2648, 12, 1305, 12, 2396, 304, 267, 408, 6476, 15, 13707, 23800, 367, 282, 2435, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 9, 398, 340, 1305, 508, 298, 4296, 582, 288, 6980, 275, 756, 288, 2004, 275, 298, 3827, 2, 267, 916, 1305, 315, 1689, 5993, 401, 298, 5993, 13, 793, 13, 5764, 2349, 288, 6980, 275, 715, 288, 2004, 275, 298, 7011, 2, 267, 587, 26, 288, 1499, 275, 3824, 5912, 1595, 531, 288, 746, 14568, 14, 2804, 14, 26553, 8, 15228, 29, 1328, 9, 398, 1591, 275, 2396, 459, 1102, 418, 267, 3366, 275, 2396, 459, 3008, 418, 267, 2203, 63, 585, 275, 469, 288, 283, 1364, 356, 469, 355, 283, 1102, 356, 1591, 12, 355, 283, 3008, 356, 3366, 12, 355, 283, 1205, 356, 2004, 12, 288, 1660, 267, 789, 267, 2004, 63, 5506, 275, 469, 288, 283, 7011, 356, 6980, 12, 288, 283, 7011, 63, 5764, 356, 488, 12, 267, 789, 267, 340, 1305, 508, 298, 5993, 13, 793, 13, 5764, 582, 288, 862, 26, 355, 4499, 275, 2396, 459, 7011, 63, 5764, 418, 288, 871, 334, 10230, 304, 355, 1499, 275, 4018, 7718, 6980, 4499, 901, 358, 355, 746, 14568, 14, 2804, 14, 21070, 8, 15228, 29, 1328, 9, 953, 2004, 63, 5506, 459, 7011, 63 ]
[ 1898, 6029, 26202, 22304, 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, 14568, 14, 2804, 199, 199, 504, 5913, 14, 1246, 14, 8512, 14, 3357, 14, 9482, 14, 86, 19, 492, 8500, 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, 492, 1919, 199, 504, 5913, 14, 73, 1085, 78, 492, 485, 199, 504, 5913, 492, 2435, 923, 199, 199, 12644, 275, 298, 736, 13, 5950, 2, 199, 14204, 275, 5478, 14, 736, 63, 3357, 63, 2502, 1793, 8, 12644, 9, 421, 199, 533, 7591, 7506, 8, 6508, 14, 7506, 304, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 1102, 63, 1246, 275, 4526, 14, 4965, 3735, 342, 267, 291, 14, 29409, 63, 1246, 275, 2435, 923, 14, 3735, 342, 339, 347, 485, 362, 63, 5950, 8, 277, 12, 2648, 304, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 9, 267, 8500, 275, 291, 14, 1102, 63, 1246, 14, 1364, 63, 362, 63, 452, 8, 288, 1067, 12, 663, 63, 13325, 29, 549, 9, 398, 1591, 275, 2125, 267, 340, 283, 1102, 7, 315, 2648, 14, 2970, 26, 288, 1591, 275, 2648, 14, 2970, 459, 1102, 418, 267, 3366, 275, 2125, 267, 340, 283, 3008, 7, 315, 2648, 14, 2970, 26, 288, 3366, 275, 2648, 14, 2970, 459, 3008, 418, 267, 340, 1591, 26, 288, 8500, 275, 359, 83, 367, 308, 315, 8500, 340, 308, 459, 1102, 418, 508, 1591, 61, 267, 340, 3366, 26, 288, 8500, 275, 359, 83, 367, 308, 315, 8500, 340, 308, 459, 3008, 418, 508, 3366, 61, 398, 372, 8500, 339, 347, 485, 362, 63, 1364, 63, 5506, 8, 277, 12, 19257, 304, 267, 19708, 275, 291, 14, 29409, 63, 1246, 14, 1364, 63, 374, 63, 384, 8, 10599, 9, 267, 1174, 275, 334, 9631, 436, 298, 384, 531, 503, 298, 2110, 2, 267, 4702, 275, 283, 3827, 7, 267, 340, 19257, 459, 7011, 2565, 288, 4702, 275, 283, 7011, 7, 267, 2435, 63, 5506, 275, 791, 3008, 356, 19257, 459, 3008, 995, 283, 1102, 356, 19257, 459, 1102, 995, 2151, 283, 344, 356, 19257, 459, 344, 995, 2151, 283, 2619, 356, 19257, 459, 11856, 63, 2619, 995, 2151, 283, 1205, 356, 4702, 12, 283, 929, 356, 1174, 12, 2151, 283, 5334, 63, 292, 356, 19257, 459, 5334, 63, 292, 995, 2151, 283, 7011, 63, 5764, 356, 19257, 459, 7011, 63, 5764, 12074, 398, 372, 2435, 63, 5506, 339, 347, 485, 362, 63, 5950, 63, 513, 8, 277, 12, 2648, 304, 267, 8500, 275, 291, 423, 362, 63, 5950, 8, 2103, 9, 267, 308, 15525, 275, 942, 267, 367, 19257, 315, 8500, 26, 288, 308, 15525, 14, 740, 8, 277, 423, 362, 63, 1364, 63, 5506, 8, 10599, 430, 398, 372, 308, 15525, 339, 768, 6508, 14, 1310, 8, 6686, 9, 272, 768, 5359, 14, 2062, 63, 2550, 1332, 5303, 12, 7901, 430, 272, 347, 3145, 8, 277, 12, 2648, 12, 1305, 304, 267, 408, 26372, 314, 2013, 2435, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 9, 398, 862, 26, 288, 291, 14, 1102, 63, 1246, 14, 1364, 63, 1807, 8, 1100, 12, 1305, 9, 267, 871, 1919, 14, 3167, 4667, 26, 288, 17531, 275, 3824, 3167, 450, 83, 440, 1911, 2685, 450, 1305, 288, 746, 14568, 14, 2804, 14, 26553, 8, 15228, 29, 15228, 9, 339, 768, 5359, 14, 2062, 63, 2550, 30812, 272, 347, 1478, 8, 277, 12, 2648, 304, 267, 408, 1767, 282, 769, 402, 1006, 3879, 8500, 14, 9388, 701, 1591, 1253, 2435, 267, 536, 267, 408, 267, 8500, 275, 291, 423, 362, 63, 5950, 63, 513, 8, 2103, 9, 398, 372, 791, 5950, 356, 8500, 93, 339, 768, 5359, 14, 2062, 63, 2550, 1332, 5303, 12, 7901, 430, 272, 768, 6136, 14, 3629, 8, 5950, 14, 1364, 63, 873, 9, 272, 347, 1678, 8, 277, 12, 2648, 12, 1305, 12, 2396, 304, 267, 408, 6476, 15, 13707, 23800, 367, 282, 2435, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 6765, 14, 1100, 418, 267, 20210, 8, 1100, 9, 398, 340, 1305, 508, 298, 4296, 582, 288, 6980, 275, 756, 288, 2004, 275, 298, 3827, 2, 267, 916, 1305, 315, 1689, 5993, 401, 298, 5993, 13, 793, 13, 5764, 2349, 288, 6980, 275, 715, 288, 2004, 275, 298, 7011, 2, 267, 587, 26, 288, 1499, 275, 3824, 5912, 1595, 531, 288, 746, 14568, 14, 2804, 14, 26553, 8, 15228, 29, 1328, 9, 398, 1591, 275, 2396, 459, 1102, 418, 267, 3366, 275, 2396, 459, 3008, 418, 267, 2203, 63, 585, 275, 469, 288, 283, 1364, 356, 469, 355, 283, 1102, 356, 1591, 12, 355, 283, 3008, 356, 3366, 12, 355, 283, 1205, 356, 2004, 12, 288, 1660, 267, 789, 267, 2004, 63, 5506, 275, 469, 288, 283, 7011, 356, 6980, 12, 288, 283, 7011, 63, 5764, 356, 488, 12, 267, 789, 267, 340, 1305, 508, 298, 5993, 13, 793, 13, 5764, 582, 288, 862, 26, 355, 4499, 275, 2396, 459, 7011, 63, 5764, 418, 288, 871, 334, 10230, 304, 355, 1499, 275, 4018, 7718, 6980, 4499, 901, 358, 355, 746, 14568, 14, 2804, 14, 21070, 8, 15228, 29, 1328, 9, 953, 2004, 63, 5506, 459, 7011, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
geektophe/shinken
shinken/satellite.py
3
46474
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (C) 2009-2014: # Gabes Jean, naparuba@gmail.com # Gerhard Lausser, Gerhard.Lausser@consol.de # Gregory Starck, g.starck@gmail.com # Hartmut Goebel, h.goebel@goebel-consult.de # # This file is part of Shinken. # # Shinken 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. # # Shinken 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 Shinken. If not, see <http://www.gnu.org/licenses/>. """ This class is an interface for Reactionner and Poller daemons A Reactionner listens to a port for the configuration from the Arbiter The conf contains the schedulers where actionners will gather actions. The Reactionner keeps on listening to the Arbiter (one a timeout) If Arbiter wants it to have a new conf, the satellite forgets the previous Schedulers (and actions into) and takes the new ones. """ # Try to see if we are in an android device or not is_android = True try: import android except ImportError: is_android = False from Queue import Empty if not is_android: from multiprocessing import Queue, active_children, cpu_count else: from Queue import Queue import os import copy import time import cPickle import traceback import zlib import base64 import threading from shinken.http_client import HTTPClient, HTTPExceptions from shinken.message import Message from shinken.worker import Worker from shinken.load import Load from shinken.daemon import Daemon, Interface from shinken.log import logger from shinken.util import get_memory, parse_memory_expr, free_memory from shinken.stats import statsmgr # Class to tell that we are facing a non worker module # but a standard one class NotWorkerMod(Exception): pass # Interface for Arbiter, our big MASTER # It gives us our conf class IForArbiter(Interface): doc = 'Remove a scheduler connection (internal)' # Arbiter ask us to do not manage a scheduler_id anymore # I do it and don't ask why def remove_from_conf(self, sched_id): try: del self.app.schedulers[sched_id] except KeyError: pass remove_from_conf.doc = doc doc = 'Return the managed configuration ids (internal)' # Arbiter ask me which sched_id I manage, If it is not ok with it # It will ask me to remove one or more sched_id def what_i_managed(self): logger.debug("The arbiter asked me what I manage. It's %s", self.app.what_i_managed()) return self.app.what_i_managed() what_i_managed.need_lock = False what_i_managed.doc = doc doc = 'Ask the daemon to drop its configuration and wait for a new one' # Call by arbiter if it thinks we are running but we must do not (like # if I was a spare that take a conf but the master returns, I must die # and wait a new conf) # Us: No please... # Arbiter: I don't care, hasta la vista baby! # Us: ... <- Nothing! We are dead! you don't get it or what?? # Reading code is not a job for eyes only... def wait_new_conf(self): logger.debug("Arbiter wants me to wait for a new configuration") self.app.schedulers.clear() self.app.cur_conf = None wait_new_conf.doc = doc doc = 'Push broks objects to the daemon (internal)' # NB: following methods are only used by broker # Used by the Arbiter to push broks to broker def push_broks(self, broks): with self.app.arbiter_broks_lock: self.app.arbiter_broks.extend(broks) push_broks.method = 'post' # We are using a Lock just for NOT lock this call from the arbiter :) push_broks.need_lock = False push_broks.doc = doc doc = 'Get the external commands from the daemon (internal)' # The arbiter ask us our external commands in queue # Same than push_broks, we will not using Global lock here, # and only lock for external_commands def get_external_commands(self): with self.app.external_commands_lock: cmds = self.app.get_external_commands() raw = cPickle.dumps(cmds) return raw get_external_commands.need_lock = False get_external_commands.doc = doc doc = 'Does the daemon got configuration (receiver)' # NB: only useful for receiver def got_conf(self): return self.app.cur_conf is not None got_conf.need_lock = False got_conf.doc = doc doc = 'Push hostname/scheduler links (receiver in direct routing)' # Use by the receivers to got the host names managed by the schedulers def push_host_names(self, sched_id, hnames): self.app.push_host_names(sched_id, hnames) push_host_names.method = 'post' push_host_names.doc = doc class ISchedulers(Interface): """Interface for Schedulers If we are passive, they connect to this and send/get actions """ doc = 'Push new actions to the scheduler (internal)' # A Scheduler send me actions to do def push_actions(self, actions, sched_id): self.app.add_actions(actions, int(sched_id)) push_actions.method = 'post' push_actions.doc = doc doc = 'Get the returns of the actions (internal)' # A scheduler ask us the action return value def get_returns(self, sched_id): # print "A scheduler ask me the returns", sched_id ret = self.app.get_return_for_passive(int(sched_id)) # print "Send mack", len(ret), "returns" return cPickle.dumps(ret) get_returns.doc = doc class IBroks(Interface): """Interface for Brokers They connect here and get all broks (data for brokers) data must be ORDERED! (initial status BEFORE update...) """ doc = 'Get broks from the daemon' # poller or reactionner ask us actions def get_broks(self, bname, broks_batch=0): res = self.app.get_broks(broks_batch) return base64.b64encode(zlib.compress(cPickle.dumps(res), 2)) get_broks.doc = doc class IStats(Interface): """ Interface for various stats about poller/reactionner activity """ doc = 'Get raw stats from the daemon' def get_raw_stats(self): app = self.app res = {} for sched_id in app.schedulers: sched = app.schedulers[sched_id] lst = [] res[sched_id] = lst for mod in app.q_by_mod: # In workers we've got actions send to queue - queue size for (i, q) in app.q_by_mod[mod].items(): lst.append({ 'scheduler_name': sched['name'], 'module': mod, 'queue_number': i, 'queue_size': q.qsize(), 'return_queue_len': app.get_returns_queue_len()}) return res get_raw_stats.doc = doc class BaseSatellite(Daemon): """Please Add a Docstring to describe the class here""" def __init__(self, name, config_file, is_daemon, do_replace, debug, debug_file): super(BaseSatellite, self).__init__(name, config_file, is_daemon, do_replace, debug, debug_file) # Ours schedulers self.schedulers = {} # Now we create the interfaces self.interface = IForArbiter(self) self.istats = IStats(self) # Can have a queue of external_commands given by modules # will be taken by arbiter to process self.external_commands = [] self.external_commands_lock = threading.RLock() # The arbiter can resent us new conf in the pyro_daemon port. # We do not want to loose time about it, so it's not a blocking # wait, timeout = 0s # If it send us a new conf, we reinit the connections of all schedulers def watch_for_new_conf(self, timeout): self.handleRequests(timeout) def do_stop(self): if self.http_daemon and self.interface: logger.info("[%s] Stopping all network connections", self.name) self.http_daemon.unregister(self.interface) super(BaseSatellite, self).do_stop() # Give the arbiter the data about what I manage # for me it's the ids of my schedulers def what_i_managed(self): r = {} for (k, v) in self.schedulers.iteritems(): r[k] = v['push_flavor'] return r # Call by arbiter to get our external commands def get_external_commands(self): res = self.external_commands self.external_commands = [] return res class Satellite(BaseSatellite): """Our main APP class""" def __init__(self, name, config_file, is_daemon, do_replace, debug, debug_file): super(Satellite, self).__init__(name, config_file, is_daemon, do_replace, debug, debug_file) # Keep broks so they can be eaten by a broker self.broks = [] self.workers = {} # dict of active workers # Init stats like Load for workers self.wait_ratio = Load(initial_value=1) self.brok_interface = IBroks(self) self.scheduler_interface = ISchedulers(self) # Just for having these attributes defined here. explicit > implicit ;) self.uri2 = None self.uri3 = None self.s = None self.returns_queue = None self.q_by_mod = {} # Wrapper function for the true con init def pynag_con_init(self, id): _t = time.time() r = self.do_pynag_con_init(id) statsmgr.timing('con-init.scheduler', time.time() - _t, "perf") return r # Initialize or re-initialize connection with scheduler def do_pynag_con_init(self, id): sched = self.schedulers[id] # If sched is not active, I do not try to init # it is just useless if not sched['active']: return sname = sched['name'] uri = sched['uri'] running_id = sched['running_id'] timeout = sched['timeout'] data_timeout = sched['data_timeout'] logger.info("[%s] Init connection with %s at %s (%ss,%ss)", self.name, sname, uri, timeout, data_timeout) try: sch_con = sched['con'] = HTTPClient( uri=uri, strong_ssl=sched['hard_ssl_name_check'], timeout=timeout, data_timeout=data_timeout) except HTTPExceptions, exp: logger.warning("[%s] Scheduler %s is not initialized or has network problem: %s", self.name, sname, str(exp)) sched['con'] = None return # timeout of 3s by default (short one) # and get the running id try: new_run_id = sch_con.get('get_running_id') new_run_id = float(new_run_id) except (HTTPExceptions, cPickle.PicklingError, KeyError), exp: logger.warning("[%s] Scheduler %s is not initialized or has network problem: %s", self.name, sname, str(exp)) sched['con'] = None return # The schedulers have been restarted: it has a new run_id. # So we clear all verifs, they are obsolete now. if sched['running_id'] != 0 and new_run_id != running_id: logger.info("[%s] The running id of the scheduler %s changed, " "we must clear its actions", self.name, sname) del sched['wait_homerun'][:] sched['running_id'] = new_run_id logger.info("[%s] Connection OK with scheduler %s", self.name, sname) # Manage action returned from Workers # We just put them into the corresponding sched # and we clean unused properties like sched_id def manage_action_return(self, action): # Maybe our workers end us something else than an action # if so, just add this in other queues and return cls_type = action.__class__.my_type if cls_type not in ['check', 'notification', 'eventhandler']: self.add(action) return # Ok, it's a result. We get it, and fill verifs of the good sched_id sched_id = action.sched_id # Now we now where to put action, we do not need sched_id anymore del action.sched_id # Unset the tag of the worker_id too try: del action.worker_id except AttributeError: pass # And we remove it from the actions queue of the scheduler too try: del self.schedulers[sched_id]['actions'][action.get_id()] except KeyError: pass # We tag it as "return wanted", and move it in the wait return queue # Stop, if it is "timeout" we need this information later # in the scheduler # action.status = 'waitforhomerun' try: self.schedulers[sched_id]['wait_homerun'].append(action) except KeyError: pass # Wrapper function for stats def manage_returns(self): _t = time.time() r = self.do_manage_returns() _type = self.__class__.my_type statsmgr.timing('core.%s.manage-returns' % _type, time.time() - _t, 'perf') return r # Return the chk to scheduler and clean them # REF: doc/shinken-action-queues.png (6) def do_manage_returns(self): # For all schedulers, we check for waitforhomerun # and we send back results count = 0 for sched_id in self.schedulers: sched = self.schedulers[sched_id] # If sched is not active, I do not try return if not sched['active']: continue # Now ret have all verifs, we can return them send_ok = False if self.results_batch > 0: batch = min(self.results_batch, len(sched['wait_homerun'])) else: batch = len(sched['wait_homerun']) ret = sched['wait_homerun'][:batch] if ret is not []: try: con = sched['con'] if con is not None: # None = not initialized send_ok = con.post('put_results', {'results': ret}) # Not connected or sched is gone except (HTTPExceptions, KeyError), exp: logger.error('manage_returns exception:: %s,%s ', type(exp), str(exp)) self.pynag_con_init(sched_id) return except AttributeError, exp: # the scheduler must not be initialized logger.error('manage_returns exception:: %s,%s ', type(exp), str(exp)) except Exception, exp: logger.error("A satellite raised an unknown exception: %s (%s)", exp, type(exp)) raise # We clean ONLY if the send is OK if send_ok: count += len(ret) del sched['wait_homerun'][:batch] else: self.pynag_con_init(sched_id) logger.warning("Sent failed!") _type = self.__class__.my_type statsmgr.incr('core.%s.results.out' % _type, count, 'queue') # Get all returning actions for a call from a # scheduler def get_return_for_passive(self, sched_id): # I do not know this scheduler? if sched_id not in self.schedulers: logger.debug("I do not know this scheduler: %s", sched_id) return [] sched = self.schedulers[sched_id] logger.debug("Preparing to return %s", str(sched['wait_homerun'])) # prepare our return if self.results_batch > 0: batch = min(self.results_batch, len(sched['wait_homerun'])) else: batch = len(sched['wait_homerun']) ret = sched['wait_homerun'][:batch] # and clear our dict del sched['wait_homerun'][:batch] return ret # Create and launch a new worker, and put it into self.workers # It can be mortal or not def create_and_launch_worker(self, module_name='fork', mortal=True): # create the input queue of this worker try: if is_android: q = Queue() else: q = self.manager.Queue() # If we got no /dev/shm on linux, we can got problem here. # Must raise with a good message except OSError, exp: # We look for the "Function not implemented" under Linux if exp.errno == 38 and os.name == 'posix': logger.critical("Got an exception (%s). If you are under Linux, " "please check that your /dev/shm directory exists and" " is read-write.", str(exp)) raise # If we are in the fork module, we do not specify a target target = None if module_name == 'fork': target = None else: for module in self.modules_manager.instances: if module.properties['type'] == module_name: # First, see if the module is a 'worker' one or not if not module.properties.get('worker_capable', False): raise NotWorkerMod target = module.work if target is None: return # We want to give to the Worker the name of the daemon (poller or reactionner) cls_name = self.__class__.__name__.lower() w = Worker(1, q, self.returns_queue, self.processes_by_worker, mortal=mortal, max_plugins_output_length=self.max_plugins_output_length, target=target, loaded_into=cls_name, http_daemon=self.http_daemon) w.module_name = module_name # save this worker self.workers[w.id] = w # And save the Queue of this worker, with key = worker id self.q_by_mod[module_name][w.id] = q logger.info("[%s] Allocating new %s Worker: %s", self.name, module_name, w.id) # Ok, all is good. Start it! w.start() # The main stop of this daemon. Stop all workers # modules and sockets def do_stop(self): logger.info("[%s] Stopping all workers", self.name) for w in self.workers.values(): try: w.terminate() w.join(timeout=1) # A already dead worker or in a worker except (AttributeError, AssertionError): pass # Close the server socket if it was opened if self.http_daemon: if self.brok_interface: self.http_daemon.unregister(self.brok_interface) if self.scheduler_interface: self.http_daemon.unregister(self.scheduler_interface) # And then call our master stop from satellite code super(Satellite, self).do_stop() # A simple function to add objects in self # like broks in self.broks, etc # TODO: better tag ID? def add(self, elt): cls_type = elt.__class__.my_type if cls_type == 'brok': # For brok, we TAG brok with our instance_id elt.instance_id = 0 self.broks.append(elt) return elif cls_type == 'externalcommand': logger.debug("Enqueuing an external command '%s'", str(elt.__dict__)) with self.external_commands_lock: self.external_commands.append(elt) # Someone ask us our broks. We send them, and clean the queue def get_broks(self, broks_batch=0): _type = self.__class__.my_type if broks_batch == 0: count = len(self.broks) else: count = min(broks_batch, len(self.broks)) res = self.broks[:count] del self.broks[:count] statsmgr.incr('core.%s.broks.out' % _type, count, 'queue') return res # workers are processes, they can die in a numerous of ways # like: # *99.99%: bug in code, sorry:p # *0.005 %: a mix between a stupid admin (or an admin without coffee), # and a kill command # *0.005%: alien attack # So they need to be detected, and restart if need def check_and_del_zombie_workers(self): # In android, we are using threads, so there is not active_children call if not is_android: # Active children make a join with everyone, useful :) active_children() w_to_del = [] for w in self.workers.values(): # If a worker goes down and we did not ask him, it's not # good: we can think that we have a worker and it's not True # So we del it if not w.is_alive(): logger.warning("[%s] The worker %s goes down unexpectedly!", self.name, w.id) # Terminate immediately w.terminate() w.join(timeout=1) w_to_del.append(w.id) # OK, now really del workers from queues # And requeue the actions it was managed for id in w_to_del: w = self.workers[id] # Del the queue of the module queue del self.q_by_mod[w.module_name][w.id] for sched_id in self.schedulers: sched = self.schedulers[sched_id] for a in sched['actions'].values(): if a.status == 'queue' and a.worker_id == id: # Got a check that will NEVER return if we do not # restart it self.assign_to_a_queue(a) # So now we can really forgot it del self.workers[id] # Here we create new workers if the queue load (len of verifs) is too long def adjust_worker_number_by_load(self): to_del = [] logger.debug("[%s] Trying to adjust worker number." " Actual number : %d, min per module : %d, max per module : %d", self.name, len(self.workers), self.min_workers, self.max_workers) # I want at least min_workers by module then if I can, I add worker for load balancing for mod in self.q_by_mod: # At least min_workers while len(self.q_by_mod[mod]) < self.max_workers: try: self.create_and_launch_worker(module_name=mod) # Maybe this modules is not a true worker one. # if so, just delete if from q_by_mod except NotWorkerMod: to_del.append(mod) break """ # Try to really adjust load if necessary if self.get_max_q_len(mod) > self.max_q_size: if len(self.q_by_mod[mod]) >= self.max_workers: logger.info("Cannot add a new %s worker, even if load is high. " "Consider changing your max_worker parameter") % mod else: try: self.create_and_launch_worker(module_name=mod) # Maybe this modules is not a true worker one. # if so, just delete if from q_by_mod except NotWorkerMod: to_del.append(mod) """ for mod in to_del: logger.debug("[%s] The module %s is not a worker one, " "I remove it from the worker list", self.name, mod) del self.q_by_mod[mod] # TODO: if len(workers) > 2*wish, maybe we can kill a worker? # Get the Queue() from an action by looking at which module # it wants with a round robin way to scale the load between # workers def _got_queue_from_action(self, a): # get the module name, if not, take fork mod = getattr(a, 'module_type', 'fork') queues = self.q_by_mod[mod].items() # Maybe there is no more queue, it's very bad! if len(queues) == 0: return (0, None) # if not get a round robin index to get a queue based # on the action id rr_idx = a.id % len(queues) (i, q) = queues[rr_idx] # return the id of the worker (i), and its queue return (i, q) # Add a list of actions to our queues def add_actions(self, lst, sched_id): for a in lst: # First we look if we do not already have it, if so # do nothing, we are already working! if a.id in self.schedulers[sched_id]['actions']: continue a.sched_id = sched_id a.status = 'queue' self.assign_to_a_queue(a) # Take an action and put it into one queue def assign_to_a_queue(self, a): msg = Message(id=0, type='Do', data=a) (i, q) = self._got_queue_from_action(a) # Tag the action as "in the worker i" a.worker_id = i if q is not None: q.put(msg) # Wrapper function for the real function def get_new_actions(self): _t = time.time() self.do_get_new_actions() _type = self.__class__.my_type statsmgr.timing('core.%s.get-new-actions' % _type, time.time() - _t, 'perf') # We get new actions from schedulers, we create a Message and we # put it in the s queue (from master to slave) # REF: doc/shinken-action-queues.png (1) def do_get_new_actions(self): # Here are the differences between a # poller and a reactionner: # Poller will only do checks, # reactionner do actions (notif + event handlers) do_checks = self.__class__.do_checks do_actions = self.__class__.do_actions # We check for new check in each schedulers and put the result in new_checks count = 0 for sched_id in self.schedulers: sched = self.schedulers[sched_id] # If sched is not active, I do not try return if not sched['active']: continue try: try: con = sched['con'] except KeyError: con = None if con is not None: # None = not initialized # OK, go for it :) # Before ask a call that can be long, do a simple ping to be sure it is alive con.get('ping') args = { 'do_checks': do_checks, 'do_actions': do_actions, 'poller_tags': self.poller_tags, 'reactionner_tags': self.reactionner_tags, 'worker_name': self.name, 'module_types': self.q_by_mod.keys(), } slots = self.get_available_slots() if slots is not None: args['max_actions'] = slots tmp = con.get('get_checks', args, wait='long') # Explicit pickle load tmp = base64.b64decode(tmp) tmp = zlib.decompress(tmp) tmp = cPickle.loads(str(tmp)) logger.debug("Ask actions to %d, got %d", sched_id, len(tmp)) # We 'tag' them with sched_id and put into queue for workers # REF: doc/shinken-action-queues.png (2) self.add_actions(tmp, sched_id) count += len(tmp) else: # no con? make the connection self.pynag_con_init(sched_id) # Ok, con is unknown, so we create it # Or maybe is the connection lost, we recreate it except (HTTPExceptions, KeyError), exp: logger.debug('get_new_actions exception:: %s,%s ', type(exp), str(exp)) self.pynag_con_init(sched_id) # scheduler must not be initialized # or scheduler must not have checks except AttributeError, exp: logger.debug('get_new_actions exception:: %s,%s ', type(exp), str(exp)) # What the F**k? We do not know what happened, # log the error message if possible. except Exception, exp: logger.error("A satellite raised an unknown exception: %s (%s)", exp, type(exp)) raise _type = self.__class__.my_type statsmgr.incr('core.%s.actions.in' % _type, count, 'queue') # Returns the maximim number of actions a satellite may accept, and ask # to the scheduler. def get_available_slots(self): # We limit the maximum number of actions to q_factor times the number of # allowed concurrent processes. if self.max_q_size > 0: slots = self.max_q_size elif self.q_factor > 0: slots = self.get_workers_count() * self.processes_by_worker slots *= self.q_factor else: # No limits return None actions = self.get_actions_queue_len() return max(0, slots - actions) # Returns the total number of elements contained in all the workers queues def get_actions_queue_len(self): actions = 0 for mod in self.q_by_mod: for q in self.q_by_mod[mod].values(): actions += q.qsize() return actions # Returns the number of registerred workers def get_workers_count(self): return len(self.workers) # In android we got a Queue, and a manager list for others def is_returns_queue_empty(self): return self.returns_queue.empty() # In android we got a Queue, and a manager list for others def get_returns_queue_len(self): return self.returns_queue.qsize() # In android we got a Queue, and a manager list for others def get_returns_queue_item(self): return self.returns_queue.get() # An arbiter ask us to wait a new conf, so we must clean # all the mess we did, and close modules too def clean_previous_run(self): # Clean all lists self.schedulers.clear() del self.broks[:] with self.external_commands_lock: self.external_commands = self.external_commands[:] def do_loop_turn(self): logger.debug("Loop turn") # Maybe the arbiter ask us to wait for a new conf # If true, we must restart all... if self.cur_conf is None: # Clean previous run from useless objects # and close modules self.clean_previous_run() self.wait_for_initial_conf() # we may have been interrupted or so; then # just return from this loop turn if not self.new_conf: return self.setup_new_conf() # Now we check if arbiter speak to us in the pyro_daemon. # If so, we listen to it # When it push a conf, we reinit connections # Sleep in waiting a new conf :) # TODO: manage the diff again. while self.timeout > 0: begin = time.time() self.watch_for_new_conf(self.timeout) end = time.time() if self.new_conf: if self.graceful_enabled and self.switch_process() is True: # Child successfully spawned, we're exiting return self.setup_new_conf() self.timeout = self.timeout - (end - begin) logger.debug(" ======================== ") self.timeout = self.polling_interval # Check if zombies workers are among us :) # If so: KILL THEM ALL!!! self.check_and_del_zombie_workers() # But also modules self.check_and_del_zombie_modules() # Print stats for debug for sched_id in self.schedulers: sched = self.schedulers[sched_id] for mod in self.q_by_mod: # In workers we've got actions send to queue - queue size for (i, q) in self.q_by_mod[mod].items(): logger.debug("[%d][%s][%s] Stats: Workers:%d (Queued:%d TotalReturnWait:%d)", sched_id, sched['name'], mod, i, q.qsize(), self.get_returns_queue_len()) # Before return or get new actions, see how we manage # old ones: are they still in queue (s)? If True, we # must wait more or at least have more workers _type = self.__class__.my_type wait_ratio = self.wait_ratio.get_load() total_q = 0 for mod in self.q_by_mod: for q in self.q_by_mod[mod].values(): total_q += q.qsize() if total_q != 0 and wait_ratio < 2 * self.polling_interval: logger.debug("I decide to up wait ratio") self.wait_ratio.update_load(wait_ratio * 2) # self.wait_ratio.update_load(self.polling_interval) else: # Go to self.polling_interval on normal run, if wait_ratio # was >2*self.polling_interval, # it make it come near 2 because if < 2, go up :) self.wait_ratio.update_load(self.polling_interval) wait_ratio = self.wait_ratio.get_load() logger.debug("Wait ratio: %f", wait_ratio) statsmgr.gauge('core.%s.wait-ratio' % _type, wait_ratio, 'queue') # We can wait more than 1s if needed, # no more than 5s, but no less than 1 timeout = self.timeout * wait_ratio timeout = max(self.polling_interval, timeout) self.timeout = min(5 * self.polling_interval, timeout) statsmgr.gauge('core.%s.timeout' % _type, self.timeout, 'queue') # Maybe we do not have enough workers, we check for it # and launch the new ones if needed self.adjust_worker_number_by_load() # Manage all messages we've got in the last timeout # for queue in self.return_messages: self.get_workers_results() # If we are passive, we do not initiate the check getting # and return if not self.passive: # Now we can get new actions from schedulers self.get_new_actions() # We send all finished checks # REF: doc/shinken-action-queues.png (6) self.manage_returns() # Get objects from our modules that are not worker based self.get_objects_from_from_queues() # Say to modules it's a new tick :) self.hook_point('tick') # Checks if memory consumption did not exceed allowed thresold self.check_memory_usage() def get_workers_results(self): while not self.is_returns_queue_empty(): item = self.get_returns_queue_item() self.manage_action_return(item) # Do this satellite (poller or reactionner) post "daemonize" init: # we must register our interfaces for 3 possible callers: arbiter, # schedulers or brokers. def do_post_daemon_init(self): # And we register them self.uri2 = self.http_daemon.register(self.interface) self.uri3 = self.http_daemon.register(self.brok_interface) self.uri4 = self.http_daemon.register(self.scheduler_interface) self.uri5 = self.http_daemon.register(self.istats) # self.s = Queue() # Global Master -> Slave # We can open the Queue for fork AFTER self.q_by_mod['fork'] = {} # Under Android, we do not have multiprocessing lib # so use standard Queue threads things # but in multiprocess, we are also using a Queue(). It's just # not the same if is_android: self.returns_queue = Queue() else: self.returns_queue = self.manager.Queue() # For multiprocess things, we should not have # socket timeouts. import socket socket.setdefaulttimeout(None) # Setup the new received conf from arbiter def setup_new_conf(self): conf = self.new_conf logger.debug("[%s] Sending us a configuration %s", self.name, conf) self.cur_conf = conf g_conf = conf['global'] # Got our name from the globals if 'poller_name' in g_conf: name = g_conf['poller_name'] service = 'poller' elif 'reactionner_name' in g_conf: name = g_conf['reactionner_name'] service = 'reactionner' else: name = 'Unnamed satellite' service = 'unknown' self.name = name # kernel.io part self.api_key = g_conf['api_key'] self.secret = g_conf['secret'] self.http_proxy = g_conf['http_proxy'] # local statsd self.statsd_host = g_conf['statsd_host'] self.statsd_port = g_conf['statsd_port'] self.statsd_prefix = g_conf['statsd_prefix'] self.statsd_enabled = g_conf['statsd_enabled'] self.statsd_interval = g_conf['statsd_interval'] self.statsd_types = g_conf['statsd_types'] self.statsd_pattern = g_conf['statsd_pattern'] self.harakiri_threshold = parse_memory_expr(g_conf['harakiri_threshold']) if self.harakiri_threshold is not None: self.raw_conf = self.new_conf else: self.raw_conf = None self.new_conf = None if self.aggressive_memory_management: free_memory() # we got a name, we can now say it to our statsmgr statsmgr.register(self, self.name, service, api_key=self.api_key, secret=self.secret, http_proxy=self.http_proxy, statsd_host=self.statsd_host, statsd_port=self.statsd_port, statsd_prefix=self.statsd_prefix, statsd_enabled=self.statsd_enabled, statsd_interval=self.statsd_interval, statsd_types=self.statsd_types, statsd_pattern=self.statsd_pattern) self.passive = g_conf['passive'] if self.passive: logger.info("[%s] Passive mode enabled.", self.name) # If we've got something in the schedulers, we do not want it anymore for sched_id in conf['schedulers']: already_got = False # We can already got this conf id, but with another address if sched_id in self.schedulers: new_addr = conf['schedulers'][sched_id]['address'] old_addr = self.schedulers[sched_id]['address'] new_port = conf['schedulers'][sched_id]['port'] old_port = self.schedulers[sched_id]['port'] # Should got all the same to be ok :) if new_addr == old_addr and new_port == old_port: already_got = True if already_got: logger.info("[%s] We already got the conf %d (%s)", self.name, sched_id, conf['schedulers'][sched_id]['name']) wait_homerun = self.schedulers[sched_id]['wait_homerun'] actions = self.schedulers[sched_id]['actions'] s = conf['schedulers'][sched_id] self.schedulers[sched_id] = s if s['name'] in g_conf['satellitemap']: s.update(g_conf['satellitemap'][s['name']]) proto = 'http' if s['use_ssl']: proto = 'https' uri = '%s://%s:%s/' % (proto, s['address'], s['port']) self.schedulers[sched_id]['uri'] = uri if already_got: self.schedulers[sched_id]['wait_homerun'] = wait_homerun self.schedulers[sched_id]['actions'] = actions else: self.schedulers[sched_id]['wait_homerun'] = [] self.schedulers[sched_id]['actions'] = {} self.schedulers[sched_id]['running_id'] = 0 self.schedulers[sched_id]['active'] = s['active'] self.schedulers[sched_id]['timeout'] = s['timeout'] self.schedulers[sched_id]['data_timeout'] = s['data_timeout'] # Do not connect if we are a passive satellite if not self.passive and not already_got: # And then we connect to it :) self.pynag_con_init(sched_id) # Now the limit part, 0 mean: number of cpu of this machine :) # if not available, use 4 (modern hardware) self.max_workers = g_conf['max_workers'] if self.max_workers == 0 and not is_android: try: self.max_workers = cpu_count() except NotImplementedError: self.max_workers = 4 logger.info("[%s] Using max workers: %s", self.name, self.max_workers) self.min_workers = g_conf['min_workers'] if self.min_workers == 0 and not is_android: try: self.min_workers = cpu_count() except NotImplementedError: self.min_workers = 4 logger.info("[%s] Using min workers: %s", self.name, self.min_workers) self.processes_by_worker = g_conf['processes_by_worker'] self.max_q_size = g_conf['max_q_size'] self.q_factor = g_conf['q_factor'] self.results_batch = g_conf['results_batch'] self.polling_interval = g_conf['polling_interval'] self.timeout = self.polling_interval # Now set tags # ['None'] is the default tags self.poller_tags = g_conf.get('poller_tags', ['None']) self.reactionner_tags = g_conf.get('reactionner_tags', ['None']) self.max_plugins_output_length = g_conf.get('max_plugins_output_length', 8192) # Set our giving timezone from arbiter use_timezone = g_conf['use_timezone'] if use_timezone != 'NOTSET': logger.info("[%s] Setting our timezone to %s", self.name, use_timezone) os.environ['TZ'] = use_timezone time.tzset() logger.info("We have our schedulers: %s", str(self.schedulers)) # Now manage modules # TODO: check how to better handle this with modules_manager.. mods = g_conf['modules'] for module in mods: # If we already got it, bypass if module.module_type not in self.q_by_mod: logger.debug("Add module object %s", str(module)) self.modules_manager.modules.append(module) logger.info("[%s] Got module: %s ", self.name, module.module_type) self.q_by_mod[module.module_type] = {} # Gets internal metrics for both statsd and def get_internal_metrics(self): _type = self.__class__.my_type # Queues metrics = [ ('core.%s.mem' % _type, get_memory(), 'system'), ('core.%s.workers' % _type, len(self.workers), 'system'), ('core.%s.external-commands.queue' % _type, len(self.external_commands), 'queue'), ('core.%s.broks.queue' % _type, len(self.broks), 'queue'), ('core.%s.results.queue' % _type, self.get_returns_queue_len(), 'queue'), ] actions = self.get_actions_queue_len() metrics.append(('core.%s.actions.queue' % _type, actions, 'queue')) return metrics # stats threads is asking us a main structure for stats def get_stats_struct(self): now = int(time.time()) # call the daemon one res = super(Satellite, self).get_stats_struct() _type = self.__class__.my_type res.update({'name': self.name, 'type': _type}) # The receiver do nto have a passie prop if hasattr(self, 'passive'): res['passive'] = self.passive # metrics specific metrics = res['metrics'] for metric in self.get_internal_metrics(): name, value, mtype = metric metrics.append(name, value, now, mtype) return res def main(self): try: for line in self.get_header(): logger.info(line) self.load_config_file() # Setting log level logger.setLevel(self.log_level) # Force the debug level if the daemon is said to start with such level if self.debug: logger.setLevel('DEBUG') # Look if we are enabled or not. If ok, start the daemon mode self.look_for_early_exit() self.load_parent_config() self.do_daemon_init_and_start() self.do_post_daemon_init() self.load_modules_manager() # We wait for initial conf self.wait_for_initial_conf() if not self.new_conf: # we must have either big problem or was requested to shutdown return self.setup_new_conf() # We can load our modules now self.modules_manager.set_modules(self.modules_manager.modules) self.do_load_modules() # And even start external ones self.modules_manager.start_external_instances() # Allocate Mortal Threads for _ in xrange(1, self.max_workers): to_del = [] for mod in self.q_by_mod: try: self.create_and_launch_worker(module_name=mod) # Maybe this modules is not a true worker one. # if so, just delete if from q_by_mod except NotWorkerMod: to_del.append(mod) for mod in to_del: logger.debug("The module %s is not a worker one, " "I remove it from the worker list", mod) del self.q_by_mod[mod] # Now main loop self.do_mainloop() except Exception: self.print_unrecoverable(traceback.format_exc()) raise
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 35, 9, 8937, 13, 7280, 26, 199, 3, 258, 598, 371, 397, 1603, 69, 290, 12, 302, 439, 285, 9405, 32, 6799, 14, 957, 199, 3, 258, 22261, 8726, 7964, 527, 332, 12, 22261, 8726, 14, 7833, 527, 332, 32, 388, 7873, 14, 271, 199, 3, 258, 29096, 1089, 1933, 285, 346, 12, 486, 14, 7848, 346, 32, 6799, 14, 957, 199, 3, 258, 869, 580, 6552, 3971, 2871, 352, 12, 394, 14, 1939, 2871, 352, 32, 1939, 2871, 352, 13, 8704, 427, 14, 271, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 5244, 30864, 14, 199, 3, 199, 3, 5244, 30864, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 5244, 30864, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 5244, 30864, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 199, 2765, 1021, 365, 376, 3217, 367, 799, 1287, 1372, 436, 8467, 1435, 11128, 83, 199, 33, 799, 1287, 1372, 1212, 1597, 561, 370, 282, 1844, 367, 314, 2897, 687, 314, 1952, 66, 1661, 199, 1918, 3743, 3509, 314, 8732, 2393, 2382, 1595, 8715, 911, 13082, 5445, 14, 199, 199, 1918, 799, 1287, 1372, 18578, 641, 22721, 370, 314, 1952, 66, 1661, 199, 8, 368, 282, 2653, 9, 199, 199, 3917, 1952, 66, 1661, 15061, 652, 370, 1172, 282, 892, 3743, 12, 314, 308, 24779, 19459, 83, 314, 4136, 199, 24317, 2393, 334, 460, 5445, 1901, 9, 436, 6181, 314, 892, 7869, 14, 199, 624, 4388, 199, 3, 7649, 370, 1937, 340, 781, 787, 315, 376, 15516, 2243, 503, 440, 199, 374, 63, 6238, 275, 715, 199, 893, 26, 272, 492, 15516, 199, 2590, 3545, 26, 272, 365, 63, 6238, 275, 756, 199, 199, 504, 10703, 492, 9630, 199, 199, 692, 440, 365, 63, 6238, 26, 272, 687, 12866, 492, 10703, 12, 4702, 63, 3223, 12, 5033, 63, 835, 199, 2836, 26, 272, 687, 10703, 492, 10703, 199, 199, 646, 747, 199, 646, 1331, 199, 646, 900, 199, 646, 17572, 199, 646, 5190, 199, 646, 12472, 199, 646, 1300, 772, 199, 646, 5796, 199, 199, 504, 1033, 30864, 14, 1014, 63, 1258, 492, 3101, 3041, 12, 3101, 16836, 199, 199, 504, 1033, 30864, 14, 1188, 492, 6430, 199, 504, 1033, 30864, 14, 6599, 492, 23886, 199, 504, 1033, 30864, 14, 912, 492, 7190, 199, 504, 1033, 30864, 14, 10824, 492, 577, 8770, 12, 14816, 199, 504, 1033, 30864, 14, 793, 492, 2512, 199, 504, 1033, 30864, 14, 1974, 492, 664, 63, 4844, 12, 2198, 63, 4844, 63, 3684, 12, 2867, 63, 4844, 199, 504, 1033, 30864, 14, 3200, 492, 5020, 7755, 421, 199, 3, 8089, 370, 11480, 626, 781, 787, 21625, 316, 282, 2222, 7239, 859, 199, 3, 1325, 282, 4465, 1373, 199, 533, 2832, 12678, 9871, 8, 1726, 304, 272, 986, 421, 199, 3, 14816, 367, 1952, 66, 1661, 12, 4154, 7282, 4828, 14471, 199, 3, 2779, 10557, 2739, 4154, 3743, 199, 533, 473, 1858, 1596, 66, 1661, 8, 4267, 304, 339, 1382, 275, 283, 5587, 282, 11899, 1950, 334, 4672, 3171, 272, 327, 1952, 66, 1661, 7198, 2739, 370, 886, 440, 9635, 282, 11899, 63, 344, 20827, 272, 327, 473, 886, 652, 436, 2793, 1133, 7198, 10842, 272, 347, 2813, 63, 504, 63, 2190, 8, 277, 12, 10286, 63, 344, 304, 267, 862, 26, 288, 2150, 291, 14, 571, 14, 7211, 2393, 59, 10487, 63, 344, 61, 267, 871, 4067, 26, 288, 986, 272, 2813, 63, 504, 63, 2190, 14, 1301, 275, 1382, 2378, 1382, 275, 283, 1767, 314, 12883, 2897, 2762, 334, 4672, 3171, 272, 327, 1952, 66, 1661, 7198, 562, 1314, 10286, 63, 344, 473, 9635, 12, 982, 652, 365, 440, 4112, 543, 652, 272, 327, 2779, 911, 7198, 562, 370, 2813, 1373, 503, 1655, 10286, 63, 344, 272, 347, 4052, 63, 73, 63, 11122, 8, 277, 304, 267, 2512, 14, 1757, 480, 1918, 601, 66, 1661, 20864, 562, 4052, 473, 9635, 14, 2779, 1159, 450, 83, 401, 291, 14, 571, 14, 10058, 63, 73, 63, 11122, 1012, 267, 372, 291, 14, 571, 14, 10058, 63, 73, 63, 11122, 342, 272, 4052, 63, 73, 63, 11122, 14, 9321, 63, 831, 275, 756, 272, 4052, 63, 73, 63, 11122, 14, 1301, 275, 1382, 339, 1382, 275, 283, 25525, 314, 11128, 370, 5978, 2399, 2897, 436, 3618, 367, 282, 892, 1373, 7, 272, 327, 6523, 701, 601, 66, 1661, 340, 652, 13516, 83, 781, 787, 3879, 1325, 781, 1471, 886, 440, 334, 2930, 272, 327, 340, 473, 1990, 282, 308, 4096, 626, 5452, 282, 3743, 1325, 314, 5288, 2529, 12, 473, 1471, 18833, 272, 327, 436, 3618, 282, 892, 3743, 9, 272, 327, 18482, 26, 3091, 8749, 1396, 272, 327, 1952, 66, 1661, 26, 473, 2793, 1133, 10296, 12, 18251, 1207, 1127, 373, 631, 65, 330, 17585, 1, 272, 327, 18482, 26, 2263, 25549, 20550, 1, 2136, 787, 12314, 1, 1265, 2793, 1133, 664, 652, 503, 4052, 10674, 272, 327, 799, 5384, 1233, 365, 440, 282, 3906, 367, 325, 5066, 1454, 1396, 272, 347, 3618, 63, 1222, 63, 2190, 8, 277, 304, 267, 2512, 14, 1757, 480, 1596, 66, 1661, 15061, 562, 370, 3618, 367, 282, 892, 2897, 531, 267, 291, 14, 571, 14, 7211, 2393, 14, 3584, 342, 267, 291, 14, 571, 14, 895, 63, 2190, 275, 488, 272, 3618, 63, 1222, 63, 2190, 14, 1301, 275, 1382, 2378, 1382, 275, 283, 10731, 330, 293, 6080 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 35, 9, 8937, 13, 7280, 26, 199, 3, 258, 598, 371, 397, 1603, 69, 290, 12, 302, 439, 285, 9405, 32, 6799, 14, 957, 199, 3, 258, 22261, 8726, 7964, 527, 332, 12, 22261, 8726, 14, 7833, 527, 332, 32, 388, 7873, 14, 271, 199, 3, 258, 29096, 1089, 1933, 285, 346, 12, 486, 14, 7848, 346, 32, 6799, 14, 957, 199, 3, 258, 869, 580, 6552, 3971, 2871, 352, 12, 394, 14, 1939, 2871, 352, 32, 1939, 2871, 352, 13, 8704, 427, 14, 271, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 5244, 30864, 14, 199, 3, 199, 3, 5244, 30864, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 5244, 30864, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 5244, 30864, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 199, 2765, 1021, 365, 376, 3217, 367, 799, 1287, 1372, 436, 8467, 1435, 11128, 83, 199, 33, 799, 1287, 1372, 1212, 1597, 561, 370, 282, 1844, 367, 314, 2897, 687, 314, 1952, 66, 1661, 199, 1918, 3743, 3509, 314, 8732, 2393, 2382, 1595, 8715, 911, 13082, 5445, 14, 199, 199, 1918, 799, 1287, 1372, 18578, 641, 22721, 370, 314, 1952, 66, 1661, 199, 8, 368, 282, 2653, 9, 199, 199, 3917, 1952, 66, 1661, 15061, 652, 370, 1172, 282, 892, 3743, 12, 314, 308, 24779, 19459, 83, 314, 4136, 199, 24317, 2393, 334, 460, 5445, 1901, 9, 436, 6181, 314, 892, 7869, 14, 199, 624, 4388, 199, 3, 7649, 370, 1937, 340, 781, 787, 315, 376, 15516, 2243, 503, 440, 199, 374, 63, 6238, 275, 715, 199, 893, 26, 272, 492, 15516, 199, 2590, 3545, 26, 272, 365, 63, 6238, 275, 756, 199, 199, 504, 10703, 492, 9630, 199, 199, 692, 440, 365, 63, 6238, 26, 272, 687, 12866, 492, 10703, 12, 4702, 63, 3223, 12, 5033, 63, 835, 199, 2836, 26, 272, 687, 10703, 492, 10703, 199, 199, 646, 747, 199, 646, 1331, 199, 646, 900, 199, 646, 17572, 199, 646, 5190, 199, 646, 12472, 199, 646, 1300, 772, 199, 646, 5796, 199, 199, 504, 1033, 30864, 14, 1014, 63, 1258, 492, 3101, 3041, 12, 3101, 16836, 199, 199, 504, 1033, 30864, 14, 1188, 492, 6430, 199, 504, 1033, 30864, 14, 6599, 492, 23886, 199, 504, 1033, 30864, 14, 912, 492, 7190, 199, 504, 1033, 30864, 14, 10824, 492, 577, 8770, 12, 14816, 199, 504, 1033, 30864, 14, 793, 492, 2512, 199, 504, 1033, 30864, 14, 1974, 492, 664, 63, 4844, 12, 2198, 63, 4844, 63, 3684, 12, 2867, 63, 4844, 199, 504, 1033, 30864, 14, 3200, 492, 5020, 7755, 421, 199, 3, 8089, 370, 11480, 626, 781, 787, 21625, 316, 282, 2222, 7239, 859, 199, 3, 1325, 282, 4465, 1373, 199, 533, 2832, 12678, 9871, 8, 1726, 304, 272, 986, 421, 199, 3, 14816, 367, 1952, 66, 1661, 12, 4154, 7282, 4828, 14471, 199, 3, 2779, 10557, 2739, 4154, 3743, 199, 533, 473, 1858, 1596, 66, 1661, 8, 4267, 304, 339, 1382, 275, 283, 5587, 282, 11899, 1950, 334, 4672, 3171, 272, 327, 1952, 66, 1661, 7198, 2739, 370, 886, 440, 9635, 282, 11899, 63, 344, 20827, 272, 327, 473, 886, 652, 436, 2793, 1133, 7198, 10842, 272, 347, 2813, 63, 504, 63, 2190, 8, 277, 12, 10286, 63, 344, 304, 267, 862, 26, 288, 2150, 291, 14, 571, 14, 7211, 2393, 59, 10487, 63, 344, 61, 267, 871, 4067, 26, 288, 986, 272, 2813, 63, 504, 63, 2190, 14, 1301, 275, 1382, 2378, 1382, 275, 283, 1767, 314, 12883, 2897, 2762, 334, 4672, 3171, 272, 327, 1952, 66, 1661, 7198, 562, 1314, 10286, 63, 344, 473, 9635, 12, 982, 652, 365, 440, 4112, 543, 652, 272, 327, 2779, 911, 7198, 562, 370, 2813, 1373, 503, 1655, 10286, 63, 344, 272, 347, 4052, 63, 73, 63, 11122, 8, 277, 304, 267, 2512, 14, 1757, 480, 1918, 601, 66, 1661, 20864, 562, 4052, 473, 9635, 14, 2779, 1159, 450, 83, 401, 291, 14, 571, 14, 10058, 63, 73, 63, 11122, 1012, 267, 372, 291, 14, 571, 14, 10058, 63, 73, 63, 11122, 342, 272, 4052, 63, 73, 63, 11122, 14, 9321, 63, 831, 275, 756, 272, 4052, 63, 73, 63, 11122, 14, 1301, 275, 1382, 339, 1382, 275, 283, 25525, 314, 11128, 370, 5978, 2399, 2897, 436, 3618, 367, 282, 892, 1373, 7, 272, 327, 6523, 701, 601, 66, 1661, 340, 652, 13516, 83, 781, 787, 3879, 1325, 781, 1471, 886, 440, 334, 2930, 272, 327, 340, 473, 1990, 282, 308, 4096, 626, 5452, 282, 3743, 1325, 314, 5288, 2529, 12, 473, 1471, 18833, 272, 327, 436, 3618, 282, 892, 3743, 9, 272, 327, 18482, 26, 3091, 8749, 1396, 272, 327, 1952, 66, 1661, 26, 473, 2793, 1133, 10296, 12, 18251, 1207, 1127, 373, 631, 65, 330, 17585, 1, 272, 327, 18482, 26, 2263, 25549, 20550, 1, 2136, 787, 12314, 1, 1265, 2793, 1133, 664, 652, 503, 4052, 10674, 272, 327, 799, 5384, 1233, 365, 440, 282, 3906, 367, 325, 5066, 1454, 1396, 272, 347, 3618, 63, 1222, 63, 2190, 8, 277, 304, 267, 2512, 14, 1757, 480, 1596, 66, 1661, 15061, 562, 370, 3618, 367, 282, 892, 2897, 531, 267, 291, 14, 571, 14, 7211, 2393, 14, 3584, 342, 267, 291, 14, 571, 14, 895, 63, 2190, 275, 488, 272, 3618, 63, 1222, 63, 2190, 14, 1301, 275, 1382, 2378, 1382, 275, 283, 10731, 330, 293, 6080, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
miltonruelas/cursotecnico
branch/l10n_py_vat/base_vat.py
4
2023
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (c) 2011 Cubic ERP - Teradata SAC. (http://cubicerp.com). # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsability of assessing all potential # consequences resulting from its eventual inadequacies and bugs # End users who are looking for a ready-to-use solution with commercial # garantees and support are strongly adviced to contract a Free Software # Service Company # # This program is Free Software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## import string from osv import osv, fields from tools.translate import _ class res_partner(osv.osv): _inherit = 'res.partner' def check_vat_py(self, vat): ruc = '' basemax = 11 for c in str(vat).replace('-', ''): ruc += c.isdigit() and c or str(ord(c)) k = 2 total = 0 for c in reversed(ruc[:-1]): n = int(c) if n > basemax: k = 2 total += n * k k += 1 resto = total % basemax if resto > 1: n = basemax - resto else: n = 0 return n == int(ruc[-1])
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 1898, 334, 67, 9, 7760, 445, 456, 530, 221, 6758, 446, 13861, 1517, 428, 1348, 14, 334, 1014, 921, 18455, 530, 281, 80, 14, 957, 680, 199, 3, 199, 3, 14750, 26, 961, 2240, 465, 4066, 365, 11619, 370, 506, 1202, 701, 22398, 28661, 199, 3, 2240, 16465, 3963, 5452, 314, 8852, 9163, 83, 3616, 402, 465, 5480, 316, 1006, 12330, 199, 3, 406, 13436, 9183, 687, 2399, 1566, 1061, 315, 9587, 27164, 2578, 436, 18227, 199, 3, 9599, 4390, 3963, 787, 10023, 367, 282, 10144, 13, 475, 13, 1180, 8744, 543, 2414, 23012, 199, 3, 486, 10475, 397, 436, 2291, 787, 30390, 1503, 722, 68, 370, 16077, 282, 2868, 2290, 199, 3, 7591, 15878, 199, 3, 199, 3, 961, 2240, 365, 2868, 2290, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 446, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 12, 8217, 14, 199, 3, 199, 4605, 199, 199, 646, 1059, 199, 199, 504, 9506, 492, 9506, 12, 1504, 199, 504, 7249, 14, 5275, 492, 485, 199, 199, 533, 522, 63, 3899, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 283, 470, 14, 3899, 7, 339, 347, 1104, 63, 16305, 63, 647, 8, 277, 12, 373, 292, 304, 267, 519, 947, 275, 2125, 267, 1300, 988, 275, 4119, 267, 367, 286, 315, 620, 8, 16305, 680, 1814, 13858, 21019, 288, 519, 947, 847, 286, 14, 13896, 342, 436, 286, 503, 620, 8, 2181, 8, 67, 430, 267, 1022, 275, 499, 267, 3141, 275, 378, 267, 367, 286, 315, 10822, 8, 82, 947, 4439, 17, 4682, 288, 302, 275, 1109, 8, 67, 9, 288, 340, 302, 690, 1300, 988, 26, 355, 1022, 275, 499, 288, 3141, 847, 302, 627, 1022, 288, 1022, 847, 413, 267, 4618, 79, 275, 3141, 450, 1300, 988, 267, 340, 4618, 79, 690, 413, 26, 288, 302, 275, 1300, 988, 446, 4618, 79, 267, 587, 26, 288, 302, 275, 378, 267, 372, 302, 508, 1109, 8, 82, 947, 1988, 17, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 1898, 334, 67, 9, 7760, 445, 456, 530, 221, 6758, 446, 13861, 1517, 428, 1348, 14, 334, 1014, 921, 18455, 530, 281, 80, 14, 957, 680, 199, 3, 199, 3, 14750, 26, 961, 2240, 465, 4066, 365, 11619, 370, 506, 1202, 701, 22398, 28661, 199, 3, 2240, 16465, 3963, 5452, 314, 8852, 9163, 83, 3616, 402, 465, 5480, 316, 1006, 12330, 199, 3, 406, 13436, 9183, 687, 2399, 1566, 1061, 315, 9587, 27164, 2578, 436, 18227, 199, 3, 9599, 4390, 3963, 787, 10023, 367, 282, 10144, 13, 475, 13, 1180, 8744, 543, 2414, 23012, 199, 3, 486, 10475, 397, 436, 2291, 787, 30390, 1503, 722, 68, 370, 16077, 282, 2868, 2290, 199, 3, 7591, 15878, 199, 3, 199, 3, 961, 2240, 365, 2868, 2290, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 446, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 12, 8217, 14, 199, 3, 199, 4605, 199, 199, 646, 1059, 199, 199, 504, 9506, 492, 9506, 12, 1504, 199, 504, 7249, 14, 5275, 492, 485, 199, 199, 533, 522, 63, 3899, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 283, 470, 14, 3899, 7, 339, 347, 1104, 63, 16305, 63, 647, 8, 277, 12, 373, 292, 304, 267, 519, 947, 275, 2125, 267, 1300, 988, 275, 4119, 267, 367, 286, 315, 620, 8, 16305, 680, 1814, 13858, 21019, 288, 519, 947, 847, 286, 14, 13896, 342, 436, 286, 503, 620, 8, 2181, 8, 67, 430, 267, 1022, 275, 499, 267, 3141, 275, 378, 267, 367, 286, 315, 10822, 8, 82, 947, 4439, 17, 4682, 288, 302, 275, 1109, 8, 67, 9, 288, 340, 302, 690, 1300, 988, 26, 355, 1022, 275, 499, 288, 3141, 847, 302, 627, 1022, 288, 1022, 847, 413, 267, 4618, 79, 275, 3141, 450, 1300, 988, 267, 340, 4618, 79, 690, 413, 26, 288, 302, 275, 1300, 988, 446, 4618, 79, 267, 587, 26, 288, 302, 275, 378, 267, 372, 302, 508, 1109, 8, 82, 947, 1988, 17, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
google/llvm-propeller
lldb/test/API/functionalities/multidebugger_commands/TestMultipleDebuggersCommands.py
13
1694
""" Test that commands do not try and hold on to stale CommandInterpreters in a multiple debuggers scenario """ from __future__ import print_function import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil class MultipleDebuggersCommandsTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @no_debug_info_test def test_multipledebuggers_commands(self): """Test that commands do not try and hold on to stale CommandInterpreters in a multiple debuggers scenario""" source_init_files = False magic_text = "The following commands may relate to 'env'" debugger_1 = lldb.SBDebugger.Create(source_init_files) interpreter_1 = debugger_1.GetCommandInterpreter() retobj = lldb.SBCommandReturnObject() interpreter_1.HandleCommand("apropos env", retobj) self.assertTrue( magic_text in str(retobj), "[interpreter_1]: the output does not contain the correct words") if self.TraceOn(): print(str(retobj)) lldb.SBDebugger.Destroy(debugger_1) # now do this again with a different debugger - we shouldn't crash debugger_2 = lldb.SBDebugger.Create(source_init_files) interpreter_2 = debugger_2.GetCommandInterpreter() retobj = lldb.SBCommandReturnObject() interpreter_2.HandleCommand("apropos env", retobj) self.assertTrue( magic_text in str(retobj), "[interpreter_2]: the output does not contain the correct words") if self.TraceOn(): print(str(retobj)) lldb.SBDebugger.Destroy(debugger_2)
apache-2.0
[ 624, 199, 774, 626, 3718, 886, 440, 862, 436, 10266, 641, 370, 20149, 5817, 2620, 657, 878, 315, 282, 3663, 14958, 83, 15728, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 421, 199, 646, 634, 15793, 199, 504, 634, 15793, 5768, 14, 396, 14, 11582, 492, 627, 199, 504, 634, 15793, 5768, 14, 396, 14, 914, 697, 396, 492, 627, 199, 504, 634, 15793, 5768, 14, 396, 492, 634, 1447, 464, 2270, 421, 199, 533, 14326, 31521, 83, 14680, 1746, 8, 14440, 304, 339, 3002, 694, 275, 1379, 1563, 14, 3357, 63, 1662, 694, 3460, 493, 3368, 339, 768, 889, 63, 1757, 63, 815, 63, 396, 272, 347, 511, 63, 6048, 17612, 83, 63, 4405, 8, 277, 304, 267, 408, 774, 626, 3718, 886, 440, 862, 436, 10266, 641, 370, 20149, 5817, 2620, 657, 878, 315, 282, 3663, 14958, 83, 15728, 624, 267, 1350, 63, 826, 63, 1725, 275, 756, 267, 10628, 63, 505, 275, 298, 1918, 2569, 3718, 1443, 295, 750, 370, 283, 1813, 4065, 398, 14958, 63, 17, 275, 634, 15793, 14, 12463, 31521, 14, 2499, 8, 1365, 63, 826, 63, 1725, 9, 267, 12693, 63, 17, 275, 14958, 63, 17, 14, 1002, 3110, 2620, 26499, 342, 398, 295, 475, 468, 275, 634, 15793, 14, 12463, 3110, 1767, 1692, 342, 267, 12693, 63, 17, 14, 5940, 3110, 480, 30204, 1712, 2589, 401, 295, 475, 468, 9, 267, 291, 14, 1815, 8, 288, 10628, 63, 505, 315, 620, 8, 264, 475, 468, 395, 288, 7369, 20244, 63, 17, 2189, 314, 1072, 1630, 440, 1395, 314, 3211, 5932, 531, 398, 340, 291, 14, 3921, 3314, 837, 288, 870, 8, 495, 8, 264, 475, 468, 430, 398, 634, 15793, 14, 12463, 31521, 14, 14704, 8, 17612, 63, 17, 9, 398, 327, 3063, 886, 642, 4020, 543, 282, 3365, 14958, 446, 781, 9296, 1133, 12420, 398, 14958, 63, 18, 275, 634, 15793, 14, 12463, 31521, 14, 2499, 8, 1365, 63, 826, 63, 1725, 9, 267, 12693, 63, 18, 275, 14958, 63, 18, 14, 1002, 3110, 2620, 26499, 342, 398, 295, 475, 468, 275, 634, 15793, 14, 12463, 3110, 1767, 1692, 342, 267, 12693, 63, 18, 14, 5940, 3110, 480, 30204, 1712, 2589, 401, 295, 475, 468, 9, 267, 291, 14, 1815, 8, 288, 10628, 63, 505, 315, 620, 8, 264, 475, 468, 395, 288, 7369, 20244, 63, 18, 2189, 314, 1072, 1630, 440, 1395, 314, 3211, 5932, 531, 398, 340, 291, 14, 3921, 3314, 837, 288, 870, 8, 495, 8, 264, 475, 468, 430, 398, 634, 15793, 14, 12463, 31521, 14, 14704, 8, 17612, 63, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 774, 626, 3718, 886, 440, 862, 436, 10266, 641, 370, 20149, 5817, 2620, 657, 878, 315, 282, 3663, 14958, 83, 15728, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 421, 199, 646, 634, 15793, 199, 504, 634, 15793, 5768, 14, 396, 14, 11582, 492, 627, 199, 504, 634, 15793, 5768, 14, 396, 14, 914, 697, 396, 492, 627, 199, 504, 634, 15793, 5768, 14, 396, 492, 634, 1447, 464, 2270, 421, 199, 533, 14326, 31521, 83, 14680, 1746, 8, 14440, 304, 339, 3002, 694, 275, 1379, 1563, 14, 3357, 63, 1662, 694, 3460, 493, 3368, 339, 768, 889, 63, 1757, 63, 815, 63, 396, 272, 347, 511, 63, 6048, 17612, 83, 63, 4405, 8, 277, 304, 267, 408, 774, 626, 3718, 886, 440, 862, 436, 10266, 641, 370, 20149, 5817, 2620, 657, 878, 315, 282, 3663, 14958, 83, 15728, 624, 267, 1350, 63, 826, 63, 1725, 275, 756, 267, 10628, 63, 505, 275, 298, 1918, 2569, 3718, 1443, 295, 750, 370, 283, 1813, 4065, 398, 14958, 63, 17, 275, 634, 15793, 14, 12463, 31521, 14, 2499, 8, 1365, 63, 826, 63, 1725, 9, 267, 12693, 63, 17, 275, 14958, 63, 17, 14, 1002, 3110, 2620, 26499, 342, 398, 295, 475, 468, 275, 634, 15793, 14, 12463, 3110, 1767, 1692, 342, 267, 12693, 63, 17, 14, 5940, 3110, 480, 30204, 1712, 2589, 401, 295, 475, 468, 9, 267, 291, 14, 1815, 8, 288, 10628, 63, 505, 315, 620, 8, 264, 475, 468, 395, 288, 7369, 20244, 63, 17, 2189, 314, 1072, 1630, 440, 1395, 314, 3211, 5932, 531, 398, 340, 291, 14, 3921, 3314, 837, 288, 870, 8, 495, 8, 264, 475, 468, 430, 398, 634, 15793, 14, 12463, 31521, 14, 14704, 8, 17612, 63, 17, 9, 398, 327, 3063, 886, 642, 4020, 543, 282, 3365, 14958, 446, 781, 9296, 1133, 12420, 398, 14958, 63, 18, 275, 634, 15793, 14, 12463, 31521, 14, 2499, 8, 1365, 63, 826, 63, 1725, 9, 267, 12693, 63, 18, 275, 14958, 63, 18, 14, 1002, 3110, 2620, 26499, 342, 398, 295, 475, 468, 275, 634, 15793, 14, 12463, 3110, 1767, 1692, 342, 267, 12693, 63, 18, 14, 5940, 3110, 480, 30204, 1712, 2589, 401, 295, 475, 468, 9, 267, 291, 14, 1815, 8, 288, 10628, 63, 505, 315, 620, 8, 264, 475, 468, 395, 288, 7369, 20244, 63, 18, 2189, 314, 1072, 1630, 440, 1395, 314, 3211, 5932, 531, 398, 340, 291, 14, 3921, 3314, 837, 288, 870, 8, 495, 8, 264, 475, 468, 430, 398, 634, 15793, 14, 12463, 31521, 14, 14704, 8, 17612, 63, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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0, 0, 0, 0, 0 ]
nkhuyu/SFrame
cxxtest/python/python3/cxxtest/cxxtestgen.py
48
23783
#------------------------------------------------------------------------- # CxxTest: A lightweight C++ unit testing library. # Copyright (c) 2008 Sandia Corporation. # This software is distributed under the LGPL License v3 # For more information, see the COPYING file in the top CxxTest directory. # Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, # the U.S. Government retains certain rights in this software. #------------------------------------------------------------------------- # vim: fileencoding=utf-8 # the above import important for forward-compatibility with python3, # which is already the default in archlinux! __all__ = ['main', 'create_manpage'] from . import __release__ import os import sys import re import glob from optparse import OptionParser from . import cxxtest_parser from string import Template try: from . import cxxtest_fog imported_fog=True except ImportError: imported_fog=False from .cxxtest_misc import abort try: from os.path import relpath except ImportError: from .cxxtest_misc import relpath # Global data is initialized by main() options = [] suites = [] wrotePreamble = 0 wroteWorld = 0 lastIncluded = '' def main(args=sys.argv, catch=False): '''The main program''' # # Reset global state # global wrotePreamble wrotePreamble=0 global wroteWorld wroteWorld=0 global lastIncluded lastIncluded = '' global suites suites = [] global options options = [] # try: files = parseCommandline(args) if imported_fog and options.fog: [options,suites] = cxxtest_fog.scanInputFiles( files, options ) else: [options,suites] = cxxtest_parser.scanInputFiles( files, options ) writeOutput() except SystemExit: if not catch: raise def create_parser(asciidoc=False): parser = OptionParser("cxxtestgen [options] [<filename> ...]") if asciidoc: parser.description="The cxxtestgen command processes C++ header files to perform test discovery, and then it creates files for the CxxTest test runner." else: parser.description="The 'cxxtestgen' command processes C++ header files to perform test discovery, and then it creates files for the 'CxxTest' test runner." parser.add_option("--version", action="store_true", dest="version", default=False, help="Write the CxxTest version.") parser.add_option("-o", "--output", dest="outputFileName", default=None, metavar="NAME", help="Write output to file NAME.") parser.add_option("-w","--world", dest="world", default="cxxtest", help="The label of the tests, used to name the XML results.") parser.add_option("", "--include", action="append", dest="headers", default=[], metavar="HEADER", help="Include file HEADER in the test runner before other headers.") parser.add_option("", "--abort-on-fail", action="store_true", dest="abortOnFail", default=False, help="Abort tests on failed asserts (like xUnit).") parser.add_option("", "--main", action="store", dest="main", default="main", help="Specify an alternative name for the main() function.") parser.add_option("", "--headers", action="store", dest="header_filename", default=None, help="Specify a filename that contains a list of header files that are processed to generate a test runner.") parser.add_option("", "--runner", dest="runner", default="", metavar="CLASS", help="Create a test runner that processes test events using the class CxxTest::CLASS.") parser.add_option("", "--gui", dest="gui", metavar="CLASS", help="Create a GUI test runner that processes test events using the class CxxTest::CLASS. (deprecated)") parser.add_option("", "--error-printer", action="store_true", dest="error_printer", default=False, help="Create a test runner using the ErrorPrinter class, and allow the use of the standard library.") parser.add_option("", "--xunit-printer", action="store_true", dest="xunit_printer", default=False, help="Create a test runner using the XUnitPrinter class.") parser.add_option("", "--xunit-file", dest="xunit_file", default="", help="The file to which the XML summary is written for test runners using the XUnitPrinter class. The default XML filename is TEST-<world>.xml, where <world> is the value of the --world option. (default: cxxtest)") parser.add_option("", "--have-std", action="store_true", dest="haveStandardLibrary", default=False, help="Use the standard library (even if not found in tests).") parser.add_option("", "--no-std", action="store_true", dest="noStandardLibrary", default=False, help="Do not use standard library (even if found in tests).") parser.add_option("", "--have-eh", action="store_true", dest="haveExceptionHandling", default=False, help="Use exception handling (even if not found in tests).") parser.add_option("", "--no-eh", action="store_true", dest="noExceptionHandling", default=False, help="Do not use exception handling (even if found in tests).") parser.add_option("", "--longlong", dest="longlong", default=None, metavar="TYPE", help="Use TYPE as for long long integers. (default: not supported)") parser.add_option("", "--no-static-init", action="store_true", dest="noStaticInit", default=False, help="Do not rely on static initialization in the test runner.") parser.add_option("", "--template", dest="templateFileName", default=None, metavar="TEMPLATE", help="Generate the test runner using file TEMPLATE to define a template.") parser.add_option("", "--root", action="store_true", dest="root", default=False, help="Write the main() function and global data for a test runner.") parser.add_option("", "--part", action="store_true", dest="part", default=False, help="Write the tester classes for a test runner.") #parser.add_option("", "--factor", #action="store_true", dest="factor", default=False, #help="Declare the _CXXTEST_FACTOR macro. (deprecated)") if imported_fog: fog_help = "Use new FOG C++ parser" else: fog_help = "Use new FOG C++ parser (disabled)" parser.add_option("-f", "--fog-parser", action="store_true", dest="fog", default=False, help=fog_help ) return parser def parseCommandline(args): '''Analyze command line arguments''' global imported_fog global options parser = create_parser() (options, args) = parser.parse_args(args=args) if not options.header_filename is None: if not os.path.exists(options.header_filename): abort( "ERROR: the file '%s' does not exist!" % options.header_filename ) INPUT = open(options.header_filename) headers = [line.strip() for line in INPUT] args.extend( headers ) INPUT.close() if options.fog and not imported_fog: abort( "Cannot use the FOG parser. Check that the 'ply' package is installed. The 'ordereddict' package is also required if running Python 2.6") if options.version: printVersion() # the cxxtest builder relies on this behaviour! don't remove if options.runner == 'none': options.runner = None if options.xunit_printer or options.runner == "XUnitPrinter": options.xunit_printer=True options.runner="XUnitPrinter" if len(args) > 1: if options.xunit_file == "": if options.world == "": options.world = "cxxtest" options.xunit_file="TEST-"+options.world+".xml" elif options.xunit_file == "": if options.world == "": options.world = "cxxtest" options.xunit_file="TEST-"+options.world+".xml" if options.error_printer: options.runner= "ErrorPrinter" options.haveStandardLibrary = True if options.noStaticInit and (options.root or options.part): abort( '--no-static-init cannot be used with --root/--part' ) if options.gui and not options.runner: options.runner = 'StdioPrinter' files = setFiles(args[1:]) if len(files) == 0 and not options.root: sys.stderr.write(parser.error("No input files found")) return files def printVersion(): '''Print CxxTest version and exit''' sys.stdout.write( "This is CxxTest version %s.\n" % __release__.__version__ ) sys.exit(0) def setFiles(patterns ): '''Set input files specified on command line''' files = expandWildcards( patterns ) return files def expandWildcards( patterns ): '''Expand all wildcards in an array (glob)''' fileNames = [] for pathName in patterns: patternFiles = glob.glob( pathName ) for fileName in patternFiles: fileNames.append( fixBackslashes( fileName ) ) return fileNames def fixBackslashes( fileName ): '''Convert backslashes to slashes in file name''' return re.sub( r'\\', '/', fileName, 0 ) def writeOutput(): '''Create output file''' if options.templateFileName: writeTemplateOutput() else: writeSimpleOutput() def writeSimpleOutput(): '''Create output not based on template''' output = startOutputFile() writePreamble( output ) if options.root or not options.part: writeMain( output ) if len(suites) > 0: output.write("bool "+suites[0]['object']+"_init = false;\n") writeWorld( output ) output.close() include_re = re.compile( r"\s*\#\s*include\s+<cxxtest/" ) preamble_re = re.compile( r"^\s*<CxxTest\s+preamble>\s*$" ) world_re = re.compile( r"^\s*<CxxTest\s+world>\s*$" ) def writeTemplateOutput(): '''Create output based on template file''' template = open(options.templateFileName) output = startOutputFile() while 1: line = template.readline() if not line: break; if include_re.search( line ): writePreamble( output ) output.write( line ) elif preamble_re.search( line ): writePreamble( output ) elif world_re.search( line ): if len(suites) > 0: output.write("bool "+suites[0]['object']+"_init = false;\n") writeWorld( output ) else: output.write( line ) template.close() output.close() def startOutputFile(): '''Create output file and write header''' if options.outputFileName is not None: output = open( options.outputFileName, 'w' ) else: output = sys.stdout output.write( "/* Generated file, do not edit */\n\n" ) return output def writePreamble( output ): '''Write the CxxTest header (#includes and #defines)''' global wrotePreamble if wrotePreamble: return output.write( "#ifndef CXXTEST_RUNNING\n" ) output.write( "#define CXXTEST_RUNNING\n" ) output.write( "#endif\n" ) output.write( "\n" ) if options.xunit_printer: output.write( "#include <fstream>\n" ) if options.haveStandardLibrary: output.write( "#define _CXXTEST_HAVE_STD\n" ) if options.haveExceptionHandling: output.write( "#define _CXXTEST_HAVE_EH\n" ) if options.abortOnFail: output.write( "#define _CXXTEST_ABORT_TEST_ON_FAIL\n" ) if options.longlong: output.write( "#define _CXXTEST_LONGLONG %s\n" % options.longlong ) #if options.factor: #output.write( "#define _CXXTEST_FACTOR\n" ) for header in options.headers: output.write( "#include \"%s\"\n" % header ) output.write( "#include <cxxtest/TestListener.h>\n" ) output.write( "#include <cxxtest/TestTracker.h>\n" ) output.write( "#include <cxxtest/TestRunner.h>\n" ) output.write( "#include <cxxtest/RealDescriptions.h>\n" ) output.write( "#include <cxxtest/TestMain.h>\n" ) if options.runner: output.write( "#include <cxxtest/%s.h>\n" % options.runner ) if options.gui: output.write( "#include <cxxtest/%s.h>\n" % options.gui ) output.write( "\n" ) wrotePreamble = 1 def writeMain( output ): '''Write the main() function for the test runner''' if not (options.gui or options.runner): return output.write( 'int %s( int argc, char *argv[] ) {\n' % options.main ) output.write( ' int status;\n' ) if options.noStaticInit: output.write( ' CxxTest::initialize();\n' ) if options.gui: tester_t = "CxxTest::GuiTuiRunner<CxxTest::%s, CxxTest::%s> " % (options.gui, options.runner) else: tester_t = "CxxTest::%s" % (options.runner) if options.xunit_printer: output.write( ' std::ofstream ofstr("%s");\n' % options.xunit_file ) output.write( ' %s tmp(ofstr);\n' % tester_t ) else: output.write( ' %s tmp;\n' % tester_t ) output.write( ' CxxTest::RealWorldDescription::_worldName = "%s";\n' % options.world ) output.write( ' status = CxxTest::Main< %s >( tmp, argc, argv );\n' % tester_t ) output.write( ' return status;\n') output.write( '}\n' ) def writeWorld( output ): '''Write the world definitions''' global wroteWorld if wroteWorld: return writePreamble( output ) writeSuites( output ) if options.root or not options.part: writeRoot( output ) writeWorldDescr( output ) if options.noStaticInit: writeInitialize( output ) wroteWorld = 1 def writeSuites(output): '''Write all TestDescriptions and SuiteDescriptions''' for suite in suites: writeInclude( output, suite['file'] ) if isGenerated(suite): generateSuite( output, suite ) if not options.noStaticInit: if isDynamic(suite): writeSuitePointer( output, suite ) else: writeSuiteObject( output, suite ) writeTestList( output, suite ) writeSuiteDescription( output, suite ) writeTestDescriptions( output, suite ) def isGenerated(suite): '''Checks whether a suite class should be created''' return suite['generated'] def isDynamic(suite): '''Checks whether a suite is dynamic''' return 'create' in suite def writeInclude(output, file): '''Add #include "file" statement''' global lastIncluded if options.outputFileName: dirname = os.path.split(options.outputFileName)[0] tfile = relpath(file, dirname) if os.path.exists(tfile): if tfile == lastIncluded: return output.writelines( [ '#include "', tfile, '"\n\n' ] ) lastIncluded = tfile return # # Use an absolute path if the relative path failed # tfile = os.path.abspath(file) if os.path.exists(tfile): if tfile == lastIncluded: return output.writelines( [ '#include "', tfile, '"\n\n' ] ) lastIncluded = tfile return def generateSuite( output, suite ): '''Write a suite declared with CXXTEST_SUITE()''' output.write( 'class %s : public CxxTest::TestSuite {\n' % suite['fullname'] ) output.write( 'public:\n' ) for line in suite['lines']: output.write(line) output.write( '};\n\n' ) def writeSuitePointer( output, suite ): '''Create static suite pointer object for dynamic suites''' if options.noStaticInit: output.write( 'static %s* %s;\n\n' % (suite['fullname'], suite['object']) ) else: output.write( 'static %s* %s = 0;\n\n' % (suite['fullname'], suite['object']) ) def writeSuiteObject( output, suite ): '''Create static suite object for non-dynamic suites''' output.writelines( [ "static ", suite['fullname'], " ", suite['object'], ";\n\n" ] ) def writeTestList( output, suite ): '''Write the head of the test linked list for a suite''' if options.noStaticInit: output.write( 'static CxxTest::List %s;\n' % suite['tlist'] ) else: output.write( 'static CxxTest::List %s = { 0, 0 };\n' % suite['tlist'] ) def writeWorldDescr( output ): '''Write the static name of the world name''' if options.noStaticInit: output.write( 'const char* CxxTest::RealWorldDescription::_worldName;\n' ) else: output.write( 'const char* CxxTest::RealWorldDescription::_worldName = "cxxtest";\n' ) def writeTestDescriptions( output, suite ): '''Write all test descriptions for a suite''' for test in suite['tests']: writeTestDescription( output, suite, test ) def writeTestDescription( output, suite, test ): '''Write test description object''' if not options.noStaticInit: output.write( 'static class %s : public CxxTest::RealTestDescription {\n' % test['class'] ) else: output.write( 'class %s : public CxxTest::RealTestDescription {\n' % test['class'] ) # output.write( 'public:\n' ) if not options.noStaticInit: output.write( ' %s() : CxxTest::RealTestDescription( %s, %s, %s, "%s" ) {}\n' % (test['class'], suite['tlist'], suite['dobject'], test['line'], test['name']) ) else: if isDynamic(suite): output.write( ' %s(%s* _%s) : %s(_%s) { }\n' % (test['class'], suite['fullname'], suite['object'], suite['object'], suite['object']) ) output.write( ' %s* %s;\n' % (suite['fullname'], suite['object']) ) else: output.write( ' %s(%s& _%s) : %s(_%s) { }\n' % (test['class'], suite['fullname'], suite['object'], suite['object'], suite['object']) ) output.write( ' %s& %s;\n' % (suite['fullname'], suite['object']) ) output.write( ' void runTest() { %s }\n' % runBody( suite, test ) ) # if not options.noStaticInit: output.write( '} %s;\n\n' % test['object'] ) else: output.write( '};\n\n' ) def runBody( suite, test ): '''Body of TestDescription::run()''' if isDynamic(suite): return dynamicRun( suite, test ) else: return staticRun( suite, test ) def dynamicRun( suite, test ): '''Body of TestDescription::run() for test in a dynamic suite''' return 'if ( ' + suite['object'] + ' ) ' + suite['object'] + '->' + test['name'] + '();' def staticRun( suite, test ): '''Body of TestDescription::run() for test in a non-dynamic suite''' return suite['object'] + '.' + test['name'] + '();' def writeSuiteDescription( output, suite ): '''Write SuiteDescription object''' if isDynamic( suite ): writeDynamicDescription( output, suite ) else: writeStaticDescription( output, suite ) def writeDynamicDescription( output, suite ): '''Write SuiteDescription for a dynamic suite''' output.write( 'CxxTest::DynamicSuiteDescription< %s > %s' % (suite['fullname'], suite['dobject']) ) if not options.noStaticInit: output.write( '( %s, %s, "%s", %s, %s, %s, %s )' % (suite['cfile'], suite['line'], suite['fullname'], suite['tlist'], suite['object'], suite['create'], suite['destroy']) ) output.write( ';\n\n' ) def writeStaticDescription( output, suite ): '''Write SuiteDescription for a static suite''' output.write( 'CxxTest::StaticSuiteDescription %s' % suite['dobject'] ) if not options.noStaticInit: output.write( '( %s, %s, "%s", %s, %s )' % (suite['cfile'], suite['line'], suite['fullname'], suite['object'], suite['tlist']) ) output.write( ';\n\n' ) def writeRoot(output): '''Write static members of CxxTest classes''' output.write( '#include <cxxtest/Root.cpp>\n' ) def writeInitialize(output): '''Write CxxTest::initialize(), which replaces static initialization''' output.write( 'namespace CxxTest {\n' ) output.write( ' void initialize()\n' ) output.write( ' {\n' ) for suite in suites: #print "HERE", suite writeTestList( output, suite ) output.write( ' %s.initialize();\n' % suite['tlist'] ) #writeSuiteObject( output, suite ) if isDynamic(suite): writeSuitePointer( output, suite ) output.write( ' %s = 0;\n' % suite['object']) else: writeSuiteObject( output, suite ) output.write( ' static ') writeSuiteDescription( output, suite ) if isDynamic(suite): #output.write( ' %s = %s.suite();\n' % (suite['object'],suite['dobject']) ) output.write( ' %s.initialize( %s, %s, "%s", %s, %s, %s, %s );\n' % (suite['dobject'], suite['cfile'], suite['line'], suite['fullname'], suite['tlist'], suite['object'], suite['create'], suite['destroy']) ) output.write( ' %s.setUp();\n' % suite['dobject']) else: output.write( ' %s.initialize( %s, %s, "%s", %s, %s );\n' % (suite['dobject'], suite['cfile'], suite['line'], suite['fullname'], suite['object'], suite['tlist']) ) for test in suite['tests']: output.write( ' static %s %s(%s);\n' % (test['class'], test['object'], suite['object']) ) output.write( ' %s.initialize( %s, %s, %s, "%s" );\n' % (test['object'], suite['tlist'], suite['dobject'], test['line'], test['name']) ) output.write( ' }\n' ) output.write( '}\n' ) man_template=Template("""CXXTESTGEN(1) ============= :doctype: manpage NAME ---- cxxtestgen - performs test discovery to create a CxxTest test runner SYNOPSIS -------- ${usage} DESCRIPTION ----------- ${description} OPTIONS ------- ${options} EXIT STATUS ----------- *0*:: Success *1*:: Failure (syntax or usage error; configuration error; document processing failure; unexpected error). BUGS ---- See the CxxTest Home Page for the link to the CxxTest ticket repository. AUTHOR ------ CxxTest was originally written by Erez Volk. Many people have contributed to it. RESOURCES --------- Home page: <http://cxxtest.com/> CxxTest User Guide: <http://cxxtest.com/cxxtest/doc/guide.html> COPYING ------- Copyright (c) 2008 Sandia Corporation. This software is distributed under the Lesser GNU General Public License (LGPL) v3 """) def create_manpage(): """Write ASCIIDOC manpage file""" parser = create_parser(asciidoc=True) # usage = parser.usage description = parser.description options="" for opt in parser.option_list: opts = opt._short_opts + opt._long_opts optstr = '*' + ', '.join(opts) + '*' if not opt.metavar is None: optstr += "='%s'" % opt.metavar optstr += '::\n' options += optstr # options += opt.help options += '\n\n' # OUTPUT = open('cxxtestgen.1.txt','w') OUTPUT.write( man_template.substitute(usage=usage, description=description, options=options) ) OUTPUT.close()
bsd-3-clause
[ 25812, 199, 3, 445, 2154, 774, 26, 437, 10540, 3463, 445, 4176, 4137, 5343, 3555, 14, 199, 3, 1898, 334, 67, 9, 9079, 29359, 2391, 11098, 14, 199, 3, 961, 2032, 365, 1854, 1334, 314, 32426, 844, 373, 19, 199, 3, 2104, 1655, 2556, 12, 1937, 314, 9685, 570, 315, 314, 2746, 445, 2154, 774, 2082, 14, 199, 3, 25010, 314, 2895, 402, 1448, 6908, 3265, 13, 1348, 966, 13, 2635, 748, 2426, 1493, 543, 29359, 2391, 11098, 12, 199, 3, 314, 738, 14, 51, 14, 598, 27639, 295, 3953, 9842, 4481, 315, 642, 2032, 14, 199, 25812, 199, 199, 3, 6695, 26, 570, 2991, 29, 1624, 13, 24, 421, 199, 3, 314, 3432, 492, 11012, 367, 7568, 13, 15390, 543, 2366, 19, 12, 199, 3, 1314, 365, 2575, 314, 849, 315, 3819, 5135, 1, 199, 199, 363, 452, 363, 275, 788, 973, 297, 283, 981, 63, 1237, 1606, 418, 199, 199, 504, 1275, 492, 636, 3221, 363, 199, 646, 747, 199, 646, 984, 199, 646, 295, 199, 646, 5739, 199, 504, 8691, 492, 13491, 199, 504, 1275, 492, 17327, 396, 63, 2087, 199, 504, 1059, 492, 5458, 199, 199, 893, 26, 272, 687, 1275, 492, 17327, 396, 63, 545, 71, 272, 8439, 63, 545, 71, 29, 549, 199, 2590, 3545, 26, 272, 8439, 63, 545, 71, 29, 797, 199, 199, 504, 1275, 9634, 396, 63, 9923, 492, 12004, 199, 199, 893, 26, 272, 687, 747, 14, 515, 492, 20700, 199, 2590, 3545, 26, 272, 687, 1275, 9634, 396, 63, 9923, 492, 20700, 199, 199, 3, 13641, 666, 365, 10038, 701, 2446, 342, 199, 1419, 275, 942, 199, 27034, 275, 942, 199, 87, 22665, 29423, 275, 378, 199, 87, 22665, 15943, 275, 378, 199, 2019, 607, 3331, 275, 2125, 421, 199, 318, 2446, 8, 589, 29, 1274, 14, 3020, 12, 8579, 29, 797, 304, 272, 1449, 1918, 2446, 2240, 2344, 272, 327, 272, 327, 15510, 2288, 1174, 272, 327, 272, 2288, 336, 22665, 29423, 272, 336, 22665, 29423, 29, 16, 272, 2288, 336, 22665, 15943, 272, 336, 22665, 15943, 29, 16, 272, 2288, 2061, 607, 3331, 272, 2061, 607, 3331, 275, 2125, 272, 2288, 24203, 272, 24203, 275, 942, 272, 2288, 1511, 272, 1511, 275, 942, 272, 327, 272, 862, 26, 267, 1584, 275, 2198, 3110, 604, 8, 589, 9, 267, 340, 8439, 63, 545, 71, 436, 1511, 14, 545, 71, 26, 288, 359, 1419, 12, 27034, 61, 275, 17327, 396, 63, 545, 71, 14, 6282, 3205, 5535, 8, 1584, 12, 1511, 776, 267, 587, 26, 288, 359, 1419, 12, 27034, 61, 275, 17327, 396, 63, 2087, 14, 6282, 3205, 5535, 8, 1584, 12, 1511, 776, 267, 2218, 2959, 342, 272, 871, 14838, 26, 267, 340, 440, 8579, 26, 288, 746, 199, 199, 318, 1218, 63, 2087, 8, 305, 559, 344, 679, 29, 797, 304, 272, 1798, 275, 13491, 480, 9634, 396, 2268, 359, 1419, 61, 24936, 1501, 30, 2263, 12523, 272, 340, 465, 559, 344, 679, 26, 267, 1798, 14, 1802, 628, 1918, 17327, 396, 2268, 1414, 10358, 445, 4176, 1406, 1584, 370, 5147, 511, 13172, 12, 436, 2066, 652, 8491, 1584, 367, 314, 445, 2154, 774, 511, 7876, 2122, 272, 587, 26, 267, 1798, 14, 1802, 628, 1918, 283, 9634, 396, 2268, 7, 1414, 10358, 445, 4176, 1406, 1584, 370, 5147, 511, 13172, 12, 436, 2066, 652, 8491, 1584, 367, 314, 283, 24275, 774, 7, 511, 7876, 2122, 339, 1798, 14, 525, 63, 1422, 6739, 1023, 401, 1993, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 1023, 401, 849, 29, 797, 12, 1993, 1720, 628, 3534, 314, 445, 2154, 774, 1015, 2685, 272, 1798, 14, 525, 63, 1422, 6096, 79, 401, 4320, 1199, 401, 1993, 2053, 628, 1199, 7733, 401, 849, 29, 403, 12, 8214, 628, 2339, 401, 1993, 1720, 628, 3534, 1072, 370, 570, 13637, 2685, 272, 1798, 14, 525, 63, 1422, 6096, 87, 2266, 306, 7617, 401, 2053, 628, 7617, 401, 849, 628, 9634, 396, 401, 1993, 1720, 628, 1918, 1768, 402, 314, 2295, 12, 1202, 370, 536, 314, 4692, 2058, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 2613, 401, 1595, 628, 740, 401, 1993, 2053, 628, 2139, 401, 849, 6034, 8214, 628, 7311, 401, 1993, 1720, 628, 7826, 570, 13053, 540, 315, 314, 511, 7876, 2544, 1163, 2323, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 13845, 13, 265, 13, 1633, 401, 1993, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 13845, 3314, 4874, 401, 849, 29, 797, 12, 1993, 1720, 628, 16682, 2295, 641, 3405, 702, 83, 334, 2930, 671, 5072, 26744, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 973, 401, 1993, 1595, 628, 1617, 401, 2053, 628, 973, 401, 849, 628, 973, 401, 1993, 1720, 628, 17768, 376, 13943, 536, 367, 314, 2446, 342, 805, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 2139, 401, 1993, 1595, 628, 1617, 401, 2053, 628, 1291, 63, 1501, 401, 849, 29, 403, 12, 1993, 1720, 628, 17768, 282, 1788, 626, 3509, 282, 769, 402, 1406, 1584, 626, 787, 7686, 370, 3550, 282, 511, 7876, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 5933, 401, 1993, 2053, 628, 5933, 401, 849, 8772, 8214, 628, 6885, 401, 1993, 1720, 628, 2499, 282, 511, 7876, 626, 10358, 511, 4474, 1808, 314, 1021, 445, 2154, 774, 447, 6885, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 5885, 401, 1993, 2053, 628, 5885, 401, 8214, 628, 6885, 401, 1993, 1720, 628, 2499, 282, 17160, 511, 7876, 626, 10358, 511, 4474, 1808, 314, 1021, 445, 2154, 774, 447, 6885, 14, 334, 6667, 6320, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 705, 13, 11835, 401, 1993, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 705, 63, 11835, 401, 849, 29, 797, 12, 1993, 1720, 628, 2499, 282, 511, 7876, 1808, 314, 4520, 14131, 1021, 12, 436, 2040, 314, 675, 402, 314, 4465, 3555, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 88, 3248, 13, 11835, 401, 1993, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 88, 3248, 63, 11835, 401, 849, 29, 797, 12, 1993, 1720, 628, 2499, 282, 511, 7876, 1808, 314, 1323, 5072, 14131, 1021, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 88, 3248 ]
[ 199, 3, 445, 2154, 774, 26, 437, 10540, 3463, 445, 4176, 4137, 5343, 3555, 14, 199, 3, 1898, 334, 67, 9, 9079, 29359, 2391, 11098, 14, 199, 3, 961, 2032, 365, 1854, 1334, 314, 32426, 844, 373, 19, 199, 3, 2104, 1655, 2556, 12, 1937, 314, 9685, 570, 315, 314, 2746, 445, 2154, 774, 2082, 14, 199, 3, 25010, 314, 2895, 402, 1448, 6908, 3265, 13, 1348, 966, 13, 2635, 748, 2426, 1493, 543, 29359, 2391, 11098, 12, 199, 3, 314, 738, 14, 51, 14, 598, 27639, 295, 3953, 9842, 4481, 315, 642, 2032, 14, 199, 25812, 199, 199, 3, 6695, 26, 570, 2991, 29, 1624, 13, 24, 421, 199, 3, 314, 3432, 492, 11012, 367, 7568, 13, 15390, 543, 2366, 19, 12, 199, 3, 1314, 365, 2575, 314, 849, 315, 3819, 5135, 1, 199, 199, 363, 452, 363, 275, 788, 973, 297, 283, 981, 63, 1237, 1606, 418, 199, 199, 504, 1275, 492, 636, 3221, 363, 199, 646, 747, 199, 646, 984, 199, 646, 295, 199, 646, 5739, 199, 504, 8691, 492, 13491, 199, 504, 1275, 492, 17327, 396, 63, 2087, 199, 504, 1059, 492, 5458, 199, 199, 893, 26, 272, 687, 1275, 492, 17327, 396, 63, 545, 71, 272, 8439, 63, 545, 71, 29, 549, 199, 2590, 3545, 26, 272, 8439, 63, 545, 71, 29, 797, 199, 199, 504, 1275, 9634, 396, 63, 9923, 492, 12004, 199, 199, 893, 26, 272, 687, 747, 14, 515, 492, 20700, 199, 2590, 3545, 26, 272, 687, 1275, 9634, 396, 63, 9923, 492, 20700, 199, 199, 3, 13641, 666, 365, 10038, 701, 2446, 342, 199, 1419, 275, 942, 199, 27034, 275, 942, 199, 87, 22665, 29423, 275, 378, 199, 87, 22665, 15943, 275, 378, 199, 2019, 607, 3331, 275, 2125, 421, 199, 318, 2446, 8, 589, 29, 1274, 14, 3020, 12, 8579, 29, 797, 304, 272, 1449, 1918, 2446, 2240, 2344, 272, 327, 272, 327, 15510, 2288, 1174, 272, 327, 272, 2288, 336, 22665, 29423, 272, 336, 22665, 29423, 29, 16, 272, 2288, 336, 22665, 15943, 272, 336, 22665, 15943, 29, 16, 272, 2288, 2061, 607, 3331, 272, 2061, 607, 3331, 275, 2125, 272, 2288, 24203, 272, 24203, 275, 942, 272, 2288, 1511, 272, 1511, 275, 942, 272, 327, 272, 862, 26, 267, 1584, 275, 2198, 3110, 604, 8, 589, 9, 267, 340, 8439, 63, 545, 71, 436, 1511, 14, 545, 71, 26, 288, 359, 1419, 12, 27034, 61, 275, 17327, 396, 63, 545, 71, 14, 6282, 3205, 5535, 8, 1584, 12, 1511, 776, 267, 587, 26, 288, 359, 1419, 12, 27034, 61, 275, 17327, 396, 63, 2087, 14, 6282, 3205, 5535, 8, 1584, 12, 1511, 776, 267, 2218, 2959, 342, 272, 871, 14838, 26, 267, 340, 440, 8579, 26, 288, 746, 199, 199, 318, 1218, 63, 2087, 8, 305, 559, 344, 679, 29, 797, 304, 272, 1798, 275, 13491, 480, 9634, 396, 2268, 359, 1419, 61, 24936, 1501, 30, 2263, 12523, 272, 340, 465, 559, 344, 679, 26, 267, 1798, 14, 1802, 628, 1918, 17327, 396, 2268, 1414, 10358, 445, 4176, 1406, 1584, 370, 5147, 511, 13172, 12, 436, 2066, 652, 8491, 1584, 367, 314, 445, 2154, 774, 511, 7876, 2122, 272, 587, 26, 267, 1798, 14, 1802, 628, 1918, 283, 9634, 396, 2268, 7, 1414, 10358, 445, 4176, 1406, 1584, 370, 5147, 511, 13172, 12, 436, 2066, 652, 8491, 1584, 367, 314, 283, 24275, 774, 7, 511, 7876, 2122, 339, 1798, 14, 525, 63, 1422, 6739, 1023, 401, 1993, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 1023, 401, 849, 29, 797, 12, 1993, 1720, 628, 3534, 314, 445, 2154, 774, 1015, 2685, 272, 1798, 14, 525, 63, 1422, 6096, 79, 401, 4320, 1199, 401, 1993, 2053, 628, 1199, 7733, 401, 849, 29, 403, 12, 8214, 628, 2339, 401, 1993, 1720, 628, 3534, 1072, 370, 570, 13637, 2685, 272, 1798, 14, 525, 63, 1422, 6096, 87, 2266, 306, 7617, 401, 2053, 628, 7617, 401, 849, 628, 9634, 396, 401, 1993, 1720, 628, 1918, 1768, 402, 314, 2295, 12, 1202, 370, 536, 314, 4692, 2058, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 2613, 401, 1595, 628, 740, 401, 1993, 2053, 628, 2139, 401, 849, 6034, 8214, 628, 7311, 401, 1993, 1720, 628, 7826, 570, 13053, 540, 315, 314, 511, 7876, 2544, 1163, 2323, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 13845, 13, 265, 13, 1633, 401, 1993, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 13845, 3314, 4874, 401, 849, 29, 797, 12, 1993, 1720, 628, 16682, 2295, 641, 3405, 702, 83, 334, 2930, 671, 5072, 26744, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 973, 401, 1993, 1595, 628, 1617, 401, 2053, 628, 973, 401, 849, 628, 973, 401, 1993, 1720, 628, 17768, 376, 13943, 536, 367, 314, 2446, 342, 805, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 2139, 401, 1993, 1595, 628, 1617, 401, 2053, 628, 1291, 63, 1501, 401, 849, 29, 403, 12, 1993, 1720, 628, 17768, 282, 1788, 626, 3509, 282, 769, 402, 1406, 1584, 626, 787, 7686, 370, 3550, 282, 511, 7876, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 5933, 401, 1993, 2053, 628, 5933, 401, 849, 8772, 8214, 628, 6885, 401, 1993, 1720, 628, 2499, 282, 511, 7876, 626, 10358, 511, 4474, 1808, 314, 1021, 445, 2154, 774, 447, 6885, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 5885, 401, 1993, 2053, 628, 5885, 401, 8214, 628, 6885, 401, 1993, 1720, 628, 2499, 282, 17160, 511, 7876, 626, 10358, 511, 4474, 1808, 314, 1021, 445, 2154, 774, 447, 6885, 14, 334, 6667, 6320, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 705, 13, 11835, 401, 1993, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 705, 63, 11835, 401, 849, 29, 797, 12, 1993, 1720, 628, 2499, 282, 511, 7876, 1808, 314, 4520, 14131, 1021, 12, 436, 2040, 314, 675, 402, 314, 4465, 3555, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 88, 3248, 13, 11835, 401, 1993, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 88, 3248, 63, 11835, 401, 849, 29, 797, 12, 1993, 1720, 628, 2499, 282, 511, 7876, 1808, 314, 1323, 5072, 14131, 1021, 2685, 272, 1798, 14, 525, 63, 1422, 12398, 4320, 88, 3248, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bracket/handsome
examples/003_circle.py
2
4941
from handsome.Micropolygon import Micropolygon from handsome.MicropolygonMesh import MicropolygonMesh, Position from handsome.Pixel import FloatPixel, array_view, pixel_view from handsome.Tile import Tile from handsome.TileCache import TileCache from handsome.capi import fill_micropolygon_mesh, generate_numpy_begin from handsome.util import save_array_as_image, point, parse_color import numpy as np def constant(f): return f() @constant def palette(): colors = { 'clear' : '#0000', 'white' : '#fff', 'red' : '#7f0000', 'black' : '#000', 'blue' : '#0000bf', # 'blue' : '#0000ff', 'orange' : '#FF9701' } colors = { key : np.array([c / 255. for c in parse_color(value)], dtype=np.float32) for key, value in colors.items() } return colors def circle(center, radius): from math import cos, sin, pi tau = 2. * pi def point_from_polar(u, v): return point( center[0] + radius * u * cos(v * tau), center[1] + radius * u * sin(v * tau), 1, 1 ) return point_from_polar def generate_meshes(surface): splits = 16 u_steps = 256 v_steps = 1024 u_step_size = int(u_steps / splits) v_step_size = int(v_steps / splits) out = [] for u in range(0, u_steps, u_step_size): for v in range(0, v_steps, v_step_size): mesh = generate_mesh_from_surface( surface, (u_step_size, v_step_size), (u / u_steps, (u + u_step_size) / u_steps), (v / v_steps, (v + v_step_size) / v_steps), ) out.append(mesh) return out def generate_meshes_(surface): out = [ generate_mesh_from_surface( surface, (1, 8), (0.0001, 1.), (0.0001, 1.) ) ] return out def main(): render_frame(29) def render_frame(frame_no): print('rendering frame {}'.format(frame_no)) from math import sin, pi tau = 2. * pi image = Tile((0, 0), (512,512), 4, dtype=FloatPixel) image.buffer[:,:] = palette['white'].view(dtype=FloatPixel) center = (256, 256) radius = 100 surface = circle(center, radius) global transform transform = np.array( [ [ 1., .0 ], [ .5 * sin(tau * frame_no / 60.), 1. ] ], dtype=np.float32 ) meshes = generate_meshes(surface) for mesh in meshes: cache = render_mesh(mesh) cache.composite_into(image) buffer = array_view(image.downsample(1)) buffer = np.clip(buffer, 0., 1.) buffer = (255. * buffer).astype(dtype=np.uint8) path = 'render/003/frame_{:03}.tiff'.format(frame_no) save_array_as_image(pixel_view(buffer), path, 'RGBA') def generate_mesh_from_surface(surface, shape, u_range, v_range): u_start, u_end = u_range v_start, v_end = v_range u_steps = np.linspace(u_start, u_end, shape[0] + 1, endpoint=True, dtype=np.float32) v_steps = np.linspace(v_start, v_end, shape[1] + 1, endpoint=True, dtype=np.float32) points = [ [ surface(u, v) for u in u_steps ] for v in v_steps ] points = np.squeeze(np.array(points).view(Position)).T start_color = palette['blue'] end_color = palette['black'] colors = [ [ shader(u, v) for u in u_steps ] for v in v_steps ] colors = np.squeeze(np.array(colors).view(FloatPixel)).T mesh = MicropolygonMesh(shape) mesh.buffer[:,:]['position'] = points mesh.buffer[:,:]['color'] = colors # mesh.buffer[:,:]['color'] = palette['red'].view(FloatPixel) return mesh def wrap(value, frequency): return value * frequency % 1. def step(value, cutoff): if value < cutoff: return 0. else: return 1. uv = np.array([ 0, 0 ], np.float32) transform = np.array([ [ 1, 0 ], [ -.5, 1 ] ], dtype=np.float32) def shader(u, v): uv[:] = (u, v) u, v = transform.dot(uv) high_color = palette['clear'] s = step(wrap(v, 10), .5) low_color = (1. - s) * palette['black'] + s * palette['blue'] t = step(wrap(v, 20), .5) return (1. - t) * low_color + t * high_color def render_mesh(mesh): cache = TileCache((16, 16), 4, FloatPixel) mesh_bounds = mesh.outer_bounds mesh_width, mesh_height = mesh.buffer.shape for tile in cache.get_tiles_for_bounds(mesh_bounds): tile_width, tile_height = tile.buffer.shape fill_micropolygon_mesh( mesh_width, mesh_height, generate_numpy_begin(mesh.buffer), generate_numpy_begin(mesh.bounds), tile_width, tile_height, tile.bounds, generate_numpy_begin(tile.coordinate_image), generate_numpy_begin(tile.buffer) ) return cache if __name__ == '__main__': main()
bsd-2-clause
[ 504, 4926, 3972, 14, 23990, 16295, 492, 27022, 16295, 199, 504, 4926, 3972, 14, 23990, 16295, 12241, 492, 27022, 16295, 12241, 12, 15483, 199, 504, 4926, 3972, 14, 14383, 492, 11140, 14383, 12, 1625, 63, 1345, 12, 7148, 63, 1345, 199, 504, 4926, 3972, 14, 29746, 492, 377, 441, 199, 504, 4926, 3972, 14, 29746, 4437, 492, 377, 441, 4437, 199, 504, 4926, 3972, 14, 14145, 492, 5554, 63, 6453, 16295, 63, 6480, 12, 3550, 63, 4714, 63, 5037, 199, 504, 4926, 3972, 14, 1974, 492, 3354, 63, 1144, 63, 305, 63, 1569, 12, 2376, 12, 2198, 63, 2326, 199, 646, 2680, 465, 980, 421, 199, 318, 4413, 8, 70, 304, 272, 372, 289, 342, 421, 199, 32, 4083, 199, 318, 17986, 837, 272, 9229, 275, 469, 267, 283, 3584, 7, 221, 520, 3943, 993, 297, 267, 283, 7510, 7, 221, 520, 3943, 18190, 297, 267, 283, 581, 7, 259, 520, 3943, 23, 70, 993, 297, 267, 283, 8399, 7, 221, 520, 3943, 1493, 297, 267, 283, 6304, 7, 520, 3943, 993, 4361, 297, 267, 327, 283, 6304, 7, 257, 520, 3943, 993, 556, 297, 267, 283, 22683, 7, 520, 3943, 1665, 2576, 614, 7, 272, 789, 339, 9229, 275, 469, 267, 790, 520, 980, 14, 1144, 779, 67, 1182, 5450, 14, 367, 286, 315, 2198, 63, 2326, 8, 585, 4360, 2152, 29, 1590, 14, 1609, 708, 9, 267, 367, 790, 12, 574, 267, 315, 9229, 14, 1744, 342, 272, 789, 339, 372, 9229, 421, 199, 318, 17990, 8, 4218, 12, 9362, 304, 272, 687, 3473, 492, 9794, 12, 9829, 12, 6682, 272, 19188, 275, 499, 14, 627, 6682, 339, 347, 2376, 63, 504, 63, 19830, 8, 85, 12, 373, 304, 267, 372, 2376, 8, 288, 8126, 59, 16, 61, 435, 9362, 627, 399, 627, 9794, 8, 86, 627, 19188, 395, 288, 8126, 59, 17, 61, 435, 9362, 627, 399, 627, 9829, 8, 86, 627, 19188, 395, 288, 413, 12, 413, 267, 776, 339, 372, 2376, 63, 504, 63, 19830, 421, 199, 318, 3550, 63, 6480, 397, 8, 10992, 304, 272, 19115, 275, 3193, 339, 399, 63, 5895, 275, 7633, 272, 373, 63, 5895, 275, 6619, 339, 399, 63, 2926, 63, 890, 275, 1109, 8, 85, 63, 5895, 1182, 19115, 9, 272, 373, 63, 2926, 63, 890, 275, 1109, 8, 86, 63, 5895, 1182, 19115, 9, 2378, 734, 275, 942, 272, 367, 399, 315, 1425, 8, 16, 12, 399, 63, 5895, 12, 399, 63, 2926, 63, 890, 304, 267, 367, 373, 315, 1425, 8, 16, 12, 373, 63, 5895, 12, 373, 63, 2926, 63, 890, 304, 288, 9364, 275, 3550, 63, 6480, 63, 504, 63, 10992, 8, 355, 13195, 12, 355, 334, 85, 63, 2926, 63, 890, 12, 373, 63, 2926, 63, 890, 395, 355, 334, 85, 1182, 399, 63, 5895, 12, 334, 85, 435, 399, 63, 2926, 63, 890, 9, 1182, 399, 63, 5895, 395, 355, 334, 86, 1182, 373, 63, 5895, 12, 334, 86, 435, 373, 63, 2926, 63, 890, 9, 1182, 373, 63, 5895, 395, 288, 776, 953, 734, 14, 740, 8, 6480, 9, 339, 372, 734, 421, 199, 318, 3550, 63, 6480, 397, 2531, 10992, 304, 272, 734, 275, 359, 267, 3550, 63, 6480, 63, 504, 63, 10992, 8, 288, 13195, 12, 288, 334, 17, 12, 1695, 395, 288, 334, 16, 14, 4183, 12, 413, 15631, 288, 334, 16, 14, 4183, 12, 413, 4959, 267, 776, 272, 1622, 339, 372, 734, 421, 199, 318, 2446, 837, 272, 3795, 63, 1943, 8, 1398, 9, 421, 199, 318, 3795, 63, 1943, 8, 1943, 63, 889, 304, 272, 870, 360, 28228, 2787, 9499, 908, 8, 1943, 63, 889, 430, 339, 687, 3473, 492, 9829, 12, 6682, 272, 19188, 275, 499, 14, 627, 6682, 339, 1834, 275, 377, 441, 1332, 16, 12, 378, 395, 334, 7736, 12, 7736, 395, 841, 12, 2152, 29, 5136, 14383, 9, 272, 1834, 14, 2738, 3981, 2938, 275, 17986, 459, 7510, 2278, 1345, 8, 2271, 29, 5136, 14383, 9, 339, 8126, 275, 334, 3912, 12, 7633, 9, 272, 9362, 275, 2948, 339, 13195, 275, 17990, 8, 4218, 12, 9362, 9, 339, 2288, 5793, 339, 5793, 275, 980, 14, 1144, 8, 267, 359, 288, 359, 413, 2020, 1275, 16, 2156, 288, 359, 1275, 21, 627, 9829, 8, 16656, 627, 2787, 63, 889, 1182, 5212, 15631, 413, 14, 1622, 267, 2156, 267, 2152, 29, 1590, 14, 1609, 708, 272, 776, 339, 9364, 397, 275, 3550, 63, 6480, 397, 8, 10992, 9, 339, 367, 9364, 315, 9364, 397, 26, 267, 2581, 275, 3795, 63, 6480, 8, 6480, 9, 267, 2581, 14, 16907, 63, 9924, 8, 1569, 9, 339, 3335, 275, 1625, 63, 1345, 8, 1569, 14, 68, 23311, 865, 8, 17, 430, 272, 3335, 275, 980, 14, 7548, 8, 2738, 12, 378, 2020, 413, 4959, 272, 3335, 275, 334, 2299, 14, 627, 3335, 680, 6041, 8, 2271, 29, 1590, 14, 1635, 24, 9, 339, 931, 275, 283, 3352, 15, 8262, 15, 1943, 7348, 26, 1644, 5565, 29119, 1370, 908, 8, 1943, 63, 889, 9, 272, 3354, 63, 1144, 63, 305, 63, 1569, 8, 8435, 63, 1345, 8, 2738, 395, 931, 12, 283, 21631, 358, 421, 199, 318, 3550, 63, 6480, 63, 504, 63, 10992, 8, 10992, 12, 2215, 12, 399, 63, 1842, 12, 373, 63, 1842, 304, 272, 399, 63, 928, 12, 399, 63, 500, 275, 399, 63, 1842, 272, 373, 63, 928, 12, 373, 63, 500, 275, 373, 63, 1842, 339, 399, 63, 5895, 275, 980, 14, 11649, 8, 85, 63, 928, 12, 399, 63, 500, 12, 2215, 59, 16, 61, 435, 413, 12, 6037, 29, 549, 12, 2152, 29, 1590, 14, 1609, 708, 9, 272, 373, 63, 5895, 275, 980, 14, 11649, 8, 86, 63, 928, 12, 373, 63, 500, 12, 2215, 59, 17, 61, 435, 413, 12, 6037, 29, 549, 12, 2152, 29, 1590, 14, 1609, 708, 9, 339, 4501, 275, 359, 267, 359, 13195, 8, 85, 12, 373, 9, 367, 399, 315, 399, 63, 5895, 1622, 267, 367, 373, 315, 373, 63, 5895, 272, 1622, 339, 4501, 275, 980, 14, 16597, 8, 1590, 14, 1144, 8, 3438, 680, 1345, 8, 5625, 4992, 52, 339, 1343, 63, 2326, 275, 17986, 459, 6304, 418, 272, 1284, 63, 2326, 275, 17986 ]
[ 4926, 3972, 14, 23990, 16295, 492, 27022, 16295, 199, 504, 4926, 3972, 14, 23990, 16295, 12241, 492, 27022, 16295, 12241, 12, 15483, 199, 504, 4926, 3972, 14, 14383, 492, 11140, 14383, 12, 1625, 63, 1345, 12, 7148, 63, 1345, 199, 504, 4926, 3972, 14, 29746, 492, 377, 441, 199, 504, 4926, 3972, 14, 29746, 4437, 492, 377, 441, 4437, 199, 504, 4926, 3972, 14, 14145, 492, 5554, 63, 6453, 16295, 63, 6480, 12, 3550, 63, 4714, 63, 5037, 199, 504, 4926, 3972, 14, 1974, 492, 3354, 63, 1144, 63, 305, 63, 1569, 12, 2376, 12, 2198, 63, 2326, 199, 646, 2680, 465, 980, 421, 199, 318, 4413, 8, 70, 304, 272, 372, 289, 342, 421, 199, 32, 4083, 199, 318, 17986, 837, 272, 9229, 275, 469, 267, 283, 3584, 7, 221, 520, 3943, 993, 297, 267, 283, 7510, 7, 221, 520, 3943, 18190, 297, 267, 283, 581, 7, 259, 520, 3943, 23, 70, 993, 297, 267, 283, 8399, 7, 221, 520, 3943, 1493, 297, 267, 283, 6304, 7, 520, 3943, 993, 4361, 297, 267, 327, 283, 6304, 7, 257, 520, 3943, 993, 556, 297, 267, 283, 22683, 7, 520, 3943, 1665, 2576, 614, 7, 272, 789, 339, 9229, 275, 469, 267, 790, 520, 980, 14, 1144, 779, 67, 1182, 5450, 14, 367, 286, 315, 2198, 63, 2326, 8, 585, 4360, 2152, 29, 1590, 14, 1609, 708, 9, 267, 367, 790, 12, 574, 267, 315, 9229, 14, 1744, 342, 272, 789, 339, 372, 9229, 421, 199, 318, 17990, 8, 4218, 12, 9362, 304, 272, 687, 3473, 492, 9794, 12, 9829, 12, 6682, 272, 19188, 275, 499, 14, 627, 6682, 339, 347, 2376, 63, 504, 63, 19830, 8, 85, 12, 373, 304, 267, 372, 2376, 8, 288, 8126, 59, 16, 61, 435, 9362, 627, 399, 627, 9794, 8, 86, 627, 19188, 395, 288, 8126, 59, 17, 61, 435, 9362, 627, 399, 627, 9829, 8, 86, 627, 19188, 395, 288, 413, 12, 413, 267, 776, 339, 372, 2376, 63, 504, 63, 19830, 421, 199, 318, 3550, 63, 6480, 397, 8, 10992, 304, 272, 19115, 275, 3193, 339, 399, 63, 5895, 275, 7633, 272, 373, 63, 5895, 275, 6619, 339, 399, 63, 2926, 63, 890, 275, 1109, 8, 85, 63, 5895, 1182, 19115, 9, 272, 373, 63, 2926, 63, 890, 275, 1109, 8, 86, 63, 5895, 1182, 19115, 9, 2378, 734, 275, 942, 272, 367, 399, 315, 1425, 8, 16, 12, 399, 63, 5895, 12, 399, 63, 2926, 63, 890, 304, 267, 367, 373, 315, 1425, 8, 16, 12, 373, 63, 5895, 12, 373, 63, 2926, 63, 890, 304, 288, 9364, 275, 3550, 63, 6480, 63, 504, 63, 10992, 8, 355, 13195, 12, 355, 334, 85, 63, 2926, 63, 890, 12, 373, 63, 2926, 63, 890, 395, 355, 334, 85, 1182, 399, 63, 5895, 12, 334, 85, 435, 399, 63, 2926, 63, 890, 9, 1182, 399, 63, 5895, 395, 355, 334, 86, 1182, 373, 63, 5895, 12, 334, 86, 435, 373, 63, 2926, 63, 890, 9, 1182, 373, 63, 5895, 395, 288, 776, 953, 734, 14, 740, 8, 6480, 9, 339, 372, 734, 421, 199, 318, 3550, 63, 6480, 397, 2531, 10992, 304, 272, 734, 275, 359, 267, 3550, 63, 6480, 63, 504, 63, 10992, 8, 288, 13195, 12, 288, 334, 17, 12, 1695, 395, 288, 334, 16, 14, 4183, 12, 413, 15631, 288, 334, 16, 14, 4183, 12, 413, 4959, 267, 776, 272, 1622, 339, 372, 734, 421, 199, 318, 2446, 837, 272, 3795, 63, 1943, 8, 1398, 9, 421, 199, 318, 3795, 63, 1943, 8, 1943, 63, 889, 304, 272, 870, 360, 28228, 2787, 9499, 908, 8, 1943, 63, 889, 430, 339, 687, 3473, 492, 9829, 12, 6682, 272, 19188, 275, 499, 14, 627, 6682, 339, 1834, 275, 377, 441, 1332, 16, 12, 378, 395, 334, 7736, 12, 7736, 395, 841, 12, 2152, 29, 5136, 14383, 9, 272, 1834, 14, 2738, 3981, 2938, 275, 17986, 459, 7510, 2278, 1345, 8, 2271, 29, 5136, 14383, 9, 339, 8126, 275, 334, 3912, 12, 7633, 9, 272, 9362, 275, 2948, 339, 13195, 275, 17990, 8, 4218, 12, 9362, 9, 339, 2288, 5793, 339, 5793, 275, 980, 14, 1144, 8, 267, 359, 288, 359, 413, 2020, 1275, 16, 2156, 288, 359, 1275, 21, 627, 9829, 8, 16656, 627, 2787, 63, 889, 1182, 5212, 15631, 413, 14, 1622, 267, 2156, 267, 2152, 29, 1590, 14, 1609, 708, 272, 776, 339, 9364, 397, 275, 3550, 63, 6480, 397, 8, 10992, 9, 339, 367, 9364, 315, 9364, 397, 26, 267, 2581, 275, 3795, 63, 6480, 8, 6480, 9, 267, 2581, 14, 16907, 63, 9924, 8, 1569, 9, 339, 3335, 275, 1625, 63, 1345, 8, 1569, 14, 68, 23311, 865, 8, 17, 430, 272, 3335, 275, 980, 14, 7548, 8, 2738, 12, 378, 2020, 413, 4959, 272, 3335, 275, 334, 2299, 14, 627, 3335, 680, 6041, 8, 2271, 29, 1590, 14, 1635, 24, 9, 339, 931, 275, 283, 3352, 15, 8262, 15, 1943, 7348, 26, 1644, 5565, 29119, 1370, 908, 8, 1943, 63, 889, 9, 272, 3354, 63, 1144, 63, 305, 63, 1569, 8, 8435, 63, 1345, 8, 2738, 395, 931, 12, 283, 21631, 358, 421, 199, 318, 3550, 63, 6480, 63, 504, 63, 10992, 8, 10992, 12, 2215, 12, 399, 63, 1842, 12, 373, 63, 1842, 304, 272, 399, 63, 928, 12, 399, 63, 500, 275, 399, 63, 1842, 272, 373, 63, 928, 12, 373, 63, 500, 275, 373, 63, 1842, 339, 399, 63, 5895, 275, 980, 14, 11649, 8, 85, 63, 928, 12, 399, 63, 500, 12, 2215, 59, 16, 61, 435, 413, 12, 6037, 29, 549, 12, 2152, 29, 1590, 14, 1609, 708, 9, 272, 373, 63, 5895, 275, 980, 14, 11649, 8, 86, 63, 928, 12, 373, 63, 500, 12, 2215, 59, 17, 61, 435, 413, 12, 6037, 29, 549, 12, 2152, 29, 1590, 14, 1609, 708, 9, 339, 4501, 275, 359, 267, 359, 13195, 8, 85, 12, 373, 9, 367, 399, 315, 399, 63, 5895, 1622, 267, 367, 373, 315, 373, 63, 5895, 272, 1622, 339, 4501, 275, 980, 14, 16597, 8, 1590, 14, 1144, 8, 3438, 680, 1345, 8, 5625, 4992, 52, 339, 1343, 63, 2326, 275, 17986, 459, 6304, 418, 272, 1284, 63, 2326, 275, 17986, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
agat63/AGAT_JB_kernel
Documentation/target/tcm_mod_builder.py
3119
42754
#!/usr/bin/python # The TCM v4 multi-protocol fabric module generation script for drivers/target/$NEW_MOD # # Copyright (c) 2010 Rising Tide Systems # Copyright (c) 2010 Linux-iSCSI.org # # Author: nab@kernel.org # import os, sys import subprocess as sub import string import re import optparse tcm_dir = "" fabric_ops = [] fabric_mod_dir = "" fabric_mod_port = "" fabric_mod_init_port = "" def tcm_mod_err(msg): print msg sys.exit(1) def tcm_mod_create_module_subdir(fabric_mod_dir_var): if os.path.isdir(fabric_mod_dir_var) == True: return 1 print "Creating fabric_mod_dir: " + fabric_mod_dir_var ret = os.mkdir(fabric_mod_dir_var) if ret: tcm_mod_err("Unable to mkdir " + fabric_mod_dir_var) return def tcm_mod_build_FC_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* Binary World Wide unique Port Name for FC Initiator Nport */\n" buf += " u64 nport_wwpn;\n" buf += " /* ASCII formatted WWPN for FC Initiator Nport */\n" buf += " char nport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n" buf += "\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* FC lport target portal group tag for TCM */\n" buf += " u16 lport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_lport */\n" buf += " struct " + fabric_mod_name + "_lport *lport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n" buf += "\n" buf += "struct " + fabric_mod_name + "_lport {\n" buf += " /* SCSI protocol the lport is providing */\n" buf += " u8 lport_proto_id;\n" buf += " /* Binary World Wide unique Port Name for FC Target Lport */\n" buf += " u64 lport_wwpn;\n" buf += " /* ASCII formatted WWPN for FC Target Lport */\n" buf += " char lport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_lport() */\n" buf += " struct se_wwn lport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "lport" fabric_mod_init_port = "nport" return def tcm_mod_build_SAS_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* Binary World Wide unique Port Name for SAS Initiator port */\n" buf += " u64 iport_wwpn;\n" buf += " /* ASCII formatted WWPN for Sas Initiator port */\n" buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* SAS port target portal group tag for TCM */\n" buf += " u16 tport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n" buf += " struct " + fabric_mod_name + "_tport *tport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tport {\n" buf += " /* SCSI protocol the tport is providing */\n" buf += " u8 tport_proto_id;\n" buf += " /* Binary World Wide unique Port Name for SAS Target port */\n" buf += " u64 tport_wwpn;\n" buf += " /* ASCII formatted WWPN for SAS Target port */\n" buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n" buf += " struct se_wwn tport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "tport" fabric_mod_init_port = "iport" return def tcm_mod_build_iSCSI_include(fabric_mod_dir_var, fabric_mod_name): global fabric_mod_port global fabric_mod_init_port buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" buf += "\n" buf += "struct " + fabric_mod_name + "_nacl {\n" buf += " /* ASCII formatted InitiatorName */\n" buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n" buf += " struct se_node_acl se_node_acl;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tpg {\n" buf += " /* iSCSI target portal group tag for TCM */\n" buf += " u16 tport_tpgt;\n" buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n" buf += " struct " + fabric_mod_name + "_tport *tport;\n" buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n" buf += " struct se_portal_group se_tpg;\n" buf += "};\n\n" buf += "struct " + fabric_mod_name + "_tport {\n" buf += " /* SCSI protocol the tport is providing */\n" buf += " u8 tport_proto_id;\n" buf += " /* ASCII formatted TargetName for IQN */\n" buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n" buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n" buf += " struct se_wwn tport_wwn;\n" buf += "};\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() fabric_mod_port = "tport" fabric_mod_init_port = "iport" return def tcm_mod_build_base_includes(proto_ident, fabric_mod_dir_val, fabric_mod_name): if proto_ident == "FC": tcm_mod_build_FC_include(fabric_mod_dir_val, fabric_mod_name) elif proto_ident == "SAS": tcm_mod_build_SAS_include(fabric_mod_dir_val, fabric_mod_name) elif proto_ident == "iSCSI": tcm_mod_build_iSCSI_include(fabric_mod_dir_val, fabric_mod_name) else: print "Unsupported proto_ident: " + proto_ident sys.exit(1) return def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_configfs.c" print "Writing file: " + f p = open(f, 'w'); if not p: tcm_mod_err("Unable to open file: " + f) buf = "#include <linux/module.h>\n" buf += "#include <linux/moduleparam.h>\n" buf += "#include <linux/version.h>\n" buf += "#include <generated/utsrelease.h>\n" buf += "#include <linux/utsname.h>\n" buf += "#include <linux/init.h>\n" buf += "#include <linux/slab.h>\n" buf += "#include <linux/kthread.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/string.h>\n" buf += "#include <linux/configfs.h>\n" buf += "#include <linux/ctype.h>\n" buf += "#include <asm/unaligned.h>\n\n" buf += "#include <target/target_core_base.h>\n" buf += "#include <target/target_core_transport.h>\n" buf += "#include <target/target_core_fabric_ops.h>\n" buf += "#include <target/target_core_fabric_configfs.h>\n" buf += "#include <target/target_core_fabric_lib.h>\n" buf += "#include <target/target_core_device.h>\n" buf += "#include <target/target_core_tpg.h>\n" buf += "#include <target/target_core_configfs.h>\n" buf += "#include <target/target_core_base.h>\n" buf += "#include <target/configfs_macros.h>\n\n" buf += "#include \"" + fabric_mod_name + "_base.h\"\n" buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" buf += "/* Local pointer to allocated TCM configfs fabric module */\n" buf += "struct target_fabric_configfs *" + fabric_mod_name + "_fabric_configfs;\n\n" buf += "static struct se_node_acl *" + fabric_mod_name + "_make_nodeacl(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct se_node_acl *se_nacl, *se_nacl_new;\n" buf += " struct " + fabric_mod_name + "_nacl *nacl;\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " u64 wwpn = 0;\n" buf += " u32 nexus_depth;\n\n" buf += " /* " + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" buf += " return ERR_PTR(-EINVAL); */\n" buf += " se_nacl_new = " + fabric_mod_name + "_alloc_fabric_acl(se_tpg);\n" buf += " if (!(se_nacl_new))\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += "//#warning FIXME: Hardcoded nexus depth in " + fabric_mod_name + "_make_nodeacl()\n" buf += " nexus_depth = 1;\n" buf += " /*\n" buf += " * se_nacl_new may be released by core_tpg_add_initiator_node_acl()\n" buf += " * when converting a NodeACL from demo mode -> explict\n" buf += " */\n" buf += " se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,\n" buf += " name, nexus_depth);\n" buf += " if (IS_ERR(se_nacl)) {\n" buf += " " + fabric_mod_name + "_release_fabric_acl(se_tpg, se_nacl_new);\n" buf += " return se_nacl;\n" buf += " }\n" buf += " /*\n" buf += " * Locate our struct " + fabric_mod_name + "_nacl and set the FC Nport WWPN\n" buf += " */\n" buf += " nacl = container_of(se_nacl, struct " + fabric_mod_name + "_nacl, se_node_acl);\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " nacl->" + fabric_mod_init_port + "_wwpn = wwpn;\n" buf += " /* " + fabric_mod_name + "_format_wwn(&nacl->" + fabric_mod_init_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n" buf += " return se_nacl;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_nodeacl(struct se_node_acl *se_acl)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl = container_of(se_acl,\n" buf += " struct " + fabric_mod_name + "_nacl, se_node_acl);\n" buf += " core_tpg_del_initiator_node_acl(se_acl->se_tpg, se_acl, 1);\n" buf += " kfree(nacl);\n" buf += "}\n\n" buf += "static struct se_portal_group *" + fabric_mod_name + "_make_tpg(\n" buf += " struct se_wwn *wwn,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + "*" + fabric_mod_port + " = container_of(wwn,\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n\n" buf += " struct " + fabric_mod_name + "_tpg *tpg;\n" buf += " unsigned long tpgt;\n" buf += " int ret;\n\n" buf += " if (strstr(name, \"tpgt_\") != name)\n" buf += " return ERR_PTR(-EINVAL);\n" buf += " if (strict_strtoul(name + 5, 10, &tpgt) || tpgt > UINT_MAX)\n" buf += " return ERR_PTR(-EINVAL);\n\n" buf += " tpg = kzalloc(sizeof(struct " + fabric_mod_name + "_tpg), GFP_KERNEL);\n" buf += " if (!(tpg)) {\n" buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_tpg\");\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += " }\n" buf += " tpg->" + fabric_mod_port + " = " + fabric_mod_port + ";\n" buf += " tpg->" + fabric_mod_port + "_tpgt = tpgt;\n\n" buf += " ret = core_tpg_register(&" + fabric_mod_name + "_fabric_configfs->tf_ops, wwn,\n" buf += " &tpg->se_tpg, (void *)tpg,\n" buf += " TRANSPORT_TPG_TYPE_NORMAL);\n" buf += " if (ret < 0) {\n" buf += " kfree(tpg);\n" buf += " return NULL;\n" buf += " }\n" buf += " return &tpg->se_tpg;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_tpg(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n\n" buf += " core_tpg_deregister(se_tpg);\n" buf += " kfree(tpg);\n" buf += "}\n\n" buf += "static struct se_wwn *" + fabric_mod_name + "_make_" + fabric_mod_port + "(\n" buf += " struct target_fabric_configfs *tf,\n" buf += " struct config_group *group,\n" buf += " const char *name)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + ";\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " u64 wwpn = 0;\n\n" buf += " /* if (" + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n" buf += " return ERR_PTR(-EINVAL); */\n\n" buf += " " + fabric_mod_port + " = kzalloc(sizeof(struct " + fabric_mod_name + "_" + fabric_mod_port + "), GFP_KERNEL);\n" buf += " if (!(" + fabric_mod_port + ")) {\n" buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_" + fabric_mod_port + "\");\n" buf += " return ERR_PTR(-ENOMEM);\n" buf += " }\n" if proto_ident == "FC" or proto_ident == "SAS": buf += " " + fabric_mod_port + "->" + fabric_mod_port + "_wwpn = wwpn;\n" buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "__NAMELEN, wwpn); */\n\n" buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_wwn;\n" buf += "}\n\n" buf += "static void " + fabric_mod_name + "_drop_" + fabric_mod_port + "(struct se_wwn *wwn)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = container_of(wwn,\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n" buf += " kfree(" + fabric_mod_port + ");\n" buf += "}\n\n" buf += "static ssize_t " + fabric_mod_name + "_wwn_show_attr_version(\n" buf += " struct target_fabric_configfs *tf,\n" buf += " char *page)\n" buf += "{\n" buf += " return sprintf(page, \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n" buf += " \"on \"UTS_RELEASE\"\\n\", " + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n" buf += " utsname()->machine);\n" buf += "}\n\n" buf += "TF_WWN_ATTR_RO(" + fabric_mod_name + ", version);\n\n" buf += "static struct configfs_attribute *" + fabric_mod_name + "_wwn_attrs[] = {\n" buf += " &" + fabric_mod_name + "_wwn_version.attr,\n" buf += " NULL,\n" buf += "};\n\n" buf += "static struct target_core_fabric_ops " + fabric_mod_name + "_ops = {\n" buf += " .get_fabric_name = " + fabric_mod_name + "_get_fabric_name,\n" buf += " .get_fabric_proto_ident = " + fabric_mod_name + "_get_fabric_proto_ident,\n" buf += " .tpg_get_wwn = " + fabric_mod_name + "_get_fabric_wwn,\n" buf += " .tpg_get_tag = " + fabric_mod_name + "_get_tag,\n" buf += " .tpg_get_default_depth = " + fabric_mod_name + "_get_default_depth,\n" buf += " .tpg_get_pr_transport_id = " + fabric_mod_name + "_get_pr_transport_id,\n" buf += " .tpg_get_pr_transport_id_len = " + fabric_mod_name + "_get_pr_transport_id_len,\n" buf += " .tpg_parse_pr_out_transport_id = " + fabric_mod_name + "_parse_pr_out_transport_id,\n" buf += " .tpg_check_demo_mode = " + fabric_mod_name + "_check_false,\n" buf += " .tpg_check_demo_mode_cache = " + fabric_mod_name + "_check_true,\n" buf += " .tpg_check_demo_mode_write_protect = " + fabric_mod_name + "_check_true,\n" buf += " .tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n" buf += " .tpg_alloc_fabric_acl = " + fabric_mod_name + "_alloc_fabric_acl,\n" buf += " .tpg_release_fabric_acl = " + fabric_mod_name + "_release_fabric_acl,\n" buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n" buf += " .release_cmd_to_pool = " + fabric_mod_name + "_release_cmd,\n" buf += " .release_cmd_direct = " + fabric_mod_name + "_release_cmd,\n" buf += " .shutdown_session = " + fabric_mod_name + "_shutdown_session,\n" buf += " .close_session = " + fabric_mod_name + "_close_session,\n" buf += " .stop_session = " + fabric_mod_name + "_stop_session,\n" buf += " .fall_back_to_erl0 = " + fabric_mod_name + "_reset_nexus,\n" buf += " .sess_logged_in = " + fabric_mod_name + "_sess_logged_in,\n" buf += " .sess_get_index = " + fabric_mod_name + "_sess_get_index,\n" buf += " .sess_get_initiator_sid = NULL,\n" buf += " .write_pending = " + fabric_mod_name + "_write_pending,\n" buf += " .write_pending_status = " + fabric_mod_name + "_write_pending_status,\n" buf += " .set_default_node_attributes = " + fabric_mod_name + "_set_default_node_attrs,\n" buf += " .get_task_tag = " + fabric_mod_name + "_get_task_tag,\n" buf += " .get_cmd_state = " + fabric_mod_name + "_get_cmd_state,\n" buf += " .new_cmd_failure = " + fabric_mod_name + "_new_cmd_failure,\n" buf += " .queue_data_in = " + fabric_mod_name + "_queue_data_in,\n" buf += " .queue_status = " + fabric_mod_name + "_queue_status,\n" buf += " .queue_tm_rsp = " + fabric_mod_name + "_queue_tm_rsp,\n" buf += " .get_fabric_sense_len = " + fabric_mod_name + "_get_fabric_sense_len,\n" buf += " .set_fabric_sense_len = " + fabric_mod_name + "_set_fabric_sense_len,\n" buf += " .is_state_remove = " + fabric_mod_name + "_is_state_remove,\n" buf += " .pack_lun = " + fabric_mod_name + "_pack_lun,\n" buf += " /*\n" buf += " * Setup function pointers for generic logic in target_core_fabric_configfs.c\n" buf += " */\n" buf += " .fabric_make_wwn = " + fabric_mod_name + "_make_" + fabric_mod_port + ",\n" buf += " .fabric_drop_wwn = " + fabric_mod_name + "_drop_" + fabric_mod_port + ",\n" buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n" buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n" buf += " .fabric_post_link = NULL,\n" buf += " .fabric_pre_unlink = NULL,\n" buf += " .fabric_make_np = NULL,\n" buf += " .fabric_drop_np = NULL,\n" buf += " .fabric_make_nodeacl = " + fabric_mod_name + "_make_nodeacl,\n" buf += " .fabric_drop_nodeacl = " + fabric_mod_name + "_drop_nodeacl,\n" buf += "};\n\n" buf += "static int " + fabric_mod_name + "_register_configfs(void)\n" buf += "{\n" buf += " struct target_fabric_configfs *fabric;\n" buf += " int ret;\n\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n" buf += " \" on \"UTS_RELEASE\"\\n\"," + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n" buf += " utsname()->machine);\n" buf += " /*\n" buf += " * Register the top level struct config_item_type with TCM core\n" buf += " */\n" buf += " fabric = target_fabric_configfs_init(THIS_MODULE, \"" + fabric_mod_name[4:] + "\");\n" buf += " if (!(fabric)) {\n" buf += " printk(KERN_ERR \"target_fabric_configfs_init() failed\\n\");\n" buf += " return -ENOMEM;\n" buf += " }\n" buf += " /*\n" buf += " * Setup fabric->tf_ops from our local " + fabric_mod_name + "_ops\n" buf += " */\n" buf += " fabric->tf_ops = " + fabric_mod_name + "_ops;\n" buf += " /*\n" buf += " * Setup default attribute lists for various fabric->tf_cit_tmpl\n" buf += " */\n" buf += " TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = " + fabric_mod_name + "_wwn_attrs;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_param_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_np_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_base_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_auth_cit.ct_attrs = NULL;\n" buf += " TF_CIT_TMPL(fabric)->tfc_tpg_nacl_param_cit.ct_attrs = NULL;\n" buf += " /*\n" buf += " * Register the fabric for use within TCM\n" buf += " */\n" buf += " ret = target_fabric_configfs_register(fabric);\n" buf += " if (ret < 0) {\n" buf += " printk(KERN_ERR \"target_fabric_configfs_register() failed\"\n" buf += " \" for " + fabric_mod_name.upper() + "\\n\");\n" buf += " return ret;\n" buf += " }\n" buf += " /*\n" buf += " * Setup our local pointer to *fabric\n" buf += " */\n" buf += " " + fabric_mod_name + "_fabric_configfs = fabric;\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Set fabric -> " + fabric_mod_name + "_fabric_configfs\\n\");\n" buf += " return 0;\n" buf += "};\n\n" buf += "static void " + fabric_mod_name + "_deregister_configfs(void)\n" buf += "{\n" buf += " if (!(" + fabric_mod_name + "_fabric_configfs))\n" buf += " return;\n\n" buf += " target_fabric_configfs_deregister(" + fabric_mod_name + "_fabric_configfs);\n" buf += " " + fabric_mod_name + "_fabric_configfs = NULL;\n" buf += " printk(KERN_INFO \"" + fabric_mod_name.upper() + "[0] - Cleared " + fabric_mod_name + "_fabric_configfs\\n\");\n" buf += "};\n\n" buf += "static int __init " + fabric_mod_name + "_init(void)\n" buf += "{\n" buf += " int ret;\n\n" buf += " ret = " + fabric_mod_name + "_register_configfs();\n" buf += " if (ret < 0)\n" buf += " return ret;\n\n" buf += " return 0;\n" buf += "};\n\n" buf += "static void " + fabric_mod_name + "_exit(void)\n" buf += "{\n" buf += " " + fabric_mod_name + "_deregister_configfs();\n" buf += "};\n\n" buf += "#ifdef MODULE\n" buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n" buf += "MODULE_LICENSE(\"GPL\");\n" buf += "module_init(" + fabric_mod_name + "_init);\n" buf += "module_exit(" + fabric_mod_name + "_exit);\n" buf += "#endif\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_scan_fabric_ops(tcm_dir): fabric_ops_api = tcm_dir + "include/target/target_core_fabric_ops.h" print "Using tcm_mod_scan_fabric_ops: " + fabric_ops_api process_fo = 0; p = open(fabric_ops_api, 'r') line = p.readline() while line: if process_fo == 0 and re.search('struct target_core_fabric_ops {', line): line = p.readline() continue if process_fo == 0: process_fo = 1; line = p.readline() # Search for function pointer if not re.search('\(\*', line): continue fabric_ops.append(line.rstrip()) continue line = p.readline() # Search for function pointer if not re.search('\(\*', line): continue fabric_ops.append(line.rstrip()) p.close() return def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name): buf = "" bufi = "" f = fabric_mod_dir_var + "/" + fabric_mod_name + "_fabric.c" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) fi = fabric_mod_dir_var + "/" + fabric_mod_name + "_fabric.h" print "Writing file: " + fi pi = open(fi, 'w') if not pi: tcm_mod_err("Unable to open file: " + fi) buf = "#include <linux/slab.h>\n" buf += "#include <linux/kthread.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/list.h>\n" buf += "#include <linux/types.h>\n" buf += "#include <linux/string.h>\n" buf += "#include <linux/ctype.h>\n" buf += "#include <asm/unaligned.h>\n" buf += "#include <scsi/scsi.h>\n" buf += "#include <scsi/scsi_host.h>\n" buf += "#include <scsi/scsi_device.h>\n" buf += "#include <scsi/scsi_cmnd.h>\n" buf += "#include <scsi/libfc.h>\n\n" buf += "#include <target/target_core_base.h>\n" buf += "#include <target/target_core_transport.h>\n" buf += "#include <target/target_core_fabric_ops.h>\n" buf += "#include <target/target_core_fabric_lib.h>\n" buf += "#include <target/target_core_device.h>\n" buf += "#include <target/target_core_tpg.h>\n" buf += "#include <target/target_core_configfs.h>\n\n" buf += "#include \"" + fabric_mod_name + "_base.h\"\n" buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" buf += "int " + fabric_mod_name + "_check_true(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_check_true(struct se_portal_group *);\n" buf += "int " + fabric_mod_name + "_check_false(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_check_false(struct se_portal_group *);\n" total_fabric_ops = len(fabric_ops) i = 0 while i < total_fabric_ops: fo = fabric_ops[i] i += 1 # print "fabric_ops: " + fo if re.search('get_fabric_name', fo): buf += "char *" + fabric_mod_name + "_get_fabric_name(void)\n" buf += "{\n" buf += " return \"" + fabric_mod_name[4:] + "\";\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_get_fabric_name(void);\n" continue if re.search('get_fabric_proto_ident', fo): buf += "u8 " + fabric_mod_name + "_get_fabric_proto_ident(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " u8 proto_id;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " proto_id = fc_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " proto_id = sas_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " proto_id = iscsi_get_fabric_proto_ident(se_tpg);\n" buf += " break;\n" buf += " }\n\n" buf += " return proto_id;\n" buf += "}\n\n" bufi += "u8 " + fabric_mod_name + "_get_fabric_proto_ident(struct se_portal_group *);\n" if re.search('get_wwn', fo): buf += "char *" + fabric_mod_name + "_get_fabric_wwn(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n\n" buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_name[0];\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_get_fabric_wwn(struct se_portal_group *);\n" if re.search('get_tag', fo): buf += "u16 " + fabric_mod_name + "_get_tag(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " return tpg->" + fabric_mod_port + "_tpgt;\n" buf += "}\n\n" bufi += "u16 " + fabric_mod_name + "_get_tag(struct se_portal_group *);\n" if re.search('get_default_depth', fo): buf += "u32 " + fabric_mod_name + "_get_default_depth(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_default_depth(struct se_portal_group *);\n" if re.search('get_pr_transport_id\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_pr_transport_id(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl,\n" buf += " struct t10_pr_registration *pr_reg,\n" buf += " int *format_code,\n" buf += " unsigned char *buf)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " int ret = 0;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " ret = fc_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " ret = sas_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " ret = iscsi_get_pr_transport_id(se_tpg, se_nacl, pr_reg,\n" buf += " format_code, buf);\n" buf += " break;\n" buf += " }\n\n" buf += " return ret;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_pr_transport_id(struct se_portal_group *,\n" bufi += " struct se_node_acl *, struct t10_pr_registration *,\n" bufi += " int *, unsigned char *);\n" if re.search('get_pr_transport_id_len\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_pr_transport_id_len(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl,\n" buf += " struct t10_pr_registration *pr_reg,\n" buf += " int *format_code)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " int ret = 0;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " ret = fc_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " ret = sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " ret = iscsi_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg,\n" buf += " format_code);\n" buf += " break;\n" buf += " }\n\n" buf += " return ret;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_pr_transport_id_len(struct se_portal_group *,\n" bufi += " struct se_node_acl *, struct t10_pr_registration *,\n" bufi += " int *);\n" if re.search('parse_pr_out_transport_id\)\(', fo): buf += "char *" + fabric_mod_name + "_parse_pr_out_transport_id(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " const char *buf,\n" buf += " u32 *out_tid_len,\n" buf += " char **port_nexus_ptr)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n" buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n" buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = tpg->" + fabric_mod_port + ";\n" buf += " char *tid = NULL;\n\n" buf += " switch (" + fabric_mod_port + "->" + fabric_mod_port + "_proto_id) {\n" if proto_ident == "FC": buf += " case SCSI_PROTOCOL_FCP:\n" buf += " default:\n" buf += " tid = fc_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" elif proto_ident == "SAS": buf += " case SCSI_PROTOCOL_SAS:\n" buf += " default:\n" buf += " tid = sas_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" elif proto_ident == "iSCSI": buf += " case SCSI_PROTOCOL_ISCSI:\n" buf += " default:\n" buf += " tid = iscsi_parse_pr_out_transport_id(se_tpg, buf, out_tid_len,\n" buf += " port_nexus_ptr);\n" buf += " }\n\n" buf += " return tid;\n" buf += "}\n\n" bufi += "char *" + fabric_mod_name + "_parse_pr_out_transport_id(struct se_portal_group *,\n" bufi += " const char *, u32 *, char **);\n" if re.search('alloc_fabric_acl\)\(', fo): buf += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl;\n\n" buf += " nacl = kzalloc(sizeof(struct " + fabric_mod_name + "_nacl), GFP_KERNEL);\n" buf += " if (!(nacl)) {\n" buf += " printk(KERN_ERR \"Unable to alocate struct " + fabric_mod_name + "_nacl\\n\");\n" buf += " return NULL;\n" buf += " }\n\n" buf += " return &nacl->se_node_acl;\n" buf += "}\n\n" bufi += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *);\n" if re.search('release_fabric_acl\)\(', fo): buf += "void " + fabric_mod_name + "_release_fabric_acl(\n" buf += " struct se_portal_group *se_tpg,\n" buf += " struct se_node_acl *se_nacl)\n" buf += "{\n" buf += " struct " + fabric_mod_name + "_nacl *nacl = container_of(se_nacl,\n" buf += " struct " + fabric_mod_name + "_nacl, se_node_acl);\n" buf += " kfree(nacl);\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_release_fabric_acl(struct se_portal_group *,\n" bufi += " struct se_node_acl *);\n" if re.search('tpg_get_inst_index\)\(', fo): buf += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *se_tpg)\n" buf += "{\n" buf += " return 1;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *);\n" if re.search('release_cmd_to_pool', fo): buf += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_release_cmd(struct se_cmd *);\n" if re.search('shutdown_session\)\(', fo): buf += "int " + fabric_mod_name + "_shutdown_session(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_shutdown_session(struct se_session *);\n" if re.search('close_session\)\(', fo): buf += "void " + fabric_mod_name + "_close_session(struct se_session *se_sess)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_close_session(struct se_session *);\n" if re.search('stop_session\)\(', fo): buf += "void " + fabric_mod_name + "_stop_session(struct se_session *se_sess, int sess_sleep , int conn_sleep)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_stop_session(struct se_session *, int, int);\n" if re.search('fall_back_to_erl0\)\(', fo): buf += "void " + fabric_mod_name + "_reset_nexus(struct se_session *se_sess)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_reset_nexus(struct se_session *);\n" if re.search('sess_logged_in\)\(', fo): buf += "int " + fabric_mod_name + "_sess_logged_in(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_sess_logged_in(struct se_session *);\n" if re.search('sess_get_index\)\(', fo): buf += "u32 " + fabric_mod_name + "_sess_get_index(struct se_session *se_sess)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_sess_get_index(struct se_session *);\n" if re.search('write_pending\)\(', fo): buf += "int " + fabric_mod_name + "_write_pending(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_write_pending(struct se_cmd *);\n" if re.search('write_pending_status\)\(', fo): buf += "int " + fabric_mod_name + "_write_pending_status(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_write_pending_status(struct se_cmd *);\n" if re.search('set_default_node_attributes\)\(', fo): buf += "void " + fabric_mod_name + "_set_default_node_attrs(struct se_node_acl *nacl)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_set_default_node_attrs(struct se_node_acl *);\n" if re.search('get_task_tag\)\(', fo): buf += "u32 " + fabric_mod_name + "_get_task_tag(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u32 " + fabric_mod_name + "_get_task_tag(struct se_cmd *);\n" if re.search('get_cmd_state\)\(', fo): buf += "int " + fabric_mod_name + "_get_cmd_state(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_get_cmd_state(struct se_cmd *);\n" if re.search('new_cmd_failure\)\(', fo): buf += "void " + fabric_mod_name + "_new_cmd_failure(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return;\n" buf += "}\n\n" bufi += "void " + fabric_mod_name + "_new_cmd_failure(struct se_cmd *);\n" if re.search('queue_data_in\)\(', fo): buf += "int " + fabric_mod_name + "_queue_data_in(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_data_in(struct se_cmd *);\n" if re.search('queue_status\)\(', fo): buf += "int " + fabric_mod_name + "_queue_status(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_status(struct se_cmd *);\n" if re.search('queue_tm_rsp\)\(', fo): buf += "int " + fabric_mod_name + "_queue_tm_rsp(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_queue_tm_rsp(struct se_cmd *);\n" if re.search('get_fabric_sense_len\)\(', fo): buf += "u16 " + fabric_mod_name + "_get_fabric_sense_len(void)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u16 " + fabric_mod_name + "_get_fabric_sense_len(void);\n" if re.search('set_fabric_sense_len\)\(', fo): buf += "u16 " + fabric_mod_name + "_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "u16 " + fabric_mod_name + "_set_fabric_sense_len(struct se_cmd *, u32);\n" if re.search('is_state_remove\)\(', fo): buf += "int " + fabric_mod_name + "_is_state_remove(struct se_cmd *se_cmd)\n" buf += "{\n" buf += " return 0;\n" buf += "}\n\n" bufi += "int " + fabric_mod_name + "_is_state_remove(struct se_cmd *);\n" if re.search('pack_lun\)\(', fo): buf += "u64 " + fabric_mod_name + "_pack_lun(unsigned int lun)\n" buf += "{\n" buf += " WARN_ON(lun >= 256);\n" buf += " /* Caller wants this byte-swapped */\n" buf += " return cpu_to_le64((lun & 0xff) << 8);\n" buf += "}\n\n" bufi += "u64 " + fabric_mod_name + "_pack_lun(unsigned int);\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() ret = pi.write(bufi) if ret: tcm_mod_err("Unable to write fi: " + fi) pi.close() return def tcm_mod_build_kbuild(fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/Makefile" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) buf += fabric_mod_name + "-objs := " + fabric_mod_name + "_fabric.o \\\n" buf += " " + fabric_mod_name + "_configfs.o\n" buf += "obj-$(CONFIG_" + fabric_mod_name.upper() + ") += " + fabric_mod_name + ".o\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_build_kconfig(fabric_mod_dir_var, fabric_mod_name): buf = "" f = fabric_mod_dir_var + "/Kconfig" print "Writing file: " + f p = open(f, 'w') if not p: tcm_mod_err("Unable to open file: " + f) buf = "config " + fabric_mod_name.upper() + "\n" buf += " tristate \"" + fabric_mod_name.upper() + " fabric module\"\n" buf += " depends on TARGET_CORE && CONFIGFS_FS\n" buf += " default n\n" buf += " ---help---\n" buf += " Say Y here to enable the " + fabric_mod_name.upper() + " fabric module\n" ret = p.write(buf) if ret: tcm_mod_err("Unable to write f: " + f) p.close() return def tcm_mod_add_kbuild(tcm_dir, fabric_mod_name): buf = "obj-$(CONFIG_" + fabric_mod_name.upper() + ") += " + fabric_mod_name.lower() + "/\n" kbuild = tcm_dir + "/drivers/target/Makefile" f = open(kbuild, 'a') f.write(buf) f.close() return def tcm_mod_add_kconfig(tcm_dir, fabric_mod_name): buf = "source \"drivers/target/" + fabric_mod_name.lower() + "/Kconfig\"\n" kconfig = tcm_dir + "/drivers/target/Kconfig" f = open(kconfig, 'a') f.write(buf) f.close() return def main(modname, proto_ident): # proto_ident = "FC" # proto_ident = "SAS" # proto_ident = "iSCSI" tcm_dir = os.getcwd(); tcm_dir += "/../../" print "tcm_dir: " + tcm_dir fabric_mod_name = modname fabric_mod_dir = tcm_dir + "drivers/target/" + fabric_mod_name print "Set fabric_mod_name: " + fabric_mod_name print "Set fabric_mod_dir: " + fabric_mod_dir print "Using proto_ident: " + proto_ident if proto_ident != "FC" and proto_ident != "SAS" and proto_ident != "iSCSI": print "Unsupported proto_ident: " + proto_ident sys.exit(1) ret = tcm_mod_create_module_subdir(fabric_mod_dir) if ret: print "tcm_mod_create_module_subdir() failed because module already exists!" sys.exit(1) tcm_mod_build_base_includes(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_scan_fabric_ops(tcm_dir) tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_build_configfs(proto_ident, fabric_mod_dir, fabric_mod_name) tcm_mod_build_kbuild(fabric_mod_dir, fabric_mod_name) tcm_mod_build_kconfig(fabric_mod_dir, fabric_mod_name) input = raw_input("Would you like to add " + fabric_mod_name + "to drivers/target/Makefile..? [yes,no]: ") if input == "yes" or input == "y": tcm_mod_add_kbuild(tcm_dir, fabric_mod_name) input = raw_input("Would you like to add " + fabric_mod_name + "to drivers/target/Kconfig..? [yes,no]: ") if input == "yes" or input == "y": tcm_mod_add_kconfig(tcm_dir, fabric_mod_name) return parser = optparse.OptionParser() parser.add_option('-m', '--modulename', help='Module name', dest='modname', action='store', nargs=1, type='string') parser.add_option('-p', '--protoident', help='Protocol Ident', dest='protoident', action='store', nargs=1, type='string') (opts, args) = parser.parse_args() mandatories = ['modname', 'protoident'] for m in mandatories: if not opts.__dict__[m]: print "mandatory option is missing\n" parser.print_help() exit(-1) if __name__ == "__main__": main(str(opts.modname), opts.protoident)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 710, 28526, 373, 20, 3510, 13, 3922, 2630, 859, 10152, 2884, 367, 19016, 15, 1375, 21792, 11365, 63, 8816, 199, 3, 199, 3, 1898, 334, 67, 9, 7129, 820, 11136, 377, 2655, 15285, 199, 3, 1898, 334, 67, 9, 7129, 10130, 13, 21534, 14, 1308, 199, 3, 199, 3, 6529, 26, 302, 371, 32, 4989, 14, 1308, 199, 3, 199, 646, 747, 12, 984, 199, 646, 3873, 465, 1007, 199, 646, 1059, 199, 646, 295, 199, 646, 8691, 199, 199, 10606, 63, 694, 275, 3087, 199, 199, 4991, 63, 1483, 275, 942, 199, 4991, 63, 1494, 63, 694, 275, 3087, 199, 4991, 63, 1494, 63, 719, 275, 3087, 199, 4991, 63, 1494, 63, 826, 63, 719, 275, 3087, 199, 199, 318, 15288, 63, 1494, 63, 1508, 8, 1328, 304, 199, 198, 1361, 1499, 199, 198, 1274, 14, 2224, 8, 17, 9, 199, 199, 318, 15288, 63, 1494, 63, 981, 63, 578, 63, 10622, 8, 4991, 63, 1494, 63, 694, 63, 1391, 304, 421, 198, 692, 747, 14, 515, 14, 6027, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 508, 715, 26, 507, 198, 1107, 413, 421, 198, 1361, 298, 14380, 2630, 63, 1494, 63, 694, 26, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 199, 198, 3292, 275, 747, 14, 8215, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 20366, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 9, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 4161, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304, 199, 198, 2966, 2630, 63, 1494, 63, 719, 199, 198, 2966, 2630, 63, 1494, 63, 826, 63, 719, 199, 198, 1436, 275, 3087, 421, 198, 70, 275, 2630, 63, 1494, 63, 694, 63, 1391, 435, 10609, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1095, 14, 72, 2, 199, 198, 1361, 298, 16646, 570, 26, 298, 435, 289, 421, 198, 80, 275, 1551, 8, 70, 12, 283, 87, 11339, 199, 198, 692, 440, 299, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 1551, 570, 26, 298, 435, 289, 9, 421, 198, 1436, 275, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 4612, 198, 4451, 86, 16, 14, 17, 13356, 78, 2, 199, 198, 1436, 847, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 198, 708, 60, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 7745, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 302, 719, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 302, 719, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 23964, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 932, 63, 5853, 542, 63, 932, 63, 5853, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 5249, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 20934, 27167, 1347, 18428, 1572, 1947, 367, 28526, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 975, 27167, 63, 28552, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 28833, 1771, 370, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 627, 25623, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 5249, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 8707, 63, 923, 542, 63, 5249, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 17822, 4113, 314, 27167, 365, 13070, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 24, 27167, 63, 2625, 63, 344, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 27167, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 27167, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 25623, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 10988, 27167, 63, 10988, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 421, 198, 3292, 275, 299, 14, 952, 8, 1436, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 2218, 289, 26, 298, 435, 289, 9, 421, 198, 80, 14, 1600, 342, 421, 198, 4991, 63, 1494, 63, 719, 275, 298, 25623, 2, 199, 198, 4991, 63, 1494, 63, 826, 63, 719, 275, 298, 78, 719, 2, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 15319, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 710, 28526, 373, 20, 3510, 13, 3922, 2630, 859, 10152, 2884, 367, 19016, 15, 1375, 21792, 11365, 63, 8816, 199, 3, 199, 3, 1898, 334, 67, 9, 7129, 820, 11136, 377, 2655, 15285, 199, 3, 1898, 334, 67, 9, 7129, 10130, 13, 21534, 14, 1308, 199, 3, 199, 3, 6529, 26, 302, 371, 32, 4989, 14, 1308, 199, 3, 199, 646, 747, 12, 984, 199, 646, 3873, 465, 1007, 199, 646, 1059, 199, 646, 295, 199, 646, 8691, 199, 199, 10606, 63, 694, 275, 3087, 199, 199, 4991, 63, 1483, 275, 942, 199, 4991, 63, 1494, 63, 694, 275, 3087, 199, 4991, 63, 1494, 63, 719, 275, 3087, 199, 4991, 63, 1494, 63, 826, 63, 719, 275, 3087, 199, 199, 318, 15288, 63, 1494, 63, 1508, 8, 1328, 304, 199, 198, 1361, 1499, 199, 198, 1274, 14, 2224, 8, 17, 9, 199, 199, 318, 15288, 63, 1494, 63, 981, 63, 578, 63, 10622, 8, 4991, 63, 1494, 63, 694, 63, 1391, 304, 421, 198, 692, 747, 14, 515, 14, 6027, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 508, 715, 26, 507, 198, 1107, 413, 421, 198, 1361, 298, 14380, 2630, 63, 1494, 63, 694, 26, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 199, 198, 3292, 275, 747, 14, 8215, 8, 4991, 63, 1494, 63, 694, 63, 1391, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 20366, 298, 435, 2630, 63, 1494, 63, 694, 63, 1391, 9, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 4161, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304, 199, 198, 2966, 2630, 63, 1494, 63, 719, 199, 198, 2966, 2630, 63, 1494, 63, 826, 63, 719, 199, 198, 1436, 275, 3087, 421, 198, 70, 275, 2630, 63, 1494, 63, 694, 63, 1391, 435, 10609, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1095, 14, 72, 2, 199, 198, 1361, 298, 16646, 570, 26, 298, 435, 289, 421, 198, 80, 275, 1551, 8, 70, 12, 283, 87, 11339, 199, 198, 692, 440, 299, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 1551, 570, 26, 298, 435, 289, 9, 421, 198, 1436, 275, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 4612, 198, 4451, 86, 16, 14, 17, 13356, 78, 2, 199, 198, 1436, 847, 5426, 4640, 298, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 198, 708, 60, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 7745, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 302, 719, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 21412, 707, 653, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 302, 719, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 23964, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 932, 63, 5853, 542, 63, 932, 63, 5853, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 5249, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 20934, 27167, 1347, 18428, 1572, 1947, 367, 28526, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 975, 27167, 63, 28552, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 28833, 1771, 370, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 627, 25623, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 5249, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 8707, 63, 923, 542, 63, 5249, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 199, 198, 1436, 847, 1867, 78, 2, 199, 198, 1436, 847, 298, 1820, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 25623, 9459, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 17822, 4113, 314, 27167, 365, 13070, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 24, 27167, 63, 2625, 63, 344, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 14161, 13064, 32612, 3747, 10977, 2812, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 85, 772, 27167, 63, 25944, 3779, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 10485, 7871, 30415, 9060, 367, 20934, 10256, 491, 719, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1560, 27167, 63, 354, 905, 435, 2630, 63, 1494, 63, 354, 14, 4142, 342, 435, 2668, 22168, 22842, 78, 2, 199, 198, 1436, 847, 298, 198, 6331, 19907, 701, 298, 435, 2630, 63, 1494, 63, 354, 435, 2668, 1875, 63, 25623, 342, 9399, 78, 2, 199, 198, 1436, 847, 298, 198, 1820, 542, 63, 10988, 27167, 63, 10988, 3779, 78, 2, 199, 198, 1436, 847, 18262, 78, 2, 421, 198, 3292, 275, 299, 14, 952, 8, 1436, 9, 199, 198, 692, 2203, 26, 507, 198, 10606, 63, 1494, 63, 1508, 480, 6005, 370, 2218, 289, 26, 298, 435, 289, 9, 421, 198, 80, 14, 1600, 342, 421, 198, 4991, 63, 1494, 63, 719, 275, 298, 25623, 2, 199, 198, 4991, 63, 1494, 63, 826, 63, 719, 275, 298, 78, 719, 2, 421, 198, 1107, 199, 199, 318, 15288, 63, 1494, 63, 1506, 63, 15319, 63, 2613, 8, 4991, 63, 1494, 63, 694, 63, 1391, 12, 2630, 63, 1494, 63, 354, 304, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
mozilla/make.mozilla.org
vendor-local/lib/python/celery/utils/dispatch/saferef.py
14
10768
# -*- coding: utf-8 -*- """ "Safe weakrefs", originally from pyDispatcher. Provides a way to safely weakref any function, including bound methods (which aren't handled by the core weakref module). """ from __future__ import absolute_import import weakref import traceback def safe_ref(target, on_delete=None): """Return a *safe* weak reference to a callable target :param target: the object to be weakly referenced, if it's a bound method reference, will create a :class:`BoundMethodWeakref`, otherwise creates a simple :class:`weakref.ref`. :keyword on_delete: if provided, will have a hard reference stored to the callable to be called after the safe reference goes out of scope with the reference object, (either a :class:`weakref.ref` or a :class:`BoundMethodWeakref`) as argument. """ if getattr(target, "im_self", None) is not None: # Turn a bound method into a BoundMethodWeakref instance. # Keep track of these instances for lookup by disconnect(). assert hasattr(target, 'im_func'), \ """safe_ref target %r has im_self, but no im_func, " \ "don't know how to create reference""" % (target, ) return get_bound_method_weakref(target=target, on_delete=on_delete) if callable(on_delete): return weakref.ref(target, on_delete) else: return weakref.ref(target) class BoundMethodWeakref(object): """'Safe' and reusable weak references to instance methods. BoundMethodWeakref objects provide a mechanism for referencing a bound method without requiring that the method object itself (which is normally a transient object) is kept alive. Instead, the BoundMethodWeakref object keeps weak references to both the object and the function which together define the instance method. .. attribute:: key the identity key for the reference, calculated by the class's :meth:`calculate_key` method applied to the target instance method .. attribute:: deletion_methods sequence of callable objects taking single argument, a reference to this object which will be called when *either* the target object or target function is garbage collected (i.e. when this object becomes invalid). These are specified as the on_delete parameters of :func:`safe_ref` calls. .. attribute:: weak_self weak reference to the target object .. attribute:: weak_func weak reference to the target function .. attribute:: _all_instances class attribute pointing to all live BoundMethodWeakref objects indexed by the class's `calculate_key(target)` method applied to the target objects. This weak value dictionary is used to short-circuit creation so that multiple references to the same (object, function) pair produce the same BoundMethodWeakref instance. """ _all_instances = weakref.WeakValueDictionary() def __new__(cls, target, on_delete=None, *arguments, **named): """Create new instance or return current instance Basically this method of construction allows us to short-circuit creation of references to already- referenced instance methods. The key corresponding to the target is calculated, and if there is already an existing reference, that is returned, with its deletionMethods attribute updated. Otherwise the new instance is created and registered in the table of already-referenced methods. """ key = cls.calculate_key(target) current = cls._all_instances.get(key) if current is not None: current.deletion_methods.append(on_delete) return current else: base = super(BoundMethodWeakref, cls).__new__(cls) cls._all_instances[key] = base base.__init__(target, on_delete, *arguments, **named) return base def __init__(self, target, on_delete=None): """Return a weak-reference-like instance for a bound method :param target: the instance-method target for the weak reference, must have `im_self` and `im_func` attributes and be reconstructable via:: target.im_func.__get__(target.im_self) which is true of built-in instance methods. :keyword on_delete: optional callback which will be called when this weak reference ceases to be valid (i.e. either the object or the function is garbage collected). Should take a single argument, which will be passed a pointer to this object. """ def remove(weak, self=self): """Set self.is_dead to true when method or instance is destroyed""" methods = self.deletion_methods[:] del(self.deletion_methods[:]) try: del(self.__class__._all_instances[self.key]) except KeyError: pass for function in methods: try: if callable(function): function(self) except Exception, exc: try: traceback.print_exc() except AttributeError: print("Exception during saferef %s cleanup function " "%s: %s" % (self, function, exc)) self.deletion_methods = [on_delete] self.key = self.calculate_key(target) self.weak_self = weakref.ref(target.im_self, remove) self.weak_func = weakref.ref(target.im_func, remove) self.self_name = str(target.im_self) self.func_name = str(target.im_func.__name__) def calculate_key(cls, target): """Calculate the reference key for this reference Currently this is a two-tuple of the `id()`'s of the target object and the target function respectively. """ return id(target.im_self), id(target.im_func) calculate_key = classmethod(calculate_key) def __str__(self): """Give a friendly representation of the object""" return """%s( %s.%s )""" % ( self.__class__.__name__, self.self_name, self.func_name, ) __repr__ = __str__ def __nonzero__(self): """Whether we are still a valid reference""" return self() is not None def __cmp__(self, other): """Compare with another reference""" if not isinstance(other, self.__class__): return cmp(self.__class__, type(other)) return cmp(self.key, other.key) def __call__(self): """Return a strong reference to the bound method If the target cannot be retrieved, then will return None, otherwise returns a bound instance method for our object and function. Note: You may call this method any number of times, as it does not invalidate the reference. """ target = self.weak_self() if target is not None: function = self.weak_func() if function is not None: return function.__get__(target) class BoundNonDescriptorMethodWeakref(BoundMethodWeakref): """A specialized :class:`BoundMethodWeakref`, for platforms where instance methods are not descriptors. It assumes that the function name and the target attribute name are the same, instead of assuming that the function is a descriptor. This approach is equally fast, but not 100% reliable because functions can be stored on an attribute named differenty than the function's name such as in:: >>> class A(object): ... pass >>> def foo(self): ... return "foo" >>> A.bar = foo But this shouldn't be a common use case. So, on platforms where methods aren't descriptors (such as Jython) this implementation has the advantage of working in the most cases. """ def __init__(self, target, on_delete=None): """Return a weak-reference-like instance for a bound method :param target: the instance-method target for the weak reference, must have `im_self` and `im_func` attributes and be reconstructable via:: target.im_func.__get__(target.im_self) which is true of built-in instance methods. :keyword on_delete: optional callback which will be called when this weak reference ceases to be valid (i.e. either the object or the function is garbage collected). Should take a single argument, which will be passed a pointer to this object. """ assert getattr(target.im_self, target.__name__) == target, \ "method %s isn't available as the attribute %s of %s" % ( target, target.__name__, target.im_self) super(BoundNonDescriptorMethodWeakref, self).__init__(target, on_delete) def __call__(self): """Return a strong reference to the bound method If the target cannot be retrieved, then will return None, otherwise returns a bound instance method for our object and function. Note: You may call this method any number of times, as it does not invalidate the reference. """ target = self.weak_self() if target is not None: function = self.weak_func() if function is not None: # Using curry() would be another option, but it erases the # "signature" of the function. That is, after a function is # curried, the inspect module can't be used to determine how # many arguments the function expects, nor what keyword # arguments it supports, and pydispatcher needs this # information. return getattr(target, function.__name__) def get_bound_method_weakref(target, on_delete): """Instantiates the appropiate :class:`BoundMethodWeakRef`, depending on the details of the underlying class method implementation.""" if hasattr(target, '__get__'): # target method is a descriptor, so the default implementation works: return BoundMethodWeakref(target=target, on_delete=on_delete) else: # no luck, use the alternative implementation: return BoundNonDescriptorMethodWeakref(target=target, on_delete=on_delete)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 2, 11090, 9282, 7655, 401, 20657, 687, 1134, 15461, 14, 199, 199, 17473, 282, 4340, 370, 19353, 13852, 1263, 805, 12, 5893, 3914, 3102, 334, 6777, 199, 65, 828, 1133, 8860, 701, 314, 6170, 13852, 859, 680, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 13852, 199, 646, 5190, 421, 199, 318, 5048, 63, 1121, 8, 1375, 12, 641, 63, 1807, 29, 403, 304, 272, 408, 1767, 282, 627, 3489, 10, 9282, 3659, 370, 282, 4550, 1347, 339, 520, 635, 1347, 26, 314, 909, 370, 506, 9282, 590, 11812, 12, 340, 652, 1159, 282, 267, 3914, 1083, 3659, 12, 911, 1218, 282, 520, 533, 1705, 8934, 3767, 18889, 1121, 3559, 267, 4257, 8491, 282, 3486, 520, 533, 1705, 21330, 14, 1121, 2313, 339, 520, 6691, 641, 63, 1807, 26, 340, 2741, 12, 911, 1172, 282, 7508, 3659, 5489, 267, 370, 314, 4550, 370, 506, 2797, 2410, 314, 5048, 3659, 267, 13538, 734, 402, 4194, 543, 314, 3659, 909, 12, 334, 22051, 282, 267, 520, 533, 1705, 21330, 14, 1121, 64, 503, 282, 520, 533, 1705, 8934, 3767, 18889, 1121, 10522, 465, 1423, 14, 272, 408, 272, 340, 2519, 8, 1375, 12, 298, 1017, 63, 277, 401, 488, 9, 365, 440, 488, 26, 267, 327, 16147, 282, 3914, 1083, 1901, 282, 21972, 3767, 18889, 1121, 1256, 14, 267, 327, 14797, 4426, 402, 3520, 4454, 367, 4237, 701, 17639, 1252, 267, 702, 2688, 8, 1375, 12, 283, 1017, 63, 1532, 659, 971, 288, 408, 3489, 63, 1121, 1347, 450, 82, 965, 3416, 63, 277, 12, 1325, 949, 3416, 63, 1532, 12, 298, 971, 288, 298, 13196, 1133, 5715, 4212, 370, 1218, 3659, 624, 450, 334, 1375, 12, 776, 267, 372, 664, 63, 3556, 63, 765, 63, 21330, 8, 1375, 29, 1375, 12, 3147, 641, 63, 1807, 29, 265, 63, 1807, 9, 272, 340, 4550, 8, 265, 63, 1807, 304, 267, 372, 13852, 14, 1121, 8, 1375, 12, 641, 63, 1807, 9, 272, 587, 26, 267, 372, 13852, 14, 1121, 8, 1375, 9, 421, 199, 533, 21972, 3767, 18889, 1121, 8, 785, 304, 272, 408, 7, 11090, 7, 436, 295, 14418, 9282, 6941, 370, 1256, 3102, 14, 339, 21972, 3767, 18889, 1121, 2251, 5647, 282, 14729, 367, 272, 28524, 282, 3914, 1083, 1928, 29963, 626, 314, 272, 1083, 909, 6337, 334, 6777, 365, 12252, 282, 7115, 14928, 272, 909, 9, 365, 16204, 19708, 14, 221, 15345, 12, 314, 21972, 3767, 18889, 1121, 272, 909, 18578, 9282, 6941, 370, 3865, 314, 909, 436, 314, 272, 805, 1314, 10451, 5627, 314, 1256, 1083, 14, 339, 2508, 2225, 447, 790, 398, 314, 8503, 790, 367, 314, 3659, 12, 12950, 267, 701, 314, 1021, 1159, 520, 5247, 1705, 12063, 63, 498, 64, 1083, 6781, 370, 314, 267, 1347, 1256, 1083, 339, 2508, 2225, 447, 14068, 63, 2474, 398, 3414, 402, 4550, 2251, 16466, 267, 2849, 1423, 12, 282, 3659, 370, 642, 909, 1314, 267, 911, 506, 2797, 1380, 627, 22051, 10, 314, 1347, 909, 503, 267, 1347, 805, 365, 17516, 13736, 334, 73, 14, 69, 14, 1380, 267, 642, 909, 15410, 3866, 680, 221, 5723, 787, 2013, 267, 465, 314, 641, 63, 1807, 2633, 402, 520, 1532, 1705, 3489, 63, 1121, 64, 4882, 14, 339, 2508, 2225, 447, 9282, 63, 277, 398, 9282, 3659, 370, 314, 1347, 909, 339, 2508, 2225, 447, 9282, 63, 1532, 398, 9282, 3659, 370, 314, 1347, 805, 339, 2508, 2225, 447, 485, 452, 63, 5990, 398, 1021, 2225, 20686, 370, 1006, 12166, 267, 21972, 3767, 18889, 1121, 2251, 15235, 701, 314, 1021, 1159, 267, 658, 12063, 63, 498, 8, 1375, 12544, 1083, 6781, 370, 314, 1347, 267, 2251, 14, 961, 9282, 574, 2600, 365, 1202, 370, 267, 3974, 13, 18516, 7143, 880, 626, 3663, 6941, 267, 370, 314, 2011, 334, 785, 12, 805, 9, 4092, 7389, 314, 267, 2011, 21972, 3767, 18889, 1121, 1256, 14, 339, 408, 339, 485, 452, 63, 5990, 275, 13852, 14, 18889, 1110, 11728, 342, 339, 347, 636, 1222, 721, 1886, 12, 1347, 12, 641, 63, 1807, 29, 403, 12, 627, 4958, 12, 1011, 4579, 304, 267, 408, 2499, 892, 1256, 503, 372, 1453, 1256, 398, 10082, 1183, 642, 1083, 402, 14538, 6127, 2739, 370, 267, 3974, 13, 18516, 7143, 402, 6941, 370, 2575, 13, 267, 11812, 1256, 3102, 14, 221, 710, 790, 5226, 267, 370, 314, 1347, 365, 12950, 12, 436, 340, 2337, 365, 2575, 267, 376, 3411, 3659, 12, 626, 365, 2138, 12, 543, 2399, 267, 14068, 10385, 2225, 4588, 14, 221, 6630, 314, 267, 892, 1256, 365, 2737, 436, 7264, 315, 314, 1817, 267, 402, 2575, 13, 22355, 3102, 14, 398, 408, 267, 790, 275, 843, 14, 12063, 63, 498, 8, 1375, 9, 267, 1453, 275, 843, 423, 452, 63, 5990, 14, 362, 8, 498, 9, 267, 340, 1453, 365, 440, 488, 26, 288, 1453, 14, 14281, 63, 2474, 14, 740, 8, 265, 63, 1807, 9, 288, 372, 1453, 267, 587, 26, 288, 1300, 275, 1613, 8, 8934, 3767, 18889, 1121, 12, 843, 2843, 1222, 721, 1886, 9, 288, 843, 423, 452, 63, 5990, 59, 498, 61, 275, 1300, 288, 1300, 855, 826, 721, 1375, 12, 641, 63, 1807, 12, 627, 4958, 12, 1011, 4579, 9, 288, 372, 1300, 339, 347, 636, 826, 721, 277, 12, 1347, 12, 641, 63, 1807, 29, 403, 304, 267, 408, 1767, 282, 9282, 13, 4443, 13, 2930, 1256, 367, 282, 3914, 1083, 398, 520, 635, 1347, 26, 314, 1256, 13, 765, 1347, 367, 314, 9282, 288, 3659, 12, 1471, 1172, 658, 1017, 63, 277, 64, 436, 658, 1017, 63, 1532, 64, 3004, 288, 436, 506, 28462, 461, 4799, 447, 2234, 1347, 14, 1017, 63, 1532, 855, 362, 721, 1375, 14, 1017, 63, 277, 9, 953, 1314, 365, 2549, 402, 6137, 13, 262, 1256, 3102, 14, 398, 520, 6691, 641, 63, 1807, 26, 2716, 3233, 1314, 911, 506, 2797, 288, 1380, 642, 9282, 3659, 10142, 3274, 370, 506, 1686, 288, 334, 73, 14, 69, 14, 1902, 314, 909, 503, 314, 805, 365, 17516, 288, 13736, 680, 221, 7719, 5452, 282, 2849, 1423, 12, 288, 1314, 911, 506, 3032, 282, 7849, 370, 642, 909, 14, 398, 408, 267 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 2, 11090, 9282, 7655, 401, 20657, 687, 1134, 15461, 14, 199, 199, 17473, 282, 4340, 370, 19353, 13852, 1263, 805, 12, 5893, 3914, 3102, 334, 6777, 199, 65, 828, 1133, 8860, 701, 314, 6170, 13852, 859, 680, 199, 624, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 13852, 199, 646, 5190, 421, 199, 318, 5048, 63, 1121, 8, 1375, 12, 641, 63, 1807, 29, 403, 304, 272, 408, 1767, 282, 627, 3489, 10, 9282, 3659, 370, 282, 4550, 1347, 339, 520, 635, 1347, 26, 314, 909, 370, 506, 9282, 590, 11812, 12, 340, 652, 1159, 282, 267, 3914, 1083, 3659, 12, 911, 1218, 282, 520, 533, 1705, 8934, 3767, 18889, 1121, 3559, 267, 4257, 8491, 282, 3486, 520, 533, 1705, 21330, 14, 1121, 2313, 339, 520, 6691, 641, 63, 1807, 26, 340, 2741, 12, 911, 1172, 282, 7508, 3659, 5489, 267, 370, 314, 4550, 370, 506, 2797, 2410, 314, 5048, 3659, 267, 13538, 734, 402, 4194, 543, 314, 3659, 909, 12, 334, 22051, 282, 267, 520, 533, 1705, 21330, 14, 1121, 64, 503, 282, 520, 533, 1705, 8934, 3767, 18889, 1121, 10522, 465, 1423, 14, 272, 408, 272, 340, 2519, 8, 1375, 12, 298, 1017, 63, 277, 401, 488, 9, 365, 440, 488, 26, 267, 327, 16147, 282, 3914, 1083, 1901, 282, 21972, 3767, 18889, 1121, 1256, 14, 267, 327, 14797, 4426, 402, 3520, 4454, 367, 4237, 701, 17639, 1252, 267, 702, 2688, 8, 1375, 12, 283, 1017, 63, 1532, 659, 971, 288, 408, 3489, 63, 1121, 1347, 450, 82, 965, 3416, 63, 277, 12, 1325, 949, 3416, 63, 1532, 12, 298, 971, 288, 298, 13196, 1133, 5715, 4212, 370, 1218, 3659, 624, 450, 334, 1375, 12, 776, 267, 372, 664, 63, 3556, 63, 765, 63, 21330, 8, 1375, 29, 1375, 12, 3147, 641, 63, 1807, 29, 265, 63, 1807, 9, 272, 340, 4550, 8, 265, 63, 1807, 304, 267, 372, 13852, 14, 1121, 8, 1375, 12, 641, 63, 1807, 9, 272, 587, 26, 267, 372, 13852, 14, 1121, 8, 1375, 9, 421, 199, 533, 21972, 3767, 18889, 1121, 8, 785, 304, 272, 408, 7, 11090, 7, 436, 295, 14418, 9282, 6941, 370, 1256, 3102, 14, 339, 21972, 3767, 18889, 1121, 2251, 5647, 282, 14729, 367, 272, 28524, 282, 3914, 1083, 1928, 29963, 626, 314, 272, 1083, 909, 6337, 334, 6777, 365, 12252, 282, 7115, 14928, 272, 909, 9, 365, 16204, 19708, 14, 221, 15345, 12, 314, 21972, 3767, 18889, 1121, 272, 909, 18578, 9282, 6941, 370, 3865, 314, 909, 436, 314, 272, 805, 1314, 10451, 5627, 314, 1256, 1083, 14, 339, 2508, 2225, 447, 790, 398, 314, 8503, 790, 367, 314, 3659, 12, 12950, 267, 701, 314, 1021, 1159, 520, 5247, 1705, 12063, 63, 498, 64, 1083, 6781, 370, 314, 267, 1347, 1256, 1083, 339, 2508, 2225, 447, 14068, 63, 2474, 398, 3414, 402, 4550, 2251, 16466, 267, 2849, 1423, 12, 282, 3659, 370, 642, 909, 1314, 267, 911, 506, 2797, 1380, 627, 22051, 10, 314, 1347, 909, 503, 267, 1347, 805, 365, 17516, 13736, 334, 73, 14, 69, 14, 1380, 267, 642, 909, 15410, 3866, 680, 221, 5723, 787, 2013, 267, 465, 314, 641, 63, 1807, 2633, 402, 520, 1532, 1705, 3489, 63, 1121, 64, 4882, 14, 339, 2508, 2225, 447, 9282, 63, 277, 398, 9282, 3659, 370, 314, 1347, 909, 339, 2508, 2225, 447, 9282, 63, 1532, 398, 9282, 3659, 370, 314, 1347, 805, 339, 2508, 2225, 447, 485, 452, 63, 5990, 398, 1021, 2225, 20686, 370, 1006, 12166, 267, 21972, 3767, 18889, 1121, 2251, 15235, 701, 314, 1021, 1159, 267, 658, 12063, 63, 498, 8, 1375, 12544, 1083, 6781, 370, 314, 1347, 267, 2251, 14, 961, 9282, 574, 2600, 365, 1202, 370, 267, 3974, 13, 18516, 7143, 880, 626, 3663, 6941, 267, 370, 314, 2011, 334, 785, 12, 805, 9, 4092, 7389, 314, 267, 2011, 21972, 3767, 18889, 1121, 1256, 14, 339, 408, 339, 485, 452, 63, 5990, 275, 13852, 14, 18889, 1110, 11728, 342, 339, 347, 636, 1222, 721, 1886, 12, 1347, 12, 641, 63, 1807, 29, 403, 12, 627, 4958, 12, 1011, 4579, 304, 267, 408, 2499, 892, 1256, 503, 372, 1453, 1256, 398, 10082, 1183, 642, 1083, 402, 14538, 6127, 2739, 370, 267, 3974, 13, 18516, 7143, 402, 6941, 370, 2575, 13, 267, 11812, 1256, 3102, 14, 221, 710, 790, 5226, 267, 370, 314, 1347, 365, 12950, 12, 436, 340, 2337, 365, 2575, 267, 376, 3411, 3659, 12, 626, 365, 2138, 12, 543, 2399, 267, 14068, 10385, 2225, 4588, 14, 221, 6630, 314, 267, 892, 1256, 365, 2737, 436, 7264, 315, 314, 1817, 267, 402, 2575, 13, 22355, 3102, 14, 398, 408, 267, 790, 275, 843, 14, 12063, 63, 498, 8, 1375, 9, 267, 1453, 275, 843, 423, 452, 63, 5990, 14, 362, 8, 498, 9, 267, 340, 1453, 365, 440, 488, 26, 288, 1453, 14, 14281, 63, 2474, 14, 740, 8, 265, 63, 1807, 9, 288, 372, 1453, 267, 587, 26, 288, 1300, 275, 1613, 8, 8934, 3767, 18889, 1121, 12, 843, 2843, 1222, 721, 1886, 9, 288, 843, 423, 452, 63, 5990, 59, 498, 61, 275, 1300, 288, 1300, 855, 826, 721, 1375, 12, 641, 63, 1807, 12, 627, 4958, 12, 1011, 4579, 9, 288, 372, 1300, 339, 347, 636, 826, 721, 277, 12, 1347, 12, 641, 63, 1807, 29, 403, 304, 267, 408, 1767, 282, 9282, 13, 4443, 13, 2930, 1256, 367, 282, 3914, 1083, 398, 520, 635, 1347, 26, 314, 1256, 13, 765, 1347, 367, 314, 9282, 288, 3659, 12, 1471, 1172, 658, 1017, 63, 277, 64, 436, 658, 1017, 63, 1532, 64, 3004, 288, 436, 506, 28462, 461, 4799, 447, 2234, 1347, 14, 1017, 63, 1532, 855, 362, 721, 1375, 14, 1017, 63, 277, 9, 953, 1314, 365, 2549, 402, 6137, 13, 262, 1256, 3102, 14, 398, 520, 6691, 641, 63, 1807, 26, 2716, 3233, 1314, 911, 506, 2797, 288, 1380, 642, 9282, 3659, 10142, 3274, 370, 506, 1686, 288, 334, 73, 14, 69, 14, 1902, 314, 909, 503, 314, 805, 365, 17516, 288, 13736, 680, 221, 7719, 5452, 282, 2849, 1423, 12, 288, 1314, 911, 506, 3032, 282, 7849, 370, 642, 909, 14, 398, 408, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
denny820909/builder
lib/python2.7/site-packages/SQLAlchemy-0.8.0b2-py2.7-linux-x86_64.egg/sqlalchemy/sql/__init__.py
6
1109
# sql/__init__.py # Copyright (C) 2005-2012 the SQLAlchemy authors and contributors <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php from .expression import ( Alias, ClauseElement, ColumnCollection, ColumnElement, CompoundSelect, Delete, FromClause, Insert, Join, Select, Selectable, TableClause, Update, alias, and_, asc, between, bindparam, case, cast, collate, column, delete, desc, distinct, except_, except_all, exists, extract, false, func, insert, intersect, intersect_all, join, label, literal, literal_column, modifier, not_, null, or_, outerjoin, outparam, over, select, subquery, table, text, true, tuple_, type_coerce, union, union_all, update, ) from .visitors import ClauseVisitor __tmp = locals().keys() __all__ = sorted([i for i in __tmp if not i.startswith('__')])
mit
[ 3, 3875, 22128, 826, 4343, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7409, 314, 14303, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 504, 1275, 5599, 492, 334, 272, 24777, 12, 272, 24433, 1180, 2162, 12, 272, 4996, 7768, 12, 272, 4996, 2162, 12, 272, 3599, 1034, 5446, 12, 272, 8496, 12, 272, 11606, 16009, 12, 272, 15496, 12, 272, 25733, 12, 272, 9496, 12, 272, 9496, 461, 12, 272, 6957, 16009, 12, 272, 6162, 12, 272, 5162, 12, 272, 436, 3131, 272, 16635, 12, 272, 3382, 12, 272, 5398, 635, 12, 272, 1930, 12, 272, 9106, 12, 272, 1048, 750, 12, 272, 2763, 12, 272, 3145, 12, 272, 4328, 12, 272, 15392, 12, 272, 871, 3131, 272, 871, 63, 452, 12, 272, 3495, 12, 272, 5536, 12, 272, 3055, 12, 272, 2562, 12, 272, 5518, 12, 272, 26066, 12, 272, 26066, 63, 452, 12, 272, 4263, 12, 272, 1768, 12, 272, 8785, 12, 272, 8785, 63, 2301, 12, 272, 17880, 12, 272, 440, 3131, 272, 2973, 12, 272, 503, 3131, 272, 6890, 904, 12, 272, 734, 635, 12, 272, 1806, 12, 272, 3504, 12, 272, 25935, 12, 272, 1817, 12, 272, 1318, 12, 272, 2549, 12, 272, 2008, 3131, 272, 730, 63, 14141, 12, 272, 13629, 12, 272, 13629, 63, 452, 12, 272, 1678, 12, 272, 776, 199, 199, 504, 1275, 5427, 1384, 492, 24433, 1180, 18324, 199, 199, 363, 2791, 275, 9480, 1252, 1612, 342, 199, 363, 452, 363, 275, 3355, 779, 73, 367, 284, 315, 636, 2791, 340, 440, 284, 14, 2460, 10714, 2023, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3875, 22128, 826, 4343, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7409, 314, 14303, 11462, 436, 8417, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 504, 1275, 5599, 492, 334, 272, 24777, 12, 272, 24433, 1180, 2162, 12, 272, 4996, 7768, 12, 272, 4996, 2162, 12, 272, 3599, 1034, 5446, 12, 272, 8496, 12, 272, 11606, 16009, 12, 272, 15496, 12, 272, 25733, 12, 272, 9496, 12, 272, 9496, 461, 12, 272, 6957, 16009, 12, 272, 6162, 12, 272, 5162, 12, 272, 436, 3131, 272, 16635, 12, 272, 3382, 12, 272, 5398, 635, 12, 272, 1930, 12, 272, 9106, 12, 272, 1048, 750, 12, 272, 2763, 12, 272, 3145, 12, 272, 4328, 12, 272, 15392, 12, 272, 871, 3131, 272, 871, 63, 452, 12, 272, 3495, 12, 272, 5536, 12, 272, 3055, 12, 272, 2562, 12, 272, 5518, 12, 272, 26066, 12, 272, 26066, 63, 452, 12, 272, 4263, 12, 272, 1768, 12, 272, 8785, 12, 272, 8785, 63, 2301, 12, 272, 17880, 12, 272, 440, 3131, 272, 2973, 12, 272, 503, 3131, 272, 6890, 904, 12, 272, 734, 635, 12, 272, 1806, 12, 272, 3504, 12, 272, 25935, 12, 272, 1817, 12, 272, 1318, 12, 272, 2549, 12, 272, 2008, 3131, 272, 730, 63, 14141, 12, 272, 13629, 12, 272, 13629, 63, 452, 12, 272, 1678, 12, 272, 776, 199, 199, 504, 1275, 5427, 1384, 492, 24433, 1180, 18324, 199, 199, 363, 2791, 275, 9480, 1252, 1612, 342, 199, 363, 452, 363, 275, 3355, 779, 73, 367, 284, 315, 636, 2791, 340, 440, 284, 14, 2460, 10714, 2023, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
wwj718/edx-video
lms/djangoapps/certificates/migrations/0010_auto__del_field_generatedcertificate_enabled__add_field_generatedcerti.py
188
5338
# -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Deleting field 'GeneratedCertificate.enabled' db.delete_column('certificates_generatedcertificate', 'enabled') # Adding field 'GeneratedCertificate.status' db.add_column('certificates_generatedcertificate', 'status', self.gf('django.db.models.fields.CharField')(default='unavailable', max_length=32), keep_default=False) def backwards(self, orm): # Adding field 'GeneratedCertificate.enabled' db.add_column('certificates_generatedcertificate', 'enabled', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) # Deleting field 'GeneratedCertificate.status' db.delete_column('certificates_generatedcertificate', 'status') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'certificates.generatedcertificate': { 'Meta': {'unique_together': "(('user', 'course_id'),)", 'object_name': 'GeneratedCertificate'}, 'certificate_id': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '32', 'blank': 'True'}), 'course_id': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'blank': 'True'}), 'distinction': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'download_url': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '128', 'blank': 'True'}), 'grade': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '5', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'key': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '32', 'blank': 'True'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'unavailable'", 'max_length': '32'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) } } complete_apps = ['certificates']
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 12706, 11414, 14, 3827, 7, 267, 1592, 14, 1807, 63, 2301, 360, 16159, 63, 10176, 6999, 297, 283, 3827, 358, 398, 327, 12934, 901, 283, 12706, 11414, 14, 1205, 7, 267, 1592, 14, 525, 63, 2301, 360, 16159, 63, 10176, 6999, 297, 283, 1205, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 28119, 297, 1390, 63, 1267, 29, 708, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 12706, 11414, 14, 3827, 7, 267, 1592, 14, 525, 63, 2301, 360, 16159, 63, 10176, 6999, 297, 283, 3827, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 797, 395, 1993, 4215, 63, 885, 29, 797, 9, 398, 327, 15920, 901, 283, 12706, 11414, 14, 1205, 7, 267, 1592, 14, 1807, 63, 2301, 360, 16159, 63, 10176, 6999, 297, 283, 1205, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 16159, 14, 10176, 6999, 356, 469, 288, 283, 3396, 356, 791, 3235, 63, 6314, 356, 9510, 751, 297, 283, 1972, 63, 344, 9878, 283, 785, 63, 354, 356, 283, 12706, 11414, 2267, 288, 283, 6999, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 885, 356, 19605, 283, 988, 63, 1267, 356, 283, 708, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 1972, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 885, 356, 19605, 283, 988, 63, 1267, 356, 283, 2299, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2686, 262, 414, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 15920, 901, 283, 12706, 11414, 14, 3827, 7, 267, 1592, 14, 1807, 63, 2301, 360, 16159, 63, 10176, 6999, 297, 283, 3827, 358, 398, 327, 12934, 901, 283, 12706, 11414, 14, 1205, 7, 267, 1592, 14, 525, 63, 2301, 360, 16159, 63, 10176, 6999, 297, 283, 1205, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 28119, 297, 1390, 63, 1267, 29, 708, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 12934, 901, 283, 12706, 11414, 14, 3827, 7, 267, 1592, 14, 525, 63, 2301, 360, 16159, 63, 10176, 6999, 297, 283, 3827, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 797, 395, 1993, 4215, 63, 885, 29, 797, 9, 398, 327, 15920, 901, 283, 12706, 11414, 14, 1205, 7, 267, 1592, 14, 1807, 63, 2301, 360, 16159, 63, 10176, 6999, 297, 283, 1205, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2473, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1216, 3071, 267, 1660, 267, 283, 16159, 14, 10176, 6999, 356, 469, 288, 283, 3396, 356, 791, 3235, 63, 6314, 356, 9510, 751, 297, 283, 1972, 63, 344, 9878, 283, 785, 63, 354, 356, 283, 12706, 11414, 2267, 288, 283, 6999, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 885, 356, 19605, 283, 988, 63, 1267, 356, 283, 708, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 1972, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 885, 356, 19605, 283, 988, 63, 1267, 356, 283,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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 ]
mnahm5/django-estore
Lib/site-packages/crispy_forms/tests/test_settings.py
28
1170
import os from crispy_forms.compatibility import text_type BASE_DIR = os.path.dirname(__file__) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.contenttypes', 'django.contrib.admin', 'crispy_forms', ) DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', } } MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', ) ROOT_URLCONF = 'urls' CRISPY_CLASS_CONVERTERS = {"textinput": "textinput textInput inputtext"} SECRET_KEY = 'secretkey' SITE_ROOT = os.path.dirname(os.path.abspath(__file__)) # http://djangosnippets.org/snippets/646/ class InvalidVarException(object): def __mod__(self, missing): try: missing_str = text_type(missing) except: missing_str = 'Failed to create string representation' raise Exception('Unknown template variable %r %s' % (missing, missing_str)) def __contains__(self, search): if search == '%s': return True return False TEMPLATE_DEBUG = True TEMPLATE_STRING_IF_INVALID = InvalidVarException()
mit
[ 646, 747, 199, 199, 504, 286, 5719, 647, 63, 3351, 14, 15390, 492, 1318, 63, 466, 421, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 199, 15942, 63, 14219, 275, 334, 272, 283, 1176, 14, 2828, 14, 1178, 297, 272, 283, 1176, 14, 2828, 14, 11676, 297, 272, 283, 1176, 14, 2828, 14, 10778, 297, 272, 283, 1176, 14, 2828, 14, 2113, 297, 272, 283, 1408, 15252, 63, 3351, 297, 199, 9, 199, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 272, 789, 199, 93, 199, 199, 19987, 63, 13748, 275, 334, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 199, 9, 199, 199, 5441, 63, 18125, 275, 283, 3603, 7, 199, 2944, 1311, 4521, 63, 6885, 63, 1864, 2111, 1157, 51, 275, 2420, 505, 1210, 582, 298, 505, 1210, 1318, 3205, 1324, 505, 3570, 199, 12961, 63, 3078, 275, 283, 4731, 498, 7, 199, 7917, 63, 5441, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 421, 199, 3, 1455, 921, 12816, 736, 78, 15147, 14, 1308, 15, 32566, 15, 11387, 15, 199, 533, 6378, 5894, 1726, 8, 785, 304, 272, 347, 636, 1494, 721, 277, 12, 4124, 304, 267, 862, 26, 288, 4124, 63, 495, 275, 1318, 63, 466, 8, 4752, 9, 267, 871, 26, 288, 4124, 63, 495, 275, 283, 4276, 370, 1218, 1059, 6025, 7, 267, 746, 2186, 360, 5912, 1978, 1750, 450, 82, 450, 83, 7, 450, 334, 4752, 12, 4124, 63, 495, 430, 339, 347, 636, 6134, 721, 277, 12, 2754, 304, 267, 340, 2754, 508, 1543, 83, 356, 288, 372, 715, 267, 372, 756, 421, 199, 7433, 63, 5287, 275, 715, 199, 7433, 63, 5353, 63, 4656, 63, 9692, 275, 6378, 5894, 1726, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 199, 199, 504, 286, 5719, 647, 63, 3351, 14, 15390, 492, 1318, 63, 466, 421, 199, 5825, 63, 3022, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 199, 199, 15942, 63, 14219, 275, 334, 272, 283, 1176, 14, 2828, 14, 1178, 297, 272, 283, 1176, 14, 2828, 14, 11676, 297, 272, 283, 1176, 14, 2828, 14, 10778, 297, 272, 283, 1176, 14, 2828, 14, 2113, 297, 272, 283, 1408, 15252, 63, 3351, 297, 199, 9, 199, 199, 27260, 275, 469, 272, 283, 885, 356, 469, 267, 283, 15956, 356, 283, 1176, 14, 697, 14, 7765, 14, 10659, 19, 297, 272, 789, 199, 93, 199, 199, 19987, 63, 13748, 275, 334, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 199, 9, 199, 199, 5441, 63, 18125, 275, 283, 3603, 7, 199, 2944, 1311, 4521, 63, 6885, 63, 1864, 2111, 1157, 51, 275, 2420, 505, 1210, 582, 298, 505, 1210, 1318, 3205, 1324, 505, 3570, 199, 12961, 63, 3078, 275, 283, 4731, 498, 7, 199, 7917, 63, 5441, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 8964, 421, 199, 3, 1455, 921, 12816, 736, 78, 15147, 14, 1308, 15, 32566, 15, 11387, 15, 199, 533, 6378, 5894, 1726, 8, 785, 304, 272, 347, 636, 1494, 721, 277, 12, 4124, 304, 267, 862, 26, 288, 4124, 63, 495, 275, 1318, 63, 466, 8, 4752, 9, 267, 871, 26, 288, 4124, 63, 495, 275, 283, 4276, 370, 1218, 1059, 6025, 7, 267, 746, 2186, 360, 5912, 1978, 1750, 450, 82, 450, 83, 7, 450, 334, 4752, 12, 4124, 63, 495, 430, 339, 347, 636, 6134, 721, 277, 12, 2754, 304, 267, 340, 2754, 508, 1543, 83, 356, 288, 372, 715, 267, 372, 756, 421, 199, 7433, 63, 5287, 275, 715, 199, 7433, 63, 5353, 63, 4656, 63, 9692, 275, 6378, 5894, 1726, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
HyperloopTeam/FullOpenMDAO
lib/python2.7/site-packages/networkx-1.9.1-py2.7.egg/networkx/algorithms/centrality/katz.py
8
9925
""" Katz centrality. """ # Copyright (C) 2004-2013 by # Aric Hagberg <hagberg@lanl.gov> # Dan Schult <dschult@colgate.edu> # Pieter Swart <swart@lanl.gov> # All rights reserved. # BSD license. import networkx as nx from networkx.utils import not_implemented_for __author__ = "\n".join(['Aric Hagberg (aric.hagberg@gmail.com)', 'Pieter Swart (swart@lanl.gov)', 'Sasha Gutfraind (ag362@cornell.edu)', 'Vincent Gauthier (vgauthier@luxbulb.org)']) __all__ = ['katz_centrality', 'katz_centrality_numpy'] @not_implemented_for('multigraph') def katz_centrality(G, alpha=0.1, beta=1.0, max_iter=1000, tol=1.0e-6, nstart=None, normalized=True, weight = 'weight'): r"""Compute the Katz centrality for the nodes of the graph G. Katz centrality is related to eigenvalue centrality and PageRank. The Katz centrality for node `i` is .. math:: x_i = \alpha \sum_{j} A_{ij} x_j + \beta, where `A` is the adjacency matrix of the graph G with eigenvalues `\lambda`. The parameter `\beta` controls the initial centrality and .. math:: \alpha < \frac{1}{\lambda_{max}}. Katz centrality computes the relative influence of a node within a network by measuring the number of the immediate neighbors (first degree nodes) and also all other nodes in the network that connect to the node under consideration through these immediate neighbors. Extra weight can be provided to immediate neighbors through the parameter :math:`\beta`. Connections made with distant neighbors are, however, penalized by an attenuation factor `\alpha` which should be strictly less than the inverse largest eigenvalue of the adjacency matrix in order for the Katz centrality to be computed correctly. More information is provided in [1]_ . Parameters ---------- G : graph A NetworkX graph alpha : float Attenuation factor beta : scalar or dictionary, optional (default=1.0) Weight attributed to the immediate neighborhood. If not a scalar the dictionary must have an value for every node. max_iter : integer, optional (default=1000) Maximum number of iterations in power method. tol : float, optional (default=1.0e-6) Error tolerance used to check convergence in power method iteration. nstart : dictionary, optional Starting value of Katz iteration for each node. normalized : bool, optional (default=True) If True normalize the resulting values. weight : None or string, optional If None, all edge weights are considered equal. Otherwise holds the name of the edge attribute used as weight. Returns ------- nodes : dictionary Dictionary of nodes with Katz centrality as the value. Examples -------- >>> import math >>> G = nx.path_graph(4) >>> phi = (1+math.sqrt(5))/2.0 # largest eigenvalue of adj matrix >>> centrality = nx.katz_centrality(G,1/phi-0.01) >>> for n,c in sorted(centrality.items()): ... print("%d %0.2f"%(n,c)) 0 0.37 1 0.60 2 0.60 3 0.37 Notes ----- This algorithm it uses the power method to find the eigenvector corresponding to the largest eigenvalue of the adjacency matrix of G. The constant alpha should be strictly less than the inverse of largest eigenvalue of the adjacency matrix for the algorithm to converge. The iteration will stop after max_iter iterations or an error tolerance of number_of_nodes(G)*tol has been reached. When `\alpha = 1/\lambda_{max}` and `\beta=1` Katz centrality is the same as eigenvector centrality. For directed graphs this finds "left" eigenvectors which corresponds to the in-edges in the graph. For out-edges Katz centrality first reverse the graph with G.reverse(). References ---------- .. [1] M. Newman, Networks: An Introduction. Oxford University Press, USA, 2010, p. 720. See Also -------- katz_centrality_numpy eigenvector_centrality eigenvector_centrality_numpy pagerank hits """ from math import sqrt if len(G) == 0: return {} nnodes = G.number_of_nodes() if nstart is None: # choose starting vector with entries of 0 x = dict([(n,0) for n in G]) else: x = nstart try: b = dict.fromkeys(G,float(beta)) except (TypeError,ValueError): b = beta if set(beta) != set(G): raise nx.NetworkXError('beta dictionary ' 'must have a value for every node') # make up to max_iter iterations for i in range(max_iter): xlast = x x = dict.fromkeys(xlast, 0) # do the multiplication y^T = Alpha * x^T A - Beta for n in x: for nbr in G[n]: x[nbr] += xlast[n] * G[n][nbr].get(weight, 1) for n in x: x[n] = alpha*x[n] + b[n] # check convergence err = sum([abs(x[n]-xlast[n]) for n in x]) if err < nnodes*tol: if normalized: # normalize vector try: s = 1.0/sqrt(sum(v**2 for v in x.values())) # this should never be zero? except ZeroDivisionError: s = 1.0 else: s = 1 for n in x: x[n] *= s return x raise nx.NetworkXError('Power iteration failed to converge in ' '%d iterations.' % max_iter) @not_implemented_for('multigraph') def katz_centrality_numpy(G, alpha=0.1, beta=1.0, normalized=True, weight = 'weight'): r"""Compute the Katz centrality for the graph G. Katz centrality is related to eigenvalue centrality and PageRank. The Katz centrality for node `i` is .. math:: x_i = \alpha \sum_{j} A_{ij} x_j + \beta, where `A` is the adjacency matrix of the graph G with eigenvalues `\lambda`. The parameter `\beta` controls the initial centrality and .. math:: \alpha < \frac{1}{\lambda_{max}}. Katz centrality computes the relative influence of a node within a network by measuring the number of the immediate neighbors (first degree nodes) and also all other nodes in the network that connect to the node under consideration through these immediate neighbors. Extra weight can be provided to immediate neighbors through the parameter :math:`\beta`. Connections made with distant neighbors are, however, penalized by an attenuation factor `\alpha` which should be strictly less than the inverse largest eigenvalue of the adjacency matrix in order for the Katz centrality to be computed correctly. More information is provided in [1]_ . Parameters ---------- G : graph A NetworkX graph alpha : float Attenuation factor beta : scalar or dictionary, optional (default=1.0) Weight attributed to the immediate neighborhood. If not a scalar the dictionary must have an value for every node. normalized : bool If True normalize the resulting values. weight : None or string, optional If None, all edge weights are considered equal. Otherwise holds the name of the edge attribute used as weight. Returns ------- nodes : dictionary Dictionary of nodes with Katz centrality as the value. Examples -------- >>> import math >>> G = nx.path_graph(4) >>> phi = (1+math.sqrt(5))/2.0 # largest eigenvalue of adj matrix >>> centrality = nx.katz_centrality_numpy(G,1/phi) >>> for n,c in sorted(centrality.items()): ... print("%d %0.2f"%(n,c)) 0 0.37 1 0.60 2 0.60 3 0.37 Notes ------ This algorithm uses a direct linear solver to solve the above equation. The constant alpha should be strictly less than the inverse of largest eigenvalue of the adjacency matrix for there to be a solution. When `\alpha = 1/\lambda_{max}` and `\beta=1` Katz centrality is the same as eigenvector centrality. For directed graphs this finds "left" eigenvectors which corresponds to the in-edges in the graph. For out-edges Katz centrality first reverse the graph with G.reverse(). References ---------- .. [1] M. Newman, Networks: An Introduction. Oxford University Press, USA, 2010, p. 720. See Also -------- katz_centrality eigenvector_centrality_numpy eigenvector_centrality pagerank hits """ try: import numpy as np except ImportError: raise ImportError('Requires NumPy: http://scipy.org/') if len(G) == 0: return {} try: nodelist = beta.keys() if set(nodelist) != set(G): raise nx.NetworkXError('beta dictionary ' 'must have a value for every node') b = np.array(list(beta.values()), dtype=float) except AttributeError: nodelist = G.nodes() try: b = np.ones((len(nodelist),1))*float(beta) except (TypeError,ValueError): raise nx.NetworkXError('beta must be a number') A = nx.adj_matrix(G, nodelist=nodelist, weight=weight).todense().T n = np.array(A).shape[0] centrality = np.linalg.solve( np.eye(n,n) - (alpha * A) , b) if normalized: norm = np.sign(sum(centrality)) * np.linalg.norm(centrality) else: norm = 1.0 centrality = dict(zip(nodelist, map(float,centrality/norm))) return centrality # fixture for nose tests def setup_module(module): from nose import SkipTest try: import numpy import scipy except: raise SkipTest("SciPy not available")
gpl-2.0
[ 624, 199, 43, 10214, 9679, 28602, 14, 199, 624, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6965, 701, 199, 3, 259, 437, 1567, 869, 643, 14630, 665, 72, 643, 14630, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 24747, 22985, 427, 665, 795, 335, 427, 32, 761, 3237, 14, 8654, 30, 199, 3, 259, 510, 1873, 351, 16666, 580, 665, 3519, 580, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 2900, 4481, 4644, 14, 199, 3, 259, 6289, 4190, 14, 199, 646, 24313, 465, 8484, 199, 504, 24313, 14, 1208, 492, 440, 63, 13825, 63, 509, 199, 363, 2502, 363, 275, 1867, 78, 1674, 904, 2941, 33, 1567, 869, 643, 14630, 334, 285, 530, 14, 72, 643, 14630, 32, 6799, 14, 957, 3196, 717, 283, 48, 1873, 351, 16666, 580, 334, 3519, 580, 32, 1502, 76, 14, 16294, 3196, 717, 283, 51, 1119, 65, 598, 1624, 345, 688, 334, 643, 16369, 32, 989, 78, 1697, 14, 8654, 3196, 717, 283, 54, 262, 2946, 598, 1178, 4446, 334, 10929, 1178, 4446, 32, 10836, 1774, 348, 66, 14, 1308, 9, 1105, 199, 199, 363, 452, 363, 275, 788, 75, 10214, 63, 2497, 28602, 297, 1779, 283, 75, 10214, 63, 2497, 28602, 63, 4714, 418, 199, 199, 32, 1397, 63, 13825, 63, 509, 360, 3029, 2180, 358, 199, 318, 1022, 10214, 63, 2497, 28602, 8, 39, 12, 5131, 29, 16, 14, 17, 12, 8201, 29, 17, 14, 16, 12, 490, 1390, 63, 1661, 29, 5279, 12, 9561, 29, 17, 14, 16, 69, 13, 22, 12, 302, 928, 29, 403, 12, 9657, 29, 549, 12, 490, 5401, 275, 283, 3463, 735, 272, 519, 624, 8564, 314, 1804, 10214, 9679, 28602, 367, 314, 3380, 402, 314, 3343, 598, 14, 2378, 1804, 10214, 9679, 28602, 365, 4048, 370, 11471, 585, 9679, 28602, 436, 10331, 19486, 14, 272, 710, 1804, 10214, 9679, 28602, 367, 1031, 658, 73, 64, 365, 339, 2508, 3473, 447, 398, 671, 63, 73, 275, 971, 4468, 971, 1838, 7348, 74, 93, 437, 7348, 7879, 93, 671, 63, 74, 435, 971, 5683, 12, 339, 2382, 658, 33, 64, 365, 314, 1503, 21274, 3634, 402, 314, 3343, 598, 543, 22953, 29520, 2734, 2313, 339, 710, 2725, 29520, 5683, 64, 13467, 314, 2536, 9679, 28602, 436, 339, 2508, 3473, 447, 398, 971, 4468, 665, 971, 10865, 91, 17, 8847, 60, 2734, 7348, 988, 4863, 14, 2378, 1804, 10214, 9679, 28602, 21445, 314, 3847, 315, 24585, 402, 282, 1031, 4453, 282, 272, 2784, 701, 17616, 4039, 314, 1329, 402, 314, 8569, 15845, 334, 2246, 272, 13666, 3380, 9, 436, 2597, 1006, 1163, 3380, 315, 314, 2784, 626, 4907, 272, 370, 314, 1031, 1334, 8219, 1754, 4012, 3520, 8569, 15845, 14, 339, 11177, 5401, 883, 506, 2741, 370, 8569, 15845, 4012, 314, 272, 2725, 520, 3442, 1705, 60, 5683, 2313, 221, 8113, 83, 6326, 543, 2917, 867, 15845, 272, 787, 12, 13432, 12, 12374, 279, 1759, 701, 376, 22624, 4086, 6535, 29520, 4468, 64, 1314, 272, 1077, 506, 22699, 6656, 2419, 314, 11484, 17451, 11471, 585, 402, 314, 272, 1503, 21274, 3634, 315, 1865, 367, 314, 1804, 10214, 9679, 28602, 370, 506, 9235, 272, 6657, 14, 16917, 2556, 365, 2741, 315, 359, 17, 25276, 1275, 2378, 3897, 272, 4143, 272, 598, 520, 3343, 489, 437, 7220, 56, 3343, 339, 5131, 520, 2069, 489, 2854, 724, 4086, 6535, 339, 8201, 520, 6917, 503, 2600, 12, 2716, 334, 885, 29, 17, 14, 16, 9, 489, 2136, 1070, 737, 24855, 370, 314, 8569, 15503, 10422, 14, 982, 440, 282, 6917, 314, 489, 2600, 1471, 1172, 376, 574, 367, 4036, 1031, 14, 339, 1390, 63, 1661, 520, 3000, 12, 2716, 334, 885, 29, 5279, 9, 489, 14212, 1329, 402, 10615, 315, 7074, 1083, 14, 339, 9561, 520, 2069, 12, 2716, 334, 885, 29, 17, 14, 16, 69, 13, 22, 9, 489, 4520, 13464, 1202, 370, 1104, 21346, 315, 7074, 1083, 8494, 14, 339, 302, 928, 520, 2600, 12, 2716, 489, 24175, 574, 402, 1804, 10214, 8494, 367, 1924, 1031, 14, 339, 9657, 520, 2155, 12, 2716, 334, 885, 29, 549, 9, 489, 982, 715, 7666, 314, 9183, 1338, 14, 339, 5401, 520, 488, 503, 1059, 12, 2716, 489, 982, 488, 12, 1006, 6275, 4931, 787, 8652, 4472, 14, 489, 6630, 15164, 314, 536, 402, 314, 6275, 2225, 1202, 465, 5401, 14, 339, 1803, 272, 5514, 272, 3380, 520, 2600, 2126, 11932, 402, 3380, 543, 1804, 10214, 9679, 28602, 465, 314, 574, 14, 339, 6058, 272, 3001, 272, 1306, 492, 3473, 272, 1306, 598, 275, 8484, 14, 515, 63, 2180, 8, 20, 9, 272, 1306, 14524, 275, 334, 17, 11, 3442, 14, 5079, 8, 21, 13342, 18, 14, 16, 327, 17451, 11471, 585, 402, 14510, 3634, 272, 1306, 9679, 28602, 275, 8484, 14, 75, 10214, 63, 2497, 28602, 8, 39, 12, 17, 15, 10909, 13, 16, 14, 614, 9, 272, 1306, 367, 302, 12, 67, 315, 3355, 8, 2497, 28602, 14, 1744, 5109, 272, 2263, 259, 870, 3647, 68, 450, 16, 14, 18, 70, 14007, 78, 12, 67, 430, 272, 378, 378, 14, 1401, 272, 413, 378, 14, 2259, 272, 499, 378, 14, 2259, 272, 650, 378, 14, 1401, 339, 8144, 272, 9063, 272, 961, 5563, 652, 4440, 314, 7074, 1083, 370, 2342, 314, 11471, 4106, 272, 5226, 370, 314, 17451, 11471, 585, 402, 314, 1503, 21274, 3634, 402, 598, 14, 272, 710, 4413, 5131, 1077, 506, 22699, 6656, 2419, 314, 11484, 402, 17451, 272, 11471, 585, 402, 314, 1503, 21274, 3634, 367, 314, 5563, 370, 3818, 303, 14, 272, 710, 8494, 911, 3631, 2410, 1390, 63, 1661, 10615, 503, 376, 1125, 13464, 402, 272, 1329, 63, 1618, 63, 2415, 8, 39, 3342, 6896, 965, 2757, 13075, 14, 339, 3979, 29520, 4468, 275, 413, 6307, 2734, 7348, 988, 23485, 436, 29520, 5683, 29, 17, 64, 1804, 10214, 9679, 28602, 365, 314, 2011, 465, 272, 11471, 4106, 9679, 28602, 14, 339, 2104, 23667, 18312, 642, 17651, 298, 3039, 2, 29802, 1314, 13718, 272, 370, 314, 315, 13, 6929, 315, 314, 3343, 14, 221, 2104, 734, 13, 6929, 1804, 10214, 9679, 28602, 272, 1642, 3837, 314, 3343, 543, 598, 14, 4471, 1252, 2378, 14504, 272, 4143, 272, 2508, 359, 17, 61, 603, 14, 7053, 1237 ]
[ 199, 43, 10214, 9679, 28602, 14, 199, 624, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6965, 701, 199, 3, 259, 437, 1567, 869, 643, 14630, 665, 72, 643, 14630, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 24747, 22985, 427, 665, 795, 335, 427, 32, 761, 3237, 14, 8654, 30, 199, 3, 259, 510, 1873, 351, 16666, 580, 665, 3519, 580, 32, 1502, 76, 14, 16294, 30, 199, 3, 259, 2900, 4481, 4644, 14, 199, 3, 259, 6289, 4190, 14, 199, 646, 24313, 465, 8484, 199, 504, 24313, 14, 1208, 492, 440, 63, 13825, 63, 509, 199, 363, 2502, 363, 275, 1867, 78, 1674, 904, 2941, 33, 1567, 869, 643, 14630, 334, 285, 530, 14, 72, 643, 14630, 32, 6799, 14, 957, 3196, 717, 283, 48, 1873, 351, 16666, 580, 334, 3519, 580, 32, 1502, 76, 14, 16294, 3196, 717, 283, 51, 1119, 65, 598, 1624, 345, 688, 334, 643, 16369, 32, 989, 78, 1697, 14, 8654, 3196, 717, 283, 54, 262, 2946, 598, 1178, 4446, 334, 10929, 1178, 4446, 32, 10836, 1774, 348, 66, 14, 1308, 9, 1105, 199, 199, 363, 452, 363, 275, 788, 75, 10214, 63, 2497, 28602, 297, 1779, 283, 75, 10214, 63, 2497, 28602, 63, 4714, 418, 199, 199, 32, 1397, 63, 13825, 63, 509, 360, 3029, 2180, 358, 199, 318, 1022, 10214, 63, 2497, 28602, 8, 39, 12, 5131, 29, 16, 14, 17, 12, 8201, 29, 17, 14, 16, 12, 490, 1390, 63, 1661, 29, 5279, 12, 9561, 29, 17, 14, 16, 69, 13, 22, 12, 302, 928, 29, 403, 12, 9657, 29, 549, 12, 490, 5401, 275, 283, 3463, 735, 272, 519, 624, 8564, 314, 1804, 10214, 9679, 28602, 367, 314, 3380, 402, 314, 3343, 598, 14, 2378, 1804, 10214, 9679, 28602, 365, 4048, 370, 11471, 585, 9679, 28602, 436, 10331, 19486, 14, 272, 710, 1804, 10214, 9679, 28602, 367, 1031, 658, 73, 64, 365, 339, 2508, 3473, 447, 398, 671, 63, 73, 275, 971, 4468, 971, 1838, 7348, 74, 93, 437, 7348, 7879, 93, 671, 63, 74, 435, 971, 5683, 12, 339, 2382, 658, 33, 64, 365, 314, 1503, 21274, 3634, 402, 314, 3343, 598, 543, 22953, 29520, 2734, 2313, 339, 710, 2725, 29520, 5683, 64, 13467, 314, 2536, 9679, 28602, 436, 339, 2508, 3473, 447, 398, 971, 4468, 665, 971, 10865, 91, 17, 8847, 60, 2734, 7348, 988, 4863, 14, 2378, 1804, 10214, 9679, 28602, 21445, 314, 3847, 315, 24585, 402, 282, 1031, 4453, 282, 272, 2784, 701, 17616, 4039, 314, 1329, 402, 314, 8569, 15845, 334, 2246, 272, 13666, 3380, 9, 436, 2597, 1006, 1163, 3380, 315, 314, 2784, 626, 4907, 272, 370, 314, 1031, 1334, 8219, 1754, 4012, 3520, 8569, 15845, 14, 339, 11177, 5401, 883, 506, 2741, 370, 8569, 15845, 4012, 314, 272, 2725, 520, 3442, 1705, 60, 5683, 2313, 221, 8113, 83, 6326, 543, 2917, 867, 15845, 272, 787, 12, 13432, 12, 12374, 279, 1759, 701, 376, 22624, 4086, 6535, 29520, 4468, 64, 1314, 272, 1077, 506, 22699, 6656, 2419, 314, 11484, 17451, 11471, 585, 402, 314, 272, 1503, 21274, 3634, 315, 1865, 367, 314, 1804, 10214, 9679, 28602, 370, 506, 9235, 272, 6657, 14, 16917, 2556, 365, 2741, 315, 359, 17, 25276, 1275, 2378, 3897, 272, 4143, 272, 598, 520, 3343, 489, 437, 7220, 56, 3343, 339, 5131, 520, 2069, 489, 2854, 724, 4086, 6535, 339, 8201, 520, 6917, 503, 2600, 12, 2716, 334, 885, 29, 17, 14, 16, 9, 489, 2136, 1070, 737, 24855, 370, 314, 8569, 15503, 10422, 14, 982, 440, 282, 6917, 314, 489, 2600, 1471, 1172, 376, 574, 367, 4036, 1031, 14, 339, 1390, 63, 1661, 520, 3000, 12, 2716, 334, 885, 29, 5279, 9, 489, 14212, 1329, 402, 10615, 315, 7074, 1083, 14, 339, 9561, 520, 2069, 12, 2716, 334, 885, 29, 17, 14, 16, 69, 13, 22, 9, 489, 4520, 13464, 1202, 370, 1104, 21346, 315, 7074, 1083, 8494, 14, 339, 302, 928, 520, 2600, 12, 2716, 489, 24175, 574, 402, 1804, 10214, 8494, 367, 1924, 1031, 14, 339, 9657, 520, 2155, 12, 2716, 334, 885, 29, 549, 9, 489, 982, 715, 7666, 314, 9183, 1338, 14, 339, 5401, 520, 488, 503, 1059, 12, 2716, 489, 982, 488, 12, 1006, 6275, 4931, 787, 8652, 4472, 14, 489, 6630, 15164, 314, 536, 402, 314, 6275, 2225, 1202, 465, 5401, 14, 339, 1803, 272, 5514, 272, 3380, 520, 2600, 2126, 11932, 402, 3380, 543, 1804, 10214, 9679, 28602, 465, 314, 574, 14, 339, 6058, 272, 3001, 272, 1306, 492, 3473, 272, 1306, 598, 275, 8484, 14, 515, 63, 2180, 8, 20, 9, 272, 1306, 14524, 275, 334, 17, 11, 3442, 14, 5079, 8, 21, 13342, 18, 14, 16, 327, 17451, 11471, 585, 402, 14510, 3634, 272, 1306, 9679, 28602, 275, 8484, 14, 75, 10214, 63, 2497, 28602, 8, 39, 12, 17, 15, 10909, 13, 16, 14, 614, 9, 272, 1306, 367, 302, 12, 67, 315, 3355, 8, 2497, 28602, 14, 1744, 5109, 272, 2263, 259, 870, 3647, 68, 450, 16, 14, 18, 70, 14007, 78, 12, 67, 430, 272, 378, 378, 14, 1401, 272, 413, 378, 14, 2259, 272, 499, 378, 14, 2259, 272, 650, 378, 14, 1401, 339, 8144, 272, 9063, 272, 961, 5563, 652, 4440, 314, 7074, 1083, 370, 2342, 314, 11471, 4106, 272, 5226, 370, 314, 17451, 11471, 585, 402, 314, 1503, 21274, 3634, 402, 598, 14, 272, 710, 4413, 5131, 1077, 506, 22699, 6656, 2419, 314, 11484, 402, 17451, 272, 11471, 585, 402, 314, 1503, 21274, 3634, 367, 314, 5563, 370, 3818, 303, 14, 272, 710, 8494, 911, 3631, 2410, 1390, 63, 1661, 10615, 503, 376, 1125, 13464, 402, 272, 1329, 63, 1618, 63, 2415, 8, 39, 3342, 6896, 965, 2757, 13075, 14, 339, 3979, 29520, 4468, 275, 413, 6307, 2734, 7348, 988, 23485, 436, 29520, 5683, 29, 17, 64, 1804, 10214, 9679, 28602, 365, 314, 2011, 465, 272, 11471, 4106, 9679, 28602, 14, 339, 2104, 23667, 18312, 642, 17651, 298, 3039, 2, 29802, 1314, 13718, 272, 370, 314, 315, 13, 6929, 315, 314, 3343, 14, 221, 2104, 734, 13, 6929, 1804, 10214, 9679, 28602, 272, 1642, 3837, 314, 3343, 543, 598, 14, 4471, 1252, 2378, 14504, 272, 4143, 272, 2508, 359, 17, 61, 603, 14, 7053, 1237, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
brachyprint/brachyprint
doc/conf.py
1
7932
# -*- coding: utf-8 -*- # # Brachyprint documentation build configuration file, created by # sphinx-quickstart on Sun Feb 9 11:09:11 2014. # # 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('../src')) # -- 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.autodoc', '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'Brachyprint' copyright = u'2014, James Cranch, Martin Green and Oliver Madge' # 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 = '0.1' # The full version, including alpha/beta/rc tags. release = '0.1' # 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 = ['_build'] # 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 = 'Brachyprintdoc' # -- 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', 'Brachyprint.tex', u'Brachyprint Documentation', u'James Cranch, Martin Green and Oliver Madge', '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', 'brachyprint', u'Brachyprint Documentation', [u'James Cranch, Martin Green and Oliver Madge'], 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', 'Brachyprint', u'Brachyprint Documentation', u'James Cranch, Martin Green and Oliver Madge', 'Brachyprint', '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-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 32377, 335, 89, 1361, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 25625, 21141, 221, 1749, 4119, 26, 1643, 26, 845, 6927, 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, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24592, 2164, 1333, 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, 28056, 297, 283, 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, 17171, 335, 89, 1361, 7, 199, 7307, 275, 399, 7, 7280, 12, 1603, 14015, 445, 2965, 12, 603, 26788, 32585, 436, 593, 317, 422, 603, 350, 303, 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, 16, 14, 17, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 16, 14, 17, 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, 4044, 1506, 418, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 32377, 335, 89, 1361, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 25625, 21141, 221, 1749, 4119, 26, 1643, 26, 845, 6927, 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, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24592, 2164, 1333, 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, 28056, 297, 283, 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, 17171, 335, 89, 1361, 7, 199, 7307, 275, 399, 7, 7280, 12, 1603, 14015, 445, 2965, 12, 603, 26788, 32585, 436, 593, 317, 422, 603, 350, 303, 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, 16, 14, 17, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 16, 14, 17, 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, 4044, 1506, 418, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
heilaw/fast-rcnn
lib/datasets/imdb.py
37
6785
# -------------------------------------------------------- # Fast R-CNN # Copyright (c) 2015 Microsoft # Licensed under The MIT License [see LICENSE for details] # Written by Ross Girshick # -------------------------------------------------------- import os import os.path as osp import PIL from utils.cython_bbox import bbox_overlaps import numpy as np import scipy.sparse import datasets class imdb(object): """Image database.""" def __init__(self, name): self._name = name self._num_classes = 0 self._classes = [] self._image_index = [] self._obj_proposer = 'selective_search' self._roidb = None self._roidb_handler = self.default_roidb # Use this dict for storing dataset specific config options self.config = {} @property def name(self): return self._name @property def num_classes(self): return len(self._classes) @property def classes(self): return self._classes @property def image_index(self): return self._image_index @property def roidb_handler(self): return self._roidb_handler @roidb_handler.setter def roidb_handler(self, val): self._roidb_handler = val @property def roidb(self): # A roidb is a list of dictionaries, each with the following keys: # boxes # gt_overlaps # gt_classes # flipped if self._roidb is not None: return self._roidb self._roidb = self.roidb_handler() return self._roidb @property def cache_path(self): cache_path = osp.abspath(osp.join(datasets.ROOT_DIR, 'data', 'cache')) if not os.path.exists(cache_path): os.makedirs(cache_path) return cache_path @property def num_images(self): return len(self.image_index) def image_path_at(self, i): raise NotImplementedError def default_roidb(self): raise NotImplementedError def evaluate_detections(self, all_boxes, output_dir=None): """ all_boxes is a list of length number-of-classes. Each list element is a list of length number-of-images. Each of those list elements is either an empty list [] or a numpy array of detection. all_boxes[class][image] = [] or np.array of shape #dets x 5 """ raise NotImplementedError def append_flipped_images(self): num_images = self.num_images widths = [PIL.Image.open(self.image_path_at(i)).size[0] for i in xrange(num_images)] for i in xrange(num_images): boxes = self.roidb[i]['boxes'].copy() oldx1 = boxes[:, 0].copy() oldx2 = boxes[:, 2].copy() boxes[:, 0] = widths[i] - oldx2 - 1 boxes[:, 2] = widths[i] - oldx1 - 1 assert (boxes[:, 2] >= boxes[:, 0]).all() entry = {'boxes' : boxes, 'gt_overlaps' : self.roidb[i]['gt_overlaps'], 'gt_classes' : self.roidb[i]['gt_classes'], 'flipped' : True} self.roidb.append(entry) self._image_index = self._image_index * 2 def evaluate_recall(self, candidate_boxes, ar_thresh=0.5): # Record max overlap value for each gt box # Return vector of overlap values gt_overlaps = np.zeros(0) for i in xrange(self.num_images): gt_inds = np.where(self.roidb[i]['gt_classes'] > 0)[0] gt_boxes = self.roidb[i]['boxes'][gt_inds, :] boxes = candidate_boxes[i] if boxes.shape[0] == 0: continue overlaps = bbox_overlaps(boxes.astype(np.float), gt_boxes.astype(np.float)) # gt_overlaps = np.hstack((gt_overlaps, overlaps.max(axis=0))) _gt_overlaps = np.zeros((gt_boxes.shape[0])) for j in xrange(gt_boxes.shape[0]): argmax_overlaps = overlaps.argmax(axis=0) max_overlaps = overlaps.max(axis=0) gt_ind = max_overlaps.argmax() gt_ovr = max_overlaps.max() assert(gt_ovr >= 0) box_ind = argmax_overlaps[gt_ind] _gt_overlaps[j] = overlaps[box_ind, gt_ind] assert(_gt_overlaps[j] == gt_ovr) overlaps[box_ind, :] = -1 overlaps[:, gt_ind] = -1 gt_overlaps = np.hstack((gt_overlaps, _gt_overlaps)) num_pos = gt_overlaps.size gt_overlaps = np.sort(gt_overlaps) step = 0.001 thresholds = np.minimum(np.arange(0.5, 1.0 + step, step), 1.0) recalls = np.zeros_like(thresholds) for i, t in enumerate(thresholds): recalls[i] = (gt_overlaps >= t).sum() / float(num_pos) ar = 2 * np.trapz(recalls, thresholds) return ar, gt_overlaps, recalls, thresholds def create_roidb_from_box_list(self, box_list, gt_roidb): assert len(box_list) == self.num_images, \ 'Number of boxes must match number of ground-truth images' roidb = [] for i in xrange(self.num_images): boxes = box_list[i] num_boxes = boxes.shape[0] overlaps = np.zeros((num_boxes, self.num_classes), dtype=np.float32) if gt_roidb is not None: gt_boxes = gt_roidb[i]['boxes'] gt_classes = gt_roidb[i]['gt_classes'] gt_overlaps = bbox_overlaps(boxes.astype(np.float), gt_boxes.astype(np.float)) argmaxes = gt_overlaps.argmax(axis=1) maxes = gt_overlaps.max(axis=1) I = np.where(maxes > 0)[0] overlaps[I, gt_classes[argmaxes[I]]] = maxes[I] overlaps = scipy.sparse.csr_matrix(overlaps) roidb.append({'boxes' : boxes, 'gt_classes' : np.zeros((num_boxes,), dtype=np.int32), 'gt_overlaps' : overlaps, 'flipped' : False}) return roidb @staticmethod def merge_roidbs(a, b): assert len(a) == len(b) for i in xrange(len(a)): a[i]['boxes'] = np.vstack((a[i]['boxes'], b[i]['boxes'])) a[i]['gt_classes'] = np.hstack((a[i]['gt_classes'], b[i]['gt_classes'])) a[i]['gt_overlaps'] = scipy.sparse.vstack([a[i]['gt_overlaps'], b[i]['gt_overlaps']]) return a def competition_mode(self, on): """Turn competition mode on or off.""" pass
mit
[ 3, 9527, 518, 199, 3, 22613, 820, 13, 35, 7178, 199, 3, 1898, 334, 67, 9, 6900, 15332, 199, 3, 3909, 1334, 710, 10697, 844, 359, 3239, 5113, 367, 2436, 61, 199, 3, 27694, 701, 6848, 385, 598, 723, 609, 2000, 199, 3, 9527, 518, 199, 199, 646, 747, 199, 646, 747, 14, 515, 465, 312, 681, 199, 646, 14937, 199, 504, 3778, 14, 20747, 63, 11246, 492, 12494, 63, 20798, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 199, 646, 13148, 199, 199, 533, 18232, 8, 785, 304, 272, 408, 3491, 3050, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 423, 354, 275, 536, 267, 291, 423, 1507, 63, 2888, 275, 378, 267, 291, 423, 2888, 275, 942, 267, 291, 423, 1569, 63, 1080, 275, 942, 267, 291, 423, 1113, 63, 496, 555, 332, 275, 283, 261, 25982, 63, 1733, 7, 267, 291, 423, 3977, 66, 275, 488, 267, 291, 423, 3977, 66, 63, 2232, 275, 291, 14, 885, 63, 3977, 66, 267, 327, 3645, 642, 1211, 367, 16915, 4789, 2488, 1101, 1511, 267, 291, 14, 888, 275, 1052, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 1967, 63, 2888, 8, 277, 304, 267, 372, 822, 8, 277, 423, 2888, 9, 339, 768, 1829, 272, 347, 3992, 8, 277, 304, 267, 372, 291, 423, 2888, 339, 768, 1829, 272, 347, 1834, 63, 1080, 8, 277, 304, 267, 372, 291, 423, 1569, 63, 1080, 339, 768, 1829, 272, 347, 882, 344, 66, 63, 2232, 8, 277, 304, 267, 372, 291, 423, 3977, 66, 63, 2232, 339, 768, 3977, 66, 63, 2232, 14, 8345, 272, 347, 882, 344, 66, 63, 2232, 8, 277, 12, 1139, 304, 267, 291, 423, 3977, 66, 63, 2232, 275, 1139, 339, 768, 1829, 272, 347, 882, 344, 66, 8, 277, 304, 267, 327, 437, 882, 344, 66, 365, 282, 769, 402, 11196, 12, 1924, 543, 314, 2569, 2883, 26, 267, 327, 257, 17193, 267, 327, 257, 16484, 63, 20798, 267, 327, 257, 16484, 63, 2888, 267, 327, 257, 18761, 1915, 267, 340, 291, 423, 3977, 66, 365, 440, 488, 26, 288, 372, 291, 423, 3977, 66, 267, 291, 423, 3977, 66, 275, 291, 14, 3977, 66, 63, 2232, 342, 267, 372, 291, 423, 3977, 66, 339, 768, 1829, 272, 347, 2581, 63, 515, 8, 277, 304, 267, 2581, 63, 515, 275, 312, 681, 14, 4832, 8, 79, 681, 14, 904, 8, 12281, 14, 5441, 63, 3022, 12, 283, 576, 297, 283, 1637, 1333, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 1637, 63, 515, 304, 288, 747, 14, 8347, 8, 1637, 63, 515, 9, 267, 372, 2581, 63, 515, 339, 768, 1829, 272, 347, 1967, 63, 4782, 8, 277, 304, 489, 372, 822, 8, 277, 14, 1569, 63, 1080, 9, 339, 347, 1834, 63, 515, 63, 292, 8, 277, 12, 284, 304, 267, 746, 4279, 339, 347, 849, 63, 3977, 66, 8, 277, 304, 267, 746, 4279, 339, 347, 9352, 63, 271, 266, 2452, 8, 277, 12, 1006, 63, 12922, 12, 1072, 63, 694, 29, 403, 304, 267, 408, 267, 1006, 63, 12922, 365, 282, 769, 402, 2582, 1329, 13, 1618, 13, 2888, 14, 267, 7048, 769, 1819, 365, 282, 769, 402, 2582, 1329, 13, 1618, 13, 4782, 14, 267, 7048, 402, 5204, 769, 4008, 365, 1902, 376, 2701, 769, 942, 267, 503, 282, 2680, 1625, 402, 15212, 14, 398, 1006, 63, 12922, 59, 533, 1527, 1569, 61, 275, 942, 503, 980, 14, 1144, 402, 2215, 327, 271, 1086, 671, 959, 267, 408, 267, 746, 4279, 339, 347, 5666, 63, 16114, 1915, 63, 4782, 8, 277, 304, 267, 1967, 63, 4782, 275, 291, 14, 1507, 63, 4782, 267, 28186, 275, 359, 48, 1193, 14, 3491, 14, 1490, 8, 277, 14, 1569, 63, 515, 63, 292, 8, 73, 4992, 890, 59, 16, 61, 2116, 367, 284, 315, 4945, 8, 1507, 63, 4782, 1874, 267, 367, 284, 315, 4945, 8, 1507, 63, 4782, 304, 288, 17193, 275, 291, 14, 3977, 66, 59, 73, 2733, 12922, 2278, 1574, 342, 288, 2269, 88, 17, 275, 17193, 3981, 378, 1055, 1574, 342, 288, 2269, 88, 18, 275, 17193, 3981, 499, 1055, 1574, 342, 288, 17193, 3981, 378, 61, 275, 28186, 59, 73, 61, 446, 2269, 88, 18, 446, 413, 288, 17193, 3981, 499, 61, 275, 28186, 59, 73, 61, 446, 2269, 88, 17, 446, 413, 288, 702, 334, 12922, 3981, 499, 61, 2356, 17193, 3981, 378, 6575, 452, 342, 288, 2397, 275, 791, 12922, 7, 520, 17193, 12, 2151, 283, 3308, 63, 20798, 7, 520, 291, 14, 3977, 66, 59, 73, 2733, 3308, 63, 20798, 995, 2151, 283, 3308, 63, 2888, 7, 520, 291, 14, 3977, 66, 59, 73, 2733, 3308, 63, 2888, 995, 2151, 283, 16114, 1915, 7, 520, 715, 93, 288, 291, 14, 3977, 66, 14, 740, 8, 2373, 9, 267, 291, 423, 1569, 63, 1080, 275, 291, 423, 1569, 63, 1080, 627, 499, 339, 347, 9352, 63, 19183, 8, 277, 12, 7627, 63, 12922, 12, 601, 63, 14898, 29, 16, 14, 21, 304, 267, 327, 12651, 1390, 15145, 574, 367, 1924, 16484, 5689, 267, 327, 1432, 5477, 402, 15145, 1338, 267, 16484, 63, 20798, 275, 980, 14, 4250, 8, 16, 9, 267, 367, 284, 315, 4945, 8, 277, 14, 1507, 63, 4782, 304, 288, 16484, 63, 18212, 275, 980, 14, 4509, 8, 277, 14, 3977, 66, 59, 73, 2733, 3308, 63, 2888, 418, 690, 378, 2788, 16, 61, 288, 16484, 63, 12922, 275, 291, 14, 3977, 66, 59, 73, 2733, 12922, 3488, 3308, 63, 18212, 12, 12228, 953, 17193, 275, 7627, 63, 12922, 59, 73, 61, 288, 340, 17193, 14, 1392, 59, 16, 61, 508, 378, 26, 355, 1980, 288, 29755, 275, 12494, 63, 20798, 8, 12922, 14, 6041, 8, 1590, 14, 1609, 395, 3660, 16484, 63, 12922, 14, 6041, 8, 1590, 14, 1609, 430, 953, 327, 16484, 63, 20798, 275, 980, 14, 20949, 1332, 3308, 63, 20798, 12, 29755, 14, 988, 8, 3127, 29, 16, 1724, 288, 485, 3308, 63, 20798, 275, 980, 14, 4250, 1332, 3308, 63, 12922, 14, 1392, 59, 16, 2459, 288, 367, 1335, 315, 4945, 8, 3308, 63, 12922 ]
[ 9527, 518, 199, 3, 22613, 820, 13, 35, 7178, 199, 3, 1898, 334, 67, 9, 6900, 15332, 199, 3, 3909, 1334, 710, 10697, 844, 359, 3239, 5113, 367, 2436, 61, 199, 3, 27694, 701, 6848, 385, 598, 723, 609, 2000, 199, 3, 9527, 518, 199, 199, 646, 747, 199, 646, 747, 14, 515, 465, 312, 681, 199, 646, 14937, 199, 504, 3778, 14, 20747, 63, 11246, 492, 12494, 63, 20798, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 4421, 199, 646, 13148, 199, 199, 533, 18232, 8, 785, 304, 272, 408, 3491, 3050, 1041, 339, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 423, 354, 275, 536, 267, 291, 423, 1507, 63, 2888, 275, 378, 267, 291, 423, 2888, 275, 942, 267, 291, 423, 1569, 63, 1080, 275, 942, 267, 291, 423, 1113, 63, 496, 555, 332, 275, 283, 261, 25982, 63, 1733, 7, 267, 291, 423, 3977, 66, 275, 488, 267, 291, 423, 3977, 66, 63, 2232, 275, 291, 14, 885, 63, 3977, 66, 267, 327, 3645, 642, 1211, 367, 16915, 4789, 2488, 1101, 1511, 267, 291, 14, 888, 275, 1052, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 1967, 63, 2888, 8, 277, 304, 267, 372, 822, 8, 277, 423, 2888, 9, 339, 768, 1829, 272, 347, 3992, 8, 277, 304, 267, 372, 291, 423, 2888, 339, 768, 1829, 272, 347, 1834, 63, 1080, 8, 277, 304, 267, 372, 291, 423, 1569, 63, 1080, 339, 768, 1829, 272, 347, 882, 344, 66, 63, 2232, 8, 277, 304, 267, 372, 291, 423, 3977, 66, 63, 2232, 339, 768, 3977, 66, 63, 2232, 14, 8345, 272, 347, 882, 344, 66, 63, 2232, 8, 277, 12, 1139, 304, 267, 291, 423, 3977, 66, 63, 2232, 275, 1139, 339, 768, 1829, 272, 347, 882, 344, 66, 8, 277, 304, 267, 327, 437, 882, 344, 66, 365, 282, 769, 402, 11196, 12, 1924, 543, 314, 2569, 2883, 26, 267, 327, 257, 17193, 267, 327, 257, 16484, 63, 20798, 267, 327, 257, 16484, 63, 2888, 267, 327, 257, 18761, 1915, 267, 340, 291, 423, 3977, 66, 365, 440, 488, 26, 288, 372, 291, 423, 3977, 66, 267, 291, 423, 3977, 66, 275, 291, 14, 3977, 66, 63, 2232, 342, 267, 372, 291, 423, 3977, 66, 339, 768, 1829, 272, 347, 2581, 63, 515, 8, 277, 304, 267, 2581, 63, 515, 275, 312, 681, 14, 4832, 8, 79, 681, 14, 904, 8, 12281, 14, 5441, 63, 3022, 12, 283, 576, 297, 283, 1637, 1333, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 1637, 63, 515, 304, 288, 747, 14, 8347, 8, 1637, 63, 515, 9, 267, 372, 2581, 63, 515, 339, 768, 1829, 272, 347, 1967, 63, 4782, 8, 277, 304, 489, 372, 822, 8, 277, 14, 1569, 63, 1080, 9, 339, 347, 1834, 63, 515, 63, 292, 8, 277, 12, 284, 304, 267, 746, 4279, 339, 347, 849, 63, 3977, 66, 8, 277, 304, 267, 746, 4279, 339, 347, 9352, 63, 271, 266, 2452, 8, 277, 12, 1006, 63, 12922, 12, 1072, 63, 694, 29, 403, 304, 267, 408, 267, 1006, 63, 12922, 365, 282, 769, 402, 2582, 1329, 13, 1618, 13, 2888, 14, 267, 7048, 769, 1819, 365, 282, 769, 402, 2582, 1329, 13, 1618, 13, 4782, 14, 267, 7048, 402, 5204, 769, 4008, 365, 1902, 376, 2701, 769, 942, 267, 503, 282, 2680, 1625, 402, 15212, 14, 398, 1006, 63, 12922, 59, 533, 1527, 1569, 61, 275, 942, 503, 980, 14, 1144, 402, 2215, 327, 271, 1086, 671, 959, 267, 408, 267, 746, 4279, 339, 347, 5666, 63, 16114, 1915, 63, 4782, 8, 277, 304, 267, 1967, 63, 4782, 275, 291, 14, 1507, 63, 4782, 267, 28186, 275, 359, 48, 1193, 14, 3491, 14, 1490, 8, 277, 14, 1569, 63, 515, 63, 292, 8, 73, 4992, 890, 59, 16, 61, 2116, 367, 284, 315, 4945, 8, 1507, 63, 4782, 1874, 267, 367, 284, 315, 4945, 8, 1507, 63, 4782, 304, 288, 17193, 275, 291, 14, 3977, 66, 59, 73, 2733, 12922, 2278, 1574, 342, 288, 2269, 88, 17, 275, 17193, 3981, 378, 1055, 1574, 342, 288, 2269, 88, 18, 275, 17193, 3981, 499, 1055, 1574, 342, 288, 17193, 3981, 378, 61, 275, 28186, 59, 73, 61, 446, 2269, 88, 18, 446, 413, 288, 17193, 3981, 499, 61, 275, 28186, 59, 73, 61, 446, 2269, 88, 17, 446, 413, 288, 702, 334, 12922, 3981, 499, 61, 2356, 17193, 3981, 378, 6575, 452, 342, 288, 2397, 275, 791, 12922, 7, 520, 17193, 12, 2151, 283, 3308, 63, 20798, 7, 520, 291, 14, 3977, 66, 59, 73, 2733, 3308, 63, 20798, 995, 2151, 283, 3308, 63, 2888, 7, 520, 291, 14, 3977, 66, 59, 73, 2733, 3308, 63, 2888, 995, 2151, 283, 16114, 1915, 7, 520, 715, 93, 288, 291, 14, 3977, 66, 14, 740, 8, 2373, 9, 267, 291, 423, 1569, 63, 1080, 275, 291, 423, 1569, 63, 1080, 627, 499, 339, 347, 9352, 63, 19183, 8, 277, 12, 7627, 63, 12922, 12, 601, 63, 14898, 29, 16, 14, 21, 304, 267, 327, 12651, 1390, 15145, 574, 367, 1924, 16484, 5689, 267, 327, 1432, 5477, 402, 15145, 1338, 267, 16484, 63, 20798, 275, 980, 14, 4250, 8, 16, 9, 267, 367, 284, 315, 4945, 8, 277, 14, 1507, 63, 4782, 304, 288, 16484, 63, 18212, 275, 980, 14, 4509, 8, 277, 14, 3977, 66, 59, 73, 2733, 3308, 63, 2888, 418, 690, 378, 2788, 16, 61, 288, 16484, 63, 12922, 275, 291, 14, 3977, 66, 59, 73, 2733, 12922, 3488, 3308, 63, 18212, 12, 12228, 953, 17193, 275, 7627, 63, 12922, 59, 73, 61, 288, 340, 17193, 14, 1392, 59, 16, 61, 508, 378, 26, 355, 1980, 288, 29755, 275, 12494, 63, 20798, 8, 12922, 14, 6041, 8, 1590, 14, 1609, 395, 3660, 16484, 63, 12922, 14, 6041, 8, 1590, 14, 1609, 430, 953, 327, 16484, 63, 20798, 275, 980, 14, 20949, 1332, 3308, 63, 20798, 12, 29755, 14, 988, 8, 3127, 29, 16, 1724, 288, 485, 3308, 63, 20798, 275, 980, 14, 4250, 1332, 3308, 63, 12922, 14, 1392, 59, 16, 2459, 288, 367, 1335, 315, 4945, 8, 3308, 63, 12922, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
orzinal/test
scripts/create_empty_label_file.py
10
2246
#! /usr/bin/env python # ---------------------------------------------------------------------- # Copyright (C) 2014-2015, Numenta, Inc. Unless you have an agreement # with Numenta, Inc., for a separate license for this software code, the # following terms and conditions apply: # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Affero Public License for more details. # # You should have received a copy of the GNU Affero Public License # along with this program. If not, see http://www.gnu.org/licenses. # # http://numenta.org/licenses/ # ---------------------------------------------------------------------- import argparse import os try: import simplejson as json except ImportError: import json from nab.corpus import Corpus from nab.util import recur """ Create a json file containing an empty label for each datafile. """ def main(args): root = recur(os.path.dirname, os.path.realpath(__file__), n=2) if not os.path.isabs(args.labelFile): args.labelDir = os.path.join(root, args.labelFile) if not os.path.isabs(args.dataDir): args.dataDir = os.path.join(root, args.dataDir) corpus = Corpus(args.dataDir) empty_labels = {p : [] for p in corpus.dataFiles.keys() if "Known" not in p} with open(args.labelFile, "w") as outFile: outFile.write(json.dumps(empty_labels, sort_keys=True, indent=4, separators=(',', ': '))) print "Empty label file written to",args.labelFile if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--dataDir", default="data", help="Directory structure containing all the CSV " "data files.") parser.add_argument("--labelFile", default=os.path.join("labels","empty_labels.json"), help="Filename containing the empty json labels file.") args = parser.parse_args() main(args)
agpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 20359, 199, 3, 1898, 334, 35, 9, 6927, 13, 7806, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 4265, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 646, 7534, 199, 646, 747, 199, 893, 26, 523, 492, 13804, 465, 2022, 199, 2590, 3545, 26, 523, 492, 2022, 199, 199, 504, 302, 371, 14, 16780, 492, 7499, 8843, 199, 504, 302, 371, 14, 1974, 492, 5344, 199, 199, 624, 199, 2499, 282, 2022, 570, 3035, 376, 2701, 1768, 367, 1924, 666, 493, 14, 199, 624, 421, 199, 318, 2446, 8, 589, 304, 819, 1738, 275, 5344, 8, 736, 14, 515, 14, 3475, 12, 747, 14, 515, 14, 11091, 3460, 493, 10139, 302, 29, 18, 9, 819, 340, 440, 747, 14, 515, 14, 17896, 8, 589, 14, 1302, 1173, 304, 272, 1249, 14, 1302, 3567, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 1249, 14, 1302, 1173, 9, 819, 340, 440, 747, 14, 515, 14, 17896, 8, 589, 14, 576, 3567, 304, 272, 1249, 14, 576, 3567, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 1249, 14, 576, 3567, 9, 819, 16831, 275, 7499, 8843, 8, 589, 14, 576, 3567, 9, 819, 2701, 63, 3512, 275, 469, 80, 520, 942, 367, 299, 315, 16831, 14, 576, 5535, 14, 1612, 342, 340, 298, 24574, 2, 440, 315, 299, 93, 819, 543, 1551, 8, 589, 14, 1302, 1173, 12, 298, 87, 531, 465, 734, 1173, 26, 272, 734, 1173, 14, 952, 8, 1001, 14, 4180, 8, 1667, 63, 3512, 12, 1467, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 12, 17658, 2687, 23324, 7596, 283, 1724, 819, 870, 298, 4699, 1768, 570, 5313, 370, 401, 589, 14, 1302, 1173, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 1798, 275, 7534, 14, 10730, 342, 819, 1798, 14, 525, 63, 2094, 6739, 576, 3567, 401, 490, 849, 628, 576, 401, 490, 1720, 628, 6231, 5523, 3035, 1006, 314, 14689, 298, 586, 298, 576, 1584, 2685, 819, 1798, 14, 525, 63, 2094, 6739, 1302, 1173, 401, 490, 849, 29, 736, 14, 515, 14, 904, 480, 3512, 2266, 1667, 63, 3512, 14, 1001, 1288, 490, 1720, 628, 8117, 3035, 314, 2701, 2022, 3628, 570, 2685, 819, 1249, 275, 1798, 14, 1122, 63, 589, 342, 523, 2446, 8, 589, 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 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 20359, 199, 3, 1898, 334, 35, 9, 6927, 13, 7806, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 4265, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 646, 7534, 199, 646, 747, 199, 893, 26, 523, 492, 13804, 465, 2022, 199, 2590, 3545, 26, 523, 492, 2022, 199, 199, 504, 302, 371, 14, 16780, 492, 7499, 8843, 199, 504, 302, 371, 14, 1974, 492, 5344, 199, 199, 624, 199, 2499, 282, 2022, 570, 3035, 376, 2701, 1768, 367, 1924, 666, 493, 14, 199, 624, 421, 199, 318, 2446, 8, 589, 304, 819, 1738, 275, 5344, 8, 736, 14, 515, 14, 3475, 12, 747, 14, 515, 14, 11091, 3460, 493, 10139, 302, 29, 18, 9, 819, 340, 440, 747, 14, 515, 14, 17896, 8, 589, 14, 1302, 1173, 304, 272, 1249, 14, 1302, 3567, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 1249, 14, 1302, 1173, 9, 819, 340, 440, 747, 14, 515, 14, 17896, 8, 589, 14, 576, 3567, 304, 272, 1249, 14, 576, 3567, 275, 747, 14, 515, 14, 904, 8, 1231, 12, 1249, 14, 576, 3567, 9, 819, 16831, 275, 7499, 8843, 8, 589, 14, 576, 3567, 9, 819, 2701, 63, 3512, 275, 469, 80, 520, 942, 367, 299, 315, 16831, 14, 576, 5535, 14, 1612, 342, 340, 298, 24574, 2, 440, 315, 299, 93, 819, 543, 1551, 8, 589, 14, 1302, 1173, 12, 298, 87, 531, 465, 734, 1173, 26, 272, 734, 1173, 14, 952, 8, 1001, 14, 4180, 8, 1667, 63, 3512, 12, 1467, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 12, 17658, 2687, 23324, 7596, 283, 1724, 819, 870, 298, 4699, 1768, 570, 5313, 370, 401, 589, 14, 1302, 1173, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 1798, 275, 7534, 14, 10730, 342, 819, 1798, 14, 525, 63, 2094, 6739, 576, 3567, 401, 490, 849, 628, 576, 401, 490, 1720, 628, 6231, 5523, 3035, 1006, 314, 14689, 298, 586, 298, 576, 1584, 2685, 819, 1798, 14, 525, 63, 2094, 6739, 1302, 1173, 401, 490, 849, 29, 736, 14, 515, 14, 904, 480, 3512, 2266, 1667, 63, 3512, 14, 1001, 1288, 490, 1720, 628, 8117, 3035, 314, 2701, 2022, 3628, 570, 2685, 819, 1249, 275, 1798, 14, 1122, 63, 589, 342, 523, 2446, 8, 589, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nanaze/pystitch
pystitch/gen_html.py
1
3100
#!/usr/bin/env python """Utilities to generate HTML from an image. Can be called from commandline. Usage: gen_html.py image.png """ from PIL import Image import os import sys import image, dmc_colors import color_map import color def _GetTextColor(bg_color): average = sum(bg_color) / float(len(bg_color)) average_float = average / (255 / 2.0) if average_float >= 0.5: return color.RGBColor(0,0,0) return color.RGBColor(255,255,255) def _GetCssRgbColor(color): return 'rgb(%s,%s,%s)' % color def PrintPixelArrayTable(pix_arr, color_map=None): print """ <style> body { font-family: Arial, sans-serif; } table.grid { border-collapse:collapse; font-size: 6px; font-weight: bold; } .grid td { border:solid 1px #888; } .grid .square { overflow: hidden; width: 6px; height: 6px; text-align: center; } .swatch { padding: 12px; display: inline-block; } </style> """ colors = set() width, height = pix_arr.size print '<table class="grid">' for y in xrange(height): print '<tr>' for x in xrange(width): style = '' color = pix_arr[x,y] if color: style += ' background-color: %s' % _GetCssRgbColor(color) print '<td style="%s">' % style if color and color_map: text_color = _GetTextColor(color) print '<div class="square" style="color: %s">' % _GetCssRgbColor(_GetTextColor(color)) print color_map.get(color) print '</div>' print '</td>' print '</td>' print '</table>' def _PrintSwatch(color): print '<span class=swatch style="background-color: %s"></span>' % _GetCssRgbColor(color) def _GetColorMapColorsSortedByName(color_map): return sorted(color_map, key=lambda c: color_map.get(c)) def PrintColorTable(color_map): for color in _GetColorMapColorsSortedByName(color_map): key = color_map.get(color) print '<h3>Color %s</h3>' % key print '<p>' print str(color) _PrintSwatch(color) print '</p>' print '<h4>Closest colors:</h4>' closest_colors = dmc_colors.GetClosestDMCColorsPairs(color)[:5] print '<table border=1>' print '<tr>' print '<th>Distance</th><th>DMC #</th><th>Name</th><th>Color</th>' print '<tr>' for dmc_color, distance in closest_colors: print '<tr>' print '<td>%s</td>' % distance print '<td>%s</td>' % dmc_color.number print '<td>%s</td>' % dmc_color.name print '<td>' _PrintSwatch(dmc_color.color) print str(dmc_color.color) print '</td>' print '</tr>' print '</table>' def _GetImage(filename): main_dir = os.path.dirname(__file__) megaman_path = os.path.join(main_dir, filename) img = Image.open(filename).convert('RGBA') return img def main(argv): if len(argv) != 2: sys.exit(__doc__) path = argv[1] img = _GetImage(path) pix_arr = image.GetPixelArrayFromImage(img) cmap = color_map.ColorMap() PrintPixelArrayTable(pix_arr, cmap) PrintColorTable(cmap) if __name__ == '__main__': main(sys.argv)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 22905, 370, 3550, 4163, 687, 376, 1834, 14, 199, 199, 6049, 506, 2797, 687, 28279, 14, 11028, 26, 199, 199, 2268, 63, 1360, 14, 647, 1834, 14, 4524, 199, 624, 199, 199, 504, 14937, 492, 6047, 199, 199, 646, 747, 199, 646, 984, 199, 646, 1834, 12, 366, 5466, 63, 7120, 199, 646, 3164, 63, 1130, 199, 646, 3164, 199, 199, 318, 485, 1002, 1872, 4117, 8, 6856, 63, 2326, 304, 523, 8095, 275, 3089, 8, 6856, 63, 2326, 9, 1182, 2069, 8, 552, 8, 6856, 63, 2326, 430, 523, 8095, 63, 1609, 275, 8095, 1182, 334, 2299, 1182, 499, 14, 16, 9, 523, 340, 8095, 63, 1609, 2356, 378, 14, 21, 26, 272, 372, 3164, 14, 12067, 4117, 8, 16, 12, 16, 12, 16, 9, 819, 372, 3164, 14, 12067, 4117, 8, 2299, 12, 2299, 12, 2299, 9, 199, 199, 318, 485, 1002, 35, 385, 50, 4908, 4117, 8, 2326, 304, 523, 372, 283, 10090, 4042, 83, 8719, 83, 8719, 83, 3171, 450, 3164, 199, 199, 318, 9101, 14383, 3836, 3186, 8, 6644, 63, 5250, 12, 3164, 63, 1130, 29, 403, 304, 819, 870, 408, 523, 665, 2487, 30, 16421, 2396, 469, 272, 5023, 13, 6606, 26, 437, 1383, 12, 308, 796, 13, 24977, 27, 523, 789, 12244, 1817, 14, 3825, 469, 272, 9162, 13, 20681, 26, 20681, 27, 272, 5023, 13, 890, 26, 1227, 5326, 27, 272, 5023, 13, 3463, 26, 17268, 27, 523, 789, 819, 1275, 3825, 12749, 469, 272, 9162, 26, 18533, 413, 5326, 327, 13997, 27, 523, 789, 819, 1275, 3825, 1275, 9646, 221, 469, 272, 15784, 26, 8752, 27, 272, 3462, 26, 1227, 5326, 27, 272, 4569, 26, 1227, 5326, 27, 272, 1318, 13, 5743, 26, 8126, 27, 523, 789, 819, 1275, 3519, 693, 469, 272, 6273, 26, 3144, 5326, 27, 272, 2929, 26, 8308, 13, 1457, 27, 12244, 789, 523, 3068, 2487, 30, 523, 408, 819, 9229, 275, 663, 342, 523, 3462, 12, 4569, 275, 25505, 63, 5250, 14, 890, 819, 870, 2650, 1224, 1021, 628, 3825, 15603, 523, 367, 612, 315, 4945, 8, 3333, 304, 272, 870, 2650, 454, 3524, 272, 367, 671, 315, 4945, 8, 2063, 304, 489, 3449, 275, 2125, 489, 3164, 275, 25505, 63, 5250, 59, 88, 12, 89, 61, 489, 340, 3164, 26, 267, 3449, 847, 283, 8020, 13, 2326, 26, 450, 83, 7, 450, 485, 1002, 35, 385, 50, 4908, 4117, 8, 2326, 9, 489, 870, 2650, 2076, 3449, 5961, 83, 15603, 450, 3449, 32115, 340, 3164, 436, 3164, 63, 1130, 26, 267, 1318, 63, 2326, 275, 485, 1002, 1872, 4117, 8, 2326, 9, 267, 870, 2650, 3015, 1021, 628, 9646, 2, 3449, 628, 2326, 26, 450, 83, 15603, 450, 485, 1002, 35, 385, 50, 4908, 4117, 1547, 1002, 1872, 4117, 8, 2326, 430, 267, 870, 3164, 63, 1130, 14, 362, 8, 2326, 9, 267, 870, 11936, 3015, 3524, 268, 489, 870, 11936, 2076, 3524, 5591, 870, 11936, 2076, 3524, 523, 870, 11936, 1224, 3524, 199, 199, 318, 485, 5375, 51, 6821, 8, 2326, 304, 523, 870, 2650, 3751, 1021, 29, 3519, 693, 3449, 628, 7451, 13, 2326, 26, 450, 83, 10070, 3751, 3524, 450, 485, 1002, 35, 385, 50, 4908, 4117, 8, 2326, 9, 421, 199, 318, 485, 1002, 4117, 2956, 20094, 22861, 11190, 8, 2326, 63, 1130, 304, 523, 372, 3355, 8, 2326, 63, 1130, 12, 790, 29, 2734, 286, 26, 3164, 63, 1130, 14, 362, 8, 67, 430, 2043, 199, 318, 9101, 4117, 3186, 8, 2326, 63, 1130, 304, 523, 367, 3164, 315, 485, 1002, 4117, 2956, 20094, 22861, 11190, 8, 2326, 63, 1130, 304, 272, 790, 275, 3164, 63, 1130, 14, 362, 8, 2326, 9, 272, 870, 2650, 72, 19, 30, 4117, 450, 83, 1108, 72, 19, 3524, 450, 790, 272, 870, 2650, 80, 3524, 272, 870, 620, 8, 2326, 9, 272, 485, 5375, 51, 6821, 8, 2326, 9, 272, 870, 11936, 80, 3524, 221, 2286, 870, 2650, 72, 20, 30, 4724, 270, 9229, 9919, 72, 20, 3524, 339, 18284, 63, 7120, 275, 366, 5466, 63, 7120, 14, 1002, 4724, 270, 36, 7608, 20094, 12882, 83, 8, 2326, 18562, 21, 61, 272, 870, 2650, 1224, 9162, 29, 17, 3524, 272, 870, 2650, 454, 3524, 272, 870, 2650, 273, 30, 10076, 1108, 273, 2535, 273, 30, 36, 7608, 327, 1108, 273, 2535, 273, 30, 985, 1108, 273, 2535, 273, 30, 4117, 1108, 273, 3524, 272, 870, 2650, 454, 3524, 2286, 367, 366, 5466, 63, 2326, 12, 6033, 315, 18284, 63, 7120, 26, 489, 870, 2650, 454, 3524, 489, 870, 2650, 2076, 6598, 83, 1108, 2076, 3524, 450, 6033, 489, 870, 2650, 2076, 6598, 83, 1108, 2076, 3524, 450, 366, 5466, 63, 2326, 14, 1955, 489, 870, 2650, 2076, 6598, 83, 1108, 2076, 3524, 450, 366, 5466, 63, 2326, 14, 354, 489, 870, 2650, 2076, 3524, 489, 485, 5375, 51, 6821, 8, 68, 5466, 63, 2326, 14, 2326, 9, 489, 870, 620, 8, 68, 5466, 63, 2326, 14, 2326, 9, 2541, 870, 11936, 2076, 3524, 489, 870, 11936, 454, 3524, 2286, 870, 11936, 1224, 3524, 199, 199, 318, 485, 1002, 3491, 8, 1501, 304, 523, 2446, 63, 694, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 523, 562, 17740, 290, 63, 515, 275, 747, 14, 515, 14, 904, 8, 973, 63, 694, 12, 1788, 9, 523, 6050, 275, 6047, 14, 1490, 8, 1501, 680, 3916, 360, 21631, 358, 523, 372, 6050, 199, 199, 318, 2446, 8, 3020, 304, 523, 340, 822, 8, 3020, 9, 1137, 499, 26, 272, 984, 14, 2224, 3460, 1301, 3368, 819, 931, 275, 9238, 59, 17, 61, 523, 6050, 275, 485, 1002, 3491, 8, 515, 9, 523, 25505, 63, 5250, 275, 1834, 14, 1002, 14383, 3836, 2532, 3491, 8, 4060, 9, 819, 14920, 275, 3164, 63, 1130, 14, 4117, 2956, 342, 523, 9101, 14383, 3836, 3186, 8, 6644, 63, 5250, 12, 14920, 9, 523, 9101, 4117, 3186, 8, 16513, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2446, 8, 1274, 14, 3020, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 22905, 370, 3550, 4163, 687, 376, 1834, 14, 199, 199, 6049, 506, 2797, 687, 28279, 14, 11028, 26, 199, 199, 2268, 63, 1360, 14, 647, 1834, 14, 4524, 199, 624, 199, 199, 504, 14937, 492, 6047, 199, 199, 646, 747, 199, 646, 984, 199, 646, 1834, 12, 366, 5466, 63, 7120, 199, 646, 3164, 63, 1130, 199, 646, 3164, 199, 199, 318, 485, 1002, 1872, 4117, 8, 6856, 63, 2326, 304, 523, 8095, 275, 3089, 8, 6856, 63, 2326, 9, 1182, 2069, 8, 552, 8, 6856, 63, 2326, 430, 523, 8095, 63, 1609, 275, 8095, 1182, 334, 2299, 1182, 499, 14, 16, 9, 523, 340, 8095, 63, 1609, 2356, 378, 14, 21, 26, 272, 372, 3164, 14, 12067, 4117, 8, 16, 12, 16, 12, 16, 9, 819, 372, 3164, 14, 12067, 4117, 8, 2299, 12, 2299, 12, 2299, 9, 199, 199, 318, 485, 1002, 35, 385, 50, 4908, 4117, 8, 2326, 304, 523, 372, 283, 10090, 4042, 83, 8719, 83, 8719, 83, 3171, 450, 3164, 199, 199, 318, 9101, 14383, 3836, 3186, 8, 6644, 63, 5250, 12, 3164, 63, 1130, 29, 403, 304, 819, 870, 408, 523, 665, 2487, 30, 16421, 2396, 469, 272, 5023, 13, 6606, 26, 437, 1383, 12, 308, 796, 13, 24977, 27, 523, 789, 12244, 1817, 14, 3825, 469, 272, 9162, 13, 20681, 26, 20681, 27, 272, 5023, 13, 890, 26, 1227, 5326, 27, 272, 5023, 13, 3463, 26, 17268, 27, 523, 789, 819, 1275, 3825, 12749, 469, 272, 9162, 26, 18533, 413, 5326, 327, 13997, 27, 523, 789, 819, 1275, 3825, 1275, 9646, 221, 469, 272, 15784, 26, 8752, 27, 272, 3462, 26, 1227, 5326, 27, 272, 4569, 26, 1227, 5326, 27, 272, 1318, 13, 5743, 26, 8126, 27, 523, 789, 819, 1275, 3519, 693, 469, 272, 6273, 26, 3144, 5326, 27, 272, 2929, 26, 8308, 13, 1457, 27, 12244, 789, 523, 3068, 2487, 30, 523, 408, 819, 9229, 275, 663, 342, 523, 3462, 12, 4569, 275, 25505, 63, 5250, 14, 890, 819, 870, 2650, 1224, 1021, 628, 3825, 15603, 523, 367, 612, 315, 4945, 8, 3333, 304, 272, 870, 2650, 454, 3524, 272, 367, 671, 315, 4945, 8, 2063, 304, 489, 3449, 275, 2125, 489, 3164, 275, 25505, 63, 5250, 59, 88, 12, 89, 61, 489, 340, 3164, 26, 267, 3449, 847, 283, 8020, 13, 2326, 26, 450, 83, 7, 450, 485, 1002, 35, 385, 50, 4908, 4117, 8, 2326, 9, 489, 870, 2650, 2076, 3449, 5961, 83, 15603, 450, 3449, 32115, 340, 3164, 436, 3164, 63, 1130, 26, 267, 1318, 63, 2326, 275, 485, 1002, 1872, 4117, 8, 2326, 9, 267, 870, 2650, 3015, 1021, 628, 9646, 2, 3449, 628, 2326, 26, 450, 83, 15603, 450, 485, 1002, 35, 385, 50, 4908, 4117, 1547, 1002, 1872, 4117, 8, 2326, 430, 267, 870, 3164, 63, 1130, 14, 362, 8, 2326, 9, 267, 870, 11936, 3015, 3524, 268, 489, 870, 11936, 2076, 3524, 5591, 870, 11936, 2076, 3524, 523, 870, 11936, 1224, 3524, 199, 199, 318, 485, 5375, 51, 6821, 8, 2326, 304, 523, 870, 2650, 3751, 1021, 29, 3519, 693, 3449, 628, 7451, 13, 2326, 26, 450, 83, 10070, 3751, 3524, 450, 485, 1002, 35, 385, 50, 4908, 4117, 8, 2326, 9, 421, 199, 318, 485, 1002, 4117, 2956, 20094, 22861, 11190, 8, 2326, 63, 1130, 304, 523, 372, 3355, 8, 2326, 63, 1130, 12, 790, 29, 2734, 286, 26, 3164, 63, 1130, 14, 362, 8, 67, 430, 2043, 199, 318, 9101, 4117, 3186, 8, 2326, 63, 1130, 304, 523, 367, 3164, 315, 485, 1002, 4117, 2956, 20094, 22861, 11190, 8, 2326, 63, 1130, 304, 272, 790, 275, 3164, 63, 1130, 14, 362, 8, 2326, 9, 272, 870, 2650, 72, 19, 30, 4117, 450, 83, 1108, 72, 19, 3524, 450, 790, 272, 870, 2650, 80, 3524, 272, 870, 620, 8, 2326, 9, 272, 485, 5375, 51, 6821, 8, 2326, 9, 272, 870, 11936, 80, 3524, 221, 2286, 870, 2650, 72, 20, 30, 4724, 270, 9229, 9919, 72, 20, 3524, 339, 18284, 63, 7120, 275, 366, 5466, 63, 7120, 14, 1002, 4724, 270, 36, 7608, 20094, 12882, 83, 8, 2326, 18562, 21, 61, 272, 870, 2650, 1224, 9162, 29, 17, 3524, 272, 870, 2650, 454, 3524, 272, 870, 2650, 273, 30, 10076, 1108, 273, 2535, 273, 30, 36, 7608, 327, 1108, 273, 2535, 273, 30, 985, 1108, 273, 2535, 273, 30, 4117, 1108, 273, 3524, 272, 870, 2650, 454, 3524, 2286, 367, 366, 5466, 63, 2326, 12, 6033, 315, 18284, 63, 7120, 26, 489, 870, 2650, 454, 3524, 489, 870, 2650, 2076, 6598, 83, 1108, 2076, 3524, 450, 6033, 489, 870, 2650, 2076, 6598, 83, 1108, 2076, 3524, 450, 366, 5466, 63, 2326, 14, 1955, 489, 870, 2650, 2076, 6598, 83, 1108, 2076, 3524, 450, 366, 5466, 63, 2326, 14, 354, 489, 870, 2650, 2076, 3524, 489, 485, 5375, 51, 6821, 8, 68, 5466, 63, 2326, 14, 2326, 9, 489, 870, 620, 8, 68, 5466, 63, 2326, 14, 2326, 9, 2541, 870, 11936, 2076, 3524, 489, 870, 11936, 454, 3524, 2286, 870, 11936, 1224, 3524, 199, 199, 318, 485, 1002, 3491, 8, 1501, 304, 523, 2446, 63, 694, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 523, 562, 17740, 290, 63, 515, 275, 747, 14, 515, 14, 904, 8, 973, 63, 694, 12, 1788, 9, 523, 6050, 275, 6047, 14, 1490, 8, 1501, 680, 3916, 360, 21631, 358, 523, 372, 6050, 199, 199, 318, 2446, 8, 3020, 304, 523, 340, 822, 8, 3020, 9, 1137, 499, 26, 272, 984, 14, 2224, 3460, 1301, 3368, 819, 931, 275, 9238, 59, 17, 61, 523, 6050, 275, 485, 1002, 3491, 8, 515, 9, 523, 25505, 63, 5250, 275, 1834, 14, 1002, 14383, 3836, 2532, 3491, 8, 4060, 9, 819, 14920, 275, 3164, 63, 1130, 14, 4117, 2956, 342, 523, 9101, 14383, 3836, 3186, 8, 6644, 63, 5250, 12, 14920, 9, 523, 9101, 4117, 3186, 8, 16513, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 2446, 8, 1274, 14, 3020, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Jeff-Tian/mybnb
Python27/Lib/codeop.py
72
6167
r"""Utilities to compile possibly incomplete Python source code. This module provides two interfaces, broadly similar to the builtin function compile(), which take program text, a filename and a 'mode' and: - Return code object if the command is complete and valid - Return None if the command is incomplete - Raise SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). Approach: First, check if the source consists entirely of blank lines and comments; if so, replace it with 'pass', because the built-in parser doesn't always do the right thing for these. Compile three times: as is, with \n, and with \n\n appended. If it compiles as is, it's complete. If it compiles with one \n appended, we expect more. If it doesn't compile either way, we compare the error we get when compiling with \n or \n\n appended. If the errors are the same, the code is broken. But if the errors are different, we expect more. Not intuitive; not even guaranteed to hold in future releases; but this matches the compiler's behavior from Python 1.4 through 2.2, at least. Caveat: It is possible (but not likely) that the parser stops parsing with a successful outcome before reaching the end of the source; in this case, trailing symbols may be ignored instead of causing an error. For example, a backslash followed by two newlines may be followed by arbitrary garbage. This will be fixed once the API for the parser is better. The two interfaces are: compile_command(source, filename, symbol): Compiles a single command in the manner described above. CommandCompiler(): Instances of this class have __call__ methods identical in signature to compile_command; the difference is that if the instance compiles program text containing a __future__ statement, the instance 'remembers' and compiles all subsequent program texts with the statement in force. The module also provides another class: Compile(): Instances of this class act like the built-in function compile, but with 'memory' in the sense described above. """ import __future__ _features = [getattr(__future__, fname) for fname in __future__.all_feature_names] __all__ = ["compile_command", "Compile", "CommandCompiler"] PyCF_DONT_IMPLY_DEDENT = 0x200 # Matches pythonrun.h def _maybe_compile(compiler, source, filename, symbol): # Check for source consisting of only blank lines and comments for line in source.split("\n"): line = line.strip() if line and line[0] != '#': break # Leave it alone else: if symbol != "eval": source = "pass" # Replace it with a 'pass' statement err = err1 = err2 = None code = code1 = code2 = None try: code = compiler(source, filename, symbol) except SyntaxError, err: pass try: code1 = compiler(source + "\n", filename, symbol) except SyntaxError, err1: pass try: code2 = compiler(source + "\n\n", filename, symbol) except SyntaxError, err2: pass if code: return code if not code1 and repr(err1) == repr(err2): raise SyntaxError, err1 def _compile(source, filename, symbol): return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT) def compile_command(source, filename="<input>", symbol="single"): r"""Compile a command and determine whether it is incomplete. Arguments: source -- the source string; may contain \n characters filename -- optional filename from which source was read; default "<input>" symbol -- optional grammar start symbol; "single" (default) or "eval" Return value / exceptions raised: - Return a code object if the command is complete and valid - Return None if the command is incomplete - Raise SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). """ return _maybe_compile(_compile, source, filename, symbol) class Compile: """Instances of this class behave much like the built-in compile function, but if one is used to compile text containing a future statement, it "remembers" and compiles all subsequent program texts with the statement in force.""" def __init__(self): self.flags = PyCF_DONT_IMPLY_DEDENT def __call__(self, source, filename, symbol): codeob = compile(source, filename, symbol, self.flags, 1) for feature in _features: if codeob.co_flags & feature.compiler_flag: self.flags |= feature.compiler_flag return codeob class CommandCompiler: """Instances of this class have __call__ methods identical in signature to compile_command; the difference is that if the instance compiles program text containing a __future__ statement, the instance 'remembers' and compiles all subsequent program texts with the statement in force.""" def __init__(self,): self.compiler = Compile() def __call__(self, source, filename="<input>", symbol="single"): r"""Compile a command and determine whether it is incomplete. Arguments: source -- the source string; may contain \n characters filename -- optional filename from which source was read; default "<input>" symbol -- optional grammar start symbol; "single" (default) or "eval" Return value / exceptions raised: - Return a code object if the command is complete and valid - Return None if the command is incomplete - Raise SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). """ return _maybe_compile(self.compiler, source, filename, symbol)
apache-2.0
[ 82, 624, 22905, 370, 6555, 12570, 17110, 2018, 1350, 1233, 14, 2999, 199, 2765, 859, 6571, 2877, 8386, 12, 330, 5063, 590, 8545, 370, 314, 6762, 202, 199, 1593, 6555, 1062, 1314, 5452, 2240, 1318, 12, 282, 1788, 436, 282, 283, 632, 7, 202, 199, 460, 26, 2999, 199, 13, 1432, 1233, 909, 340, 314, 1414, 365, 4890, 436, 1686, 202, 199, 13, 1432, 488, 340, 314, 1414, 365, 17110, 202, 199, 13, 14771, 12053, 12, 1722, 503, 23870, 340, 314, 1414, 365, 282, 10292, 6302, 1125, 334, 21821, 436, 1722, 883, 506, 13584, 701, 10292, 24159, 18041, 680, 2999, 199, 25923, 1225, 26, 2999, 199, 7147, 12, 1104, 340, 314, 1350, 18581, 21926, 402, 4596, 2385, 436, 202, 199, 6223, 27, 340, 880, 12, 3350, 652, 543, 283, 1529, 297, 2952, 314, 6137, 13, 262, 202, 199, 2087, 3181, 1133, 3544, 886, 314, 2451, 8377, 367, 3520, 14, 2999, 199, 12626, 7795, 5431, 26, 465, 365, 12, 543, 971, 78, 12, 436, 543, 971, 78, 60, 78, 11544, 14, 221, 982, 652, 202, 199, 2014, 83, 465, 365, 12, 652, 1159, 4890, 14, 221, 982, 652, 6555, 83, 543, 1373, 971, 78, 11544, 12, 202, 199, 1129, 4282, 1655, 14, 221, 982, 652, 3181, 1133, 6555, 1902, 4340, 12, 781, 6540, 314, 202, 199, 705, 781, 664, 1380, 1013, 5662, 543, 971, 78, 503, 971, 78, 60, 78, 11544, 14, 221, 982, 314, 2552, 202, 199, 1530, 314, 2011, 12, 314, 1233, 365, 10529, 14, 221, 11017, 340, 314, 2552, 787, 3365, 12, 781, 202, 199, 4921, 1655, 14, 221, 2832, 1109, 1907, 857, 27, 440, 2755, 17334, 370, 10266, 315, 6466, 202, 199, 11840, 27, 1325, 642, 4450, 314, 6365, 1159, 5953, 687, 2018, 413, 14, 20, 202, 199, 8304, 499, 14, 18, 12, 737, 5210, 14, 2999, 199, 35, 811, 292, 26, 2999, 199, 7940, 365, 3962, 334, 7911, 440, 12060, 9, 626, 314, 1798, 20922, 6057, 543, 282, 202, 199, 18157, 15955, 2544, 12276, 316, 314, 1284, 402, 314, 1350, 27, 315, 642, 202, 199, 2546, 12, 8520, 6698, 1443, 506, 5525, 3140, 402, 25498, 376, 1125, 14, 202, 199, 1858, 2893, 12, 282, 13831, 9437, 701, 2877, 14930, 1443, 506, 9437, 701, 202, 199, 285, 8734, 17516, 14, 221, 961, 911, 506, 6317, 5403, 314, 3261, 367, 314, 1798, 365, 202, 199, 9549, 351, 14, 2999, 199, 1918, 2877, 8386, 787, 26, 2999, 199, 2014, 63, 1531, 8, 1365, 12, 1788, 12, 5272, 304, 2958, 3599, 22894, 282, 2849, 1414, 315, 314, 30800, 11736, 3432, 14, 2999, 199, 3110, 9131, 837, 2958, 10066, 83, 402, 642, 1021, 1172, 636, 1250, 363, 3102, 13130, 315, 1128, 4955, 370, 6555, 63, 1531, 27, 314, 8865, 365, 626, 340, 314, 1128, 1256, 6555, 83, 2240, 1318, 3035, 282, 636, 2443, 363, 5164, 12, 1128, 314, 1256, 283, 264, 6334, 7, 436, 6555, 83, 1006, 13372, 2240, 24857, 1128, 543, 314, 5164, 315, 3542, 14, 2999, 199, 1918, 859, 2597, 6571, 4573, 1021, 26, 2999, 199, 12626, 837, 2958, 10066, 83, 402, 642, 1021, 2454, 2839, 314, 6137, 13, 262, 805, 6555, 12, 1128, 1325, 543, 283, 4844, 7, 315, 314, 12249, 11736, 3432, 14, 202, 199, 624, 2999, 199, 646, 636, 2443, 363, 2999, 199, 63, 3179, 275, 359, 5675, 3460, 2443, 3108, 6748, 9, 17554, 367, 6748, 315, 636, 2443, 4343, 452, 63, 4445, 63, 1247, 61, 2999, 199, 363, 452, 363, 275, 2097, 2014, 63, 1531, 401, 298, 12626, 401, 298, 3110, 9131, 937, 2999, 199, 2713, 5487, 63, 31874, 63, 26312, 57, 63, 8280, 1309, 275, 378, 88, 1840, 3515, 327, 21682, 2366, 1065, 14, 72, 2999, 199, 318, 485, 11853, 63, 2014, 8, 5772, 12, 1350, 12, 1788, 12, 5272, 304, 1128, 327, 2670, 367, 1350, 22581, 402, 1454, 4596, 2385, 436, 6786, 1128, 367, 1004, 315, 1350, 14, 1294, 4582, 78, 2349, 1039, 1004, 275, 1004, 14, 1913, 342, 1039, 340, 1004, 436, 1004, 59, 16, 61, 1137, 32326, 1675, 2059, 5185, 327, 28015, 652, 23016, 1128, 587, 26, 1039, 340, 5272, 1137, 298, 2579, 582, 1675, 1350, 275, 298, 1529, 2, 258, 327, 14402, 652, 543, 282, 283, 1529, 7, 5164, 2958, 2329, 275, 2329, 17, 275, 2329, 18, 275, 488, 1128, 1233, 275, 1233, 17, 275, 1233, 18, 275, 488, 2958, 862, 26, 1039, 1233, 275, 6365, 8, 1365, 12, 1788, 12, 5272, 9, 1128, 871, 12053, 12, 2329, 26, 1039, 986, 2958, 862, 26, 1039, 1233, 17, 275, 6365, 8, 1365, 435, 1867, 78, 401, 1788, 12, 5272, 9, 1128, 871, 12053, 12, 2329, 17, 26, 1039, 986, 2958, 862, 26, 1039, 1233, 18, 275, 6365, 8, 1365, 435, 1867, 78, 60, 78, 401, 1788, 12, 5272, 9, 1128, 871, 12053, 12, 2329, 18, 26, 1039, 986, 2958, 340, 1233, 26, 1039, 372, 1233, 1128, 340, 440, 1233, 17, 436, 4700, 8, 1508, 17, 9, 508, 4700, 8, 1508, 18, 304, 1039, 746, 12053, 12, 2329, 17, 2999, 199, 318, 485, 2014, 8, 1365, 12, 1788, 12, 5272, 304, 1128, 372, 6555, 8, 1365, 12, 1788, 12, 5272, 12, 1611, 5487, 63, 31874, 63, 26312, 57, 63, 8280, 1309, 9, 2999, 199, 318, 6555, 63, 1531, 8, 1365, 12, 1788, 28066, 1210, 7166, 5272, 628, 4780, 2349, 1128, 519, 624, 12626, 282, 1414, 436, 6705, 3775, 652, 365, 17110, 14, 2958, 7628, 26, 2958, 1350, 1553, 314, 1350, 1059, 27, 1443, 1395, 971, 78, 4110, 1128, 1788, 1553, 2716, 1788, 687, 1314, 1350, 1990, 1586, 27, 849, 2628, 3886, 1210, 4335, 1128, 5272, 1553, 2716, 12528, 1343, 5272, 27, 298, 4780, 2, 334, 885, 9, 503, 298, 2579, 2, 2958, 1432, 574, 1182, 4967, 4915, 26, 2958, 446, 1432, 282, 1233, 909, 340, 314, 1414, 365, 4890, 436, 1686, 1128, 446, 1432, 488, 340, 314, 1414, 365, 17110, 1128, 446, 14771, 12053, 12, 1722, 503, 23870, 340, 314, 1414, 365, 282, 8608, 6302, 1125, 334, 21821, 436, 1722, 883, 506, 13584, 701, 8608, 24159, 18041, 680, 1128, 408, 1128, 372, 485, 11853, 63, 2014, 1547, 2014, 12, 1350, 12, 1788, 12, 5272, 9, 2999, 199, 533, 24562, 26, 1128, 408, 18194, 402, 642, 1021, 24062, 8298, 2839, 314, 6137, 13, 262, 6555, 1128, 805 ]
[ 624, 22905, 370, 6555, 12570, 17110, 2018, 1350, 1233, 14, 2999, 199, 2765, 859, 6571, 2877, 8386, 12, 330, 5063, 590, 8545, 370, 314, 6762, 202, 199, 1593, 6555, 1062, 1314, 5452, 2240, 1318, 12, 282, 1788, 436, 282, 283, 632, 7, 202, 199, 460, 26, 2999, 199, 13, 1432, 1233, 909, 340, 314, 1414, 365, 4890, 436, 1686, 202, 199, 13, 1432, 488, 340, 314, 1414, 365, 17110, 202, 199, 13, 14771, 12053, 12, 1722, 503, 23870, 340, 314, 1414, 365, 282, 10292, 6302, 1125, 334, 21821, 436, 1722, 883, 506, 13584, 701, 10292, 24159, 18041, 680, 2999, 199, 25923, 1225, 26, 2999, 199, 7147, 12, 1104, 340, 314, 1350, 18581, 21926, 402, 4596, 2385, 436, 202, 199, 6223, 27, 340, 880, 12, 3350, 652, 543, 283, 1529, 297, 2952, 314, 6137, 13, 262, 202, 199, 2087, 3181, 1133, 3544, 886, 314, 2451, 8377, 367, 3520, 14, 2999, 199, 12626, 7795, 5431, 26, 465, 365, 12, 543, 971, 78, 12, 436, 543, 971, 78, 60, 78, 11544, 14, 221, 982, 652, 202, 199, 2014, 83, 465, 365, 12, 652, 1159, 4890, 14, 221, 982, 652, 6555, 83, 543, 1373, 971, 78, 11544, 12, 202, 199, 1129, 4282, 1655, 14, 221, 982, 652, 3181, 1133, 6555, 1902, 4340, 12, 781, 6540, 314, 202, 199, 705, 781, 664, 1380, 1013, 5662, 543, 971, 78, 503, 971, 78, 60, 78, 11544, 14, 221, 982, 314, 2552, 202, 199, 1530, 314, 2011, 12, 314, 1233, 365, 10529, 14, 221, 11017, 340, 314, 2552, 787, 3365, 12, 781, 202, 199, 4921, 1655, 14, 221, 2832, 1109, 1907, 857, 27, 440, 2755, 17334, 370, 10266, 315, 6466, 202, 199, 11840, 27, 1325, 642, 4450, 314, 6365, 1159, 5953, 687, 2018, 413, 14, 20, 202, 199, 8304, 499, 14, 18, 12, 737, 5210, 14, 2999, 199, 35, 811, 292, 26, 2999, 199, 7940, 365, 3962, 334, 7911, 440, 12060, 9, 626, 314, 1798, 20922, 6057, 543, 282, 202, 199, 18157, 15955, 2544, 12276, 316, 314, 1284, 402, 314, 1350, 27, 315, 642, 202, 199, 2546, 12, 8520, 6698, 1443, 506, 5525, 3140, 402, 25498, 376, 1125, 14, 202, 199, 1858, 2893, 12, 282, 13831, 9437, 701, 2877, 14930, 1443, 506, 9437, 701, 202, 199, 285, 8734, 17516, 14, 221, 961, 911, 506, 6317, 5403, 314, 3261, 367, 314, 1798, 365, 202, 199, 9549, 351, 14, 2999, 199, 1918, 2877, 8386, 787, 26, 2999, 199, 2014, 63, 1531, 8, 1365, 12, 1788, 12, 5272, 304, 2958, 3599, 22894, 282, 2849, 1414, 315, 314, 30800, 11736, 3432, 14, 2999, 199, 3110, 9131, 837, 2958, 10066, 83, 402, 642, 1021, 1172, 636, 1250, 363, 3102, 13130, 315, 1128, 4955, 370, 6555, 63, 1531, 27, 314, 8865, 365, 626, 340, 314, 1128, 1256, 6555, 83, 2240, 1318, 3035, 282, 636, 2443, 363, 5164, 12, 1128, 314, 1256, 283, 264, 6334, 7, 436, 6555, 83, 1006, 13372, 2240, 24857, 1128, 543, 314, 5164, 315, 3542, 14, 2999, 199, 1918, 859, 2597, 6571, 4573, 1021, 26, 2999, 199, 12626, 837, 2958, 10066, 83, 402, 642, 1021, 2454, 2839, 314, 6137, 13, 262, 805, 6555, 12, 1128, 1325, 543, 283, 4844, 7, 315, 314, 12249, 11736, 3432, 14, 202, 199, 624, 2999, 199, 646, 636, 2443, 363, 2999, 199, 63, 3179, 275, 359, 5675, 3460, 2443, 3108, 6748, 9, 17554, 367, 6748, 315, 636, 2443, 4343, 452, 63, 4445, 63, 1247, 61, 2999, 199, 363, 452, 363, 275, 2097, 2014, 63, 1531, 401, 298, 12626, 401, 298, 3110, 9131, 937, 2999, 199, 2713, 5487, 63, 31874, 63, 26312, 57, 63, 8280, 1309, 275, 378, 88, 1840, 3515, 327, 21682, 2366, 1065, 14, 72, 2999, 199, 318, 485, 11853, 63, 2014, 8, 5772, 12, 1350, 12, 1788, 12, 5272, 304, 1128, 327, 2670, 367, 1350, 22581, 402, 1454, 4596, 2385, 436, 6786, 1128, 367, 1004, 315, 1350, 14, 1294, 4582, 78, 2349, 1039, 1004, 275, 1004, 14, 1913, 342, 1039, 340, 1004, 436, 1004, 59, 16, 61, 1137, 32326, 1675, 2059, 5185, 327, 28015, 652, 23016, 1128, 587, 26, 1039, 340, 5272, 1137, 298, 2579, 582, 1675, 1350, 275, 298, 1529, 2, 258, 327, 14402, 652, 543, 282, 283, 1529, 7, 5164, 2958, 2329, 275, 2329, 17, 275, 2329, 18, 275, 488, 1128, 1233, 275, 1233, 17, 275, 1233, 18, 275, 488, 2958, 862, 26, 1039, 1233, 275, 6365, 8, 1365, 12, 1788, 12, 5272, 9, 1128, 871, 12053, 12, 2329, 26, 1039, 986, 2958, 862, 26, 1039, 1233, 17, 275, 6365, 8, 1365, 435, 1867, 78, 401, 1788, 12, 5272, 9, 1128, 871, 12053, 12, 2329, 17, 26, 1039, 986, 2958, 862, 26, 1039, 1233, 18, 275, 6365, 8, 1365, 435, 1867, 78, 60, 78, 401, 1788, 12, 5272, 9, 1128, 871, 12053, 12, 2329, 18, 26, 1039, 986, 2958, 340, 1233, 26, 1039, 372, 1233, 1128, 340, 440, 1233, 17, 436, 4700, 8, 1508, 17, 9, 508, 4700, 8, 1508, 18, 304, 1039, 746, 12053, 12, 2329, 17, 2999, 199, 318, 485, 2014, 8, 1365, 12, 1788, 12, 5272, 304, 1128, 372, 6555, 8, 1365, 12, 1788, 12, 5272, 12, 1611, 5487, 63, 31874, 63, 26312, 57, 63, 8280, 1309, 9, 2999, 199, 318, 6555, 63, 1531, 8, 1365, 12, 1788, 28066, 1210, 7166, 5272, 628, 4780, 2349, 1128, 519, 624, 12626, 282, 1414, 436, 6705, 3775, 652, 365, 17110, 14, 2958, 7628, 26, 2958, 1350, 1553, 314, 1350, 1059, 27, 1443, 1395, 971, 78, 4110, 1128, 1788, 1553, 2716, 1788, 687, 1314, 1350, 1990, 1586, 27, 849, 2628, 3886, 1210, 4335, 1128, 5272, 1553, 2716, 12528, 1343, 5272, 27, 298, 4780, 2, 334, 885, 9, 503, 298, 2579, 2, 2958, 1432, 574, 1182, 4967, 4915, 26, 2958, 446, 1432, 282, 1233, 909, 340, 314, 1414, 365, 4890, 436, 1686, 1128, 446, 1432, 488, 340, 314, 1414, 365, 17110, 1128, 446, 14771, 12053, 12, 1722, 503, 23870, 340, 314, 1414, 365, 282, 8608, 6302, 1125, 334, 21821, 436, 1722, 883, 506, 13584, 701, 8608, 24159, 18041, 680, 1128, 408, 1128, 372, 485, 11853, 63, 2014, 1547, 2014, 12, 1350, 12, 1788, 12, 5272, 9, 2999, 199, 533, 24562, 26, 1128, 408, 18194, 402, 642, 1021, 24062, 8298, 2839, 314, 6137, 13, 262, 6555, 1128, 805, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
takaaptech/sky_engine
sky/tools/webkitpy/common/system/filesystem_mock.py
11
16806
# Copyright (C) 2009 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import StringIO import errno import hashlib import os import re from webkitpy.common.system import path class MockFileSystem(object): sep = '/' pardir = '..' def __init__(self, files=None, dirs=None, cwd='/'): """Initializes a "mock" filesystem that can be used to completely stub out a filesystem. Args: files: a dict of filenames -> file contents. A file contents value of None is used to indicate that the file should not exist. """ self.files = files or {} self.written_files = {} self.last_tmpdir = None self.current_tmpno = 0 self.cwd = cwd self.dirs = set(dirs or []) self.dirs.add(cwd) for f in self.files: d = self.dirname(f) while not d in self.dirs: self.dirs.add(d) d = self.dirname(d) def clear_written_files(self): # This function can be used to track what is written between steps in a test. self.written_files = {} def _raise_not_found(self, path): raise IOError(errno.ENOENT, path, os.strerror(errno.ENOENT)) def _split(self, path): # This is not quite a full implementation of os.path.split # http://docs.python.org/library/os.path.html#os.path.split if self.sep in path: return path.rsplit(self.sep, 1) return ('', path) def abspath(self, path): if os.path.isabs(path): return self.normpath(path) return self.abspath(self.join(self.cwd, path)) def realpath(self, path): return self.abspath(path) def basename(self, path): return self._split(path)[1] def expanduser(self, path): if path[0] != "~": return path parts = path.split(self.sep, 1) home_directory = self.sep + "Users" + self.sep + "mock" if len(parts) == 1: return home_directory return home_directory + self.sep + parts[1] def path_to_module(self, module_name): return "/mock-checkout/third_party/WebKit/tools/" + module_name.replace('.', '/') + ".py" def chdir(self, path): path = self.normpath(path) if not self.isdir(path): raise OSError(errno.ENOENT, path, os.strerror(errno.ENOENT)) self.cwd = path def copyfile(self, source, destination): if not self.exists(source): self._raise_not_found(source) if self.isdir(source): raise IOError(errno.EISDIR, source, os.strerror(errno.EISDIR)) if self.isdir(destination): raise IOError(errno.EISDIR, destination, os.strerror(errno.EISDIR)) if not self.exists(self.dirname(destination)): raise IOError(errno.ENOENT, destination, os.strerror(errno.ENOENT)) self.files[destination] = self.files[source] self.written_files[destination] = self.files[source] def dirname(self, path): return self._split(path)[0] def exists(self, path): return self.isfile(path) or self.isdir(path) def files_under(self, path, dirs_to_skip=[], file_filter=None): def filter_all(fs, dirpath, basename): return True file_filter = file_filter or filter_all files = [] if self.isfile(path): if file_filter(self, self.dirname(path), self.basename(path)) and self.files[path] is not None: files.append(path) return files if self.basename(path) in dirs_to_skip: return [] if not path.endswith(self.sep): path += self.sep dir_substrings = [self.sep + d + self.sep for d in dirs_to_skip] for filename in self.files: if not filename.startswith(path): continue suffix = filename[len(path) - 1:] if any(dir_substring in suffix for dir_substring in dir_substrings): continue dirpath, basename = self._split(filename) if file_filter(self, dirpath, basename) and self.files[filename] is not None: files.append(filename) return files def getcwd(self): return self.cwd def glob(self, glob_string): # FIXME: This handles '*', but not '?', '[', or ']'. glob_string = re.escape(glob_string) glob_string = glob_string.replace('\\*', '[^\\/]*') + '$' glob_string = glob_string.replace('\\/', '/') path_filter = lambda path: re.match(glob_string, path) # We could use fnmatch.fnmatch, but that might not do the right thing on windows. existing_files = [path for path, contents in self.files.items() if contents is not None] return filter(path_filter, existing_files) + filter(path_filter, self.dirs) def isabs(self, path): return path.startswith(self.sep) def isfile(self, path): return path in self.files and self.files[path] is not None def isdir(self, path): return self.normpath(path) in self.dirs def _slow_but_correct_join(self, *comps): return re.sub(re.escape(os.path.sep), self.sep, os.path.join(*comps)) def join(self, *comps): # This function is called a lot, so we optimize it; there are # unittests to check that we match _slow_but_correct_join(), above. path = '' sep = self.sep for comp in comps: if not comp: continue if comp[0] == sep: path = comp continue if path: path += sep path += comp if comps[-1] == '' and path: path += '/' path = path.replace(sep + sep, sep) return path def listdir(self, path): root, dirs, files = list(self.walk(path))[0] return dirs + files def walk(self, top): sep = self.sep if not self.isdir(top): raise OSError("%s is not a directory" % top) if not top.endswith(sep): top += sep dirs = [] files = [] for f in self.files: if self.exists(f) and f.startswith(top): remaining = f[len(top):] if sep in remaining: dir = remaining[:remaining.index(sep)] if not dir in dirs: dirs.append(dir) else: files.append(remaining) return [(top[:-1], dirs, files)] def mtime(self, path): if self.exists(path): return 0 self._raise_not_found(path) def _mktemp(self, suffix='', prefix='tmp', dir=None, **kwargs): if dir is None: dir = self.sep + '__im_tmp' curno = self.current_tmpno self.current_tmpno += 1 self.last_tmpdir = self.join(dir, '%s_%u_%s' % (prefix, curno, suffix)) return self.last_tmpdir def mkdtemp(self, **kwargs): class TemporaryDirectory(object): def __init__(self, fs, **kwargs): self._kwargs = kwargs self._filesystem = fs self._directory_path = fs._mktemp(**kwargs) fs.maybe_make_directory(self._directory_path) def __str__(self): return self._directory_path def __enter__(self): return self._directory_path def __exit__(self, type, value, traceback): # Only self-delete if necessary. # FIXME: Should we delete non-empty directories? if self._filesystem.exists(self._directory_path): self._filesystem.rmtree(self._directory_path) return TemporaryDirectory(fs=self, **kwargs) def maybe_make_directory(self, *path): norm_path = self.normpath(self.join(*path)) while norm_path and not self.isdir(norm_path): self.dirs.add(norm_path) norm_path = self.dirname(norm_path) def move(self, source, destination): if not self.exists(source): self._raise_not_found(source) if self.isfile(source): self.files[destination] = self.files[source] self.written_files[destination] = self.files[destination] self.files[source] = None self.written_files[source] = None return self.copytree(source, destination) self.rmtree(source) def _slow_but_correct_normpath(self, path): return re.sub(re.escape(os.path.sep), self.sep, os.path.normpath(path)) def normpath(self, path): # This function is called a lot, so we try to optimize the common cases # instead of always calling _slow_but_correct_normpath(), above. if '..' in path or '/./' in path: # This doesn't happen very often; don't bother trying to optimize it. return self._slow_but_correct_normpath(path) if not path: return '.' if path == '/': return path if path == '/.': return '/' if path.endswith('/.'): return path[:-2] if path.endswith('/'): return path[:-1] return path def open_binary_tempfile(self, suffix=''): path = self._mktemp(suffix) return (WritableBinaryFileObject(self, path), path) def open_binary_file_for_reading(self, path): if self.files[path] is None: self._raise_not_found(path) return ReadableBinaryFileObject(self, path, self.files[path]) def read_binary_file(self, path): # Intentionally raises KeyError if we don't recognize the path. if self.files[path] is None: self._raise_not_found(path) return self.files[path] def write_binary_file(self, path, contents): # FIXME: should this assert if dirname(path) doesn't exist? self.maybe_make_directory(self.dirname(path)) self.files[path] = contents self.written_files[path] = contents def open_text_file_for_reading(self, path): if self.files[path] is None: self._raise_not_found(path) return ReadableTextFileObject(self, path, self.files[path]) def open_text_file_for_writing(self, path): return WritableTextFileObject(self, path) def read_text_file(self, path): return self.read_binary_file(path).decode('utf-8') def write_text_file(self, path, contents): return self.write_binary_file(path, contents.encode('utf-8')) def sha1(self, path): contents = self.read_binary_file(path) return hashlib.sha1(contents).hexdigest() def relpath(self, path, start='.'): # Since os.path.relpath() calls os.path.normpath() # (see http://docs.python.org/library/os.path.html#os.path.abspath ) # it also removes trailing slashes and converts forward and backward # slashes to the preferred slash os.sep. start = self.abspath(start) path = self.abspath(path) common_root = start dot_dot = '' while not common_root == '': if path.startswith(common_root): break common_root = self.dirname(common_root) dot_dot += '..' + self.sep rel_path = path[len(common_root):] if not rel_path: return '.' if rel_path[0] == self.sep: # It is probably sufficient to remove just the first character # since os.path.normpath() collapses separators, but we use # lstrip() just to be sure. rel_path = rel_path.lstrip(self.sep) elif not common_root == '/': # We are in the case typified by the following example: # path = "/tmp/foobar", start = "/tmp/foo" -> rel_path = "bar" common_root = self.dirname(common_root) dot_dot += '..' + self.sep rel_path = path[len(common_root) + 1:] return dot_dot + rel_path def remove(self, path): if self.files[path] is None: self._raise_not_found(path) self.files[path] = None self.written_files[path] = None def rmtree(self, path): path = self.normpath(path) for f in self.files: # We need to add a trailing separator to path to avoid matching # cases like path='/foo/b' and f='/foo/bar/baz'. if f == path or f.startswith(path + self.sep): self.files[f] = None self.dirs = set(filter(lambda d: not (d == path or d.startswith(path + self.sep)), self.dirs)) def copytree(self, source, destination): source = self.normpath(source) destination = self.normpath(destination) for source_file in list(self.files): if source_file.startswith(source): destination_path = self.join(destination, self.relpath(source_file, source)) self.maybe_make_directory(self.dirname(destination_path)) self.files[destination_path] = self.files[source_file] def split(self, path): idx = path.rfind(self.sep) if idx == -1: return ('', path) return (path[:idx], path[(idx + 1):]) def splitext(self, path): idx = path.rfind('.') if idx == -1: idx = len(path) return (path[0:idx], path[idx:]) class WritableBinaryFileObject(object): def __init__(self, fs, path): self.fs = fs self.path = path self.closed = False self.fs.files[path] = "" def __enter__(self): return self def __exit__(self, type, value, traceback): self.close() def close(self): self.closed = True def write(self, str): self.fs.files[self.path] += str self.fs.written_files[self.path] = self.fs.files[self.path] class WritableTextFileObject(WritableBinaryFileObject): def write(self, str): WritableBinaryFileObject.write(self, str.encode('utf-8')) class ReadableBinaryFileObject(object): def __init__(self, fs, path, data): self.fs = fs self.path = path self.closed = False self.data = data self.offset = 0 def __enter__(self): return self def __exit__(self, type, value, traceback): self.close() def close(self): self.closed = True def read(self, bytes=None): if not bytes: return self.data[self.offset:] start = self.offset self.offset += bytes return self.data[start:self.offset] class ReadableTextFileObject(ReadableBinaryFileObject): def __init__(self, fs, path, data): super(ReadableTextFileObject, self).__init__(fs, path, StringIO.StringIO(data.decode("utf-8"))) def close(self): self.data.close() super(ReadableTextFileObject, self).close() def read(self, bytes=-1): return self.data.read(bytes) def readline(self, length=None): return self.data.readline(length) def __iter__(self): return self.data.__iter__() def next(self): return self.data.next() def seek(self, offset, whence=os.SEEK_SET): self.data.seek(offset, whence)
bsd-3-clause
[ 3, 1898, 334, 35, 9, 8937, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 259, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 259, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 259, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 5228, 199, 646, 7554, 199, 646, 8337, 199, 646, 747, 199, 646, 295, 199, 199, 504, 18007, 14, 2330, 14, 2253, 492, 931, 421, 199, 533, 4420, 17521, 8, 785, 304, 272, 7375, 275, 7324, 272, 623, 694, 275, 11541, 7, 339, 347, 636, 826, 721, 277, 12, 1584, 29, 403, 12, 7606, 29, 403, 12, 8288, 8805, 735, 267, 408, 23489, 282, 298, 1805, 2, 10036, 626, 883, 506, 1202, 370, 14793, 267, 10098, 734, 282, 10036, 14, 398, 3033, 26, 288, 1584, 26, 282, 1211, 402, 6203, 1035, 570, 4072, 14, 437, 570, 4072, 355, 574, 402, 488, 365, 1202, 370, 6623, 626, 314, 570, 1077, 355, 440, 2187, 14, 267, 408, 267, 291, 14, 1725, 275, 1584, 503, 1052, 267, 291, 14, 8938, 63, 1725, 275, 1052, 267, 291, 14, 2019, 63, 8616, 275, 488, 267, 291, 14, 1818, 63, 2791, 889, 275, 378, 267, 291, 14, 6525, 275, 8288, 267, 291, 14, 3220, 275, 663, 8, 3220, 503, 3073, 267, 291, 14, 3220, 14, 525, 8, 6525, 9, 267, 367, 289, 315, 291, 14, 1725, 26, 288, 366, 275, 291, 14, 3475, 8, 70, 9, 288, 1830, 440, 366, 315, 291, 14, 3220, 26, 355, 291, 14, 3220, 14, 525, 8, 68, 9, 355, 366, 275, 291, 14, 3475, 8, 68, 9, 339, 347, 5436, 63, 8938, 63, 1725, 8, 277, 304, 267, 327, 961, 805, 883, 506, 1202, 370, 4426, 4052, 365, 5313, 3382, 7124, 315, 282, 511, 14, 267, 291, 14, 8938, 63, 1725, 275, 1052, 339, 347, 485, 3730, 63, 1397, 63, 4214, 8, 277, 12, 931, 304, 267, 746, 5925, 8, 7931, 14, 20465, 12, 931, 12, 747, 14, 20395, 8, 7931, 14, 20465, 430, 339, 347, 485, 1294, 8, 277, 12, 931, 304, 267, 327, 961, 365, 440, 18794, 282, 2615, 4514, 402, 747, 14, 515, 14, 1294, 267, 327, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 736, 14, 515, 14, 1360, 3, 736, 14, 515, 14, 1294, 267, 340, 291, 14, 4127, 315, 931, 26, 288, 372, 931, 14, 13490, 8, 277, 14, 4127, 12, 413, 9, 267, 372, 13134, 931, 9, 339, 347, 19529, 8, 277, 12, 931, 304, 267, 340, 747, 14, 515, 14, 17896, 8, 515, 304, 288, 372, 291, 14, 9267, 8, 515, 9, 267, 372, 291, 14, 4832, 8, 277, 14, 904, 8, 277, 14, 6525, 12, 931, 430, 339, 347, 3363, 515, 8, 277, 12, 931, 304, 267, 372, 291, 14, 4832, 8, 515, 9, 339, 347, 9593, 8, 277, 12, 931, 304, 267, 372, 291, 423, 1294, 8, 515, 2788, 17, 61, 339, 347, 6544, 751, 8, 277, 12, 931, 304, 267, 340, 931, 59, 16, 61, 1137, 26810, 582, 288, 372, 931, 267, 4184, 275, 931, 14, 1294, 8, 277, 14, 4127, 12, 413, 9, 267, 5629, 63, 3619, 275, 291, 14, 4127, 435, 298, 12117, 2, 435, 291, 14, 4127, 435, 298, 1805, 2, 267, 340, 822, 8, 4181, 9, 508, 413, 26, 288, 372, 5629, 63, 3619, 267, 372, 5629, 63, 3619, 435, 291, 14, 4127, 435, 4184, 59, 17, 61, 339, 347, 931, 63, 475, 63, 578, 8, 277, 12, 859, 63, 354, 304, 267, 372, 3286, 1805, 13, 12891, 15, 11470, 63, 7522, 15, 21666, 15, 2537, 6687, 435, 859, 63, 354, 14, 1814, 14078, 15107, 435, 3680, 647, 2, 339, 347, 13097, 8, 277, 12, 931, 304, 267, 931, 275, 291, 14, 9267, 8, 515, 9, 267, 340, 440, 291, 14, 6027, 8, 515, 304, 288, 746, 6440, 8, 7931, 14, 20465, 12, 931, 12, 747, 14, 20395, 8, 7931, 14, 20465, 430, 267, 291, 14, 6525, 275, 931, 339, 347, 1331, 493, 8, 277, 12, 1350, 12, 5724, 304, 267, 340, 440, 291, 14, 2444, 8, 1365, 304, 288, 291, 423, 3730, 63, 1397, 63, 4214, 8, 1365, 9, 267, 340, 291, 14, 6027, 8, 1365, 304, 288, 746, 5925, 8, 7931, 14, 37, 1311, 3022, 12, 1350, 12, 747, 14, 20395, 8, 7931, 14, 37, 1311, 3022, 430, 267, 340, 291, 14, 6027, 8, 6881, 304, 288, 746, 5925, 8, 7931, 14, 37, 1311, 3022, 12, 5724, 12, 747, 14, 20395, 8, 7931, 14, 37, 1311, 3022, 430, 267, 340, 440, 291, 14 ]
[ 1898, 334, 35, 9, 8937, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 259, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 259, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 259, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 5228, 199, 646, 7554, 199, 646, 8337, 199, 646, 747, 199, 646, 295, 199, 199, 504, 18007, 14, 2330, 14, 2253, 492, 931, 421, 199, 533, 4420, 17521, 8, 785, 304, 272, 7375, 275, 7324, 272, 623, 694, 275, 11541, 7, 339, 347, 636, 826, 721, 277, 12, 1584, 29, 403, 12, 7606, 29, 403, 12, 8288, 8805, 735, 267, 408, 23489, 282, 298, 1805, 2, 10036, 626, 883, 506, 1202, 370, 14793, 267, 10098, 734, 282, 10036, 14, 398, 3033, 26, 288, 1584, 26, 282, 1211, 402, 6203, 1035, 570, 4072, 14, 437, 570, 4072, 355, 574, 402, 488, 365, 1202, 370, 6623, 626, 314, 570, 1077, 355, 440, 2187, 14, 267, 408, 267, 291, 14, 1725, 275, 1584, 503, 1052, 267, 291, 14, 8938, 63, 1725, 275, 1052, 267, 291, 14, 2019, 63, 8616, 275, 488, 267, 291, 14, 1818, 63, 2791, 889, 275, 378, 267, 291, 14, 6525, 275, 8288, 267, 291, 14, 3220, 275, 663, 8, 3220, 503, 3073, 267, 291, 14, 3220, 14, 525, 8, 6525, 9, 267, 367, 289, 315, 291, 14, 1725, 26, 288, 366, 275, 291, 14, 3475, 8, 70, 9, 288, 1830, 440, 366, 315, 291, 14, 3220, 26, 355, 291, 14, 3220, 14, 525, 8, 68, 9, 355, 366, 275, 291, 14, 3475, 8, 68, 9, 339, 347, 5436, 63, 8938, 63, 1725, 8, 277, 304, 267, 327, 961, 805, 883, 506, 1202, 370, 4426, 4052, 365, 5313, 3382, 7124, 315, 282, 511, 14, 267, 291, 14, 8938, 63, 1725, 275, 1052, 339, 347, 485, 3730, 63, 1397, 63, 4214, 8, 277, 12, 931, 304, 267, 746, 5925, 8, 7931, 14, 20465, 12, 931, 12, 747, 14, 20395, 8, 7931, 14, 20465, 430, 339, 347, 485, 1294, 8, 277, 12, 931, 304, 267, 327, 961, 365, 440, 18794, 282, 2615, 4514, 402, 747, 14, 515, 14, 1294, 267, 327, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 736, 14, 515, 14, 1360, 3, 736, 14, 515, 14, 1294, 267, 340, 291, 14, 4127, 315, 931, 26, 288, 372, 931, 14, 13490, 8, 277, 14, 4127, 12, 413, 9, 267, 372, 13134, 931, 9, 339, 347, 19529, 8, 277, 12, 931, 304, 267, 340, 747, 14, 515, 14, 17896, 8, 515, 304, 288, 372, 291, 14, 9267, 8, 515, 9, 267, 372, 291, 14, 4832, 8, 277, 14, 904, 8, 277, 14, 6525, 12, 931, 430, 339, 347, 3363, 515, 8, 277, 12, 931, 304, 267, 372, 291, 14, 4832, 8, 515, 9, 339, 347, 9593, 8, 277, 12, 931, 304, 267, 372, 291, 423, 1294, 8, 515, 2788, 17, 61, 339, 347, 6544, 751, 8, 277, 12, 931, 304, 267, 340, 931, 59, 16, 61, 1137, 26810, 582, 288, 372, 931, 267, 4184, 275, 931, 14, 1294, 8, 277, 14, 4127, 12, 413, 9, 267, 5629, 63, 3619, 275, 291, 14, 4127, 435, 298, 12117, 2, 435, 291, 14, 4127, 435, 298, 1805, 2, 267, 340, 822, 8, 4181, 9, 508, 413, 26, 288, 372, 5629, 63, 3619, 267, 372, 5629, 63, 3619, 435, 291, 14, 4127, 435, 4184, 59, 17, 61, 339, 347, 931, 63, 475, 63, 578, 8, 277, 12, 859, 63, 354, 304, 267, 372, 3286, 1805, 13, 12891, 15, 11470, 63, 7522, 15, 21666, 15, 2537, 6687, 435, 859, 63, 354, 14, 1814, 14078, 15107, 435, 3680, 647, 2, 339, 347, 13097, 8, 277, 12, 931, 304, 267, 931, 275, 291, 14, 9267, 8, 515, 9, 267, 340, 440, 291, 14, 6027, 8, 515, 304, 288, 746, 6440, 8, 7931, 14, 20465, 12, 931, 12, 747, 14, 20395, 8, 7931, 14, 20465, 430, 267, 291, 14, 6525, 275, 931, 339, 347, 1331, 493, 8, 277, 12, 1350, 12, 5724, 304, 267, 340, 440, 291, 14, 2444, 8, 1365, 304, 288, 291, 423, 3730, 63, 1397, 63, 4214, 8, 1365, 9, 267, 340, 291, 14, 6027, 8, 1365, 304, 288, 746, 5925, 8, 7931, 14, 37, 1311, 3022, 12, 1350, 12, 747, 14, 20395, 8, 7931, 14, 37, 1311, 3022, 430, 267, 340, 291, 14, 6027, 8, 6881, 304, 288, 746, 5925, 8, 7931, 14, 37, 1311, 3022, 12, 5724, 12, 747, 14, 20395, 8, 7931, 14, 37, 1311, 3022, 430, 267, 340, 440, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
alex/boto
boto/fps/connection.py
153
14335
# Copyright (c) 2012 Andy Davidoff http://www.disruptek.com/ # Copyright (c) 2010 Jason R. Coombs http://www.jaraco.com/ # Copyright (c) 2008 Chris Moyer http://coredumped.org/ # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. import urllib import uuid from boto.connection import AWSQueryConnection from boto.fps.exception import ResponseErrorFactory from boto.fps.response import ResponseFactory import boto.fps.response __all__ = ['FPSConnection'] decorated_attrs = ('action', 'response') def add_attrs_from(func, to): for attr in decorated_attrs: setattr(to, attr, getattr(func, attr, None)) return to def complex_amounts(*fields): def decorator(func): def wrapper(self, *args, **kw): for field in filter(kw.has_key, fields): amount = kw.pop(field) kw[field + '.Value'] = getattr(amount, 'Value', str(amount)) kw[field + '.CurrencyCode'] = getattr(amount, 'CurrencyCode', self.currencycode) return func(self, *args, **kw) wrapper.__doc__ = "{0}\nComplex Amounts: {1}".format(func.__doc__, ', '.join(fields)) return add_attrs_from(func, to=wrapper) return decorator def requires(*groups): def decorator(func): def wrapper(*args, **kw): hasgroup = lambda x: len(x) == len(filter(kw.has_key, x)) if 1 != len(filter(hasgroup, groups)): message = ' OR '.join(['+'.join(g) for g in groups]) message = "{0} requires {1} argument(s)" \ "".format(getattr(func, 'action', 'Method'), message) raise KeyError(message) return func(*args, **kw) message = ' OR '.join(['+'.join(g) for g in groups]) wrapper.__doc__ = "{0}\nRequired: {1}".format(func.__doc__, message) return add_attrs_from(func, to=wrapper) return decorator def needs_caller_reference(func): def wrapper(*args, **kw): kw.setdefault('CallerReference', uuid.uuid4()) return func(*args, **kw) wrapper.__doc__ = "{0}\nUses CallerReference, defaults " \ "to uuid.uuid4()".format(func.__doc__) return add_attrs_from(func, to=wrapper) def api_action(*api): def decorator(func): action = ''.join(api or map(str.capitalize, func.__name__.split('_'))) response = ResponseFactory(action) if hasattr(boto.fps.response, action + 'Response'): response = getattr(boto.fps.response, action + 'Response') def wrapper(self, *args, **kw): return func(self, action, response, *args, **kw) wrapper.action, wrapper.response = action, response wrapper.__doc__ = "FPS {0} API call\n{1}".format(action, func.__doc__) return wrapper return decorator class FPSConnection(AWSQueryConnection): APIVersion = '2010-08-28' ResponseError = ResponseErrorFactory currencycode = 'USD' def __init__(self, *args, **kw): self.currencycode = kw.pop('CurrencyCode', self.currencycode) kw.setdefault('host', 'fps.sandbox.amazonaws.com') super(FPSConnection, self).__init__(*args, **kw) def _required_auth_capability(self): return ['fps'] @needs_caller_reference @complex_amounts('SettlementAmount') @requires(['CreditInstrumentId', 'SettlementAmount.Value', 'SenderTokenId', 'SettlementAmount.CurrencyCode']) @api_action() def settle_debt(self, action, response, **kw): """ Allows a caller to initiate a transaction that atomically transfers money from a sender's payment instrument to the recipient, while decreasing corresponding debt balance. """ return self.get_object(action, kw, response) @requires(['TransactionId']) @api_action() def get_transaction_status(self, action, response, **kw): """ Gets the latest status of a transaction. """ return self.get_object(action, kw, response) @requires(['StartDate']) @api_action() def get_account_activity(self, action, response, **kw): """ Returns transactions for a given date range. """ return self.get_object(action, kw, response) @requires(['TransactionId']) @api_action() def get_transaction(self, action, response, **kw): """ Returns all details of a transaction. """ return self.get_object(action, kw, response) @api_action() def get_outstanding_debt_balance(self, action, response): """ Returns the total outstanding balance for all the credit instruments for the given creditor account. """ return self.get_object(action, {}, response) @requires(['PrepaidInstrumentId']) @api_action() def get_prepaid_balance(self, action, response, **kw): """ Returns the balance available on the given prepaid instrument. """ return self.get_object(action, kw, response) @api_action() def get_total_prepaid_liability(self, action, response): """ Returns the total liability held by the given account corresponding to all the prepaid instruments owned by the account. """ return self.get_object(action, {}, response) @api_action() def get_account_balance(self, action, response): """ Returns the account balance for an account in real time. """ return self.get_object(action, {}, response) @needs_caller_reference @requires(['PaymentInstruction', 'TokenType']) @api_action() def install_payment_instruction(self, action, response, **kw): """ Installs a payment instruction for caller. """ return self.get_object(action, kw, response) @needs_caller_reference @requires(['returnURL', 'pipelineName']) def cbui_url(self, **kw): """ Generate a signed URL for the Co-Branded service API given arguments as payload. """ sandbox = 'sandbox' in self.host and 'payments-sandbox' or 'payments' endpoint = 'authorize.{0}.amazon.com'.format(sandbox) base = '/cobranded-ui/actions/start' validpipelines = ('SingleUse', 'MultiUse', 'Recurring', 'Recipient', 'SetupPrepaid', 'SetupPostpaid', 'EditToken') assert kw['pipelineName'] in validpipelines, "Invalid pipelineName" kw.update({ 'signatureMethod': 'HmacSHA256', 'signatureVersion': '2', }) kw.setdefault('callerKey', self.aws_access_key_id) safestr = lambda x: x is not None and str(x) or '' safequote = lambda x: urllib.quote(safestr(x), safe='~') payload = sorted([(k, safequote(v)) for k, v in kw.items()]) encoded = lambda p: '&'.join([k + '=' + v for k, v in p]) canonical = '\n'.join(['GET', endpoint, base, encoded(payload)]) signature = self._auth_handler.sign_string(canonical) payload += [('signature', safequote(signature))] payload.sort() return 'https://{0}{1}?{2}'.format(endpoint, base, encoded(payload)) @needs_caller_reference @complex_amounts('TransactionAmount') @requires(['SenderTokenId', 'TransactionAmount.Value', 'TransactionAmount.CurrencyCode']) @api_action() def reserve(self, action, response, **kw): """ Reserve API is part of the Reserve and Settle API conjunction that serve the purpose of a pay where the authorization and settlement have a timing difference. """ return self.get_object(action, kw, response) @needs_caller_reference @complex_amounts('TransactionAmount') @requires(['SenderTokenId', 'TransactionAmount.Value', 'TransactionAmount.CurrencyCode']) @api_action() def pay(self, action, response, **kw): """ Allows calling applications to move money from a sender to a recipient. """ return self.get_object(action, kw, response) @requires(['TransactionId']) @api_action() def cancel(self, action, response, **kw): """ Cancels an ongoing transaction and puts it in cancelled state. """ return self.get_object(action, kw, response) @complex_amounts('TransactionAmount') @requires(['ReserveTransactionId', 'TransactionAmount.Value', 'TransactionAmount.CurrencyCode']) @api_action() def settle(self, action, response, **kw): """ The Settle API is used in conjunction with the Reserve API and is used to settle previously reserved transaction. """ return self.get_object(action, kw, response) @complex_amounts('RefundAmount') @requires(['TransactionId', 'RefundAmount.Value', 'CallerReference', 'RefundAmount.CurrencyCode']) @api_action() def refund(self, action, response, **kw): """ Refunds a previously completed transaction. """ return self.get_object(action, kw, response) @requires(['RecipientTokenId']) @api_action() def get_recipient_verification_status(self, action, response, **kw): """ Returns the recipient status. """ return self.get_object(action, kw, response) @requires(['CallerReference'], ['TokenId']) @api_action() def get_token_by_caller(self, action, response, **kw): """ Returns the details of a particular token installed by this calling application using the subway co-branded UI. """ return self.get_object(action, kw, response) @requires(['UrlEndPoint', 'HttpParameters']) @api_action() def verify_signature(self, action, response, **kw): """ Verify the signature that FPS sent in IPN or callback urls. """ return self.get_object(action, kw, response) @api_action() def get_tokens(self, action, response, **kw): """ Returns a list of tokens installed on the given account. """ return self.get_object(action, kw, response) @requires(['TokenId']) @api_action() def get_token_usage(self, action, response, **kw): """ Returns the usage of a token. """ return self.get_object(action, kw, response) @requires(['TokenId']) @api_action() def cancel_token(self, action, response, **kw): """ Cancels any token installed by the calling application on its own account. """ return self.get_object(action, kw, response) @needs_caller_reference @complex_amounts('FundingAmount') @requires(['PrepaidInstrumentId', 'FundingAmount.Value', 'SenderTokenId', 'FundingAmount.CurrencyCode']) @api_action() def fund_prepaid(self, action, response, **kw): """ Funds the prepaid balance on the given prepaid instrument. """ return self.get_object(action, kw, response) @requires(['CreditInstrumentId']) @api_action() def get_debt_balance(self, action, response, **kw): """ Returns the balance corresponding to the given credit instrument. """ return self.get_object(action, kw, response) @needs_caller_reference @complex_amounts('AdjustmentAmount') @requires(['CreditInstrumentId', 'AdjustmentAmount.Value', 'AdjustmentAmount.CurrencyCode']) @api_action() def write_off_debt(self, action, response, **kw): """ Allows a creditor to write off the debt balance accumulated partially or fully at any time. """ return self.get_object(action, kw, response) @requires(['SubscriptionId']) @api_action() def get_transactions_for_subscription(self, action, response, **kw): """ Returns the transactions for a given subscriptionID. """ return self.get_object(action, kw, response) @requires(['SubscriptionId']) @api_action() def get_subscription_details(self, action, response, **kw): """ Returns the details of Subscription for a given subscriptionID. """ return self.get_object(action, kw, response) @needs_caller_reference @complex_amounts('RefundAmount') @requires(['SubscriptionId']) @api_action() def cancel_subscription_and_refund(self, action, response, **kw): """ Cancels a subscription. """ message = "If you specify a RefundAmount, " \ "you must specify CallerReference." assert not 'RefundAmount.Value' in kw \ or 'CallerReference' in kw, message return self.get_object(action, kw, response) @requires(['TokenId']) @api_action() def get_payment_instruction(self, action, response, **kw): """ Gets the payment instruction of a token. """ return self.get_object(action, kw, response)
mit
[ 3, 1898, 334, 67, 9, 6029, 6061, 89, 20232, 1997, 1455, 921, 1544, 14, 2297, 5505, 266, 75, 14, 957, 15, 199, 3, 1898, 334, 67, 9, 7129, 1603, 2660, 820, 14, 1849, 676, 1533, 1455, 921, 1544, 14, 7338, 13286, 14, 957, 15, 199, 3, 1898, 334, 67, 9, 9079, 2799, 5719, 3930, 23009, 1455, 921, 331, 581, 1220, 379, 14, 1308, 15, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 199, 646, 4011, 199, 646, 5377, 199, 504, 6055, 14, 2105, 492, 10168, 3227, 3225, 199, 504, 6055, 14, 24709, 14, 1971, 492, 7232, 547, 2927, 199, 504, 6055, 14, 24709, 14, 1310, 492, 7232, 2927, 199, 646, 6055, 14, 24709, 14, 1310, 199, 199, 363, 452, 363, 275, 788, 38, 5067, 3225, 418, 199, 199, 29299, 63, 3288, 275, 661, 1287, 297, 283, 1310, 358, 421, 199, 318, 1050, 63, 3288, 63, 504, 8, 1532, 12, 370, 304, 272, 367, 1921, 315, 16225, 63, 3288, 26, 267, 5371, 8, 475, 12, 1921, 12, 2519, 8, 1532, 12, 1921, 12, 488, 430, 272, 372, 370, 421, 199, 318, 6114, 63, 4606, 83, 2031, 955, 304, 272, 347, 7531, 8, 1532, 304, 267, 347, 4975, 8, 277, 12, 627, 589, 12, 1011, 829, 304, 288, 367, 901, 315, 2457, 8, 829, 14, 1989, 63, 498, 12, 1504, 304, 355, 5982, 275, 4775, 14, 1935, 8, 698, 9, 355, 4775, 59, 698, 435, 1987, 1110, 418, 275, 2519, 8, 4606, 12, 283, 1110, 297, 620, 8, 4606, 430, 355, 4775, 59, 698, 435, 1987, 19567, 3034, 418, 275, 2519, 8, 4606, 12, 283, 19567, 3034, 297, 10028, 291, 14, 4968, 600, 9, 288, 372, 2562, 8, 277, 12, 627, 589, 12, 1011, 829, 9, 267, 4975, 855, 1301, 363, 275, 5310, 16, 4988, 78, 14500, 437, 25810, 26, 469, 17, 5469, 908, 8, 1532, 855, 1301, 3108, 1740, 1656, 1987, 904, 8, 955, 430, 267, 372, 1050, 63, 3288, 63, 504, 8, 1532, 12, 370, 29, 5029, 9, 272, 372, 7531, 421, 199, 318, 5074, 2031, 2634, 304, 339, 347, 7531, 8, 1532, 304, 398, 347, 4975, 2031, 589, 12, 1011, 829, 304, 288, 965, 923, 275, 2400, 671, 26, 822, 8, 88, 9, 508, 822, 8, 1541, 8, 829, 14, 1989, 63, 498, 12, 671, 430, 288, 340, 413, 1137, 822, 8, 1541, 8, 1989, 923, 12, 4652, 2298, 355, 1245, 275, 283, 1549, 1987, 904, 2941, 18098, 904, 8, 71, 9, 367, 486, 315, 4652, 566, 355, 1245, 275, 5310, 16, 93, 5074, 469, 17, 93, 1423, 8, 83, 2924, 971, 2079, 10587, 908, 8, 5675, 8, 1532, 12, 283, 1287, 297, 283, 3767, 659, 1245, 9, 355, 746, 4067, 8, 1188, 9, 288, 372, 2562, 2031, 589, 12, 1011, 829, 9, 267, 1245, 275, 283, 1549, 1987, 904, 2941, 18098, 904, 8, 71, 9, 367, 486, 315, 4652, 566, 267, 4975, 855, 1301, 363, 275, 5310, 16, 4988, 78, 8030, 26, 469, 17, 5469, 908, 8, 1532, 855, 1301, 3108, 15491, 1245, 9, 267, 372, 1050, 63, 3288, 63, 504, 8, 1532, 12, 370, 29, 5029, 9, 272, 372, 7531, 421, 199, 318, 4839, 63, 11219, 63, 4443, 8, 1532, 304, 339, 347, 4975, 2031, 589, 12, 1011, 829, 304, 267, 4775, 14, 5486, 360, 6584, 1435, 5083, 297, 5377, 14, 2580, 20, 1012, 267, 372, 2562, 2031, 589, 12, 1011, 829, 9, 272, 4975, 855, 1301, 363, 275, 5310, 16, 4988, 78, 21896, 8256, 1435, 5083, 12, 4243, 298, 971, 1993, 298, 475, 5377, 14, 2580, 20, 342, 1674, 908, 8, 1532, 855, 1301, 3368, 272, 372, 1050, 63, 3288, 63, 504, 8, 1532, 12, 370, 29, 5029, 9, 421, 199, 318, 2986, 63, 1287, 2031, 1246, 304, 339, 347, 7531, 8, 1532, 304, 267, 1595, 275, 6522, 904, 8, 1246, 503, 2341, 8, 495, 14, 18351, 12, 2562, 855, 354, 4343, 1294, 6412, 7058, 267, 1177, 275, 7232, 2927, 8, 1287, 9, 267, 340, 2688, 8, 10914, 14, 24709, 14, 1310, 12, 1595, 435, 283, 2364, 735, 288, 1177, 275, 2519, 8, 10914, 14, 24709, 14, 1310, 12, 1595, 435, 283, 2364, 358, 398, 347, 4975, 8, 277, 12, 627, 589, 12, 1011, 829, 304, 288, 372, 2562, 8, 277, 12, 1595, 12, 1177, 12, 627, 589, 12, 1011, 829, 9, 267, 4975, 14, 1287, 12, 4975, 14, 1310, 275, 1595, 12, 1177, 267, 4975, 855, 1301, 363, 275, 298, 38, 5067, 469, 16, 93, 3261, 1240, 60, 78, 91, 17, 5469, 908, 8, 1287, 12, 12740, 2562, 855, 1301, 3368, 267, 372, 4975, 272, 372, 7531, 421, 199, 533, 481, 5067, 3225, 8, 13226, 3227, 3225, 304, 339, 3261, 3353, 275, 283, 6542, 13, 2036, 13, 1651, 7, 272, 7232, 547, 275, 7232, 547, 2927, 272, 9952, 600, 275, 283, 1668, 36, 7, 339, 347, 636, 826, 721, 277, 12, 627 ]
[ 1898, 334, 67, 9, 6029, 6061, 89, 20232, 1997, 1455, 921, 1544, 14, 2297, 5505, 266, 75, 14, 957, 15, 199, 3, 1898, 334, 67, 9, 7129, 1603, 2660, 820, 14, 1849, 676, 1533, 1455, 921, 1544, 14, 7338, 13286, 14, 957, 15, 199, 3, 1898, 334, 67, 9, 9079, 2799, 5719, 3930, 23009, 1455, 921, 331, 581, 1220, 379, 14, 1308, 15, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 199, 646, 4011, 199, 646, 5377, 199, 504, 6055, 14, 2105, 492, 10168, 3227, 3225, 199, 504, 6055, 14, 24709, 14, 1971, 492, 7232, 547, 2927, 199, 504, 6055, 14, 24709, 14, 1310, 492, 7232, 2927, 199, 646, 6055, 14, 24709, 14, 1310, 199, 199, 363, 452, 363, 275, 788, 38, 5067, 3225, 418, 199, 199, 29299, 63, 3288, 275, 661, 1287, 297, 283, 1310, 358, 421, 199, 318, 1050, 63, 3288, 63, 504, 8, 1532, 12, 370, 304, 272, 367, 1921, 315, 16225, 63, 3288, 26, 267, 5371, 8, 475, 12, 1921, 12, 2519, 8, 1532, 12, 1921, 12, 488, 430, 272, 372, 370, 421, 199, 318, 6114, 63, 4606, 83, 2031, 955, 304, 272, 347, 7531, 8, 1532, 304, 267, 347, 4975, 8, 277, 12, 627, 589, 12, 1011, 829, 304, 288, 367, 901, 315, 2457, 8, 829, 14, 1989, 63, 498, 12, 1504, 304, 355, 5982, 275, 4775, 14, 1935, 8, 698, 9, 355, 4775, 59, 698, 435, 1987, 1110, 418, 275, 2519, 8, 4606, 12, 283, 1110, 297, 620, 8, 4606, 430, 355, 4775, 59, 698, 435, 1987, 19567, 3034, 418, 275, 2519, 8, 4606, 12, 283, 19567, 3034, 297, 10028, 291, 14, 4968, 600, 9, 288, 372, 2562, 8, 277, 12, 627, 589, 12, 1011, 829, 9, 267, 4975, 855, 1301, 363, 275, 5310, 16, 4988, 78, 14500, 437, 25810, 26, 469, 17, 5469, 908, 8, 1532, 855, 1301, 3108, 1740, 1656, 1987, 904, 8, 955, 430, 267, 372, 1050, 63, 3288, 63, 504, 8, 1532, 12, 370, 29, 5029, 9, 272, 372, 7531, 421, 199, 318, 5074, 2031, 2634, 304, 339, 347, 7531, 8, 1532, 304, 398, 347, 4975, 2031, 589, 12, 1011, 829, 304, 288, 965, 923, 275, 2400, 671, 26, 822, 8, 88, 9, 508, 822, 8, 1541, 8, 829, 14, 1989, 63, 498, 12, 671, 430, 288, 340, 413, 1137, 822, 8, 1541, 8, 1989, 923, 12, 4652, 2298, 355, 1245, 275, 283, 1549, 1987, 904, 2941, 18098, 904, 8, 71, 9, 367, 486, 315, 4652, 566, 355, 1245, 275, 5310, 16, 93, 5074, 469, 17, 93, 1423, 8, 83, 2924, 971, 2079, 10587, 908, 8, 5675, 8, 1532, 12, 283, 1287, 297, 283, 3767, 659, 1245, 9, 355, 746, 4067, 8, 1188, 9, 288, 372, 2562, 2031, 589, 12, 1011, 829, 9, 267, 1245, 275, 283, 1549, 1987, 904, 2941, 18098, 904, 8, 71, 9, 367, 486, 315, 4652, 566, 267, 4975, 855, 1301, 363, 275, 5310, 16, 4988, 78, 8030, 26, 469, 17, 5469, 908, 8, 1532, 855, 1301, 3108, 15491, 1245, 9, 267, 372, 1050, 63, 3288, 63, 504, 8, 1532, 12, 370, 29, 5029, 9, 272, 372, 7531, 421, 199, 318, 4839, 63, 11219, 63, 4443, 8, 1532, 304, 339, 347, 4975, 2031, 589, 12, 1011, 829, 304, 267, 4775, 14, 5486, 360, 6584, 1435, 5083, 297, 5377, 14, 2580, 20, 1012, 267, 372, 2562, 2031, 589, 12, 1011, 829, 9, 272, 4975, 855, 1301, 363, 275, 5310, 16, 4988, 78, 21896, 8256, 1435, 5083, 12, 4243, 298, 971, 1993, 298, 475, 5377, 14, 2580, 20, 342, 1674, 908, 8, 1532, 855, 1301, 3368, 272, 372, 1050, 63, 3288, 63, 504, 8, 1532, 12, 370, 29, 5029, 9, 421, 199, 318, 2986, 63, 1287, 2031, 1246, 304, 339, 347, 7531, 8, 1532, 304, 267, 1595, 275, 6522, 904, 8, 1246, 503, 2341, 8, 495, 14, 18351, 12, 2562, 855, 354, 4343, 1294, 6412, 7058, 267, 1177, 275, 7232, 2927, 8, 1287, 9, 267, 340, 2688, 8, 10914, 14, 24709, 14, 1310, 12, 1595, 435, 283, 2364, 735, 288, 1177, 275, 2519, 8, 10914, 14, 24709, 14, 1310, 12, 1595, 435, 283, 2364, 358, 398, 347, 4975, 8, 277, 12, 627, 589, 12, 1011, 829, 304, 288, 372, 2562, 8, 277, 12, 1595, 12, 1177, 12, 627, 589, 12, 1011, 829, 9, 267, 4975, 14, 1287, 12, 4975, 14, 1310, 275, 1595, 12, 1177, 267, 4975, 855, 1301, 363, 275, 298, 38, 5067, 469, 16, 93, 3261, 1240, 60, 78, 91, 17, 5469, 908, 8, 1287, 12, 12740, 2562, 855, 1301, 3368, 267, 372, 4975, 272, 372, 7531, 421, 199, 533, 481, 5067, 3225, 8, 13226, 3227, 3225, 304, 339, 3261, 3353, 275, 283, 6542,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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 ]
pniedzielski/fb-hackathon-2013-11-21
src/repl.it/jsrepl/extern/python/reloop-closured/lib/python2.7/imputil.py
228
25764
""" Import utilities Exported classes: ImportManager Manage the import process Importer Base class for replacing standard import functions BuiltinImporter Emulate the import mechanism for builtin and frozen modules DynLoadSuffixImporter """ from warnings import warnpy3k warnpy3k("the imputil module has been removed in Python 3.0", stacklevel=2) del warnpy3k # note: avoid importing non-builtin modules import imp ### not available in Jython? import sys import __builtin__ # for the DirectoryImporter import struct import marshal __all__ = ["ImportManager","Importer","BuiltinImporter"] _StringType = type('') _ModuleType = type(sys) ### doesn't work in Jython... class ImportManager: "Manage the import process." def install(self, namespace=vars(__builtin__)): "Install this ImportManager into the specified namespace." if isinstance(namespace, _ModuleType): namespace = vars(namespace) # Note: we have no notion of "chaining" # Record the previous import hook, then install our own. self.previous_importer = namespace['__import__'] self.namespace = namespace namespace['__import__'] = self._import_hook ### fix this #namespace['reload'] = self._reload_hook def uninstall(self): "Restore the previous import mechanism." self.namespace['__import__'] = self.previous_importer def add_suffix(self, suffix, importFunc): assert hasattr(importFunc, '__call__') self.fs_imp.add_suffix(suffix, importFunc) ###################################################################### # # PRIVATE METHODS # clsFilesystemImporter = None def __init__(self, fs_imp=None): # we're definitely going to be importing something in the future, # so let's just load the OS-related facilities. if not _os_stat: _os_bootstrap() # This is the Importer that we use for grabbing stuff from the # filesystem. It defines one more method (import_from_dir) for our use. if fs_imp is None: cls = self.clsFilesystemImporter or _FilesystemImporter fs_imp = cls() self.fs_imp = fs_imp # Initialize the set of suffixes that we recognize and import. # The default will import dynamic-load modules first, followed by # .py files (or a .py file's cached bytecode) for desc in imp.get_suffixes(): if desc[2] == imp.C_EXTENSION: self.add_suffix(desc[0], DynLoadSuffixImporter(desc).import_file) self.add_suffix('.py', py_suffix_importer) def _import_hook(self, fqname, globals=None, locals=None, fromlist=None): """Python calls this hook to locate and import a module.""" parts = fqname.split('.') # determine the context of this import parent = self._determine_import_context(globals) # if there is a parent, then its importer should manage this import if parent: module = parent.__importer__._do_import(parent, parts, fromlist) if module: return module # has the top module already been imported? try: top_module = sys.modules[parts[0]] except KeyError: # look for the topmost module top_module = self._import_top_module(parts[0]) if not top_module: # the topmost module wasn't found at all. raise ImportError, 'No module named ' + fqname # fast-path simple imports if len(parts) == 1: if not fromlist: return top_module if not top_module.__dict__.get('__ispkg__'): # __ispkg__ isn't defined (the module was not imported by us), # or it is zero. # # In the former case, there is no way that we could import # sub-modules that occur in the fromlist (but we can't raise an # error because it may just be names) because we don't know how # to deal with packages that were imported by other systems. # # In the latter case (__ispkg__ == 0), there can't be any sub- # modules present, so we can just return. # # In both cases, since len(parts) == 1, the top_module is also # the "bottom" which is the defined return when a fromlist # exists. return top_module importer = top_module.__dict__.get('__importer__') if importer: return importer._finish_import(top_module, parts[1:], fromlist) # Grrr, some people "import os.path" or do "from os.path import ..." if len(parts) == 2 and hasattr(top_module, parts[1]): if fromlist: return getattr(top_module, parts[1]) else: return top_module # If the importer does not exist, then we have to bail. A missing # importer means that something else imported the module, and we have # no knowledge of how to get sub-modules out of the thing. raise ImportError, 'No module named ' + fqname def _determine_import_context(self, globals): """Returns the context in which a module should be imported. The context could be a loaded (package) module and the imported module will be looked for within that package. The context could also be None, meaning there is no context -- the module should be looked for as a "top-level" module. """ if not globals or not globals.get('__importer__'): # globals does not refer to one of our modules or packages. That # implies there is no relative import context (as far as we are # concerned), and it should just pick it off the standard path. return None # The globals refer to a module or package of ours. It will define # the context of the new import. Get the module/package fqname. parent_fqname = globals['__name__'] # if a package is performing the import, then return itself (imports # refer to pkg contents) if globals['__ispkg__']: parent = sys.modules[parent_fqname] assert globals is parent.__dict__ return parent i = parent_fqname.rfind('.') # a module outside of a package has no particular import context if i == -1: return None # if a module in a package is performing the import, then return the # package (imports refer to siblings) parent_fqname = parent_fqname[:i] parent = sys.modules[parent_fqname] assert parent.__name__ == parent_fqname return parent def _import_top_module(self, name): # scan sys.path looking for a location in the filesystem that contains # the module, or an Importer object that can import the module. for item in sys.path: if isinstance(item, _StringType): module = self.fs_imp.import_from_dir(item, name) else: module = item.import_top(name) if module: return module return None def _reload_hook(self, module): "Python calls this hook to reload a module." # reloading of a module may or may not be possible (depending on the # importer), but at least we can validate that it's ours to reload importer = module.__dict__.get('__importer__') if not importer: ### oops. now what... pass # okay. it is using the imputil system, and we must delegate it, but # we don't know what to do (yet) ### we should blast the module dict and do another get_code(). need to ### flesh this out and add proper docco... raise SystemError, "reload not yet implemented" class Importer: "Base class for replacing standard import functions." def import_top(self, name): "Import a top-level module." return self._import_one(None, name, name) ###################################################################### # # PRIVATE METHODS # def _finish_import(self, top, parts, fromlist): # if "a.b.c" was provided, then load the ".b.c" portion down from # below the top-level module. bottom = self._load_tail(top, parts) # if the form is "import a.b.c", then return "a" if not fromlist: # no fromlist: return the top of the import tree return top # the top module was imported by self. # # this means that the bottom module was also imported by self (just # now, or in the past and we fetched it from sys.modules). # # since we imported/handled the bottom module, this means that we can # also handle its fromlist (and reliably use __ispkg__). # if the bottom node is a package, then (potentially) import some # modules. # # note: if it is not a package, then "fromlist" refers to names in # the bottom module rather than modules. # note: for a mix of names and modules in the fromlist, we will # import all modules and insert those into the namespace of # the package module. Python will pick up all fromlist names # from the bottom (package) module; some will be modules that # we imported and stored in the namespace, others are expected # to be present already. if bottom.__ispkg__: self._import_fromlist(bottom, fromlist) # if the form is "from a.b import c, d" then return "b" return bottom def _import_one(self, parent, modname, fqname): "Import a single module." # has the module already been imported? try: return sys.modules[fqname] except KeyError: pass # load the module's code, or fetch the module itself result = self.get_code(parent, modname, fqname) if result is None: return None module = self._process_result(result, fqname) # insert the module into its parent if parent: setattr(parent, modname, module) return module def _process_result(self, result, fqname): ispkg, code, values = result # did get_code() return an actual module? (rather than a code object) is_module = isinstance(code, _ModuleType) # use the returned module, or create a new one to exec code into if is_module: module = code else: module = imp.new_module(fqname) ### record packages a bit differently?? module.__importer__ = self module.__ispkg__ = ispkg # insert additional values into the module (before executing the code) module.__dict__.update(values) # the module is almost ready... make it visible sys.modules[fqname] = module # execute the code within the module's namespace if not is_module: try: exec code in module.__dict__ except: if fqname in sys.modules: del sys.modules[fqname] raise # fetch from sys.modules instead of returning module directly. # also make module's __name__ agree with fqname, in case # the "exec code in module.__dict__" played games on us. module = sys.modules[fqname] module.__name__ = fqname return module def _load_tail(self, m, parts): """Import the rest of the modules, down from the top-level module. Returns the last module in the dotted list of modules. """ for part in parts: fqname = "%s.%s" % (m.__name__, part) m = self._import_one(m, part, fqname) if not m: raise ImportError, "No module named " + fqname return m def _import_fromlist(self, package, fromlist): 'Import any sub-modules in the "from" list.' # if '*' is present in the fromlist, then look for the '__all__' # variable to find additional items (modules) to import. if '*' in fromlist: fromlist = list(fromlist) + \ list(package.__dict__.get('__all__', [])) for sub in fromlist: # if the name is already present, then don't try to import it (it # might not be a module!). if sub != '*' and not hasattr(package, sub): subname = "%s.%s" % (package.__name__, sub) submod = self._import_one(package, sub, subname) if not submod: raise ImportError, "cannot import name " + subname def _do_import(self, parent, parts, fromlist): """Attempt to import the module relative to parent. This method is used when the import context specifies that <self> imported the parent module. """ top_name = parts[0] top_fqname = parent.__name__ + '.' + top_name top_module = self._import_one(parent, top_name, top_fqname) if not top_module: # this importer and parent could not find the module (relatively) return None return self._finish_import(top_module, parts[1:], fromlist) ###################################################################### # # METHODS TO OVERRIDE # def get_code(self, parent, modname, fqname): """Find and retrieve the code for the given module. parent specifies a parent module to define a context for importing. It may be None, indicating no particular context for the search. modname specifies a single module (not dotted) within the parent. fqname specifies the fully-qualified module name. This is a (potentially) dotted name from the "root" of the module namespace down to the modname. If there is no parent, then modname==fqname. This method should return None, or a 3-tuple. * If the module was not found, then None should be returned. * The first item of the 2- or 3-tuple should be the integer 0 or 1, specifying whether the module that was found is a package or not. * The second item is the code object for the module (it will be executed within the new module's namespace). This item can also be a fully-loaded module object (e.g. loaded from a shared lib). * The third item is a dictionary of name/value pairs that will be inserted into new module before the code object is executed. This is provided in case the module's code expects certain values (such as where the module was found). When the second item is a module object, then these names/values will be inserted *after* the module has been loaded/initialized. """ raise RuntimeError, "get_code not implemented" ###################################################################### # # Some handy stuff for the Importers # # byte-compiled file suffix character _suffix_char = __debug__ and 'c' or 'o' # byte-compiled file suffix _suffix = '.py' + _suffix_char def _compile(pathname, timestamp): """Compile (and cache) a Python source file. The file specified by <pathname> is compiled to a code object and returned. Presuming the appropriate privileges exist, the bytecodes will be saved back to the filesystem for future imports. The source file's modification timestamp must be provided as a Long value. """ codestring = open(pathname, 'rU').read() if codestring and codestring[-1] != '\n': codestring = codestring + '\n' code = __builtin__.compile(codestring, pathname, 'exec') # try to cache the compiled code try: f = open(pathname + _suffix_char, 'wb') except IOError: pass else: f.write('\0\0\0\0') f.write(struct.pack('<I', timestamp)) marshal.dump(code, f) f.flush() f.seek(0, 0) f.write(imp.get_magic()) f.close() return code _os_stat = _os_path_join = None def _os_bootstrap(): "Set up 'os' module replacement functions for use during import bootstrap." names = sys.builtin_module_names join = None if 'posix' in names: sep = '/' from posix import stat elif 'nt' in names: sep = '\\' from nt import stat elif 'dos' in names: sep = '\\' from dos import stat elif 'os2' in names: sep = '\\' from os2 import stat else: raise ImportError, 'no os specific module found' if join is None: def join(a, b, sep=sep): if a == '': return b lastchar = a[-1:] if lastchar == '/' or lastchar == sep: return a + b return a + sep + b global _os_stat _os_stat = stat global _os_path_join _os_path_join = join def _os_path_isdir(pathname): "Local replacement for os.path.isdir()." try: s = _os_stat(pathname) except OSError: return None return (s.st_mode & 0170000) == 0040000 def _timestamp(pathname): "Return the file modification time as a Long." try: s = _os_stat(pathname) except OSError: return None return long(s.st_mtime) ###################################################################### # # Emulate the import mechanism for builtin and frozen modules # class BuiltinImporter(Importer): def get_code(self, parent, modname, fqname): if parent: # these modules definitely do not occur within a package context return None # look for the module if imp.is_builtin(modname): type = imp.C_BUILTIN elif imp.is_frozen(modname): type = imp.PY_FROZEN else: # not found return None # got it. now load and return it. module = imp.load_module(modname, None, modname, ('', '', type)) return 0, module, { } ###################################################################### # # Internal importer used for importing from the filesystem # class _FilesystemImporter(Importer): def __init__(self): self.suffixes = [ ] def add_suffix(self, suffix, importFunc): assert hasattr(importFunc, '__call__') self.suffixes.append((suffix, importFunc)) def import_from_dir(self, dir, fqname): result = self._import_pathname(_os_path_join(dir, fqname), fqname) if result: return self._process_result(result, fqname) return None def get_code(self, parent, modname, fqname): # This importer is never used with an empty parent. Its existence is # private to the ImportManager. The ImportManager uses the # import_from_dir() method to import top-level modules/packages. # This method is only used when we look for a module within a package. assert parent for submodule_path in parent.__path__: code = self._import_pathname(_os_path_join(submodule_path, modname), fqname) if code is not None: return code return self._import_pathname(_os_path_join(parent.__pkgdir__, modname), fqname) def _import_pathname(self, pathname, fqname): if _os_path_isdir(pathname): result = self._import_pathname(_os_path_join(pathname, '__init__'), fqname) if result: values = result[2] values['__pkgdir__'] = pathname values['__path__'] = [ pathname ] return 1, result[1], values return None for suffix, importFunc in self.suffixes: filename = pathname + suffix try: finfo = _os_stat(filename) except OSError: pass else: return importFunc(filename, finfo, fqname) return None ###################################################################### # # SUFFIX-BASED IMPORTERS # def py_suffix_importer(filename, finfo, fqname): file = filename[:-3] + _suffix t_py = long(finfo[8]) t_pyc = _timestamp(file) code = None if t_pyc is not None and t_pyc >= t_py: f = open(file, 'rb') if f.read(4) == imp.get_magic(): t = struct.unpack('<I', f.read(4))[0] if t == t_py: code = marshal.load(f) f.close() if code is None: file = filename code = _compile(file, t_py) return 0, code, { '__file__' : file } class DynLoadSuffixImporter: def __init__(self, desc): self.desc = desc def import_file(self, filename, finfo, fqname): fp = open(filename, self.desc[1]) module = imp.load_module(fqname, fp, filename, self.desc) module.__file__ = filename return 0, module, { } ###################################################################### def _print_importers(): items = sys.modules.items() items.sort() for name, module in items: if module: print name, module.__dict__.get('__importer__', '-- no importer') else: print name, '-- non-existent module' def _test_revamp(): ImportManager().install() sys.path.insert(0, BuiltinImporter()) ###################################################################### # # TODO # # from Finn Bock: # type(sys) is not a module in Jython. what to use instead? # imp.C_EXTENSION is not in Jython. same for get_suffixes and new_module # # given foo.py of: # import sys # sys.modules['foo'] = sys # # ---- standard import mechanism # >>> import foo # >>> foo # <module 'sys' (built-in)> # # ---- revamped import mechanism # >>> import imputil # >>> imputil._test_revamp() # >>> import foo # >>> foo # <module 'foo' from 'foo.py'> # # # from MAL: # should BuiltinImporter exist in sys.path or hard-wired in ImportManager? # need __path__ processing # performance # move chaining to a subclass [gjs: it's been nuked] # deinstall should be possible # query mechanism needed: is a specific Importer installed? # py/pyc/pyo piping hooks to filter/process these files # wish list: # distutils importer hooked to list of standard Internet repositories # module->file location mapper to speed FS-based imports # relative imports # keep chaining so that it can play nice with other import hooks # # from Gordon: # push MAL's mapper into sys.path[0] as a cache (hard-coded for apps) # # from Guido: # need to change sys.* references for rexec environs # need hook for MAL's walk-me-up import strategy, or Tim's absolute strategy # watch out for sys.modules[...] is None # flag to force absolute imports? (speeds _determine_import_context and # checking for a relative module) # insert names of archives into sys.path (see quote below) # note: reload does NOT blast module dict # shift import mechanisms and policies around; provide for hooks, overrides # (see quote below) # add get_source stuff # get_topcode and get_subcode # CRLF handling in _compile # race condition in _compile # refactoring of os.py to deal with _os_bootstrap problem # any special handling to do for importing a module with a SyntaxError? # (e.g. clean up the traceback) # implement "domain" for path-type functionality using pkg namespace # (rather than FS-names like __path__) # don't use the word "private"... maybe "internal" # # # Guido's comments on sys.path caching: # # We could cache this in a dictionary: the ImportManager can have a # cache dict mapping pathnames to importer objects, and a separate # method for coming up with an importer given a pathname that's not yet # in the cache. The method should do a stat and/or look at the # extension to decide which importer class to use; you can register new # importer classes by registering a suffix or a Boolean function, plus a # class. If you register a new importer class, the cache is zapped. # The cache is independent from sys.path (but maintained per # ImportManager instance) so that rearrangements of sys.path do the # right thing. If a path is dropped from sys.path the corresponding # cache entry is simply no longer used. # # My/Guido's comments on factoring ImportManager and Importer: # # > However, we still have a tension occurring here: # > # > 1) implementing policy in ImportManager assists in single-point policy # > changes for app/rexec situations # > 2) implementing policy in Importer assists in package-private policy # > changes for normal, operating conditions # > # > I'll see if I can sort out a way to do this. Maybe the Importer class will # > implement the methods (which can be overridden to change policy) by # > delegating to ImportManager. # # Maybe also think about what kind of policies an Importer would be # likely to want to change. I have a feeling that a lot of the code # there is actually not so much policy but a *necessity* to get things # working given the calling conventions for the __import__ hook: whether # to return the head or tail of a dotted name, or when to do the "finish # fromlist" stuff. #
agpl-3.0
[ 624, 199, 6295, 15841, 199, 199, 920, 2315, 3992, 26, 272, 3161, 2988, 257, 14944, 314, 492, 2112, 339, 8362, 3968, 263, 3523, 1021, 367, 15810, 4465, 492, 3423, 272, 22422, 18484, 662, 3703, 323, 314, 492, 14729, 367, 6762, 436, 8101, 4621, 339, 577, 1236, 6200, 20126, 18484, 199, 624, 199, 504, 3598, 492, 7987, 647, 19, 75, 199, 4050, 647, 19, 75, 480, 1589, 1742, 1974, 859, 965, 2757, 4829, 315, 2018, 650, 14, 16, 401, 13232, 29, 18, 9, 199, 2264, 7987, 647, 19, 75, 199, 199, 3, 5317, 26, 5126, 16306, 2222, 13, 5351, 4621, 199, 646, 1742, 10473, 6754, 440, 2808, 315, 25333, 31, 199, 646, 984, 199, 646, 636, 5351, 363, 199, 199, 3, 367, 314, 15191, 18484, 199, 646, 2702, 199, 646, 21985, 199, 199, 363, 452, 363, 275, 2097, 6295, 2988, 2266, 18484, 2266, 12306, 18484, 937, 199, 199, 63, 22463, 275, 730, 8355, 199, 63, 21820, 275, 730, 8, 1274, 9, 260, 6754, 3181, 1133, 1736, 315, 25333, 1396, 199, 199, 533, 3161, 2988, 26, 272, 298, 20588, 314, 492, 2112, 2122, 339, 347, 3907, 8, 277, 12, 3231, 29, 2936, 3460, 5351, 363, 2298, 267, 298, 8154, 642, 3161, 2988, 1901, 314, 2013, 3231, 2122, 398, 340, 1228, 8, 3251, 12, 485, 21820, 304, 288, 3231, 275, 6802, 8, 3251, 9, 398, 327, 3390, 26, 781, 1172, 949, 949, 296, 402, 298, 4429, 316, 2, 398, 327, 12651, 314, 4136, 492, 5759, 12, 2066, 3907, 4154, 5705, 14, 267, 291, 14, 6352, 63, 12138, 275, 3231, 13742, 646, 17501, 267, 291, 14, 3251, 275, 3231, 267, 3231, 13742, 646, 17501, 275, 291, 423, 646, 63, 3664, 398, 6754, 5325, 642, 267, 327, 3251, 459, 9233, 418, 275, 291, 423, 9233, 63, 3664, 339, 347, 22199, 8, 277, 304, 267, 298, 21012, 314, 4136, 492, 14729, 2122, 267, 291, 14, 3251, 13742, 646, 17501, 275, 291, 14, 6352, 63, 12138, 339, 347, 1050, 63, 4511, 8, 277, 12, 4739, 12, 492, 7465, 304, 267, 702, 2688, 8, 646, 7465, 12, 2560, 1250, 13766, 267, 291, 14, 2319, 63, 3236, 14, 525, 63, 4511, 8, 4511, 12, 492, 7465, 9, 339, 15779, 3726, 272, 327, 272, 327, 28644, 1951, 27411, 3177, 272, 327, 339, 843, 1173, 2253, 18484, 275, 488, 339, 347, 636, 826, 721, 277, 12, 7449, 63, 3236, 29, 403, 304, 267, 327, 781, 3984, 28088, 590, 9995, 370, 506, 16306, 6020, 315, 314, 6466, 12, 267, 327, 880, 4691, 1159, 2951, 2248, 314, 4403, 13, 2407, 30242, 7999, 14, 267, 340, 440, 485, 736, 63, 3736, 26, 288, 485, 736, 63, 11146, 342, 398, 327, 961, 365, 314, 8362, 3968, 626, 781, 675, 367, 1999, 2501, 316, 8292, 687, 314, 267, 327, 10036, 14, 2779, 7890, 1373, 1655, 1083, 334, 646, 63, 504, 63, 694, 9, 367, 4154, 675, 14, 267, 340, 7449, 63, 3236, 365, 488, 26, 288, 843, 275, 291, 14, 1886, 1173, 2253, 18484, 503, 485, 1173, 2253, 18484, 288, 7449, 63, 3236, 275, 843, 342, 267, 291, 14, 2319, 63, 3236, 275, 7449, 63, 3236, 398, 327, 11578, 314, 663, 402, 19475, 626, 781, 27159, 436, 492, 14, 267, 327, 710, 849, 911, 492, 8336, 13, 912, 4621, 1642, 12, 9437, 701, 267, 327, 1275, 647, 1584, 334, 269, 282, 1275, 647, 570, 1159, 6328, 16855, 9, 267, 367, 4328, 315, 1742, 14, 362, 63, 16097, 837, 288, 340, 4328, 59, 18, 61, 508, 1742, 14, 35, 63, 15498, 26, 355, 291, 14, 525, 63, 4511, 8, 3257, 59, 16, 467, 1816, 577, 1236, 6200, 20126, 18484, 8, 3257, 680, 646, 63, 493, 9, 267, 291, 14, 525, 63, 4511, 5175, 647, 297, 1134, 63, 4511, 63, 12138, 9, 339, 347, 485, 646, 63, 3664, 8, 277, 12, 289, 12333, 12, 7992, 29, 403, 12, 9480, 29, 403, 12, 25321, 29, 403, 304, 267, 408, 4718, 4882, 642, 5759, 370, 16592, 436, 492, 282, 859, 1041, 398, 4184, 275, 289, 12333, 14, 1294, 7563, 398, 327, 6705, 314, 1067, 402, 642, 492, 267, 1676, 275, 291, 423, 22189, 63, 646, 63, 1100, 8, 8473, 9, 398, 327, 340, 2337, 365, 282, 1676, 12, 2066, 2399, 13479, 1077, 9635, 642, 492, 267, 340, 1676, 26, 288, 859, 275, 1676, 855, 12138, 363, 423, 1117, 63, 646, 8, 1708, 12, 4184, 12, 25321, 9, 288, 340, 859, 26, 355, 372, 859, 398, 327, 965, 314, 2746, 859, 2575, 2757, 8439, 31, 267, 862, 26, 288, 2746, 63, 578, 275, 984, 14, 3112, 59, 4181, 59, 16, 2677, 267, 871, 4067, 26, 953, 327, 3648, 367, 314, 2746, 2786, 859, 288, 2746, 63, 578, 275, 291, 423, 646, 63, 2119, 63, 578, 8, 4181, 59, 16, 566, 288, 340, 440, 2746, 63, 578, 26, 355, 327, 314, 2746, 2786, 859, 17373, 1133, 1911, 737, 1006, 14, 355, 746, 3545, 12, 283, 1944, 859, 4310, 283, 435, 289, 12333, 398, 327, 7377, 13, 515, 3486, 8925, 267, 340, 822, 8, 4181, 9, 508, 413, 26, 288, 340, 440, 25321, 26, 355, 372, 2746, 63, 578, 953, 340, 440, 2746, 63, 578, 855, 807, 4343, 362, 10714, 374, 4600, 12168, 355, 327, 636, 374, 4600, 363, 5712, 1133, 3247, 334, 1589, 859, 1990, 440, 8439, 701, 2739, 395, 355, 327, 503, 652, 365, 4697, 14, 355, 327, 355, 327, 1010, 314, 26610, 1930, 12, 2337, 365, 949, 4340, 626, 781, 4293, 492, 355, 327, 1007, 13, 3112, 626, 4781, 315, 314, 25321, 334, 7911, 781, 883, 1133, 746, 376, 355, 327, 1125, 2952, 652, 1443, 2951, 506, 1561, 9, 2952, 781, 2793, 1133, 5715, 4212, 355, 327, 370, 7962, 543, 6117, 626, 4898, 8439, 701, 1163, 10460, 14, 355, 327, 355, 327, 1010, 314, 19045, 1930, 25373, 374, 4600, 363, 508, 378, 395, 2337, 883, 1133, 506, 1263, 1007, 13, 355, 327, 4621, 3451, 12, 880, 781, 883, 2951, 372, 14, 355, 327, 355, 327, 1010, 3865, 5560, 12, 3967, 822, 8, 4181, 9, 508, 413, 12, 314, 2746, 63, 578, 365, 2597, 355, 327, 314, 298, 8305, 2, 1314, 365, 314, 3247, 372, 1380, 282, 25321, 355, 327, 3495, 14, 355, 372, 2746, 63, 578, 398, 13479, 275, 2746, 63, 578, 855, 807 ]
[ 199, 6295, 15841, 199, 199, 920, 2315, 3992, 26, 272, 3161, 2988, 257, 14944, 314, 492, 2112, 339, 8362, 3968, 263, 3523, 1021, 367, 15810, 4465, 492, 3423, 272, 22422, 18484, 662, 3703, 323, 314, 492, 14729, 367, 6762, 436, 8101, 4621, 339, 577, 1236, 6200, 20126, 18484, 199, 624, 199, 504, 3598, 492, 7987, 647, 19, 75, 199, 4050, 647, 19, 75, 480, 1589, 1742, 1974, 859, 965, 2757, 4829, 315, 2018, 650, 14, 16, 401, 13232, 29, 18, 9, 199, 2264, 7987, 647, 19, 75, 199, 199, 3, 5317, 26, 5126, 16306, 2222, 13, 5351, 4621, 199, 646, 1742, 10473, 6754, 440, 2808, 315, 25333, 31, 199, 646, 984, 199, 646, 636, 5351, 363, 199, 199, 3, 367, 314, 15191, 18484, 199, 646, 2702, 199, 646, 21985, 199, 199, 363, 452, 363, 275, 2097, 6295, 2988, 2266, 18484, 2266, 12306, 18484, 937, 199, 199, 63, 22463, 275, 730, 8355, 199, 63, 21820, 275, 730, 8, 1274, 9, 260, 6754, 3181, 1133, 1736, 315, 25333, 1396, 199, 199, 533, 3161, 2988, 26, 272, 298, 20588, 314, 492, 2112, 2122, 339, 347, 3907, 8, 277, 12, 3231, 29, 2936, 3460, 5351, 363, 2298, 267, 298, 8154, 642, 3161, 2988, 1901, 314, 2013, 3231, 2122, 398, 340, 1228, 8, 3251, 12, 485, 21820, 304, 288, 3231, 275, 6802, 8, 3251, 9, 398, 327, 3390, 26, 781, 1172, 949, 949, 296, 402, 298, 4429, 316, 2, 398, 327, 12651, 314, 4136, 492, 5759, 12, 2066, 3907, 4154, 5705, 14, 267, 291, 14, 6352, 63, 12138, 275, 3231, 13742, 646, 17501, 267, 291, 14, 3251, 275, 3231, 267, 3231, 13742, 646, 17501, 275, 291, 423, 646, 63, 3664, 398, 6754, 5325, 642, 267, 327, 3251, 459, 9233, 418, 275, 291, 423, 9233, 63, 3664, 339, 347, 22199, 8, 277, 304, 267, 298, 21012, 314, 4136, 492, 14729, 2122, 267, 291, 14, 3251, 13742, 646, 17501, 275, 291, 14, 6352, 63, 12138, 339, 347, 1050, 63, 4511, 8, 277, 12, 4739, 12, 492, 7465, 304, 267, 702, 2688, 8, 646, 7465, 12, 2560, 1250, 13766, 267, 291, 14, 2319, 63, 3236, 14, 525, 63, 4511, 8, 4511, 12, 492, 7465, 9, 339, 15779, 3726, 272, 327, 272, 327, 28644, 1951, 27411, 3177, 272, 327, 339, 843, 1173, 2253, 18484, 275, 488, 339, 347, 636, 826, 721, 277, 12, 7449, 63, 3236, 29, 403, 304, 267, 327, 781, 3984, 28088, 590, 9995, 370, 506, 16306, 6020, 315, 314, 6466, 12, 267, 327, 880, 4691, 1159, 2951, 2248, 314, 4403, 13, 2407, 30242, 7999, 14, 267, 340, 440, 485, 736, 63, 3736, 26, 288, 485, 736, 63, 11146, 342, 398, 327, 961, 365, 314, 8362, 3968, 626, 781, 675, 367, 1999, 2501, 316, 8292, 687, 314, 267, 327, 10036, 14, 2779, 7890, 1373, 1655, 1083, 334, 646, 63, 504, 63, 694, 9, 367, 4154, 675, 14, 267, 340, 7449, 63, 3236, 365, 488, 26, 288, 843, 275, 291, 14, 1886, 1173, 2253, 18484, 503, 485, 1173, 2253, 18484, 288, 7449, 63, 3236, 275, 843, 342, 267, 291, 14, 2319, 63, 3236, 275, 7449, 63, 3236, 398, 327, 11578, 314, 663, 402, 19475, 626, 781, 27159, 436, 492, 14, 267, 327, 710, 849, 911, 492, 8336, 13, 912, 4621, 1642, 12, 9437, 701, 267, 327, 1275, 647, 1584, 334, 269, 282, 1275, 647, 570, 1159, 6328, 16855, 9, 267, 367, 4328, 315, 1742, 14, 362, 63, 16097, 837, 288, 340, 4328, 59, 18, 61, 508, 1742, 14, 35, 63, 15498, 26, 355, 291, 14, 525, 63, 4511, 8, 3257, 59, 16, 467, 1816, 577, 1236, 6200, 20126, 18484, 8, 3257, 680, 646, 63, 493, 9, 267, 291, 14, 525, 63, 4511, 5175, 647, 297, 1134, 63, 4511, 63, 12138, 9, 339, 347, 485, 646, 63, 3664, 8, 277, 12, 289, 12333, 12, 7992, 29, 403, 12, 9480, 29, 403, 12, 25321, 29, 403, 304, 267, 408, 4718, 4882, 642, 5759, 370, 16592, 436, 492, 282, 859, 1041, 398, 4184, 275, 289, 12333, 14, 1294, 7563, 398, 327, 6705, 314, 1067, 402, 642, 492, 267, 1676, 275, 291, 423, 22189, 63, 646, 63, 1100, 8, 8473, 9, 398, 327, 340, 2337, 365, 282, 1676, 12, 2066, 2399, 13479, 1077, 9635, 642, 492, 267, 340, 1676, 26, 288, 859, 275, 1676, 855, 12138, 363, 423, 1117, 63, 646, 8, 1708, 12, 4184, 12, 25321, 9, 288, 340, 859, 26, 355, 372, 859, 398, 327, 965, 314, 2746, 859, 2575, 2757, 8439, 31, 267, 862, 26, 288, 2746, 63, 578, 275, 984, 14, 3112, 59, 4181, 59, 16, 2677, 267, 871, 4067, 26, 953, 327, 3648, 367, 314, 2746, 2786, 859, 288, 2746, 63, 578, 275, 291, 423, 646, 63, 2119, 63, 578, 8, 4181, 59, 16, 566, 288, 340, 440, 2746, 63, 578, 26, 355, 327, 314, 2746, 2786, 859, 17373, 1133, 1911, 737, 1006, 14, 355, 746, 3545, 12, 283, 1944, 859, 4310, 283, 435, 289, 12333, 398, 327, 7377, 13, 515, 3486, 8925, 267, 340, 822, 8, 4181, 9, 508, 413, 26, 288, 340, 440, 25321, 26, 355, 372, 2746, 63, 578, 953, 340, 440, 2746, 63, 578, 855, 807, 4343, 362, 10714, 374, 4600, 12168, 355, 327, 636, 374, 4600, 363, 5712, 1133, 3247, 334, 1589, 859, 1990, 440, 8439, 701, 2739, 395, 355, 327, 503, 652, 365, 4697, 14, 355, 327, 355, 327, 1010, 314, 26610, 1930, 12, 2337, 365, 949, 4340, 626, 781, 4293, 492, 355, 327, 1007, 13, 3112, 626, 4781, 315, 314, 25321, 334, 7911, 781, 883, 1133, 746, 376, 355, 327, 1125, 2952, 652, 1443, 2951, 506, 1561, 9, 2952, 781, 2793, 1133, 5715, 4212, 355, 327, 370, 7962, 543, 6117, 626, 4898, 8439, 701, 1163, 10460, 14, 355, 327, 355, 327, 1010, 314, 19045, 1930, 25373, 374, 4600, 363, 508, 378, 395, 2337, 883, 1133, 506, 1263, 1007, 13, 355, 327, 4621, 3451, 12, 880, 781, 883, 2951, 372, 14, 355, 327, 355, 327, 1010, 3865, 5560, 12, 3967, 822, 8, 4181, 9, 508, 413, 12, 314, 2746, 63, 578, 365, 2597, 355, 327, 314, 298, 8305, 2, 1314, 365, 314, 3247, 372, 1380, 282, 25321, 355, 327, 3495, 14, 355, 372, 2746, 63, 578, 398, 13479, 275, 2746, 63, 578, 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, 1, 1, 1, 1 ]
tallakahath/pymatgen
pymatgen/analysis/elasticity/tests/test_stress.py
8
2805
from __future__ import absolute_import import unittest import numpy as np import warnings from pymatgen.analysis.elasticity.stress import Stress from pymatgen.analysis.elasticity.strain import Deformation from pymatgen.util.testing import PymatgenTest class StressTest(PymatgenTest): def setUp(self): self.rand_stress = Stress(np.random.randn(3, 3)) self.symm_stress = Stress([[0.51, 2.29, 2.42], [2.29, 5.14, 5.07], [2.42, 5.07, 5.33]]) self.non_symm = Stress([[0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.2, 0.5, 0.5]]) def test_properties(self): # mean_stress self.assertEqual(self.rand_stress.mean_stress, 1. / 3. * (self.rand_stress[0, 0] + self.rand_stress[1, 1] + self.rand_stress[2, 2])) self.assertAlmostEqual(self.symm_stress.mean_stress, 3.66) # deviator_stress self.assertArrayAlmostEqual(self.symm_stress.deviator_stress, Stress([[-3.15, 2.29, 2.42], [2.29, 1.48, 5.07], [2.42, 5.07, 1.67]])) self.assertArrayAlmostEqual(self.non_symm.deviator_stress, [[-0.2666666667, 0.2, 0.3], [0.4, 0.133333333, 0.6], [0.2, 0.5, 0.133333333]]) # deviator_principal_invariants self.assertArrayAlmostEqual(self.symm_stress.dev_principal_invariants, [0, 44.2563, 111.953628]) # von_mises self.assertAlmostEqual(self.symm_stress.von_mises, 11.52253878275) # piola_kirchoff 1, 2 f = Deformation.from_index_amount((0, 1), 0.03) self.assertArrayAlmostEqual(self.symm_stress.piola_kirchoff_1(f), [[0.4413, 2.29, 2.42], [2.1358, 5.14, 5.07], [2.2679, 5.07, 5.33]]) self.assertArrayAlmostEqual(self.symm_stress.piola_kirchoff_2(f), [[0.377226, 2.1358, 2.2679], [2.1358, 5.14, 5.07], [2.2679, 5.07, 5.33]]) # voigt self.assertArrayEqual(self.symm_stress.voigt, [0.51, 5.14, 5.33, 5.07, 2.42, 2.29]) with warnings.catch_warnings(record=True) as w: self.non_symm.voigt self.assertEqual(len(w), 1) if __name__ == '__main__': unittest.main()
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2882, 199, 199, 646, 2680, 465, 980, 199, 646, 3598, 199, 199, 504, 1134, 30649, 14, 10466, 14, 15565, 1209, 14, 29530, 492, 1933, 753, 199, 504, 1134, 30649, 14, 10466, 14, 15565, 1209, 14, 270, 6322, 492, 1487, 1869, 199, 504, 1134, 30649, 14, 1974, 14, 4776, 492, 1611, 30649, 774, 421, 199, 533, 1933, 753, 774, 8, 2713, 30649, 774, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 3759, 63, 29530, 275, 1933, 753, 8, 1590, 14, 2355, 14, 10843, 8, 19, 12, 650, 430, 267, 291, 14, 1786, 596, 63, 29530, 275, 1933, 753, 4038, 16, 14, 2869, 12, 499, 14, 1398, 12, 499, 14, 2260, 467, 3521, 359, 18, 14, 1398, 12, 959, 14, 1079, 12, 959, 14, 1780, 467, 3521, 359, 18, 14, 2260, 12, 959, 14, 1780, 12, 959, 14, 1153, 3934, 267, 291, 14, 2865, 63, 1786, 596, 275, 1933, 753, 4038, 16, 14, 17, 12, 378, 14, 18, 12, 378, 14, 19, 467, 1816, 359, 16, 14, 20, 12, 378, 14, 21, 12, 378, 14, 22, 467, 1816, 359, 16, 14, 18, 12, 378, 14, 21, 12, 378, 14, 21, 3934, 339, 347, 511, 63, 3282, 8, 277, 304, 267, 327, 4615, 63, 29530, 267, 291, 14, 629, 8, 277, 14, 3759, 63, 29530, 14, 3670, 63, 29530, 12, 586, 413, 14, 1182, 650, 14, 627, 334, 277, 14, 3759, 63, 29530, 59, 16, 12, 378, 61, 435, 2511, 291, 14, 3759, 63, 29530, 59, 17, 12, 413, 61, 435, 2511, 291, 14, 3759, 63, 29530, 59, 18, 12, 499, 2459, 267, 291, 14, 7904, 8, 277, 14, 1786, 596, 63, 29530, 14, 3670, 63, 29530, 12, 650, 14, 1272, 9, 267, 327, 29052, 707, 63, 29530, 267, 291, 14, 479, 3836, 7331, 8, 277, 14, 1786, 596, 63, 29530, 14, 271, 433, 707, 63, 29530, 12, 2511, 1933, 753, 22844, 19, 14, 1046, 12, 499, 14, 1398, 12, 499, 14, 2260, 467, 4490, 359, 18, 14, 1398, 12, 413, 14, 2006, 12, 959, 14, 1780, 467, 4490, 359, 18, 14, 2260, 12, 959, 14, 1780, 12, 413, 14, 1822, 17723, 267, 291, 14, 479, 3836, 7331, 8, 277, 14, 2865, 63, 1786, 596, 14, 271, 433, 707, 63, 29530, 12, 2511, 27291, 16, 14, 18, 14936, 23, 12, 378, 14, 18, 12, 378, 14, 19, 467, 3660, 359, 16, 14, 20, 12, 378, 14, 969, 6772, 11769, 12, 378, 14, 22, 467, 3660, 359, 16, 14, 18, 12, 378, 14, 21, 12, 378, 14, 969, 6772, 11769, 3934, 267, 327, 29052, 707, 63, 19200, 63, 262, 15680, 267, 291, 14, 479, 3836, 7331, 8, 277, 14, 1786, 596, 63, 29530, 14, 2374, 63, 19200, 63, 262, 15680, 12, 2511, 359, 16, 12, 10868, 14, 29990, 12, 20128, 14, 2720, 1344, 1651, 566, 267, 327, 373, 265, 63, 77, 1388, 267, 291, 14, 7904, 8, 277, 14, 1786, 596, 63, 29530, 14, 86, 265, 63, 77, 1388, 12, 3044, 4119, 14, 2528, 3781, 14681, 13643, 9, 267, 327, 6682, 22205, 63, 75, 723, 335, 1997, 413, 12, 499, 267, 289, 275, 1487, 1869, 14, 504, 63, 1080, 63, 4606, 1332, 16, 12, 413, 395, 378, 14, 1644, 9, 267, 291, 14, 479, 3836, 7331, 8, 277, 14, 1786, 596, 63, 29530, 14, 1038, 22205, 63, 75, 723, 335, 1997, 63, 17, 8, 70, 395, 2511, 3474, 16, 14, 1602, 969, 12, 499, 14, 1398, 12, 499, 14, 2260, 467, 3660, 359, 18, 14, 969, 2010, 12, 959, 14, 1079, 12, 959, 14, 1780, 467, 3660, 359, 18, 14, 1479, 1965, 12, 959, 14, 1780, 12, 959, 14, 1153, 3934, 267, 291, 14, 479, 3836, 7331, 8, 277, 14, 1786, 596, 63, 29530, 14, 1038, 22205, 63, 75, 723, 335, 1997, 63, 18, 8, 70, 395, 2511, 3474, 16, 14, 7332, 11085, 12, 499, 14, 969, 2010, 12, 499, 14, 1479, 1965, 467, 3660, 359, 18, 14, 969, 2010, 12, 959, 14, 1079, 12, 959, 14, 1780, 467, 3660, 359, 18, 14, 1479, 1965, 12, 959, 14, 1780, 12, 959, 14, 1153, 3934, 267, 327, 14164, 528, 84, 267, 291, 14, 479, 3836, 591, 8, 277, 14, 1786, 596, 63, 29530, 14, 2392, 528, 84, 12, 2892, 359, 16, 14, 2869, 12, 959, 14, 1079, 12, 959, 14, 1153, 12, 959, 14, 1780, 12, 499, 14, 2260, 12, 499, 14, 1398, 566, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 291, 14, 2865, 63, 1786, 596, 14, 2392, 528, 84, 288, 291, 14, 629, 8, 552, 8, 87, 395, 413, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2882, 199, 199, 646, 2680, 465, 980, 199, 646, 3598, 199, 199, 504, 1134, 30649, 14, 10466, 14, 15565, 1209, 14, 29530, 492, 1933, 753, 199, 504, 1134, 30649, 14, 10466, 14, 15565, 1209, 14, 270, 6322, 492, 1487, 1869, 199, 504, 1134, 30649, 14, 1974, 14, 4776, 492, 1611, 30649, 774, 421, 199, 533, 1933, 753, 774, 8, 2713, 30649, 774, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 3759, 63, 29530, 275, 1933, 753, 8, 1590, 14, 2355, 14, 10843, 8, 19, 12, 650, 430, 267, 291, 14, 1786, 596, 63, 29530, 275, 1933, 753, 4038, 16, 14, 2869, 12, 499, 14, 1398, 12, 499, 14, 2260, 467, 3521, 359, 18, 14, 1398, 12, 959, 14, 1079, 12, 959, 14, 1780, 467, 3521, 359, 18, 14, 2260, 12, 959, 14, 1780, 12, 959, 14, 1153, 3934, 267, 291, 14, 2865, 63, 1786, 596, 275, 1933, 753, 4038, 16, 14, 17, 12, 378, 14, 18, 12, 378, 14, 19, 467, 1816, 359, 16, 14, 20, 12, 378, 14, 21, 12, 378, 14, 22, 467, 1816, 359, 16, 14, 18, 12, 378, 14, 21, 12, 378, 14, 21, 3934, 339, 347, 511, 63, 3282, 8, 277, 304, 267, 327, 4615, 63, 29530, 267, 291, 14, 629, 8, 277, 14, 3759, 63, 29530, 14, 3670, 63, 29530, 12, 586, 413, 14, 1182, 650, 14, 627, 334, 277, 14, 3759, 63, 29530, 59, 16, 12, 378, 61, 435, 2511, 291, 14, 3759, 63, 29530, 59, 17, 12, 413, 61, 435, 2511, 291, 14, 3759, 63, 29530, 59, 18, 12, 499, 2459, 267, 291, 14, 7904, 8, 277, 14, 1786, 596, 63, 29530, 14, 3670, 63, 29530, 12, 650, 14, 1272, 9, 267, 327, 29052, 707, 63, 29530, 267, 291, 14, 479, 3836, 7331, 8, 277, 14, 1786, 596, 63, 29530, 14, 271, 433, 707, 63, 29530, 12, 2511, 1933, 753, 22844, 19, 14, 1046, 12, 499, 14, 1398, 12, 499, 14, 2260, 467, 4490, 359, 18, 14, 1398, 12, 413, 14, 2006, 12, 959, 14, 1780, 467, 4490, 359, 18, 14, 2260, 12, 959, 14, 1780, 12, 413, 14, 1822, 17723, 267, 291, 14, 479, 3836, 7331, 8, 277, 14, 2865, 63, 1786, 596, 14, 271, 433, 707, 63, 29530, 12, 2511, 27291, 16, 14, 18, 14936, 23, 12, 378, 14, 18, 12, 378, 14, 19, 467, 3660, 359, 16, 14, 20, 12, 378, 14, 969, 6772, 11769, 12, 378, 14, 22, 467, 3660, 359, 16, 14, 18, 12, 378, 14, 21, 12, 378, 14, 969, 6772, 11769, 3934, 267, 327, 29052, 707, 63, 19200, 63, 262, 15680, 267, 291, 14, 479, 3836, 7331, 8, 277, 14, 1786, 596, 63, 29530, 14, 2374, 63, 19200, 63, 262, 15680, 12, 2511, 359, 16, 12, 10868, 14, 29990, 12, 20128, 14, 2720, 1344, 1651, 566, 267, 327, 373, 265, 63, 77, 1388, 267, 291, 14, 7904, 8, 277, 14, 1786, 596, 63, 29530, 14, 86, 265, 63, 77, 1388, 12, 3044, 4119, 14, 2528, 3781, 14681, 13643, 9, 267, 327, 6682, 22205, 63, 75, 723, 335, 1997, 413, 12, 499, 267, 289, 275, 1487, 1869, 14, 504, 63, 1080, 63, 4606, 1332, 16, 12, 413, 395, 378, 14, 1644, 9, 267, 291, 14, 479, 3836, 7331, 8, 277, 14, 1786, 596, 63, 29530, 14, 1038, 22205, 63, 75, 723, 335, 1997, 63, 17, 8, 70, 395, 2511, 3474, 16, 14, 1602, 969, 12, 499, 14, 1398, 12, 499, 14, 2260, 467, 3660, 359, 18, 14, 969, 2010, 12, 959, 14, 1079, 12, 959, 14, 1780, 467, 3660, 359, 18, 14, 1479, 1965, 12, 959, 14, 1780, 12, 959, 14, 1153, 3934, 267, 291, 14, 479, 3836, 7331, 8, 277, 14, 1786, 596, 63, 29530, 14, 1038, 22205, 63, 75, 723, 335, 1997, 63, 18, 8, 70, 395, 2511, 3474, 16, 14, 7332, 11085, 12, 499, 14, 969, 2010, 12, 499, 14, 1479, 1965, 467, 3660, 359, 18, 14, 969, 2010, 12, 959, 14, 1079, 12, 959, 14, 1780, 467, 3660, 359, 18, 14, 1479, 1965, 12, 959, 14, 1780, 12, 959, 14, 1153, 3934, 267, 327, 14164, 528, 84, 267, 291, 14, 479, 3836, 591, 8, 277, 14, 1786, 596, 63, 29530, 14, 2392, 528, 84, 12, 2892, 359, 16, 14, 2869, 12, 959, 14, 1079, 12, 959, 14, 1153, 12, 959, 14, 1780, 12, 499, 14, 2260, 12, 499, 14, 1398, 566, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 291, 14, 2865, 63, 1786, 596, 14, 2392, 528, 84, 288, 291, 14, 629, 8, 552, 8, 87, 395, 413, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Displays system-wide system call totals, broken down by syscall. # If a [comm] arg is specified, only syscalls called by [comm] are displayed. import os, sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import syscall_name usage = "perf script -s syscall-counts-by-pid.py [comm]\n"; for_comm = None for_pid = None if len(sys.argv) > 2: sys.exit(usage) if len(sys.argv) > 1: try: for_pid = int(sys.argv[1]) except: for_comm = sys.argv[1] syscalls = autodict() def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): print_syscall_totals() def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if (for_comm and common_comm != for_comm) or \ (for_pid and common_pid != for_pid ): return try: syscalls[common_comm][common_pid][id] += 1 except TypeError: syscalls[common_comm][common_pid][id] = 1 def print_syscall_totals(): if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events by comm/pid:\n\n", print "%-40s %10s\n" % ("comm [pid]/syscalls", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "----------"), comm_keys = syscalls.keys() for comm in comm_keys: pid_keys = syscalls[comm].keys() for pid in pid_keys: print "\n%s [%d]\n" % (comm, pid), id_keys = syscalls[comm][pid].keys() for id, val in sorted(syscalls[comm][pid].iteritems(), \ key = lambda(k, v): (v, k), reverse = True): print " %-38s %10d\n" % (syscall_name(id), val),
gpl-2.0
[ 3, 2656, 1240, 8242, 12, 701, 4422, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 12, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 509, 63, 3150, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 509, 63, 3150, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 421, 198, 692, 334, 509, 63, 1404, 436, 2863, 63, 1404, 1137, 367, 63, 1404, 9, 503, 971, 21979, 334, 509, 63, 3150, 221, 436, 2863, 63, 3150, 221, 1137, 367, 63, 3150, 3461, 507, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 701, 1923, 15, 3150, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 12978, 14507, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1055, 4611, 1062, 971, 1871, 221, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 24449, 870, 298, 221, 19752, 1703, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2656, 1240, 8242, 12, 701, 4422, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 28750, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 18901, 14, 199, 3, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 359, 1404, 61, 787, 9080, 14, 199, 199, 646, 747, 12, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 18901, 63, 354, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 18901, 13, 6851, 13, 991, 13, 3150, 14, 647, 359, 1404, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 509, 63, 3150, 275, 488, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 509, 63, 3150, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 1361, 63, 19444, 63, 17552, 342, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 421, 198, 692, 334, 509, 63, 1404, 436, 2863, 63, 1404, 1137, 367, 63, 1404, 9, 503, 971, 21979, 334, 509, 63, 3150, 221, 436, 2863, 63, 3150, 221, 1137, 367, 63, 3150, 3461, 507, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 2330, 63, 1404, 1527, 2330, 63, 3150, 1527, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 837, 272, 340, 367, 63, 1404, 365, 440, 488, 26, 6722, 870, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 272, 587, 26, 6722, 870, 1867, 26605, 4474, 701, 1923, 15, 3150, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1404, 359, 3150, 12978, 14507, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 9460, 1288, 339, 1923, 63, 1612, 275, 19473, 14, 1612, 342, 272, 367, 1923, 315, 1923, 63, 1612, 26, 6722, 4422, 63, 1612, 275, 19473, 59, 1404, 1055, 1612, 342, 6722, 367, 4422, 315, 4422, 63, 1612, 26, 15075, 870, 1867, 78, 5, 83, 8978, 68, 7272, 78, 2, 450, 334, 1404, 12, 4422, 395, 15075, 1305, 63, 1612, 275, 19473, 59, 1404, 1527, 3150, 1055, 1612, 342, 15075, 367, 1305, 12, 1139, 315, 3355, 8, 14507, 59, 1404, 1527, 3150, 1055, 4611, 1062, 971, 1871, 221, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 221, 3837, 275, 715, 304, 24449, 870, 298, 221, 19752, 1703, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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# -*- 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/>. # ############################################################################## # 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, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
liuwenf/moose
modules/porous_flow/doc/tests/dispersion.py
14
1881
#!/usr/bin/env python import os import sys import numpy as np import matplotlib.pyplot as plt from scipy.special import erfc import pandas as pd # # Diffusion-only test # # Read MOOSE simulation data data = pd.read_csv("../../tests/dispersion/diff01_out_xmass_0021.csv") # The analytical solution is erfc(u) where u is a similarity variable x = np.linspace(0,10,100) t = 20 d = 1 tau = 0.1 D = d*tau u = x/(2*np.sqrt(D*t)) plt.figure(1) plt.plot(x, erfc(u), label = 'Analytical') plt.plot(data.x, data.massfrac0, 'o', label = 'MOOSE') plt.xlabel('x (m)') plt.ylabel('Mass fraction (-)') plt.legend() plt.title('Mass fraction (t = 50 s)') plt.ylim([-0.05,1]) plt.savefig("diffusion_fig.pdf") # # Dispersion tests # def expected(x,t): porosity = 0.3 alphal = 0.2 v = 1.05e-3 / porosity D = alphal * v return 0.5 * erfc((x - v * t)/(2 *np.sqrt(D * t))) + np.sqrt(v * v * t/(np.pi * D)) * \ np.exp(- (x - v * t)**2/(4 * D * t)) - 0.5 * (1 + v * x / D + v * v * t / D) * np.exp(v * x / D) *\ erfc((x+v*t)/(2*np.sqrt(D*t))) # Read MOOSE simulation data data = pd.read_csv("../../tests/dispersion/disp01_out_xmass_0029.csv") plt.figure(2) plt.plot(x, expected(x, 1e3), label = 'Analytical') plt.plot(data.x, data.massfrac0, 'o', label = 'MOOSE') plt.xlabel('x (m)') plt.ylabel('Mass fraction (-)') plt.legend() plt.title('Mass fraction (t = 1000 s)') plt.ylim([-0.05,1]) plt.savefig("dispersion_fig.pdf") # # Heavy dispersion test # # Read MOOSE simulation data data = pd.read_csv("../../tests/dispersion/disp01_heavy_out_xmass_0105.csv") plt.figure(3) plt.plot(x, expected(x, 1e3), label = 'Analytical') plt.plot(data.x, data.massfrac0, 'o', label = 'MOOSE', markevery=4) plt.xlabel('x (m)') plt.ylabel('Mass fraction (-)') plt.legend() plt.title('Mass fraction (t = 1000 s)') plt.ylim([-0.05,1]) plt.savefig("dispersion_heavy_fig.pdf") sys.exit(0)
lgpl-2.1
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 7026, 14, 6664, 492, 9266, 3003, 199, 646, 10634, 465, 6454, 199, 199, 3, 199, 3, 27134, 12444, 13, 2118, 511, 199, 3, 199, 3, 5574, 603, 5757, 899, 17625, 666, 199, 576, 275, 6454, 14, 739, 63, 4737, 480, 9707, 2219, 15, 2297, 529, 438, 15, 3028, 614, 63, 548, 63, 10198, 405, 63, 383, 2025, 14, 4737, 531, 199, 199, 3, 710, 5909, 3294, 8744, 365, 9266, 3003, 8, 85, 9, 2382, 399, 365, 282, 22838, 1750, 199, 88, 275, 980, 14, 11649, 8, 16, 12, 709, 12, 1960, 9, 199, 84, 275, 3388, 199, 68, 275, 413, 199, 16656, 275, 378, 14, 17, 199, 36, 275, 366, 10, 16656, 199, 85, 275, 671, 7985, 18, 10, 1590, 14, 5079, 8, 36, 10, 84, 430, 199, 199, 6003, 14, 8941, 8, 17, 9, 199, 6003, 14, 2798, 8, 88, 12, 9266, 3003, 8, 85, 395, 1768, 275, 283, 8014, 3294, 358, 199, 6003, 14, 2798, 8, 576, 14, 88, 12, 666, 14, 11535, 10865, 16, 12, 283, 79, 297, 1768, 275, 283, 2679, 47, 899, 358, 199, 6003, 14, 14168, 360, 88, 334, 77, 5942, 199, 6003, 14, 13849, 360, 27218, 12347, 5868, 5942, 199, 6003, 14, 10231, 342, 199, 6003, 14, 1213, 360, 27218, 12347, 334, 84, 275, 5238, 308, 5942, 199, 6003, 14, 18123, 11468, 16, 14, 1717, 12, 17, 566, 199, 6003, 14, 19556, 480, 3028, 12444, 63, 592, 14, 5607, 531, 199, 199, 3, 199, 3, 5289, 529, 438, 2295, 199, 3, 199, 318, 1420, 8, 88, 12, 84, 304, 272, 8706, 79, 3677, 275, 378, 14, 19, 272, 9797, 279, 275, 378, 14, 18, 272, 373, 275, 413, 14, 1717, 69, 13, 19, 1182, 8706, 79, 3677, 272, 577, 275, 9797, 279, 627, 373, 272, 372, 378, 14, 21, 627, 9266, 3003, 1332, 88, 446, 373, 627, 307, 15136, 18, 627, 1590, 14, 5079, 8, 36, 627, 307, 1724, 435, 980, 14, 5079, 8, 86, 627, 373, 627, 307, 7985, 1590, 14, 1038, 627, 577, 430, 627, 971, 272, 980, 14, 1474, 2801, 334, 88, 446, 373, 627, 307, 6422, 18, 7985, 20, 627, 577, 627, 307, 430, 446, 378, 14, 21, 627, 334, 17, 435, 373, 627, 671, 1182, 577, 435, 373, 627, 373, 627, 307, 1182, 577, 9, 627, 980, 14, 1474, 8, 86, 627, 671, 1182, 577, 9, 30940, 272, 9266, 3003, 1332, 88, 11, 86, 10, 84, 15136, 18, 10, 1590, 14, 5079, 8, 36, 10, 84, 1724, 199, 199, 3, 5574, 603, 5757, 899, 17625, 666, 199, 576, 275, 6454, 14, 739, 63, 4737, 480, 9707, 2219, 15, 2297, 529, 438, 15, 13654, 614, 63, 548, 63, 10198, 405, 63, 31361, 14, 4737, 531, 199, 199, 6003, 14, 8941, 8, 18, 9, 199, 6003, 14, 2798, 8, 88, 12, 1420, 8, 88, 12, 413, 69, 19, 395, 1768, 275, 283, 8014, 3294, 358, 199, 6003, 14, 2798, 8, 576, 14, 88, 12, 666, 14, 11535, 10865, 16, 12, 283, 79, 297, 1768, 275, 283, 2679, 47, 899, 358, 199, 6003, 14, 14168, 360, 88, 334, 77, 5942, 199, 6003, 14, 13849, 360, 27218, 12347, 5868, 5942, 199, 6003, 14, 10231, 342, 199, 6003, 14, 1213, 360, 27218, 12347, 334, 84, 275, 5198, 308, 5942, 199, 6003, 14, 18123, 11468, 16, 14, 1717, 12, 17, 566, 199, 6003, 14, 19556, 480, 2297, 529, 438, 63, 592, 14, 5607, 531, 199, 199, 3, 199, 3, 5311, 22421, 2153, 529, 438, 511, 199, 3, 199, 3, 5574, 603, 5757, 899, 17625, 666, 199, 576, 275, 6454, 14, 739, 63, 4737, 480, 9707, 2219, 15, 2297, 529, 438, 15, 13654, 614, 63, 426, 22421, 63, 548, 63, 10198, 405, 63, 614, 1717, 14, 4737, 531, 199, 199, 6003, 14, 8941, 8, 19, 9, 199, 6003, 14, 2798, 8, 88, 12, 1420, 8, 88, 12, 413, 69, 19, 395, 1768, 275, 283, 8014, 3294, 358, 199, 6003, 14, 2798, 8, 576, 14, 88, 12, 666, 14, 11535, 10865, 16, 12, 283, 79, 297, 1768, 275, 283, 2679, 47, 899, 297, 7557, 415, 2588, 29, 20, 9, 199, 6003, 14, 14168, 360, 88, 334, 77, 5942, 199, 6003, 14, 13849, 360, 27218, 12347, 5868, 5942, 199, 6003, 14, 10231, 342, 199, 6003, 14, 1213, 360, 27218, 12347, 334, 84, 275, 5198, 308, 5942, 199, 6003, 14, 18123, 11468, 16, 14, 1717, 12, 17, 566, 199, 6003, 14, 19556, 480, 2297, 529, 438, 63, 426, 22421, 63, 592, 14, 5607, 531, 199, 199, 1274, 14, 2224, 8, 16, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 646, 984, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 504, 7026, 14, 6664, 492, 9266, 3003, 199, 646, 10634, 465, 6454, 199, 199, 3, 199, 3, 27134, 12444, 13, 2118, 511, 199, 3, 199, 3, 5574, 603, 5757, 899, 17625, 666, 199, 576, 275, 6454, 14, 739, 63, 4737, 480, 9707, 2219, 15, 2297, 529, 438, 15, 3028, 614, 63, 548, 63, 10198, 405, 63, 383, 2025, 14, 4737, 531, 199, 199, 3, 710, 5909, 3294, 8744, 365, 9266, 3003, 8, 85, 9, 2382, 399, 365, 282, 22838, 1750, 199, 88, 275, 980, 14, 11649, 8, 16, 12, 709, 12, 1960, 9, 199, 84, 275, 3388, 199, 68, 275, 413, 199, 16656, 275, 378, 14, 17, 199, 36, 275, 366, 10, 16656, 199, 85, 275, 671, 7985, 18, 10, 1590, 14, 5079, 8, 36, 10, 84, 430, 199, 199, 6003, 14, 8941, 8, 17, 9, 199, 6003, 14, 2798, 8, 88, 12, 9266, 3003, 8, 85, 395, 1768, 275, 283, 8014, 3294, 358, 199, 6003, 14, 2798, 8, 576, 14, 88, 12, 666, 14, 11535, 10865, 16, 12, 283, 79, 297, 1768, 275, 283, 2679, 47, 899, 358, 199, 6003, 14, 14168, 360, 88, 334, 77, 5942, 199, 6003, 14, 13849, 360, 27218, 12347, 5868, 5942, 199, 6003, 14, 10231, 342, 199, 6003, 14, 1213, 360, 27218, 12347, 334, 84, 275, 5238, 308, 5942, 199, 6003, 14, 18123, 11468, 16, 14, 1717, 12, 17, 566, 199, 6003, 14, 19556, 480, 3028, 12444, 63, 592, 14, 5607, 531, 199, 199, 3, 199, 3, 5289, 529, 438, 2295, 199, 3, 199, 318, 1420, 8, 88, 12, 84, 304, 272, 8706, 79, 3677, 275, 378, 14, 19, 272, 9797, 279, 275, 378, 14, 18, 272, 373, 275, 413, 14, 1717, 69, 13, 19, 1182, 8706, 79, 3677, 272, 577, 275, 9797, 279, 627, 373, 272, 372, 378, 14, 21, 627, 9266, 3003, 1332, 88, 446, 373, 627, 307, 15136, 18, 627, 1590, 14, 5079, 8, 36, 627, 307, 1724, 435, 980, 14, 5079, 8, 86, 627, 373, 627, 307, 7985, 1590, 14, 1038, 627, 577, 430, 627, 971, 272, 980, 14, 1474, 2801, 334, 88, 446, 373, 627, 307, 6422, 18, 7985, 20, 627, 577, 627, 307, 430, 446, 378, 14, 21, 627, 334, 17, 435, 373, 627, 671, 1182, 577, 435, 373, 627, 373, 627, 307, 1182, 577, 9, 627, 980, 14, 1474, 8, 86, 627, 671, 1182, 577, 9, 30940, 272, 9266, 3003, 1332, 88, 11, 86, 10, 84, 15136, 18, 10, 1590, 14, 5079, 8, 36, 10, 84, 1724, 199, 199, 3, 5574, 603, 5757, 899, 17625, 666, 199, 576, 275, 6454, 14, 739, 63, 4737, 480, 9707, 2219, 15, 2297, 529, 438, 15, 13654, 614, 63, 548, 63, 10198, 405, 63, 31361, 14, 4737, 531, 199, 199, 6003, 14, 8941, 8, 18, 9, 199, 6003, 14, 2798, 8, 88, 12, 1420, 8, 88, 12, 413, 69, 19, 395, 1768, 275, 283, 8014, 3294, 358, 199, 6003, 14, 2798, 8, 576, 14, 88, 12, 666, 14, 11535, 10865, 16, 12, 283, 79, 297, 1768, 275, 283, 2679, 47, 899, 358, 199, 6003, 14, 14168, 360, 88, 334, 77, 5942, 199, 6003, 14, 13849, 360, 27218, 12347, 5868, 5942, 199, 6003, 14, 10231, 342, 199, 6003, 14, 1213, 360, 27218, 12347, 334, 84, 275, 5198, 308, 5942, 199, 6003, 14, 18123, 11468, 16, 14, 1717, 12, 17, 566, 199, 6003, 14, 19556, 480, 2297, 529, 438, 63, 592, 14, 5607, 531, 199, 199, 3, 199, 3, 5311, 22421, 2153, 529, 438, 511, 199, 3, 199, 3, 5574, 603, 5757, 899, 17625, 666, 199, 576, 275, 6454, 14, 739, 63, 4737, 480, 9707, 2219, 15, 2297, 529, 438, 15, 13654, 614, 63, 426, 22421, 63, 548, 63, 10198, 405, 63, 614, 1717, 14, 4737, 531, 199, 199, 6003, 14, 8941, 8, 19, 9, 199, 6003, 14, 2798, 8, 88, 12, 1420, 8, 88, 12, 413, 69, 19, 395, 1768, 275, 283, 8014, 3294, 358, 199, 6003, 14, 2798, 8, 576, 14, 88, 12, 666, 14, 11535, 10865, 16, 12, 283, 79, 297, 1768, 275, 283, 2679, 47, 899, 297, 7557, 415, 2588, 29, 20, 9, 199, 6003, 14, 14168, 360, 88, 334, 77, 5942, 199, 6003, 14, 13849, 360, 27218, 12347, 5868, 5942, 199, 6003, 14, 10231, 342, 199, 6003, 14, 1213, 360, 27218, 12347, 334, 84, 275, 5198, 308, 5942, 199, 6003, 14, 18123, 11468, 16, 14, 1717, 12, 17, 566, 199, 6003, 14, 19556, 480, 2297, 529, 438, 63, 426, 22421, 63, 592, 14, 5607, 531, 199, 199, 1274, 14, 2224, 8, 16, 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, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
storm-computers/odoo
openerp/report/render/odt2odt/odt2odt.py
49
1309
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. from openerp.report.render.rml2pdf import utils import copy class odt2odt(object): def __init__(self, odt, localcontext): self.localcontext = localcontext self.etree = odt self._node = None def render(self): def process_text(node,new_node): for child in utils._child_get(node, self): new_child = copy.deepcopy(child) new_node.append(new_child) if len(child): for n in new_child: new_child.text = utils._process_text(self, child.text) new_child.tail = utils._process_text(self, child.tail) new_child.remove(n) process_text(child, new_child) else: new_child.text = utils._process_text(self, child.text) new_child.tail = utils._process_text(self, child.tail) self._node = copy.deepcopy(self.etree) for n in self._node: self._node.remove(n) process_text(self.etree, self._node) return self._node def parseNode(node, localcontext = {}): r = odt2odt(node, localcontext) return r.render()
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 14320, 402, 28935, 14, 1666, 5113, 570, 367, 2615, 4248, 436, 32572, 2436, 14, 199, 199, 504, 5166, 14, 3070, 14, 3352, 14, 16300, 18, 5607, 492, 3778, 199, 646, 1331, 199, 199, 533, 312, 3583, 18, 364, 84, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 312, 3583, 12, 2257, 1100, 304, 267, 291, 14, 17886, 275, 2257, 1100, 267, 291, 14, 9464, 275, 312, 3583, 267, 291, 423, 932, 275, 488, 339, 347, 3795, 8, 277, 304, 267, 347, 2112, 63, 505, 8, 932, 12, 1222, 63, 932, 304, 288, 367, 1982, 315, 3778, 423, 1739, 63, 362, 8, 932, 12, 291, 304, 355, 892, 63, 1739, 275, 1331, 14, 8293, 8, 1739, 9, 355, 892, 63, 932, 14, 740, 8, 1222, 63, 1739, 9, 355, 340, 822, 8, 1739, 304, 490, 367, 302, 315, 892, 63, 1739, 26, 717, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 717, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 717, 892, 63, 1739, 14, 2168, 8, 78, 9, 490, 2112, 63, 505, 8, 1739, 12, 892, 63, 1739, 9, 355, 587, 26, 490, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 490, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 267, 291, 423, 932, 275, 1331, 14, 8293, 8, 277, 14, 9464, 9, 267, 367, 302, 315, 291, 423, 932, 26, 288, 291, 423, 932, 14, 2168, 8, 78, 9, 267, 2112, 63, 505, 8, 277, 14, 9464, 12, 291, 423, 932, 9, 267, 372, 291, 423, 932, 199, 199, 318, 2198, 1716, 8, 932, 12, 2257, 1100, 275, 1052, 304, 272, 519, 275, 312, 3583, 18, 364, 84, 8, 932, 12, 2257, 1100, 9, 272, 372, 519, 14, 3352, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 14320, 402, 28935, 14, 1666, 5113, 570, 367, 2615, 4248, 436, 32572, 2436, 14, 199, 199, 504, 5166, 14, 3070, 14, 3352, 14, 16300, 18, 5607, 492, 3778, 199, 646, 1331, 199, 199, 533, 312, 3583, 18, 364, 84, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 312, 3583, 12, 2257, 1100, 304, 267, 291, 14, 17886, 275, 2257, 1100, 267, 291, 14, 9464, 275, 312, 3583, 267, 291, 423, 932, 275, 488, 339, 347, 3795, 8, 277, 304, 267, 347, 2112, 63, 505, 8, 932, 12, 1222, 63, 932, 304, 288, 367, 1982, 315, 3778, 423, 1739, 63, 362, 8, 932, 12, 291, 304, 355, 892, 63, 1739, 275, 1331, 14, 8293, 8, 1739, 9, 355, 892, 63, 932, 14, 740, 8, 1222, 63, 1739, 9, 355, 340, 822, 8, 1739, 304, 490, 367, 302, 315, 892, 63, 1739, 26, 717, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 717, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 717, 892, 63, 1739, 14, 2168, 8, 78, 9, 490, 2112, 63, 505, 8, 1739, 12, 892, 63, 1739, 9, 355, 587, 26, 490, 892, 63, 1739, 14, 505, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 505, 9, 490, 892, 63, 1739, 14, 1521, 221, 275, 3778, 423, 1412, 63, 505, 8, 277, 12, 1982, 14, 1521, 9, 267, 291, 423, 932, 275, 1331, 14, 8293, 8, 277, 14, 9464, 9, 267, 367, 302, 315, 291, 423, 932, 26, 288, 291, 423, 932, 14, 2168, 8, 78, 9, 267, 2112, 63, 505, 8, 277, 14, 9464, 12, 291, 423, 932, 9, 267, 372, 291, 423, 932, 199, 199, 318, 2198, 1716, 8, 932, 12, 2257, 1100, 275, 1052, 304, 272, 519, 275, 312, 3583, 18, 364, 84, 8, 932, 12, 2257, 1100, 9, 272, 372, 519, 14, 3352, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1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/virtsparsify.py
2
2040
# # Copyright 2014 Red Hat, 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 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # Refer to the README and COPYING files for full details of the license # from __future__ import absolute_import import signal from . import utils # Fedora, EL6 _VIRTSPARSIFY = utils.CommandPath("virt-sparsify", "/usr/bin/virt-sparsify",) class Error(Exception): def __init__(self, ecode, stderr): self.ecode = ecode self.stderr = stderr def __str__(self): return "[Error %d] %s" % (self.ecode, self.stderr) def sparsify(src_vol, tmp_vol, dst_vol, src_format=None, dst_format=None): """ Sparsify the 'src_vol' volume (src_format) to 'dst_vol' volume (dst_format) using libguestfs virt-sparsify src_vol: path of base volume tmp_vol: path of temporary volume created with src_vol as backing volume dst_vol: path of destination volume src_format: format of base volume ('raw' or `qcow2') src_format: format of destination volume ('raw' or `qcow2') """ cmd = [_VIRTSPARSIFY.cmd, '--tmp', 'prebuilt:' + tmp_vol] if src_format: cmd.extend(("--format", src_format)) if dst_format: cmd.extend(("--convert", dst_format)) cmd.extend((src_vol, dst_vol)) rc, _, err = utils.execCmd(cmd, deathSignal=signal.SIGKILL) if rc != 0: raise Error(rc, err)
gpl-2.0
[ 3, 199, 3, 1898, 6927, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 199, 3, 199, 3, 21751, 370, 314, 27781, 436, 9685, 1584, 367, 2615, 2436, 402, 314, 4190, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 646, 4673, 199, 199, 504, 1275, 492, 3778, 199, 199, 3, 481, 379, 11131, 12, 22325, 22, 199, 63, 13679, 9730, 4014, 2684, 18114, 275, 3778, 14, 3110, 2042, 480, 4549, 13, 22502, 338, 1399, 401, 3303, 3286, 2647, 15, 1393, 15, 4549, 13, 22502, 338, 1399, 26360, 421, 199, 533, 4520, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 325, 600, 12, 4635, 304, 267, 291, 14, 69, 600, 275, 325, 600, 267, 291, 14, 3083, 275, 4635, 339, 347, 636, 495, 721, 277, 304, 267, 372, 7369, 547, 450, 68, 61, 450, 83, 2, 450, 334, 277, 14, 69, 600, 12, 291, 14, 3083, 9, 421, 199, 318, 28668, 338, 1399, 8, 2164, 63, 5650, 12, 3529, 63, 5650, 12, 5042, 63, 5650, 12, 2928, 63, 908, 29, 403, 12, 5042, 63, 908, 29, 403, 304, 272, 408, 272, 428, 462, 338, 1399, 314, 283, 2164, 63, 5650, 7, 3301, 334, 2164, 63, 908, 9, 370, 283, 5119, 63, 5650, 7, 3301, 334, 5119, 63, 908, 9, 272, 1808, 1973, 10409, 2319, 12043, 13, 22502, 338, 1399, 339, 2928, 63, 5650, 26, 931, 402, 1300, 3301, 272, 3529, 63, 5650, 26, 931, 402, 7937, 3301, 2737, 543, 2928, 63, 5650, 465, 21094, 3301, 272, 5042, 63, 5650, 26, 931, 402, 5724, 3301, 272, 2928, 63, 908, 26, 1475, 402, 1300, 3301, 661, 1773, 7, 503, 658, 81, 19969, 18, 358, 272, 2928, 63, 908, 26, 1475, 402, 5724, 3301, 661, 1773, 7, 503, 658, 81, 19969, 18, 358, 272, 408, 272, 2088, 275, 15500, 13679, 9730, 4014, 2684, 18114, 14, 1760, 12, 2850, 2791, 297, 283, 657, 11730, 4881, 435, 3529, 63, 5650, 61, 339, 340, 2928, 63, 908, 26, 267, 2088, 14, 2880, 8, 6739, 908, 401, 2928, 63, 908, 430, 339, 340, 5042, 63, 908, 26, 267, 2088, 14, 2880, 8, 6739, 3916, 401, 5042, 63, 908, 430, 339, 2088, 14, 2880, 1332, 2164, 63, 5650, 12, 5042, 63, 5650, 430, 339, 4819, 12, 5501, 2329, 275, 3778, 14, 1628, 7874, 8, 1760, 12, 477, 1619, 11274, 29, 4653, 14, 7864, 30691, 9, 339, 340, 4819, 1137, 378, 26, 267, 746, 4520, 8, 1195, 12, 2329, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 6927, 9572, 13002, 12, 3277, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 199, 3, 199, 3, 21751, 370, 314, 27781, 436, 9685, 1584, 367, 2615, 2436, 402, 314, 4190, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 646, 4673, 199, 199, 504, 1275, 492, 3778, 199, 199, 3, 481, 379, 11131, 12, 22325, 22, 199, 63, 13679, 9730, 4014, 2684, 18114, 275, 3778, 14, 3110, 2042, 480, 4549, 13, 22502, 338, 1399, 401, 3303, 3286, 2647, 15, 1393, 15, 4549, 13, 22502, 338, 1399, 26360, 421, 199, 533, 4520, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 325, 600, 12, 4635, 304, 267, 291, 14, 69, 600, 275, 325, 600, 267, 291, 14, 3083, 275, 4635, 339, 347, 636, 495, 721, 277, 304, 267, 372, 7369, 547, 450, 68, 61, 450, 83, 2, 450, 334, 277, 14, 69, 600, 12, 291, 14, 3083, 9, 421, 199, 318, 28668, 338, 1399, 8, 2164, 63, 5650, 12, 3529, 63, 5650, 12, 5042, 63, 5650, 12, 2928, 63, 908, 29, 403, 12, 5042, 63, 908, 29, 403, 304, 272, 408, 272, 428, 462, 338, 1399, 314, 283, 2164, 63, 5650, 7, 3301, 334, 2164, 63, 908, 9, 370, 283, 5119, 63, 5650, 7, 3301, 334, 5119, 63, 908, 9, 272, 1808, 1973, 10409, 2319, 12043, 13, 22502, 338, 1399, 339, 2928, 63, 5650, 26, 931, 402, 1300, 3301, 272, 3529, 63, 5650, 26, 931, 402, 7937, 3301, 2737, 543, 2928, 63, 5650, 465, 21094, 3301, 272, 5042, 63, 5650, 26, 931, 402, 5724, 3301, 272, 2928, 63, 908, 26, 1475, 402, 1300, 3301, 661, 1773, 7, 503, 658, 81, 19969, 18, 358, 272, 2928, 63, 908, 26, 1475, 402, 5724, 3301, 661, 1773, 7, 503, 658, 81, 19969, 18, 358, 272, 408, 272, 2088, 275, 15500, 13679, 9730, 4014, 2684, 18114, 14, 1760, 12, 2850, 2791, 297, 283, 657, 11730, 4881, 435, 3529, 63, 5650, 61, 339, 340, 2928, 63, 908, 26, 267, 2088, 14, 2880, 8, 6739, 908, 401, 2928, 63, 908, 430, 339, 340, 5042, 63, 908, 26, 267, 2088, 14, 2880, 8, 6739, 3916, 401, 5042, 63, 908, 430, 339, 2088, 14, 2880, 1332, 2164, 63, 5650, 12, 5042, 63, 5650, 430, 339, 4819, 12, 5501, 2329, 275, 3778, 14, 1628, 7874, 8, 1760, 12, 477, 1619, 11274, 29, 4653, 14, 7864, 30691, 9, 339, 340, 4819, 1137, 378, 26, 267, 746, 4520, 8, 1195, 12, 2329, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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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 ]
us-ignite/us_ignite
us_ignite/resources/models.py
1
4037
import watson from django.core.urlresolvers import reverse from django.db import models from us_ignite.constants import IMAGE_HELP_TEXT from us_ignite.common.fields import AutoUUIDField, URL_HELP_TEXT from us_ignite.resources import managers, search from django_extensions.db.fields import ( AutoSlugField, CreationDateTimeField, ModificationDateTimeField, ) from taggit.managers import TaggableManager class ResourceType(models.Model): name = models.CharField(max_length=255) slug = AutoSlugField(populate_from='name', unique=True) def __unicode__(self): return self.name class Sector(models.Model): name = models.CharField(max_length=255) slug = AutoSlugField(populate_from='name', unique=True) def __unicode__(self): return self.name class Resource(models.Model): PUBLISHED = 1 DRAFT = 2 REMOVED = 3 STATUS_CHOICES = ( (PUBLISHED, 'Published'), (DRAFT, 'Draft'), (REMOVED, 'Removed'), ) name = models.CharField(max_length=255, verbose_name='name of resource') slug = AutoUUIDField(unique=True, editable=True) status = models.IntegerField(choices=STATUS_CHOICES, default=DRAFT) url = models.URLField( max_length=500, blank=True, help_text=URL_HELP_TEXT, verbose_name=u'URL') description = models.TextField() resource_type = models.ForeignKey( 'resources.ResourceType', blank=True, null=True, on_delete=models.SET_NULL) sector = models.ForeignKey( 'resources.Sector', blank=True, null=True, on_delete=models.SET_NULL) contact = models.ForeignKey( 'auth.User', blank=True, null=True, on_delete=models.SET_NULL, related_name='resource_contact_set') author = models.TextField( blank=True, help_text=u'Primary Author/Presenter (if different ' 'from contact)') organization = models.ForeignKey( 'organizations.Organization', blank=True, null=True, on_delete=models.SET_NULL) image = models.ImageField( upload_to="resource", blank=True, help_text=IMAGE_HELP_TEXT) asset = models.FileField(upload_to="resource", blank=True) resource_date = models.DateField( blank=True, null=True, help_text=u'Format: YYYY-MM-DD') is_featured = models.BooleanField(default=False) is_homepage = models.BooleanField( default=False, verbose_name='Show in the homepage?', help_text=u'If marked this element will be shown in the homepage.') tags = TaggableManager(blank=True) created = CreationDateTimeField() modified = ModificationDateTimeField() # Managers objects = models.Manager() published = managers.ResourcePublishedManager() class Meta: ordering = ('-is_featured', '-created') def __unicode__(self): return self.name def save(self, *args, **kwargs): # Replace any previous homepage item when published: if self.is_homepage and self.is_published(): self.__class__.objects.all().update(is_homepage=False) return super(Resource, self).save(*args, **kwargs) def get_absolute_url(self): return reverse('resource_detail', args=[self.slug]) def get_edit_url(self): return reverse('resource_edit', args=[self.slug]) def get_admin_url(self): return reverse('admin:resources_resource_change', args=[self.id]) def get_resource_url(self): if self.asset: return self.asset.url if self.url: return self.url return u'' def is_visible_by(self, user): return self.is_published() or self.is_editable_by(user) def is_editable_by(self, user): return self.contact and (user == self.contact) def is_published(self): return self.status == self.PUBLISHED def is_draft(self): return self.status == self.DRAFT @property def website(self): return self.url # Search: watson.register( Resource.published.all(), search.ResourceSearchAdapter )
bsd-3-clause
[ 646, 336, 292, 834, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 504, 2739, 63, 1030, 1175, 14, 5559, 492, 25228, 63, 17930, 63, 3876, 199, 504, 2739, 63, 1030, 1175, 14, 2330, 14, 955, 492, 9195, 8757, 792, 12, 2851, 63, 17930, 63, 3876, 199, 504, 2739, 63, 1030, 1175, 14, 4435, 492, 19680, 12, 2754, 199, 199, 504, 1639, 63, 5359, 14, 697, 14, 955, 492, 334, 272, 9195, 17315, 12, 272, 9750, 425, 4626, 12, 272, 12972, 3477, 4626, 12, 199, 9, 199, 504, 1947, 3187, 14, 16259, 492, 8053, 16725, 2988, 421, 199, 533, 7337, 804, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 8889, 275, 9195, 17315, 8, 13817, 63, 504, 534, 354, 297, 3747, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 428, 2406, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 8889, 275, 9195, 17315, 8, 13817, 63, 504, 534, 354, 297, 3747, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 7337, 8, 992, 14, 1685, 304, 272, 18787, 44, 20450, 275, 413, 272, 577, 29650, 275, 499, 272, 5363, 2679, 14112, 275, 650, 272, 18460, 63, 16236, 275, 334, 267, 334, 30266, 20450, 12, 283, 27862, 659, 267, 334, 36, 29650, 12, 283, 18332, 659, 267, 334, 907, 2679, 14112, 12, 283, 23407, 659, 272, 776, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 354, 402, 2073, 358, 272, 8889, 275, 9195, 8757, 792, 8, 3235, 29, 549, 12, 14783, 29, 549, 9, 272, 2004, 275, 1709, 14, 3901, 8, 4577, 29, 6305, 63, 16236, 12, 849, 29, 36, 29650, 9, 272, 1166, 275, 1709, 14, 17363, 8, 267, 1390, 63, 1267, 29, 5783, 12, 4596, 29, 549, 12, 1720, 63, 505, 29, 2632, 63, 17930, 63, 3876, 12, 3376, 63, 354, 29, 85, 7, 2632, 358, 272, 1369, 275, 1709, 14, 6254, 342, 272, 2073, 63, 466, 275, 1709, 14, 3190, 8, 267, 283, 4435, 14, 4031, 804, 297, 4596, 29, 549, 12, 2973, 29, 549, 12, 267, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 9, 272, 27935, 275, 1709, 14, 3190, 8, 267, 283, 4435, 14, 51, 2406, 297, 4596, 29, 549, 12, 2973, 29, 549, 12, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 9, 272, 8966, 275, 1709, 14, 3190, 8, 267, 283, 1178, 14, 1899, 297, 4596, 29, 549, 12, 2973, 29, 549, 12, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 12, 267, 4048, 63, 354, 534, 1927, 63, 7811, 63, 409, 358, 272, 4132, 275, 1709, 14, 6254, 8, 267, 4596, 29, 549, 12, 1720, 63, 505, 29, 85, 7, 14908, 6529, 15, 2398, 2464, 351, 334, 692, 3365, 283, 267, 283, 504, 8966, 5942, 272, 13237, 275, 1709, 14, 3190, 8, 267, 283, 19916, 12270, 14, 15928, 297, 4596, 29, 549, 12, 2973, 29, 549, 12, 267, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 9, 272, 1834, 275, 1709, 14, 21910, 8, 267, 5802, 63, 475, 628, 1927, 401, 4596, 29, 549, 12, 1720, 63, 505, 29, 9438, 63, 17930, 63, 3876, 9, 272, 8977, 275, 1709, 14, 23252, 8, 5064, 63, 475, 628, 1927, 401, 4596, 29, 549, 9, 272, 2073, 63, 602, 275, 1709, 14, 14071, 8, 267, 4596, 29, 549, 12, 2973, 29, 549, 12, 1720, 63, 505, 29, 85, 7, 3484, 26, 31946, 13, 3218, 13, 5745, 358, 272, 365, 63, 30779, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 272, 365, 63, 25539, 275, 1709, 14, 5036, 8, 267, 849, 29, 797, 12, 3376, 63, 354, 534, 6824, 315, 314, 26586, 7044, 267, 1720, 63, 505, 29, 85, 7, 3917, 11584, 642, 1819, 911, 506, 9164, 315, 314, 26586, 2659, 272, 3762, 275, 8053, 16725, 2988, 8, 2500, 29, 549, 9, 272, 2737, 275, 9750, 425, 4626, 342, 272, 6042, 275, 12972, 3477, 4626, 342, 339, 327, 4688, 10246, 272, 2251, 275, 1709, 14, 2988, 342, 272, 3267, 275, 19680, 14, 4031, 27862, 2988, 342, 339, 1021, 6288, 26, 267, 7794, 275, 12291, 374, 63, 30779, 297, 2475, 3966, 358, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 14402, 1263, 4136, 26586, 1242, 1380, 3267, 26, 267, 340, 291, 14, 374, 63, 25539, 436, 291, 14, 374, 63, 8987, 837, 288, 291, 855, 533, 4343, 1462, 14, 452, 1252, 873, 8, 374, 63, 25539, 29, 797, 9, 267, 372, 1613, 8, 4031, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 6116, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 1927, 63, 5506, 297, 1249, 1524, 277, 14, 5464, 566, 339, 347, 664, 63, 3773, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 1927, 63, 3773, 297, 1249, 1524, 277, 14, 5464, 566, 339, 347, 664, 63, 2113, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 2113, 26, 4435, 63, 1927, 63, 1461, 297, 1249, 1524, 277, 14, 344, 566, 339, 347, 664, 63, 1927, 63, 633, 8, 277, 304, 267, 340, 291, 14, 6562, 26, 288, 372, 291, 14, 6562, 14, 633, 267, 340, 291, 14, 633, 26, 288, 372, 291, 14, 633, 267, 372, 399, 891, 339, 347, 365, 63, 6604, 63, 991, 8, 277, 12, 922, 304, 267, 372, 291, 14, 374, 63, 8987, 342, 503, 291, 14, 374, 63, 10820, 63, 991, 8, 751, 9, 339, 347, 365, 63, 10820, 63, 991, 8, 277, 12, 922, 304, 267, 372, 291, 14, 7811, 436, 334, 751, 508, 291, 14, 7811, 9, 339, 347, 365, 63, 8987, 8, 277, 304, 267, 372, 291, 14, 1205, 508, 291, 14, 30266, 20450, 339, 347, 365, 63, 7185, 8, 277, 304, 267, 372, 291, 14, 1205, 508, 291, 14, 36, 29650, 339, 768, 1829, 272, 347, 10691, 8, 277 ]
[ 336, 292, 834, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 504, 2739, 63, 1030, 1175, 14, 5559, 492, 25228, 63, 17930, 63, 3876, 199, 504, 2739, 63, 1030, 1175, 14, 2330, 14, 955, 492, 9195, 8757, 792, 12, 2851, 63, 17930, 63, 3876, 199, 504, 2739, 63, 1030, 1175, 14, 4435, 492, 19680, 12, 2754, 199, 199, 504, 1639, 63, 5359, 14, 697, 14, 955, 492, 334, 272, 9195, 17315, 12, 272, 9750, 425, 4626, 12, 272, 12972, 3477, 4626, 12, 199, 9, 199, 504, 1947, 3187, 14, 16259, 492, 8053, 16725, 2988, 421, 199, 533, 7337, 804, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 8889, 275, 9195, 17315, 8, 13817, 63, 504, 534, 354, 297, 3747, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 428, 2406, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 8889, 275, 9195, 17315, 8, 13817, 63, 504, 534, 354, 297, 3747, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 7337, 8, 992, 14, 1685, 304, 272, 18787, 44, 20450, 275, 413, 272, 577, 29650, 275, 499, 272, 5363, 2679, 14112, 275, 650, 272, 18460, 63, 16236, 275, 334, 267, 334, 30266, 20450, 12, 283, 27862, 659, 267, 334, 36, 29650, 12, 283, 18332, 659, 267, 334, 907, 2679, 14112, 12, 283, 23407, 659, 272, 776, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 3376, 63, 354, 534, 354, 402, 2073, 358, 272, 8889, 275, 9195, 8757, 792, 8, 3235, 29, 549, 12, 14783, 29, 549, 9, 272, 2004, 275, 1709, 14, 3901, 8, 4577, 29, 6305, 63, 16236, 12, 849, 29, 36, 29650, 9, 272, 1166, 275, 1709, 14, 17363, 8, 267, 1390, 63, 1267, 29, 5783, 12, 4596, 29, 549, 12, 1720, 63, 505, 29, 2632, 63, 17930, 63, 3876, 12, 3376, 63, 354, 29, 85, 7, 2632, 358, 272, 1369, 275, 1709, 14, 6254, 342, 272, 2073, 63, 466, 275, 1709, 14, 3190, 8, 267, 283, 4435, 14, 4031, 804, 297, 4596, 29, 549, 12, 2973, 29, 549, 12, 267, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 9, 272, 27935, 275, 1709, 14, 3190, 8, 267, 283, 4435, 14, 51, 2406, 297, 4596, 29, 549, 12, 2973, 29, 549, 12, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 9, 272, 8966, 275, 1709, 14, 3190, 8, 267, 283, 1178, 14, 1899, 297, 4596, 29, 549, 12, 2973, 29, 549, 12, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 12, 267, 4048, 63, 354, 534, 1927, 63, 7811, 63, 409, 358, 272, 4132, 275, 1709, 14, 6254, 8, 267, 4596, 29, 549, 12, 1720, 63, 505, 29, 85, 7, 14908, 6529, 15, 2398, 2464, 351, 334, 692, 3365, 283, 267, 283, 504, 8966, 5942, 272, 13237, 275, 1709, 14, 3190, 8, 267, 283, 19916, 12270, 14, 15928, 297, 4596, 29, 549, 12, 2973, 29, 549, 12, 267, 641, 63, 1807, 29, 992, 14, 3597, 63, 8084, 9, 272, 1834, 275, 1709, 14, 21910, 8, 267, 5802, 63, 475, 628, 1927, 401, 4596, 29, 549, 12, 1720, 63, 505, 29, 9438, 63, 17930, 63, 3876, 9, 272, 8977, 275, 1709, 14, 23252, 8, 5064, 63, 475, 628, 1927, 401, 4596, 29, 549, 9, 272, 2073, 63, 602, 275, 1709, 14, 14071, 8, 267, 4596, 29, 549, 12, 2973, 29, 549, 12, 1720, 63, 505, 29, 85, 7, 3484, 26, 31946, 13, 3218, 13, 5745, 358, 272, 365, 63, 30779, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 272, 365, 63, 25539, 275, 1709, 14, 5036, 8, 267, 849, 29, 797, 12, 3376, 63, 354, 534, 6824, 315, 314, 26586, 7044, 267, 1720, 63, 505, 29, 85, 7, 3917, 11584, 642, 1819, 911, 506, 9164, 315, 314, 26586, 2659, 272, 3762, 275, 8053, 16725, 2988, 8, 2500, 29, 549, 9, 272, 2737, 275, 9750, 425, 4626, 342, 272, 6042, 275, 12972, 3477, 4626, 342, 339, 327, 4688, 10246, 272, 2251, 275, 1709, 14, 2988, 342, 272, 3267, 275, 19680, 14, 4031, 27862, 2988, 342, 339, 1021, 6288, 26, 267, 7794, 275, 12291, 374, 63, 30779, 297, 2475, 3966, 358, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 3354, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 14402, 1263, 4136, 26586, 1242, 1380, 3267, 26, 267, 340, 291, 14, 374, 63, 25539, 436, 291, 14, 374, 63, 8987, 837, 288, 291, 855, 533, 4343, 1462, 14, 452, 1252, 873, 8, 374, 63, 25539, 29, 797, 9, 267, 372, 1613, 8, 4031, 12, 291, 680, 2117, 2031, 589, 12, 1011, 958, 9, 339, 347, 664, 63, 6116, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 1927, 63, 5506, 297, 1249, 1524, 277, 14, 5464, 566, 339, 347, 664, 63, 3773, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 1927, 63, 3773, 297, 1249, 1524, 277, 14, 5464, 566, 339, 347, 664, 63, 2113, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 2113, 26, 4435, 63, 1927, 63, 1461, 297, 1249, 1524, 277, 14, 344, 566, 339, 347, 664, 63, 1927, 63, 633, 8, 277, 304, 267, 340, 291, 14, 6562, 26, 288, 372, 291, 14, 6562, 14, 633, 267, 340, 291, 14, 633, 26, 288, 372, 291, 14, 633, 267, 372, 399, 891, 339, 347, 365, 63, 6604, 63, 991, 8, 277, 12, 922, 304, 267, 372, 291, 14, 374, 63, 8987, 342, 503, 291, 14, 374, 63, 10820, 63, 991, 8, 751, 9, 339, 347, 365, 63, 10820, 63, 991, 8, 277, 12, 922, 304, 267, 372, 291, 14, 7811, 436, 334, 751, 508, 291, 14, 7811, 9, 339, 347, 365, 63, 8987, 8, 277, 304, 267, 372, 291, 14, 1205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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 ]
cancro7/gem5
src/mem/slicc/ast/StateDeclAST.py
32
3307
# Copyright (c) 2011 Advanced Micro Devices, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer; # redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution; # neither the name of the copyright holders nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from slicc.ast.DeclAST import DeclAST from slicc.symbols import Func, Type class StateDeclAST(DeclAST): def __init__(self, slicc, type_ast, pairs, states): super(StateDeclAST, self).__init__(slicc, pairs) self.type_ast = type_ast self.states = states def __repr__(self): return "[StateDecl: %s]" % (self.type_ast) def files(self, parent=None): if "external" in self: return set() if parent: ident = "%s_%s" % (parent, self.type_ast.ident) else: ident = self.type_ast.ident s = set(("%s.hh" % ident, "%s.cc" % ident)) return s def generate(self): ident = str(self.type_ast) # Make the new type t = Type(self.symtab, ident, self.location, self.pairs, self.state_machine) self.symtab.newSymbol(t) # Add all of the states of the type to it for state in self.states: state.generate(t) # Add the implicit State_to_string method - FIXME, this is a bit dirty func_id = "%s_to_string" % t.c_ident pairs = { "external" : "yes" } func = Func(self.symtab, func_id + "_" + t.ident, func_id, self.location, self.symtab.find("std::string", Type), [ t ], [], "", pairs) self.symtab.newSymbol(func) # Add the State_to_permission method func_id = "%s_to_permission" % t.c_ident pairs = { "external" : "yes" } func = Func(self.symtab, func_id + "_" + t.ident, func_id, self.location, self.symtab.find("AccessPermission", Type), [ t ], [], "", pairs) self.symtab.newSymbol(func)
bsd-3-clause
[ 3, 1898, 334, 67, 9, 7760, 32445, 27022, 12272, 83, 12, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 308, 606, 67, 14, 1810, 14, 20856, 11307, 492, 1487, 429, 11307, 199, 504, 308, 606, 67, 14, 7450, 492, 28794, 12, 2434, 199, 199, 533, 8511, 20856, 11307, 8, 20856, 11307, 304, 272, 347, 636, 826, 721, 277, 12, 308, 606, 67, 12, 730, 63, 1810, 12, 6342, 12, 6363, 304, 267, 1613, 8, 2223, 20856, 11307, 12, 291, 2843, 826, 721, 83, 606, 67, 12, 6342, 9, 398, 291, 14, 466, 63, 1810, 275, 730, 63, 1810, 267, 291, 14, 4981, 275, 6363, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 7369, 2223, 20856, 26, 450, 83, 8480, 450, 334, 277, 14, 466, 63, 1810, 9, 339, 347, 1584, 8, 277, 12, 1676, 29, 403, 304, 267, 340, 298, 5159, 2, 315, 291, 26, 288, 372, 663, 342, 398, 340, 1676, 26, 288, 12893, 275, 2071, 83, 4970, 83, 2, 450, 334, 1708, 12, 291, 14, 466, 63, 1810, 14, 5425, 9, 267, 587, 26, 288, 12893, 275, 291, 14, 466, 63, 1810, 14, 5425, 267, 308, 275, 663, 8, 3647, 83, 14, 12156, 2, 450, 12893, 12, 2071, 83, 14, 2055, 2, 450, 12893, 430, 267, 372, 308, 339, 347, 3550, 8, 277, 304, 267, 12893, 275, 620, 8, 277, 14, 466, 63, 1810, 9, 398, 327, 4155, 314, 892, 730, 267, 307, 275, 2434, 8, 277, 14, 1786, 2037, 371, 12, 12893, 12, 291, 14, 1985, 12, 291, 14, 7322, 12, 326, 291, 14, 929, 63, 6744, 9, 267, 291, 14, 1786, 2037, 371, 14, 1222, 8169, 8, 84, 9, 398, 327, 2654, 1006, 402, 314, 6363, 402, 314, 730, 370, 652, 267, 367, 1174, 315, 291, 14, 4981, 26, 288, 1174, 14, 4208, 8, 84, 9, 398, 327, 2654, 314, 9227, 8511, 63, 475, 63, 875, 1083, 446, 7600, 12, 642, 365, 282, 4546, 14650, 267, 2562, 63, 344, 275, 2071, 83, 63, 475, 63, 875, 2, 450, 307, 14, 67, 63, 5425, 398, 6342, 275, 469, 298, 5159, 2, 520, 298, 5066, 2, 789, 267, 2562, 275, 28794, 8, 277, 14, 1786, 2037, 371, 12, 2562, 63, 344, 435, 14220, 435, 490, 307, 14, 5425, 12, 2562, 63, 344, 12, 291, 14, 1985, 12, 490, 291, 14, 1786, 2037, 371, 14, 1623, 480, 1516, 447, 875, 401, 2434, 395, 359, 307, 2156, 990, 4873, 490, 6342, 9, 267, 291, 14, 1786, 2037, 371, 14, 1222, 8169, 8, 1532, 9, 398, 327, 2654, 314, 8511, 63, 475, 63, 5693, 1083, 267, 2562, 63, 344, 275, 2071, 83, 63, 475, 63, 5693, 2, 450, 307, 14, 67, 63, 5425, 398, 6342, 275, 469, 298, 5159, 2, 520, 298, 5066, 2, 789, 267, 2562, 275, 28794, 8, 277, 14, 1786, 2037, 371, 12, 2562, 63, 344, 435, 14220, 435, 490, 307, 14, 5425, 12, 2562, 63, 344, 12, 291, 14, 1985, 12, 490, 291, 14, 1786, 2037, 371, 14, 1623, 480, 3946, 7980, 401, 2434, 395, 359, 307, 2156, 990, 4873, 490, 6342, 9, 267, 291, 14, 1786, 2037, 371, 14, 1222, 8169, 8, 1532, 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 ]
[ 1898, 334, 67, 9, 7760, 32445, 27022, 12272, 83, 12, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 26771, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 27, 199, 3, 26771, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 27, 199, 3, 15564, 314, 536, 402, 314, 4248, 31976, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 504, 308, 606, 67, 14, 1810, 14, 20856, 11307, 492, 1487, 429, 11307, 199, 504, 308, 606, 67, 14, 7450, 492, 28794, 12, 2434, 199, 199, 533, 8511, 20856, 11307, 8, 20856, 11307, 304, 272, 347, 636, 826, 721, 277, 12, 308, 606, 67, 12, 730, 63, 1810, 12, 6342, 12, 6363, 304, 267, 1613, 8, 2223, 20856, 11307, 12, 291, 2843, 826, 721, 83, 606, 67, 12, 6342, 9, 398, 291, 14, 466, 63, 1810, 275, 730, 63, 1810, 267, 291, 14, 4981, 275, 6363, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 7369, 2223, 20856, 26, 450, 83, 8480, 450, 334, 277, 14, 466, 63, 1810, 9, 339, 347, 1584, 8, 277, 12, 1676, 29, 403, 304, 267, 340, 298, 5159, 2, 315, 291, 26, 288, 372, 663, 342, 398, 340, 1676, 26, 288, 12893, 275, 2071, 83, 4970, 83, 2, 450, 334, 1708, 12, 291, 14, 466, 63, 1810, 14, 5425, 9, 267, 587, 26, 288, 12893, 275, 291, 14, 466, 63, 1810, 14, 5425, 267, 308, 275, 663, 8, 3647, 83, 14, 12156, 2, 450, 12893, 12, 2071, 83, 14, 2055, 2, 450, 12893, 430, 267, 372, 308, 339, 347, 3550, 8, 277, 304, 267, 12893, 275, 620, 8, 277, 14, 466, 63, 1810, 9, 398, 327, 4155, 314, 892, 730, 267, 307, 275, 2434, 8, 277, 14, 1786, 2037, 371, 12, 12893, 12, 291, 14, 1985, 12, 291, 14, 7322, 12, 326, 291, 14, 929, 63, 6744, 9, 267, 291, 14, 1786, 2037, 371, 14, 1222, 8169, 8, 84, 9, 398, 327, 2654, 1006, 402, 314, 6363, 402, 314, 730, 370, 652, 267, 367, 1174, 315, 291, 14, 4981, 26, 288, 1174, 14, 4208, 8, 84, 9, 398, 327, 2654, 314, 9227, 8511, 63, 475, 63, 875, 1083, 446, 7600, 12, 642, 365, 282, 4546, 14650, 267, 2562, 63, 344, 275, 2071, 83, 63, 475, 63, 875, 2, 450, 307, 14, 67, 63, 5425, 398, 6342, 275, 469, 298, 5159, 2, 520, 298, 5066, 2, 789, 267, 2562, 275, 28794, 8, 277, 14, 1786, 2037, 371, 12, 2562, 63, 344, 435, 14220, 435, 490, 307, 14, 5425, 12, 2562, 63, 344, 12, 291, 14, 1985, 12, 490, 291, 14, 1786, 2037, 371, 14, 1623, 480, 1516, 447, 875, 401, 2434, 395, 359, 307, 2156, 990, 4873, 490, 6342, 9, 267, 291, 14, 1786, 2037, 371, 14, 1222, 8169, 8, 1532, 9, 398, 327, 2654, 314, 8511, 63, 475, 63, 5693, 1083, 267, 2562, 63, 344, 275, 2071, 83, 63, 475, 63, 5693, 2, 450, 307, 14, 67, 63, 5425, 398, 6342, 275, 469, 298, 5159, 2, 520, 298, 5066, 2, 789, 267, 2562, 275, 28794, 8, 277, 14, 1786, 2037, 371, 12, 2562, 63, 344, 435, 14220, 435, 490, 307, 14, 5425, 12, 2562, 63, 344, 12, 291, 14, 1985, 12, 490, 291, 14, 1786, 2037, 371, 14, 1623, 480, 3946, 7980, 401, 2434, 395, 359, 307, 2156, 990, 4873, 490, 6342, 9, 267, 291, 14, 1786, 2037, 371, 14, 1222, 8169, 8, 1532, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
xinwu/horizon
openstack_dashboard/dashboards/project/access_and_security/tests.py
10
9143
# Copyright 2012 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Copyright 2012 Nebula, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from copy import deepcopy # noqa from django.core.urlresolvers import reverse from django import http from mox3.mox import IsA # noqa from horizon.workflows import views from openstack_dashboard import api from openstack_dashboard.dashboards.project.access_and_security \ import api_access from openstack_dashboard.dashboards.project.access_and_security \ .security_groups import tables from openstack_dashboard.test import helpers as test from openstack_dashboard.usage import quotas INDEX_URL = reverse('horizon:project:access_and_security:index') class AccessAndSecurityTests(test.TestCase): def setUp(self): super(AccessAndSecurityTests, self).setUp() @test.create_stubs({api.network: ('floating_ip_supported', 'tenant_floating_ip_list', 'security_group_list',), api.nova: ('keypair_list', 'server_list',), api.base: ('is_service_enabled',), quotas: ('tenant_quota_usages',)}) def _test_index(self, ec2_enabled): keypairs = self.keypairs.list() sec_groups = self.security_groups.list() floating_ips = self.floating_ips.list() quota_data = self.quota_usages.first() quota_data['security_groups']['available'] = 10 api.nova.server_list( IsA(http.HttpRequest)) \ .AndReturn([self.servers.list(), False]) api.nova.keypair_list( IsA(http.HttpRequest)) \ .AndReturn(keypairs) api.network.floating_ip_supported( IsA(http.HttpRequest)) \ .AndReturn(True) api.network.tenant_floating_ip_list( IsA(http.HttpRequest)) \ .AndReturn(floating_ips) api.network.security_group_list( IsA(http.HttpRequest)) \ .AndReturn(sec_groups) quotas.tenant_quota_usages( IsA(http.HttpRequest)).MultipleTimes() \ .AndReturn(quota_data) api.base.is_service_enabled( IsA(http.HttpRequest), 'network').MultipleTimes() \ .AndReturn(True) api.base.is_service_enabled( IsA(http.HttpRequest), 'ec2').MultipleTimes() \ .AndReturn(ec2_enabled) self.mox.ReplayAll() res = self.client.get(INDEX_URL) self.assertTemplateUsed(res, 'project/access_and_security/index.html') self.assertItemsEqual(res.context['keypairs_table'].data, keypairs) self.assertItemsEqual(res.context['security_groups_table'].data, sec_groups) self.assertItemsEqual(res.context['floating_ips_table'].data, floating_ips) if ec2_enabled: self.assertTrue(any(map( lambda x: isinstance(x, api_access.tables.DownloadEC2), res.context['endpoints_table'].get_table_actions() ))) else: self.assertFalse(any(map( lambda x: isinstance(x, api_access.tables.DownloadEC2), res.context['endpoints_table'].get_table_actions() ))) def test_index(self): self._test_index(ec2_enabled=True) def test_index_with_ec2_disabled(self): self._test_index(ec2_enabled=False) @test.create_stubs({api.network: ('floating_ip_target_list', 'tenant_floating_ip_list',)}) def test_association(self): servers = [api.nova.Server(s, self.request) for s in self.servers.list()] # Add duplicate instance name to test instance name with [ID] # Change id and private IP server3 = api.nova.Server(self.servers.first(), self.request) server3.id = 101 server3.addresses = deepcopy(server3.addresses) server3.addresses['private'][0]['addr'] = "10.0.0.5" servers.append(server3) targets = [api.nova.FloatingIpTarget(s) for s in servers] api.network.tenant_floating_ip_list( IsA(http.HttpRequest)) \ .AndReturn(self.floating_ips.list()) api.network.floating_ip_target_list( IsA(http.HttpRequest)) \ .AndReturn(targets) self.mox.ReplayAll() res = self.client.get(reverse("horizon:project:access_and_security:" "floating_ips:associate")) self.assertTemplateUsed(res, views.WorkflowView.template_name) self.assertContains(res, '<option value="1">server_1 (1)</option>') self.assertContains(res, '<option value="101">server_1 (101)</option>') self.assertContains(res, '<option value="2">server_2 (2)</option>') class AccessAndSecurityNeutronProxyTests(AccessAndSecurityTests): def setUp(self): super(AccessAndSecurityNeutronProxyTests, self).setUp() self.floating_ips = self.floating_ips_uuid class SecurityGroupTabTests(test.TestCase): def setUp(self): super(SecurityGroupTabTests, self).setUp() @test.create_stubs({api.network: ('floating_ip_supported', 'tenant_floating_ip_list', 'security_group_list', 'floating_ip_pools_list',), api.nova: ('keypair_list', 'server_list',), quotas: ('tenant_quota_usages',), api.base: ('is_service_enabled',)}) def _test_create_button_disabled_when_quota_exceeded(self, network_enabled): keypairs = self.keypairs.list() floating_ips = self.floating_ips.list() floating_pools = self.pools.list() sec_groups = self.security_groups.list() quota_data = self.quota_usages.first() quota_data['security_groups']['available'] = 0 api.network.floating_ip_supported( IsA(http.HttpRequest)) \ .AndReturn(True) api.network.tenant_floating_ip_list( IsA(http.HttpRequest)) \ .AndReturn(floating_ips) api.network.floating_ip_pools_list( IsA(http.HttpRequest)) \ .AndReturn(floating_pools) api.network.security_group_list( IsA(http.HttpRequest)) \ .AndReturn(sec_groups) api.nova.keypair_list( IsA(http.HttpRequest)) \ .AndReturn(keypairs) api.nova.server_list( IsA(http.HttpRequest)) \ .AndReturn([self.servers.list(), False]) quotas.tenant_quota_usages( IsA(http.HttpRequest)).MultipleTimes() \ .AndReturn(quota_data) api.base.is_service_enabled( IsA(http.HttpRequest), 'network').MultipleTimes() \ .AndReturn(network_enabled) api.base.is_service_enabled( IsA(http.HttpRequest), 'ec2').MultipleTimes() \ .AndReturn(False) self.mox.ReplayAll() res = self.client.get(INDEX_URL + "?tab=access_security_tabs__security_groups_tab") security_groups = res.context['security_groups_table'].data self.assertItemsEqual(security_groups, self.security_groups.list()) create_link = tables.CreateGroup() url = create_link.get_link_url() classes = (list(create_link.get_default_classes()) + list(create_link.classes)) link_name = "%s (%s)" % (unicode(create_link.verbose_name), "Quota exceeded") expected_string = "<a href='%s' title='%s' class='%s disabled' "\ "id='security_groups__action_create'>" \ "<span class='fa fa-plus'></span>%s</a>" \ % (url, link_name, " ".join(classes), link_name) self.assertContains(res, expected_string, html=True, msg_prefix="The create button is not disabled") def test_create_button_disabled_when_quota_exceeded_neutron_disabled(self): self._test_create_button_disabled_when_quota_exceeded(False) def test_create_button_disabled_when_quota_exceeded_neutron_enabled(self): self._test_create_button_disabled_when_quota_exceeded(True)
apache-2.0
[ 3, 1898, 6029, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 1331, 492, 14800, 221, 327, 8151, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 492, 1455, 199, 504, 18610, 19, 14, 6625, 492, 29719, 221, 327, 8151, 199, 199, 504, 21726, 14, 25964, 492, 6858, 199, 504, 13869, 63, 9743, 492, 2986, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 2732, 63, 460, 63, 4416, 971, 272, 492, 2986, 63, 2732, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 2732, 63, 460, 63, 4416, 971, 272, 1275, 4416, 63, 2634, 492, 6716, 199, 504, 13869, 63, 9743, 14, 396, 492, 10897, 465, 511, 199, 504, 13869, 63, 9743, 14, 3807, 492, 22874, 199, 199, 10215, 63, 2632, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 26, 1080, 358, 421, 199, 533, 11003, 3325, 7676, 2925, 8, 396, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 3946, 3325, 7676, 2925, 12, 291, 680, 5996, 342, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 1200, 26, 661, 7774, 63, 711, 63, 4946, 297, 4228, 283, 4647, 63, 7774, 63, 711, 63, 513, 297, 4228, 283, 4416, 63, 923, 63, 513, 5529, 717, 2986, 14, 6765, 26, 661, 19263, 63, 513, 297, 3521, 283, 1000, 63, 513, 5529, 717, 2986, 14, 1095, 26, 661, 374, 63, 1364, 63, 3827, 5529, 717, 22874, 26, 661, 4647, 63, 8848, 63, 21503, 9538, 1552, 272, 347, 485, 396, 63, 1080, 8, 277, 12, 7062, 18, 63, 3827, 304, 267, 790, 7322, 275, 291, 14, 30825, 14, 513, 342, 267, 6513, 63, 2634, 275, 291, 14, 4416, 63, 2634, 14, 513, 342, 267, 8402, 63, 6142, 275, 291, 14, 7774, 63, 6142, 14, 513, 342, 267, 12132, 63, 576, 275, 291, 14, 8848, 63, 21503, 14, 2246, 342, 267, 12132, 63, 576, 459, 4416, 63, 2634, 2545, 4561, 418, 275, 1616, 398, 2986, 14, 6765, 14, 1000, 63, 513, 8, 288, 29719, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 779, 277, 14, 5871, 14, 513, 1062, 756, 566, 267, 2986, 14, 6765, 14, 19263, 63, 513, 8, 288, 29719, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 8, 30825, 9, 267, 2986, 14, 1200, 14, 7774, 63, 711, 63, 4946, 8, 288, 29719, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 8, 549, 9, 267, 2986, 14, 1200, 14, 4647, 63, 7774, 63, 711, 63, 513, 8, 288, 29719, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 8, 7774, 63, 6142, 9, 267, 2986, 14, 1200, 14, 4416, 63, 923, 63, 513, 8, 288, 29719, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 8, 3321, 63, 2634, 9, 267, 22874, 14, 4647, 63, 8848, 63, 21503, 8, 288, 29719, 8, 1014, 14, 10441, 4992, 8433, 17687, 342, 971, 288, 1275, 8572, 8, 8848, 63, 576, 9, 398, 2986, 14, 1095, 14, 374, 63, 1364, 63, 3827, 8, 288, 29719, 8, 1014, 14, 10441, 395, 288, 283, 1200, 1959, 8433, 17687, 342, 971, 288, 1275, 8572, 8, 549, 9, 267, 2986, 14, 1095, 14, 374, 63, 1364, 63, 3827, 8, 288, 29719, 8, 1014, 14, 10441, 395, 288, 283, 825, 18, 1959, 8433, 17687, 342, 971, 288, 1275, 8572, 8, 825, 18, 63, 3827, 9, 398, 291, 14, 6625, 14, 12982, 342, 398, 522, 275, 291, 14, 1258, 14, 362, 8, 10215, 63, 2632, 9, 398, 291, 14, 19661, 8, 470, 12, 283, 1715, 15, 2732, 63, 460, 63, 4416, 15, 1080, 14, 1360, 358, 267, 291, 14, 19673, 8, 470, 14, 1100, 459, 30825, 63, 1224, 2278, 576, 12, 790, 7322, 9, 267, 291, 14, 19673, 8, 470, 14, 1100, 459, 4416, 63, 2634, 63, 1224, 2278, 576, 12, 2892, 6513, 63, 2634, 9, 267, 291, 14, 19673, 8, 470, 14, 1100, 459, 7774, 63, 6142, 63, 1224, 2278, 576, 12, 2892, 8402, 63, 6142, 9, 267, 340, 7062, 18, 63, 3827, 26, 288, 291, 14, 1815, 8, 1629, 8, 1130, 8, 355, 2400, 671, 26, 1228, 8, 88, 12, 2986, 63, 2732, 14, 5987, 14, 11950, 4220, 18, 395, 355, 522, 14, 1100, 459, 14461, 63, 1224, 2278, 362, 63, 1224, 63, 3723, 342, 288, 23183, 267, 587, 26, 288, 291, 14, 3334, 8, 1629, 8, 1130, 8, 355, 2400, 671, 26, 1228, 8, 88, 12, 2986, 63, 2732, 14, 5987, 14, 11950, 4220, 18, 395, 355, 522, 14, 1100, 459, 14461, 63, 1224, 2278, 362, 63, 1224, 63, 3723, 342, 288, 23183, 339, 347, 511, 63, 1080, 8, 277, 304, 267, 291, 423, 396, 63, 1080, 8, 825, 18, 63, 3827, 29, 549, 9, 339, 347, 511, 63, 1080, 63, 1045, 63, 825, 18, 63, 7011, 8, 277, 304, 267, 291, 423, 396, 63, 1080, 8, 825, 18, 63, 3827, 29, 797, 9, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 1200, 26, 661, 7774, 63, 711, 63, 1375, 63, 513, 297, 4228, 283, 4647, 63, 7774, 63, 711, 63, 513, 9538, 1552, 272, 347, 511, 63, 20252, 8, 277, 304, 267, 8037, 275 ]
[ 1898, 6029, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 1331, 492, 14800, 221, 327, 8151, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 492, 1455, 199, 504, 18610, 19, 14, 6625, 492, 29719, 221, 327, 8151, 199, 199, 504, 21726, 14, 25964, 492, 6858, 199, 504, 13869, 63, 9743, 492, 2986, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 2732, 63, 460, 63, 4416, 971, 272, 492, 2986, 63, 2732, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 2732, 63, 460, 63, 4416, 971, 272, 1275, 4416, 63, 2634, 492, 6716, 199, 504, 13869, 63, 9743, 14, 396, 492, 10897, 465, 511, 199, 504, 13869, 63, 9743, 14, 3807, 492, 22874, 199, 199, 10215, 63, 2632, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 26, 1080, 358, 421, 199, 533, 11003, 3325, 7676, 2925, 8, 396, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 3946, 3325, 7676, 2925, 12, 291, 680, 5996, 342, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 1200, 26, 661, 7774, 63, 711, 63, 4946, 297, 4228, 283, 4647, 63, 7774, 63, 711, 63, 513, 297, 4228, 283, 4416, 63, 923, 63, 513, 5529, 717, 2986, 14, 6765, 26, 661, 19263, 63, 513, 297, 3521, 283, 1000, 63, 513, 5529, 717, 2986, 14, 1095, 26, 661, 374, 63, 1364, 63, 3827, 5529, 717, 22874, 26, 661, 4647, 63, 8848, 63, 21503, 9538, 1552, 272, 347, 485, 396, 63, 1080, 8, 277, 12, 7062, 18, 63, 3827, 304, 267, 790, 7322, 275, 291, 14, 30825, 14, 513, 342, 267, 6513, 63, 2634, 275, 291, 14, 4416, 63, 2634, 14, 513, 342, 267, 8402, 63, 6142, 275, 291, 14, 7774, 63, 6142, 14, 513, 342, 267, 12132, 63, 576, 275, 291, 14, 8848, 63, 21503, 14, 2246, 342, 267, 12132, 63, 576, 459, 4416, 63, 2634, 2545, 4561, 418, 275, 1616, 398, 2986, 14, 6765, 14, 1000, 63, 513, 8, 288, 29719, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 779, 277, 14, 5871, 14, 513, 1062, 756, 566, 267, 2986, 14, 6765, 14, 19263, 63, 513, 8, 288, 29719, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 8, 30825, 9, 267, 2986, 14, 1200, 14, 7774, 63, 711, 63, 4946, 8, 288, 29719, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 8, 549, 9, 267, 2986, 14, 1200, 14, 4647, 63, 7774, 63, 711, 63, 513, 8, 288, 29719, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 8, 7774, 63, 6142, 9, 267, 2986, 14, 1200, 14, 4416, 63, 923, 63, 513, 8, 288, 29719, 8, 1014, 14, 10441, 430, 971, 288, 1275, 8572, 8, 3321, 63, 2634, 9, 267, 22874, 14, 4647, 63, 8848, 63, 21503, 8, 288, 29719, 8, 1014, 14, 10441, 4992, 8433, 17687, 342, 971, 288, 1275, 8572, 8, 8848, 63, 576, 9, 398, 2986, 14, 1095, 14, 374, 63, 1364, 63, 3827, 8, 288, 29719, 8, 1014, 14, 10441, 395, 288, 283, 1200, 1959, 8433, 17687, 342, 971, 288, 1275, 8572, 8, 549, 9, 267, 2986, 14, 1095, 14, 374, 63, 1364, 63, 3827, 8, 288, 29719, 8, 1014, 14, 10441, 395, 288, 283, 825, 18, 1959, 8433, 17687, 342, 971, 288, 1275, 8572, 8, 825, 18, 63, 3827, 9, 398, 291, 14, 6625, 14, 12982, 342, 398, 522, 275, 291, 14, 1258, 14, 362, 8, 10215, 63, 2632, 9, 398, 291, 14, 19661, 8, 470, 12, 283, 1715, 15, 2732, 63, 460, 63, 4416, 15, 1080, 14, 1360, 358, 267, 291, 14, 19673, 8, 470, 14, 1100, 459, 30825, 63, 1224, 2278, 576, 12, 790, 7322, 9, 267, 291, 14, 19673, 8, 470, 14, 1100, 459, 4416, 63, 2634, 63, 1224, 2278, 576, 12, 2892, 6513, 63, 2634, 9, 267, 291, 14, 19673, 8, 470, 14, 1100, 459, 7774, 63, 6142, 63, 1224, 2278, 576, 12, 2892, 8402, 63, 6142, 9, 267, 340, 7062, 18, 63, 3827, 26, 288, 291, 14, 1815, 8, 1629, 8, 1130, 8, 355, 2400, 671, 26, 1228, 8, 88, 12, 2986, 63, 2732, 14, 5987, 14, 11950, 4220, 18, 395, 355, 522, 14, 1100, 459, 14461, 63, 1224, 2278, 362, 63, 1224, 63, 3723, 342, 288, 23183, 267, 587, 26, 288, 291, 14, 3334, 8, 1629, 8, 1130, 8, 355, 2400, 671, 26, 1228, 8, 88, 12, 2986, 63, 2732, 14, 5987, 14, 11950, 4220, 18, 395, 355, 522, 14, 1100, 459, 14461, 63, 1224, 2278, 362, 63, 1224, 63, 3723, 342, 288, 23183, 339, 347, 511, 63, 1080, 8, 277, 304, 267, 291, 423, 396, 63, 1080, 8, 825, 18, 63, 3827, 29, 549, 9, 339, 347, 511, 63, 1080, 63, 1045, 63, 825, 18, 63, 7011, 8, 277, 304, 267, 291, 423, 396, 63, 1080, 8, 825, 18, 63, 3827, 29, 797, 9, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 1200, 26, 661, 7774, 63, 711, 63, 1375, 63, 513, 297, 4228, 283, 4647, 63, 7774, 63, 711, 63, 513, 9538, 1552, 272, 347, 511, 63, 20252, 8, 277, 304, 267, 8037, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
treetrnk/Tuxemon
tuxemon/core/components/db.py
2
4617
# -*- coding: utf-8 -*- # # Tuxemon # Copyright (C) 2014, William Edwards <shadowapex@gmail.com>, # Benjamin Bean <superman2k5@gmail.com> # # This file is part of Tuxemon. # # Tuxemon 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. # # Tuxemon 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 Tuxemon. If not, see <http://www.gnu.org/licenses/>. # # Contributor(s): # # William Edwards <shadowapex@gmail.com> # # # core.components.db Database handling module. # # import json import logging import os from operator import itemgetter from core import prepare # Create a logger for optional handling of debug messages. logger = logging.getLogger(__name__) def process_targets(json_targets): """ Return values in order of preference for targeting things. example: ["own monster", "enemy monster"] :param json_targets: :return: """ return list(map(itemgetter(0), filter(itemgetter(1), sorted(json_targets.items(), key=itemgetter(1), reverse=True)))) class JSONDatabase(object): """Handles connecting to the game database for resources such as monsters, stats, etc. """ def __init__(self): self.path = prepare.BASEDIR + "resources/db/" self.database = {"item": {}, "monster": {}, "npc": {}, "technique": {}, "encounter": {}} def load(self, directory="all"): """Loads all data from JSON files located under our data path. :param directory: The directory under resources/db/ to load. Defaults to "all". :type directory: String :returns: None """ if directory == "all": self.load_json("item") self.load_json("monster") self.load_json("technique") self.load_json("npc") self.load_json("encounter") else: self.load_json(directory) def load_json(self, directory): """Loads all JSON items under a specified path. :param directory: The directory under resources/db/ to look in. :type directory: String :returns: None """ for json_item in os.listdir(self.path + directory): # Only load .json files. if not json_item.endswith(".json"): continue # Load our json as a dictionary. with open(self.path + directory + "/" + json_item) as fp: item = json.load(fp) if item['slug'] not in self.database[directory]: self.database[directory][item['slug']] = item else: logger.error(item, json) raise Exception("Error: Item with this slug was already loaded.") def lookup(self, slug, table="monster"): """Looks up a monster, technique, item, or npc based on slug. :param slug: The slug of the monster, technique, item, or npc. A short English identifier. :param table: Which index to do the search in. Can be: "monster", "item", "npc", or "technique". :type slug: String :type table: String :rtype: Dict :returns: A dictionary from the resulting lookup. """ return self.database[table][slug] def lookup_sprite(self, slug, table="sprite"): """Looks up a monster's sprite image paths based on monster slug. NOTE: This method has been deprecated. Use the following instead: JSONDatabase.database['monster'][slug]['sprites'] :param slug: The monster ID to look up. :type slug: String :param slug: The monster slug to look up. :type slug: String :rtype: List :returns: A list of sprites """ logger.warning("lookup_sprite is deprecated. Use JSONDatabase.database") results = {'sprite_battle1': self.database['monster'][slug]['sprites']['battle1'], 'sprite_battle2': self.database['monster'][slug]['sprites']['battle2'], 'sprite_menu1': self.database['monster'][slug]['sprites']['menu1']} return results
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 377, 85, 1845, 2106, 199, 3, 1898, 334, 35, 9, 6927, 12, 644, 8148, 455, 17379, 4751, 665, 14714, 924, 88, 32, 6799, 14, 957, 6244, 199, 3, 9326, 26844, 16997, 262, 6423, 290, 665, 4792, 1237, 18, 75, 21, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 377, 85, 1845, 2106, 14, 199, 3, 199, 3, 377, 85, 1845, 2106, 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, 377, 85, 1845, 2106, 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, 377, 85, 1845, 2106, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 199, 3, 644, 8148, 455, 17379, 4751, 665, 14714, 924, 88, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 199, 3, 6170, 14, 4608, 14, 697, 8692, 7252, 859, 14, 199, 3, 199, 3, 199, 199, 646, 2022, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 4182, 492, 1242, 7416, 199, 199, 504, 6170, 492, 9275, 199, 199, 3, 2790, 282, 2512, 367, 2716, 7252, 402, 3105, 3788, 14, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 2112, 63, 4684, 8, 1001, 63, 4684, 304, 272, 408, 1432, 1338, 315, 1865, 402, 16705, 367, 1347, 316, 7645, 14, 339, 2893, 26, 2097, 944, 3485, 11652, 401, 298, 6349, 1662, 3485, 11652, 937, 339, 520, 635, 2022, 63, 4684, 26, 272, 520, 1107, 26, 272, 408, 339, 372, 769, 8, 1130, 8, 20832, 8, 16, 395, 2457, 8, 20832, 8, 17, 395, 3355, 8, 1001, 63, 4684, 14, 1744, 1062, 790, 29, 20832, 8, 17, 395, 3837, 29, 549, 7845, 421, 199, 533, 4840, 7243, 8, 785, 304, 272, 408, 23555, 18170, 370, 314, 9219, 3050, 367, 5944, 4066, 465, 3485, 83, 878, 12, 272, 5020, 12, 5423, 14, 339, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 515, 275, 9275, 14, 5825, 3022, 435, 298, 4435, 15, 697, 6687, 267, 291, 14, 4659, 275, 2420, 1053, 582, 5479, 586, 298, 2106, 11652, 582, 5479, 586, 298, 1590, 67, 582, 5479, 586, 298, 266, 11019, 2029, 582, 5479, 586, 298, 287, 5337, 582, 24312, 2378, 347, 2248, 8, 277, 12, 2082, 628, 452, 2349, 267, 408, 30777, 1006, 666, 687, 4840, 1584, 16180, 1334, 4154, 666, 931, 14, 398, 520, 635, 2082, 26, 710, 2082, 1334, 5944, 15, 697, 15, 370, 2248, 14, 7827, 288, 370, 298, 452, 1674, 267, 520, 466, 2082, 26, 2624, 398, 520, 5808, 26, 488, 398, 408, 398, 340, 2082, 508, 298, 452, 582, 288, 291, 14, 912, 63, 1001, 480, 1053, 531, 288, 291, 14, 912, 63, 1001, 480, 2106, 11652, 531, 288, 291, 14, 912, 63, 1001, 480, 266, 11019, 2029, 531, 288, 291, 14, 912, 63, 1001, 480, 1590, 67, 531, 288, 291, 14, 912, 63, 1001, 480, 287, 5337, 531, 267, 587, 26, 288, 291, 14, 912, 63, 1001, 8, 3619, 9, 2378, 347, 2248, 63, 1001, 8, 277, 12, 2082, 304, 267, 408, 30777, 1006, 4840, 2974, 1334, 282, 2013, 931, 14, 398, 520, 635, 2082, 26, 710, 2082, 1334, 5944, 15, 697, 15, 370, 3648, 315, 14, 267, 520, 466, 2082, 26, 2624, 398, 520, 5808, 26, 488, 398, 408, 398, 367, 2022, 63, 1053, 315, 747, 14, 7374, 8, 277, 14, 515, 435, 2082, 304, 953, 327, 5972, 2248, 1275, 1001, 1584, 14, 288, 340, 440, 2022, 63, 1053, 14, 4130, 9520, 1001, 2349, 355, 1980, 953, 327, 7190, 4154, 2022, 465, 282, 2600, 14, 288, 543, 1551, 8, 277, 14, 515, 435, 2082, 435, 10609, 435, 2022, 63, 1053, 9, 465, 4090, 26, 355, 1242, 275, 2022, 14, 912, 8, 3997, 9, 953, 340, 1242, 459, 5464, 418, 440, 315, 291, 14, 4659, 59, 3619, 2189, 355, 291, 14, 4659, 59, 3619, 1527, 1053, 459, 5464, 6538, 275, 1242, 288, 587, 26, 355, 2512, 14, 705, 8, 1053, 12, 2022, 9, 355, 746, 2186, 480, 547, 26, 7020, 543, 642, 8889, 1990, 2575, 6511, 2685, 2378, 347, 4237, 8, 277, 12, 8889, 12, 1817, 628, 2106, 11652, 2349, 267, 408, 20926, 83, 1536, 282, 3485, 11652, 12, 32414, 12, 1242, 12, 503, 980, 67, 4079, 641, 8889, 14, 398, 520, 635, 8889, 26, 710, 8889, 402, 314, 3485, 11652, 12, 32414, 12, 1242, 12, 503, 980, 67, 14, 221, 437, 3974, 20144, 5148, 14, 267, 520, 635, 1817, 26, 26058, 1478, 370, 886, 314, 2754, 315, 14, 6855, 506, 26, 298, 2106, 11652, 401, 288, 298, 1053, 401, 298, 1590, 67, 401, 503, 298, 266, 11019, 2029, 1674, 267, 520, 466, 8889, 26, 2624, 267, 520, 466, 1817, 26, 2624, 398, 520, 4500, 26, 7448, 267, 520, 5808, 26, 437, 2600, 687, 314, 9183, 4237, 14, 398, 408, 267, 372, 291, 14, 4659, 59, 1224, 1527, 5464, 61, 2378, 347, 4237, 63, 15972, 8, 277, 12, 8889, 12, 1817, 628, 15972, 2349, 267, 408, 20926, 83, 1536, 282, 3485, 11652, 1159, 17325, 1834, 3792, 4079, 641, 3485, 11652, 8889, 14, 267, 6944, 26, 961, 1083, 965, 2757, 5906, 14, 3645, 314, 2569, 3140, 26, 267, 4840, 7243, 14, 4659, 459, 2106, 11652, 3488, 5464, 2733, 27495, 418, 398, 520, 635, 8889, 26, 710, 3485, 11652, 2870, 370, 3648, 1536, 14, 267, 520, 466, 8889, 26, 2624, 267, 520, 635, 8889, 26, 710, 3485, 11652, 8889, 370, 3648, 1536, 14, 267, 520, 466, 8889, 26, 2624 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 377, 85, 1845, 2106, 199, 3, 1898, 334, 35, 9, 6927, 12, 644, 8148, 455, 17379, 4751, 665, 14714, 924, 88, 32, 6799, 14, 957, 6244, 199, 3, 9326, 26844, 16997, 262, 6423, 290, 665, 4792, 1237, 18, 75, 21, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 377, 85, 1845, 2106, 14, 199, 3, 199, 3, 377, 85, 1845, 2106, 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, 377, 85, 1845, 2106, 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, 377, 85, 1845, 2106, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3, 17636, 8, 83, 304, 199, 3, 199, 3, 644, 8148, 455, 17379, 4751, 665, 14714, 924, 88, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 199, 3, 6170, 14, 4608, 14, 697, 8692, 7252, 859, 14, 199, 3, 199, 3, 199, 199, 646, 2022, 199, 646, 2050, 199, 646, 747, 199, 199, 504, 4182, 492, 1242, 7416, 199, 199, 504, 6170, 492, 9275, 199, 199, 3, 2790, 282, 2512, 367, 2716, 7252, 402, 3105, 3788, 14, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 2112, 63, 4684, 8, 1001, 63, 4684, 304, 272, 408, 1432, 1338, 315, 1865, 402, 16705, 367, 1347, 316, 7645, 14, 339, 2893, 26, 2097, 944, 3485, 11652, 401, 298, 6349, 1662, 3485, 11652, 937, 339, 520, 635, 2022, 63, 4684, 26, 272, 520, 1107, 26, 272, 408, 339, 372, 769, 8, 1130, 8, 20832, 8, 16, 395, 2457, 8, 20832, 8, 17, 395, 3355, 8, 1001, 63, 4684, 14, 1744, 1062, 790, 29, 20832, 8, 17, 395, 3837, 29, 549, 7845, 421, 199, 533, 4840, 7243, 8, 785, 304, 272, 408, 23555, 18170, 370, 314, 9219, 3050, 367, 5944, 4066, 465, 3485, 83, 878, 12, 272, 5020, 12, 5423, 14, 339, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 515, 275, 9275, 14, 5825, 3022, 435, 298, 4435, 15, 697, 6687, 267, 291, 14, 4659, 275, 2420, 1053, 582, 5479, 586, 298, 2106, 11652, 582, 5479, 586, 298, 1590, 67, 582, 5479, 586, 298, 266, 11019, 2029, 582, 5479, 586, 298, 287, 5337, 582, 24312, 2378, 347, 2248, 8, 277, 12, 2082, 628, 452, 2349, 267, 408, 30777, 1006, 666, 687, 4840, 1584, 16180, 1334, 4154, 666, 931, 14, 398, 520, 635, 2082, 26, 710, 2082, 1334, 5944, 15, 697, 15, 370, 2248, 14, 7827, 288, 370, 298, 452, 1674, 267, 520, 466, 2082, 26, 2624, 398, 520, 5808, 26, 488, 398, 408, 398, 340, 2082, 508, 298, 452, 582, 288, 291, 14, 912, 63, 1001, 480, 1053, 531, 288, 291, 14, 912, 63, 1001, 480, 2106, 11652, 531, 288, 291, 14, 912, 63, 1001, 480, 266, 11019, 2029, 531, 288, 291, 14, 912, 63, 1001, 480, 1590, 67, 531, 288, 291, 14, 912, 63, 1001, 480, 287, 5337, 531, 267, 587, 26, 288, 291, 14, 912, 63, 1001, 8, 3619, 9, 2378, 347, 2248, 63, 1001, 8, 277, 12, 2082, 304, 267, 408, 30777, 1006, 4840, 2974, 1334, 282, 2013, 931, 14, 398, 520, 635, 2082, 26, 710, 2082, 1334, 5944, 15, 697, 15, 370, 3648, 315, 14, 267, 520, 466, 2082, 26, 2624, 398, 520, 5808, 26, 488, 398, 408, 398, 367, 2022, 63, 1053, 315, 747, 14, 7374, 8, 277, 14, 515, 435, 2082, 304, 953, 327, 5972, 2248, 1275, 1001, 1584, 14, 288, 340, 440, 2022, 63, 1053, 14, 4130, 9520, 1001, 2349, 355, 1980, 953, 327, 7190, 4154, 2022, 465, 282, 2600, 14, 288, 543, 1551, 8, 277, 14, 515, 435, 2082, 435, 10609, 435, 2022, 63, 1053, 9, 465, 4090, 26, 355, 1242, 275, 2022, 14, 912, 8, 3997, 9, 953, 340, 1242, 459, 5464, 418, 440, 315, 291, 14, 4659, 59, 3619, 2189, 355, 291, 14, 4659, 59, 3619, 1527, 1053, 459, 5464, 6538, 275, 1242, 288, 587, 26, 355, 2512, 14, 705, 8, 1053, 12, 2022, 9, 355, 746, 2186, 480, 547, 26, 7020, 543, 642, 8889, 1990, 2575, 6511, 2685, 2378, 347, 4237, 8, 277, 12, 8889, 12, 1817, 628, 2106, 11652, 2349, 267, 408, 20926, 83, 1536, 282, 3485, 11652, 12, 32414, 12, 1242, 12, 503, 980, 67, 4079, 641, 8889, 14, 398, 520, 635, 8889, 26, 710, 8889, 402, 314, 3485, 11652, 12, 32414, 12, 1242, 12, 503, 980, 67, 14, 221, 437, 3974, 20144, 5148, 14, 267, 520, 635, 1817, 26, 26058, 1478, 370, 886, 314, 2754, 315, 14, 6855, 506, 26, 298, 2106, 11652, 401, 288, 298, 1053, 401, 298, 1590, 67, 401, 503, 298, 266, 11019, 2029, 1674, 267, 520, 466, 8889, 26, 2624, 267, 520, 466, 1817, 26, 2624, 398, 520, 4500, 26, 7448, 267, 520, 5808, 26, 437, 2600, 687, 314, 9183, 4237, 14, 398, 408, 267, 372, 291, 14, 4659, 59, 1224, 1527, 5464, 61, 2378, 347, 4237, 63, 15972, 8, 277, 12, 8889, 12, 1817, 628, 15972, 2349, 267, 408, 20926, 83, 1536, 282, 3485, 11652, 1159, 17325, 1834, 3792, 4079, 641, 3485, 11652, 8889, 14, 267, 6944, 26, 961, 1083, 965, 2757, 5906, 14, 3645, 314, 2569, 3140, 26, 267, 4840, 7243, 14, 4659, 459, 2106, 11652, 3488, 5464, 2733, 27495, 418, 398, 520, 635, 8889, 26, 710, 3485, 11652, 2870, 370, 3648, 1536, 14, 267, 520, 466, 8889, 26, 2624, 267, 520, 635, 8889, 26, 710, 3485, 11652, 8889, 370, 3648, 1536, 14, 267, 520, 466, 8889, 26, 2624, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
neerajvashistha/pa-dude
lib/python2.7/site-packages/django/contrib/gis/geos/geometry.py
216
23649
""" This module contains the 'base' GEOSGeometry object -- all GEOS Geometries inherit from this object. """ from __future__ import unicode_literals import json from ctypes import addressof, byref, c_double from django.contrib.gis import gdal from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.coordseq import GEOSCoordSeq from django.contrib.gis.geos.error import GEOSException from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.mutable_list import ListMixin from django.contrib.gis.geos.prepared import PreparedGeometry from django.contrib.gis.geos.prototypes.io import ( ewkb_w, wkb_r, wkb_w, wkt_r, wkt_w, ) from django.utils import six from django.utils.encoding import force_bytes, force_text class GEOSGeometry(GEOSBase, ListMixin): "A class that, generally, encapsulates a GEOS geometry." _GEOS_CLASSES = None ptr_type = GEOM_PTR has_cs = False # Only Point, LineString, LinearRing have coordinate sequences def __init__(self, geo_input, srid=None): """ The base constructor for GEOS geometry objects, and may take the following inputs: * strings: - WKT - HEXEWKB (a PostGIS-specific canonical form) - GeoJSON (requires GDAL) * buffer: - WKB The `srid` keyword is used to specify the Source Reference Identifier (SRID) number for this Geometry. If not set, the SRID will be None. """ if isinstance(geo_input, bytes): geo_input = force_text(geo_input) if isinstance(geo_input, six.string_types): wkt_m = wkt_regex.match(geo_input) if wkt_m: # Handling WKT input. if wkt_m.group('srid'): srid = int(wkt_m.group('srid')) g = wkt_r().read(force_bytes(wkt_m.group('wkt'))) elif hex_regex.match(geo_input): # Handling HEXEWKB input. g = wkb_r().read(force_bytes(geo_input)) elif json_regex.match(geo_input): # Handling GeoJSON input. if not gdal.HAS_GDAL: raise ValueError('Initializing geometry from JSON input requires GDAL.') g = wkb_r().read(gdal.OGRGeometry(geo_input).wkb) else: raise ValueError('String or unicode input unrecognized as WKT EWKT, and HEXEWKB.') elif isinstance(geo_input, GEOM_PTR): # When the input is a pointer to a geometry (GEOM_PTR). g = geo_input elif isinstance(geo_input, six.memoryview): # When the input is a buffer (WKB). g = wkb_r().read(geo_input) elif isinstance(geo_input, GEOSGeometry): g = capi.geom_clone(geo_input.ptr) else: # Invalid geometry type. raise TypeError('Improper geometry input type: %s' % str(type(geo_input))) if g: # Setting the pointer object with a valid pointer. self.ptr = g else: raise GEOSException('Could not initialize GEOS Geometry with given input.') # Post-initialization setup. self._post_init(srid) def _post_init(self, srid): "Helper routine for performing post-initialization setup." # Setting the SRID, if given. if srid and isinstance(srid, int): self.srid = srid # Setting the class type (e.g., Point, Polygon, etc.) if GEOSGeometry._GEOS_CLASSES is None: # Lazy-loaded variable to avoid import conflicts with GEOSGeometry. from .linestring import LineString, LinearRing from .point import Point from .polygon import Polygon from .collections import ( GeometryCollection, MultiPoint, MultiLineString, MultiPolygon) GEOSGeometry._GEOS_CLASSES = { 0: Point, 1: LineString, 2: LinearRing, 3: Polygon, 4: MultiPoint, 5: MultiLineString, 6: MultiPolygon, 7: GeometryCollection, } self.__class__ = GEOSGeometry._GEOS_CLASSES[self.geom_typeid] # Setting the coordinate sequence for the geometry (will be None on # geometries that do not have coordinate sequences) self._set_cs() def __del__(self): """ Destroys this Geometry; in other words, frees the memory used by the GEOS C++ object. """ if self._ptr and capi: capi.destroy_geom(self._ptr) def __copy__(self): """ Returns a clone because the copy of a GEOSGeometry may contain an invalid pointer location if the original is garbage collected. """ return self.clone() def __deepcopy__(self, memodict): """ The `deepcopy` routine is used by the `Node` class of django.utils.tree; thus, the protocol routine needs to be implemented to return correct copies (clones) of these GEOS objects, which use C pointers. """ return self.clone() def __str__(self): "EWKT is used for the string representation." return self.ewkt def __repr__(self): "Short-hand representation because WKT may be very large." return '<%s object at %s>' % (self.geom_type, hex(addressof(self.ptr))) # Pickling support def __getstate__(self): # The pickled state is simply a tuple of the WKB (in string form) # and the SRID. return bytes(self.wkb), self.srid def __setstate__(self, state): # Instantiating from the tuple state that was pickled. wkb, srid = state ptr = wkb_r().read(six.memoryview(wkb)) if not ptr: raise GEOSException('Invalid Geometry loaded from pickled state.') self.ptr = ptr self._post_init(srid) # Comparison operators def __eq__(self, other): """ Equivalence testing, a Geometry may be compared with another Geometry or a WKT representation. """ if isinstance(other, six.string_types): return self.wkt == other elif isinstance(other, GEOSGeometry): return self.equals_exact(other) else: return False def __ne__(self, other): "The not equals operator." return not (self == other) # ### Geometry set-like operations ### # Thanks to Sean Gillies for inspiration: # http://lists.gispython.org/pipermail/community/2007-July/001034.html # g = g1 | g2 def __or__(self, other): "Returns the union of this Geometry and the other." return self.union(other) # g = g1 & g2 def __and__(self, other): "Returns the intersection of this Geometry and the other." return self.intersection(other) # g = g1 - g2 def __sub__(self, other): "Return the difference this Geometry and the other." return self.difference(other) # g = g1 ^ g2 def __xor__(self, other): "Return the symmetric difference of this Geometry and the other." return self.sym_difference(other) # #### Coordinate Sequence Routines #### def _set_cs(self): "Sets the coordinate sequence for this Geometry." if self.has_cs: self._cs = GEOSCoordSeq(capi.get_cs(self.ptr), self.hasz) else: self._cs = None @property def coord_seq(self): "Returns a clone of the coordinate sequence for this Geometry." if self.has_cs: return self._cs.clone() # #### Geometry Info #### @property def geom_type(self): "Returns a string representing the Geometry type, e.g. 'Polygon'" return capi.geos_type(self.ptr).decode() @property def geom_typeid(self): "Returns an integer representing the Geometry type." return capi.geos_typeid(self.ptr) @property def num_geom(self): "Returns the number of geometries in the Geometry." return capi.get_num_geoms(self.ptr) @property def num_coords(self): "Returns the number of coordinates in the Geometry." return capi.get_num_coords(self.ptr) @property def num_points(self): "Returns the number points, or coordinates, in the Geometry." return self.num_coords @property def dims(self): "Returns the dimension of this Geometry (0=point, 1=line, 2=surface)." return capi.get_dims(self.ptr) def normalize(self): "Converts this Geometry to normal form (or canonical form)." return capi.geos_normalize(self.ptr) # #### Unary predicates #### @property def empty(self): """ Returns a boolean indicating whether the set of points in this Geometry are empty. """ return capi.geos_isempty(self.ptr) @property def hasz(self): "Returns whether the geometry has a 3D dimension." return capi.geos_hasz(self.ptr) @property def ring(self): "Returns whether or not the geometry is a ring." return capi.geos_isring(self.ptr) @property def simple(self): "Returns false if the Geometry not simple." return capi.geos_issimple(self.ptr) @property def valid(self): "This property tests the validity of this Geometry." return capi.geos_isvalid(self.ptr) @property def valid_reason(self): """ Returns a string containing the reason for any invalidity. """ return capi.geos_isvalidreason(self.ptr).decode() # #### Binary predicates. #### def contains(self, other): "Returns true if other.within(this) returns true." return capi.geos_contains(self.ptr, other.ptr) def crosses(self, other): """ Returns true if the DE-9IM intersection matrix for the two Geometries is T*T****** (for a point and a curve,a point and an area or a line and an area) 0******** (for two curves). """ return capi.geos_crosses(self.ptr, other.ptr) def disjoint(self, other): """ Returns true if the DE-9IM intersection matrix for the two Geometries is FF*FF****. """ return capi.geos_disjoint(self.ptr, other.ptr) def equals(self, other): """ Returns true if the DE-9IM intersection matrix for the two Geometries is T*F**FFF*. """ return capi.geos_equals(self.ptr, other.ptr) def equals_exact(self, other, tolerance=0): """ Returns true if the two Geometries are exactly equal, up to a specified tolerance. """ return capi.geos_equalsexact(self.ptr, other.ptr, float(tolerance)) def intersects(self, other): "Returns true if disjoint returns false." return capi.geos_intersects(self.ptr, other.ptr) def overlaps(self, other): """ Returns true if the DE-9IM intersection matrix for the two Geometries is T*T***T** (for two points or two surfaces) 1*T***T** (for two curves). """ return capi.geos_overlaps(self.ptr, other.ptr) def relate_pattern(self, other, pattern): """ Returns true if the elements in the DE-9IM intersection matrix for the two Geometries match the elements in pattern. """ if not isinstance(pattern, six.string_types) or len(pattern) > 9: raise GEOSException('invalid intersection matrix pattern') return capi.geos_relatepattern(self.ptr, other.ptr, force_bytes(pattern)) def touches(self, other): """ Returns true if the DE-9IM intersection matrix for the two Geometries is FT*******, F**T***** or F***T****. """ return capi.geos_touches(self.ptr, other.ptr) def within(self, other): """ Returns true if the DE-9IM intersection matrix for the two Geometries is T*F**F***. """ return capi.geos_within(self.ptr, other.ptr) # #### SRID Routines #### def get_srid(self): "Gets the SRID for the geometry, returns None if no SRID is set." s = capi.geos_get_srid(self.ptr) if s == 0: return None else: return s def set_srid(self, srid): "Sets the SRID for the geometry." capi.geos_set_srid(self.ptr, srid) srid = property(get_srid, set_srid) # #### Output Routines #### @property def ewkt(self): """ Returns the EWKT (SRID + WKT) of the Geometry. Note that Z values are only included in this representation if GEOS >= 3.3.0. """ if self.get_srid(): return 'SRID=%s;%s' % (self.srid, self.wkt) else: return self.wkt @property def wkt(self): "Returns the WKT (Well-Known Text) representation of this Geometry." return wkt_w(3 if self.hasz else 2).write(self).decode() @property def hex(self): """ Returns the WKB of this Geometry in hexadecimal form. Please note that the SRID is not included in this representation because it is not a part of the OGC specification (use the `hexewkb` property instead). """ # A possible faster, all-python, implementation: # str(self.wkb).encode('hex') return wkb_w(3 if self.hasz else 2).write_hex(self) @property def hexewkb(self): """ Returns the EWKB of this Geometry in hexadecimal form. This is an extension of the WKB specification that includes SRID value that are a part of this geometry. """ return ewkb_w(3 if self.hasz else 2).write_hex(self) @property def json(self): """ Returns GeoJSON representation of this Geometry. """ return json.dumps({'type': self.__class__.__name__, 'coordinates': self.coords}) geojson = json @property def wkb(self): """ Returns the WKB (Well-Known Binary) representation of this Geometry as a Python buffer. SRID and Z values are not included, use the `ewkb` property instead. """ return wkb_w(3 if self.hasz else 2).write(self) @property def ewkb(self): """ Return the EWKB representation of this Geometry as a Python buffer. This is an extension of the WKB specification that includes any SRID value that are a part of this geometry. """ return ewkb_w(3 if self.hasz else 2).write(self) @property def kml(self): "Returns the KML representation of this Geometry." gtype = self.geom_type return '<%s>%s</%s>' % (gtype, self.coord_seq.kml, gtype) @property def prepared(self): """ Returns a PreparedGeometry corresponding to this geometry -- it is optimized for the contains, intersects, and covers operations. """ return PreparedGeometry(self) # #### GDAL-specific output routines #### @property def ogr(self): "Returns the OGR Geometry for this Geometry." if not gdal.HAS_GDAL: raise GEOSException('GDAL required to convert to an OGRGeometry.') if self.srid: try: return gdal.OGRGeometry(self.wkb, self.srid) except gdal.SRSException: pass return gdal.OGRGeometry(self.wkb) @property def srs(self): "Returns the OSR SpatialReference for SRID of this Geometry." if not gdal.HAS_GDAL: raise GEOSException('GDAL required to return a SpatialReference object.') if self.srid: try: return gdal.SpatialReference(self.srid) except gdal.SRSException: pass return None @property def crs(self): "Alias for `srs` property." return self.srs def transform(self, ct, clone=False): """ Requires GDAL. Transforms the geometry according to the given transformation object, which may be an integer SRID, and WKT or PROJ.4 string. By default, the geometry is transformed in-place and nothing is returned. However if the `clone` keyword is set, then this geometry will not be modified and a transformed clone will be returned instead. """ srid = self.srid if ct == srid: # short-circuit where source & dest SRIDs match if clone: return self.clone() else: return if (srid is None) or (srid < 0): raise GEOSException("Calling transform() with no SRID set is not supported") if not gdal.HAS_GDAL: raise GEOSException("GDAL library is not available to transform() geometry.") # Creating an OGR Geometry, which is then transformed. g = self.ogr g.transform(ct) # Getting a new GEOS pointer ptr = wkb_r().read(g.wkb) if clone: # User wants a cloned transformed geometry returned. return GEOSGeometry(ptr, srid=g.srid) if ptr: # Reassigning pointer, and performing post-initialization setup # again due to the reassignment. capi.destroy_geom(self.ptr) self.ptr = ptr self._post_init(g.srid) else: raise GEOSException('Transformed WKB was invalid.') # #### Topology Routines #### def _topology(self, gptr): "Helper routine to return Geometry from the given pointer." return GEOSGeometry(gptr, srid=self.srid) @property def boundary(self): "Returns the boundary as a newly allocated Geometry object." return self._topology(capi.geos_boundary(self.ptr)) def buffer(self, width, quadsegs=8): """ Returns a geometry that represents all points whose distance from this Geometry is less than or equal to distance. Calculations are in the Spatial Reference System of this Geometry. The optional third parameter sets the number of segment used to approximate a quarter circle (defaults to 8). (Text from PostGIS documentation at ch. 6.1.3) """ return self._topology(capi.geos_buffer(self.ptr, width, quadsegs)) @property def centroid(self): """ The centroid is equal to the centroid of the set of component Geometries of highest dimension (since the lower-dimension geometries contribute zero "weight" to the centroid). """ return self._topology(capi.geos_centroid(self.ptr)) @property def convex_hull(self): """ Returns the smallest convex Polygon that contains all the points in the Geometry. """ return self._topology(capi.geos_convexhull(self.ptr)) def difference(self, other): """ Returns a Geometry representing the points making up this Geometry that do not make up other. """ return self._topology(capi.geos_difference(self.ptr, other.ptr)) @property def envelope(self): "Return the envelope for this geometry (a polygon)." return self._topology(capi.geos_envelope(self.ptr)) def intersection(self, other): "Returns a Geometry representing the points shared by this Geometry and other." return self._topology(capi.geos_intersection(self.ptr, other.ptr)) @property def point_on_surface(self): "Computes an interior point of this Geometry." return self._topology(capi.geos_pointonsurface(self.ptr)) def relate(self, other): "Returns the DE-9IM intersection matrix for this Geometry and the other." return capi.geos_relate(self.ptr, other.ptr).decode() def simplify(self, tolerance=0.0, preserve_topology=False): """ Returns the Geometry, simplified using the Douglas-Peucker algorithm to the specified tolerance (higher tolerance => less points). If no tolerance provided, defaults to 0. By default, this function does not preserve topology - e.g. polygons can be split, collapse to lines or disappear holes can be created or disappear, and lines can cross. By specifying preserve_topology=True, the result will have the same dimension and number of components as the input. This is significantly slower. """ if preserve_topology: return self._topology(capi.geos_preservesimplify(self.ptr, tolerance)) else: return self._topology(capi.geos_simplify(self.ptr, tolerance)) def sym_difference(self, other): """ Returns a set combining the points in this Geometry not in other, and the points in other not in this Geometry. """ return self._topology(capi.geos_symdifference(self.ptr, other.ptr)) def union(self, other): "Returns a Geometry representing all the points in this Geometry and other." return self._topology(capi.geos_union(self.ptr, other.ptr)) # #### Other Routines #### @property def area(self): "Returns the area of the Geometry." return capi.geos_area(self.ptr, byref(c_double())) def distance(self, other): """ Returns the distance between the closest points on this Geometry and the other. Units will be in those of the coordinate system of the Geometry. """ if not isinstance(other, GEOSGeometry): raise TypeError('distance() works only on other GEOS Geometries.') return capi.geos_distance(self.ptr, other.ptr, byref(c_double())) @property def extent(self): """ Returns the extent of this geometry as a 4-tuple, consisting of (xmin, ymin, xmax, ymax). """ from .point import Point env = self.envelope if isinstance(env, Point): xmin, ymin = env.tuple xmax, ymax = xmin, ymin else: xmin, ymin = env[0][0] xmax, ymax = env[0][2] return (xmin, ymin, xmax, ymax) @property def length(self): """ Returns the length of this Geometry (e.g., 0 for point, or the circumference of a Polygon). """ return capi.geos_length(self.ptr, byref(c_double())) def clone(self): "Clones this Geometry." return GEOSGeometry(capi.geom_clone(self.ptr), srid=self.srid) class ProjectInterpolateMixin(object): """ Used for LineString and MultiLineString. """ def interpolate(self, distance): return self._topology(capi.geos_interpolate(self.ptr, distance)) def interpolate_normalized(self, distance): return self._topology(capi.geos_interpolate_normalized(self.ptr, distance)) def project(self, point): from .point import Point if not isinstance(point, Point): raise TypeError('locate_point argument must be a Point') return capi.geos_project(self.ptr, point.ptr) def project_normalized(self, point): from .point import Point if not isinstance(point, Point): raise TypeError('locate_point argument must be a Point') return capi.geos_project_normalized(self.ptr, point.ptr)
mit
[ 624, 199, 961, 859, 3509, 314, 283, 1095, 7, 21479, 909, 1553, 1006, 11920, 5346, 14100, 199, 8287, 687, 642, 909, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2022, 199, 504, 5577, 492, 2287, 1618, 12, 15968, 12, 286, 63, 3157, 199, 199, 504, 1639, 14, 2828, 14, 5668, 492, 15834, 199, 504, 1639, 14, 2828, 14, 5668, 14, 7660, 14, 3821, 492, 6318, 63, 3821, 12, 2022, 63, 3821, 12, 21992, 63, 3821, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 19393, 83, 465, 13648, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 1095, 492, 11920, 1563, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 7988, 3610, 492, 11920, 14957, 11205, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 705, 492, 21390, 21686, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 773, 12151, 492, 8991, 7474, 63, 14528, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 17404, 63, 513, 492, 3820, 4256, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 19260, 492, 5543, 9508, 6831, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 2308, 492, 334, 272, 325, 18914, 63, 87, 12, 24249, 63, 82, 12, 24249, 63, 87, 12, 21992, 63, 82, 12, 21992, 63, 87, 12, 199, 9, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 3542, 63, 505, 421, 199, 533, 21479, 8, 14151, 1563, 12, 3820, 4256, 304, 272, 298, 33, 1021, 626, 12, 16711, 12, 22667, 15409, 282, 11920, 3400, 2122, 339, 485, 14151, 63, 13748, 275, 488, 339, 12448, 63, 466, 275, 8991, 7474, 63, 14528, 272, 965, 63, 1259, 275, 756, 221, 327, 5972, 7584, 12, 30020, 12, 12489, 15420, 1172, 10021, 8013, 339, 347, 636, 826, 721, 277, 12, 8509, 63, 1210, 12, 15627, 29, 403, 304, 267, 408, 267, 710, 1300, 3787, 367, 11920, 3400, 2251, 12, 436, 1443, 5452, 314, 267, 2569, 4153, 26, 13359, 627, 3326, 26, 288, 446, 22561, 288, 446, 869, 23017, 28328, 334, 65, 20929, 13, 6100, 11358, 1824, 9, 288, 446, 8875, 6243, 334, 6537, 15801, 9, 268, 627, 3335, 26, 288, 446, 644, 12780, 398, 710, 658, 10498, 64, 4252, 365, 1202, 370, 4165, 314, 5800, 10944, 23285, 267, 334, 5943, 998, 9, 1329, 367, 642, 10579, 14, 221, 982, 440, 663, 12, 314, 22425, 911, 506, 488, 14, 267, 408, 267, 340, 1228, 8, 6721, 63, 1210, 12, 2783, 304, 288, 8509, 63, 1210, 275, 3542, 63, 505, 8, 6721, 63, 1210, 9, 267, 340, 1228, 8, 6721, 63, 1210, 12, 3816, 14, 875, 63, 1313, 304, 288, 21992, 63, 77, 275, 21992, 63, 3821, 14, 1431, 8, 6721, 63, 1210, 9, 288, 340, 21992, 63, 77, 26, 355, 327, 18405, 2983, 22561, 1324, 14, 355, 340, 21992, 63, 77, 14, 923, 360, 10498, 735, 490, 15627, 275, 1109, 8, 11412, 63, 77, 14, 923, 360, 10498, 1333, 355, 486, 275, 21992, 63, 82, 1252, 739, 8, 3990, 63, 2394, 8, 11412, 63, 77, 14, 923, 360, 11412, 7058, 288, 916, 6318, 63, 3821, 14, 1431, 8, 6721, 63, 1210, 304, 355, 327, 18405, 2983, 869, 23017, 28328, 1324, 14, 355, 486, 275, 24249, 63, 82, 1252, 739, 8, 3990, 63, 2394, 8, 6721, 63, 1210, 430, 288, 916, 2022, 63, 3821, 14, 1431, 8, 6721, 63, 1210, 304, 355, 327, 18405, 2983, 8875, 6243, 1324, 14, 355, 340, 440, 15834, 14, 13533, 63, 17835, 26, 490, 746, 1722, 360, 5733, 9147, 3400, 687, 4840, 1324, 5074, 15801, 2659, 355, 486, 275, 24249, 63, 82, 1252, 739, 8, 11600, 14, 17275, 6831, 8, 6721, 63, 1210, 680, 18914, 9, 288, 587, 26, 355, 746, 1722, 360, 1558, 503, 2649, 1324, 24718, 465, 22561, 662, 55, 12362, 12, 436, 869, 23017, 28328, 2659, 267, 916, 1228, 8, 6721, 63, 1210, 12, 8991, 7474, 63, 14528, 304, 288, 327, 3979, 314, 1324, 365, 282, 7849, 370, 282, 3400, 334, 31080, 63, 14528, 680, 288, 486, 275, 8509, 63, 1210, 267, 916, 1228, 8, 6721, 63, 1210, 12, 3816, 14, 31519, 304, 288, 327, 3979, 314, 1324, 365, 282, 3335, 334, 28328, 680, 288, 486, 275, 24249, 63, 82, 1252, 739, 8, 6721, 63, 1210, 9, 267, 916, 1228, 8, 6721, 63, 1210, 12, 21479, 304, 288, 486, 275, 13648, 14, 6481, 63, 6311, 8, 6721, 63, 1210, 14, 4695, 9, 267, 587, 26, 288, 327, 6378, 3400, 730, 14, 288, 746, 3146, 360, 8499, 9198, 3400, 1324, 730, 26, 450, 83, 7, 450, 620, 8, 466, 8, 6721, 63, 1210, 1724, 398, 340, 486, 26, 288, 327, 13510, 314, 7849, 909, 543, 282, 1686, 7849, 14, 288, 291, 14, 4695, 275, 486, 267, 587, 26, 288, 746, 21390, 21686, 360, 6531, 440, 8265, 11920, 10579, 543, 1627, 1324, 2659, 398, 327, 7711, 13, 27876, 3272, 14, 267, 291, 423, 1932, 63, 826, 8, 10498, 9, 339, 347, 485, 1932, 63, 826, 8, 277, 12, 15627, 304, 267, 298, 4433, 12981, 367, 19203, 2963, 13, 27876, 3272, 2122, 267, 327, 13510, 314, 22425, 12, 340, 1627, 14, 267, 340, 15627, 436, 1228, 8, 10498, 12, 1109, 304, 288, 291, 14, 10498, 275, 15627, 398, 327, 13510, 314, 1021, 730, 334, 69, 14, 71, 2020, 7584, 12, 17560, 12, 5423, 4959, 267, 340, 21479, 423, 14151, 63, 13748, 365, 488, 26, 288, 327, 22373, 13, 4591, 1750, 370, 5126, 492, 18511, 543, 21479, 14, 288, 687, 1275, 604, 875, 492, 30020, 12, 12489, 15420, 288, 687, 1275, 1403, 492, 7584, 288, 687, 1275, 16295, 492, 17560, 288, 687, 1275, 7882, 492, 334, 355, 10579, 7768, 12, 6879, 3428, 12, 6879, 22134, 12, 6879, 12367, 9, 288, 21479, 423, 14151, 63, 13748, 275, 469, 355, 378, 26, 7584, 12, 355, 413, 26, 30020, 12, 355, 499, 26, 12489, 15420, 12, 355, 650, 26, 17560, 12, 355, 841, 26, 6879, 3428, 12, 355, 959, 26, 6879, 22134, 12, 355, 1227, 26, 6879, 12367, 12, 355, 1520, 26, 10579, 7768, 12, 288, 789, 267, 291, 855, 533, 363, 275, 21479, 423, 14151, 63, 13748, 59 ]
[ 199, 961, 859, 3509, 314, 283, 1095, 7, 21479, 909, 1553, 1006, 11920, 5346, 14100, 199, 8287, 687, 642, 909, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2022, 199, 504, 5577, 492, 2287, 1618, 12, 15968, 12, 286, 63, 3157, 199, 199, 504, 1639, 14, 2828, 14, 5668, 492, 15834, 199, 504, 1639, 14, 2828, 14, 5668, 14, 7660, 14, 3821, 492, 6318, 63, 3821, 12, 2022, 63, 3821, 12, 21992, 63, 3821, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 492, 19393, 83, 465, 13648, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 1095, 492, 11920, 1563, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 7988, 3610, 492, 11920, 14957, 11205, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 705, 492, 21390, 21686, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 773, 12151, 492, 8991, 7474, 63, 14528, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 17404, 63, 513, 492, 3820, 4256, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 19260, 492, 5543, 9508, 6831, 199, 504, 1639, 14, 2828, 14, 5668, 14, 12151, 14, 16141, 83, 14, 2308, 492, 334, 272, 325, 18914, 63, 87, 12, 24249, 63, 82, 12, 24249, 63, 87, 12, 21992, 63, 82, 12, 21992, 63, 87, 12, 199, 9, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 12, 3542, 63, 505, 421, 199, 533, 21479, 8, 14151, 1563, 12, 3820, 4256, 304, 272, 298, 33, 1021, 626, 12, 16711, 12, 22667, 15409, 282, 11920, 3400, 2122, 339, 485, 14151, 63, 13748, 275, 488, 339, 12448, 63, 466, 275, 8991, 7474, 63, 14528, 272, 965, 63, 1259, 275, 756, 221, 327, 5972, 7584, 12, 30020, 12, 12489, 15420, 1172, 10021, 8013, 339, 347, 636, 826, 721, 277, 12, 8509, 63, 1210, 12, 15627, 29, 403, 304, 267, 408, 267, 710, 1300, 3787, 367, 11920, 3400, 2251, 12, 436, 1443, 5452, 314, 267, 2569, 4153, 26, 13359, 627, 3326, 26, 288, 446, 22561, 288, 446, 869, 23017, 28328, 334, 65, 20929, 13, 6100, 11358, 1824, 9, 288, 446, 8875, 6243, 334, 6537, 15801, 9, 268, 627, 3335, 26, 288, 446, 644, 12780, 398, 710, 658, 10498, 64, 4252, 365, 1202, 370, 4165, 314, 5800, 10944, 23285, 267, 334, 5943, 998, 9, 1329, 367, 642, 10579, 14, 221, 982, 440, 663, 12, 314, 22425, 911, 506, 488, 14, 267, 408, 267, 340, 1228, 8, 6721, 63, 1210, 12, 2783, 304, 288, 8509, 63, 1210, 275, 3542, 63, 505, 8, 6721, 63, 1210, 9, 267, 340, 1228, 8, 6721, 63, 1210, 12, 3816, 14, 875, 63, 1313, 304, 288, 21992, 63, 77, 275, 21992, 63, 3821, 14, 1431, 8, 6721, 63, 1210, 9, 288, 340, 21992, 63, 77, 26, 355, 327, 18405, 2983, 22561, 1324, 14, 355, 340, 21992, 63, 77, 14, 923, 360, 10498, 735, 490, 15627, 275, 1109, 8, 11412, 63, 77, 14, 923, 360, 10498, 1333, 355, 486, 275, 21992, 63, 82, 1252, 739, 8, 3990, 63, 2394, 8, 11412, 63, 77, 14, 923, 360, 11412, 7058, 288, 916, 6318, 63, 3821, 14, 1431, 8, 6721, 63, 1210, 304, 355, 327, 18405, 2983, 869, 23017, 28328, 1324, 14, 355, 486, 275, 24249, 63, 82, 1252, 739, 8, 3990, 63, 2394, 8, 6721, 63, 1210, 430, 288, 916, 2022, 63, 3821, 14, 1431, 8, 6721, 63, 1210, 304, 355, 327, 18405, 2983, 8875, 6243, 1324, 14, 355, 340, 440, 15834, 14, 13533, 63, 17835, 26, 490, 746, 1722, 360, 5733, 9147, 3400, 687, 4840, 1324, 5074, 15801, 2659, 355, 486, 275, 24249, 63, 82, 1252, 739, 8, 11600, 14, 17275, 6831, 8, 6721, 63, 1210, 680, 18914, 9, 288, 587, 26, 355, 746, 1722, 360, 1558, 503, 2649, 1324, 24718, 465, 22561, 662, 55, 12362, 12, 436, 869, 23017, 28328, 2659, 267, 916, 1228, 8, 6721, 63, 1210, 12, 8991, 7474, 63, 14528, 304, 288, 327, 3979, 314, 1324, 365, 282, 7849, 370, 282, 3400, 334, 31080, 63, 14528, 680, 288, 486, 275, 8509, 63, 1210, 267, 916, 1228, 8, 6721, 63, 1210, 12, 3816, 14, 31519, 304, 288, 327, 3979, 314, 1324, 365, 282, 3335, 334, 28328, 680, 288, 486, 275, 24249, 63, 82, 1252, 739, 8, 6721, 63, 1210, 9, 267, 916, 1228, 8, 6721, 63, 1210, 12, 21479, 304, 288, 486, 275, 13648, 14, 6481, 63, 6311, 8, 6721, 63, 1210, 14, 4695, 9, 267, 587, 26, 288, 327, 6378, 3400, 730, 14, 288, 746, 3146, 360, 8499, 9198, 3400, 1324, 730, 26, 450, 83, 7, 450, 620, 8, 466, 8, 6721, 63, 1210, 1724, 398, 340, 486, 26, 288, 327, 13510, 314, 7849, 909, 543, 282, 1686, 7849, 14, 288, 291, 14, 4695, 275, 486, 267, 587, 26, 288, 746, 21390, 21686, 360, 6531, 440, 8265, 11920, 10579, 543, 1627, 1324, 2659, 398, 327, 7711, 13, 27876, 3272, 14, 267, 291, 423, 1932, 63, 826, 8, 10498, 9, 339, 347, 485, 1932, 63, 826, 8, 277, 12, 15627, 304, 267, 298, 4433, 12981, 367, 19203, 2963, 13, 27876, 3272, 2122, 267, 327, 13510, 314, 22425, 12, 340, 1627, 14, 267, 340, 15627, 436, 1228, 8, 10498, 12, 1109, 304, 288, 291, 14, 10498, 275, 15627, 398, 327, 13510, 314, 1021, 730, 334, 69, 14, 71, 2020, 7584, 12, 17560, 12, 5423, 4959, 267, 340, 21479, 423, 14151, 63, 13748, 365, 488, 26, 288, 327, 22373, 13, 4591, 1750, 370, 5126, 492, 18511, 543, 21479, 14, 288, 687, 1275, 604, 875, 492, 30020, 12, 12489, 15420, 288, 687, 1275, 1403, 492, 7584, 288, 687, 1275, 16295, 492, 17560, 288, 687, 1275, 7882, 492, 334, 355, 10579, 7768, 12, 6879, 3428, 12, 6879, 22134, 12, 6879, 12367, 9, 288, 21479, 423, 14151, 63, 13748, 275, 469, 355, 378, 26, 7584, 12, 355, 413, 26, 30020, 12, 355, 499, 26, 12489, 15420, 12, 355, 650, 26, 17560, 12, 355, 841, 26, 6879, 3428, 12, 355, 959, 26, 6879, 22134, 12, 355, 1227, 26, 6879, 12367, 12, 355, 1520, 26, 10579, 7768, 12, 288, 789, 267, 291, 855, 533, 363, 275, 21479, 423, 14151, 63, 13748, 59, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
publicRoman/spark
examples/src/main/python/streaming/flume_wordcount.py
83
2032
# # 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. # """ Counts words in UTF8 encoded, '\n' delimited text received from the network every second. Usage: flume_wordcount.py <hostname> <port> To run this on your local machine, you need to setup Flume first, see https://flume.apache.org/documentation.html and then run the example `$ bin/spark-submit --jars \ external/flume-assembly/target/scala-*/spark-streaming-flume-assembly-*.jar \ examples/src/main/python/streaming/flume_wordcount.py \ localhost 12345 """ from __future__ import print_function import sys from pyspark import SparkContext from pyspark.streaming import StreamingContext from pyspark.streaming.flume import FlumeUtils if __name__ == "__main__": if len(sys.argv) != 3: print("Usage: flume_wordcount.py <hostname> <port>", file=sys.stderr) exit(-1) sc = SparkContext(appName="PythonStreamingFlumeWordCount") ssc = StreamingContext(sc, 1) hostname, port = sys.argv[1:] kvs = FlumeUtils.createStream(ssc, hostname, int(port)) lines = kvs.map(lambda x: x[1]) counts = lines.flatMap(lambda line: line.split(" ")) \ .map(lambda word: (word, 1)) \ .reduceByKey(lambda a, b: a+b) counts.pprint() ssc.start() ssc.awaitTermination()
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 199, 14826, 83, 5932, 315, 9094, 24, 5737, 12, 1557, 78, 7, 21941, 1318, 3086, 687, 314, 2784, 4036, 3499, 14, 199, 11028, 26, 2717, 940, 63, 1027, 835, 14, 647, 665, 4269, 30, 665, 719, 30, 421, 4005, 1255, 642, 641, 2195, 2257, 6844, 12, 1265, 1929, 370, 3272, 11040, 940, 1642, 12, 1937, 199, 4178, 921, 2327, 940, 14, 3796, 14, 1308, 15, 9970, 14, 1360, 421, 436, 2066, 1255, 314, 2893, 272, 658, 4, 2517, 15, 9852, 13, 7275, 1553, 32262, 971, 489, 5957, 15, 2327, 940, 13, 17828, 15, 1375, 15, 28708, 13, 15870, 9852, 13, 12076, 13, 2327, 940, 13, 17828, 13, 4856, 7338, 971, 489, 7251, 15, 2164, 15, 973, 15, 1548, 15, 12076, 15, 2327, 940, 63, 1027, 835, 14, 647, 971, 489, 11667, 25538, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 199, 504, 15847, 492, 21769, 199, 504, 15847, 14, 12076, 492, 28167, 2998, 199, 504, 15847, 14, 12076, 14, 2327, 940, 492, 11040, 940, 7535, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 340, 822, 8, 1274, 14, 3020, 9, 1137, 650, 26, 267, 870, 480, 7692, 26, 2717, 940, 63, 1027, 835, 14, 647, 665, 4269, 30, 665, 719, 7166, 570, 29, 1274, 14, 3083, 9, 267, 4458, 2801, 17, 9, 339, 4061, 275, 21769, 8, 571, 985, 628, 4718, 22555, 7579, 940, 10155, 2353, 531, 272, 308, 551, 275, 28167, 2998, 8, 551, 12, 413, 9, 339, 6246, 12, 1844, 275, 984, 14, 3020, 59, 17, 2938, 272, 1022, 3122, 275, 11040, 940, 7535, 14, 981, 3296, 8, 385, 67, 12, 6246, 12, 1109, 8, 719, 430, 272, 2385, 275, 1022, 3122, 14, 1130, 8, 2734, 671, 26, 671, 59, 17, 566, 272, 8242, 275, 2385, 14, 7088, 2956, 8, 2734, 1004, 26, 1004, 14, 1294, 480, 26725, 971, 267, 1275, 1130, 8, 2734, 4349, 26, 334, 1027, 12, 413, 430, 971, 267, 1275, 5270, 2175, 1197, 8, 2734, 282, 12, 330, 26, 282, 11, 66, 9, 272, 8242, 14, 15380, 342, 339, 308, 551, 14, 928, 342, 272, 308, 551, 14, 32365, 12154, 425, 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 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 199, 14826, 83, 5932, 315, 9094, 24, 5737, 12, 1557, 78, 7, 21941, 1318, 3086, 687, 314, 2784, 4036, 3499, 14, 199, 11028, 26, 2717, 940, 63, 1027, 835, 14, 647, 665, 4269, 30, 665, 719, 30, 421, 4005, 1255, 642, 641, 2195, 2257, 6844, 12, 1265, 1929, 370, 3272, 11040, 940, 1642, 12, 1937, 199, 4178, 921, 2327, 940, 14, 3796, 14, 1308, 15, 9970, 14, 1360, 421, 436, 2066, 1255, 314, 2893, 272, 658, 4, 2517, 15, 9852, 13, 7275, 1553, 32262, 971, 489, 5957, 15, 2327, 940, 13, 17828, 15, 1375, 15, 28708, 13, 15870, 9852, 13, 12076, 13, 2327, 940, 13, 17828, 13, 4856, 7338, 971, 489, 7251, 15, 2164, 15, 973, 15, 1548, 15, 12076, 15, 2327, 940, 63, 1027, 835, 14, 647, 971, 489, 11667, 25538, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 199, 504, 15847, 492, 21769, 199, 504, 15847, 14, 12076, 492, 28167, 2998, 199, 504, 15847, 14, 12076, 14, 2327, 940, 492, 11040, 940, 7535, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 340, 822, 8, 1274, 14, 3020, 9, 1137, 650, 26, 267, 870, 480, 7692, 26, 2717, 940, 63, 1027, 835, 14, 647, 665, 4269, 30, 665, 719, 7166, 570, 29, 1274, 14, 3083, 9, 267, 4458, 2801, 17, 9, 339, 4061, 275, 21769, 8, 571, 985, 628, 4718, 22555, 7579, 940, 10155, 2353, 531, 272, 308, 551, 275, 28167, 2998, 8, 551, 12, 413, 9, 339, 6246, 12, 1844, 275, 984, 14, 3020, 59, 17, 2938, 272, 1022, 3122, 275, 11040, 940, 7535, 14, 981, 3296, 8, 385, 67, 12, 6246, 12, 1109, 8, 719, 430, 272, 2385, 275, 1022, 3122, 14, 1130, 8, 2734, 671, 26, 671, 59, 17, 566, 272, 8242, 275, 2385, 14, 7088, 2956, 8, 2734, 1004, 26, 1004, 14, 1294, 480, 26725, 971, 267, 1275, 1130, 8, 2734, 4349, 26, 334, 1027, 12, 413, 430, 971, 267, 1275, 5270, 2175, 1197, 8, 2734, 282, 12, 330, 26, 282, 11, 66, 9, 272, 8242, 14, 15380, 342, 339, 308, 551, 14, 928, 342, 272, 308, 551, 14, 32365, 12154, 425, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chauhanhardik/populo
common/lib/calc/calc/preview.py
224
12317
""" Provide a `latex_preview` method similar in syntax to `evaluator`. That is, given a math string, parse it and render each branch of the result, always returning valid latex. Because intermediate values of the render contain more data than simply the string of latex, store it in a custom class `LatexRendered`. """ from calc import ParseAugmenter, DEFAULT_VARIABLES, DEFAULT_FUNCTIONS, SUFFIXES class LatexRendered(object): """ Data structure to hold a typeset representation of some math. Fields: -`latex` is a generated, valid latex string (as if it were standalone). -`sans_parens` is usually the same as `latex` except without the outermost parens (if applicable). -`tall` is a boolean representing if the latex has any elements extending above or below a normal height, specifically things of the form 'a^b' and '\frac{a}{b}'. This affects the height of wrapping parenthesis. """ def __init__(self, latex, parens=None, tall=False): """ Instantiate with the latex representing the math. Optionally include parenthesis to wrap around it and the height. `parens` must be one of '(', '[' or '{'. `tall` is a boolean (see note above). """ self.latex = latex self.sans_parens = latex self.tall = tall # Generate parens and overwrite `self.latex`. if parens is not None: left_parens = parens if left_parens == '{': left_parens = r'\{' pairs = {'(': ')', '[': ']', r'\{': r'\}'} if left_parens not in pairs: raise Exception( u"Unknown parenthesis '{}': coder error".format(left_parens) ) right_parens = pairs[left_parens] if self.tall: left_parens = r"\left" + left_parens right_parens = r"\right" + right_parens self.latex = u"{left}{expr}{right}".format( left=left_parens, expr=latex, right=right_parens ) def __repr__(self): # pragma: no cover """ Give a sensible representation of the object. If `sans_parens` is different, include both. If `tall` then have '<[]>' around the code, otherwise '<>'. """ if self.latex == self.sans_parens: latex_repr = u'"{}"'.format(self.latex) else: latex_repr = u'"{}" or "{}"'.format(self.latex, self.sans_parens) if self.tall: wrap = u'<[{}]>' else: wrap = u'<{}>' return wrap.format(latex_repr) def render_number(children): """ Combine the elements forming the number, escaping the suffix if needed. """ children_latex = [k.latex for k in children] suffix = "" if children_latex[-1] in SUFFIXES: suffix = children_latex.pop() suffix = ur"\text{{{s}}}".format(s=suffix) # Exponential notation-- the "E" splits the mantissa and exponent if "E" in children_latex: pos = children_latex.index("E") mantissa = "".join(children_latex[:pos]) exponent = "".join(children_latex[pos + 1:]) latex = ur"{m}\!\times\!10^{{{e}}}{s}".format( m=mantissa, e=exponent, s=suffix ) return LatexRendered(latex, tall=True) else: easy_number = "".join(children_latex) return LatexRendered(easy_number + suffix) def enrich_varname(varname): """ Prepend a backslash if we're given a greek character. """ greek = ("alpha beta gamma delta epsilon varepsilon zeta eta theta " "vartheta iota kappa lambda mu nu xi pi rho sigma tau upsilon " "phi varphi chi psi omega").split() # add capital greek letters greek += [x.capitalize() for x in greek] # add hbar for QM greek.append('hbar') # add infinity greek.append('infty') if varname in greek: return ur"\{letter}".format(letter=varname) else: return varname.replace("_", r"\_") def variable_closure(variables, casify): """ Wrap `render_variable` so it knows the variables allowed. """ def render_variable(children): """ Replace greek letters, otherwise escape the variable names. """ varname = children[0].latex if casify(varname) not in variables: pass # TODO turn unknown variable red or give some kind of error first, _, second = varname.partition("_") if second: # Then 'a_b' must become 'a_{b}' varname = ur"{a}_{{{b}}}".format( a=enrich_varname(first), b=enrich_varname(second) ) else: varname = enrich_varname(varname) return LatexRendered(varname) # .replace("_", r"\_")) return render_variable def function_closure(functions, casify): """ Wrap `render_function` so it knows the functions allowed. """ def render_function(children): """ Escape function names and give proper formatting to exceptions. The exceptions being 'sqrt', 'log2', and 'log10' as of now. """ fname = children[0].latex if casify(fname) not in functions: pass # TODO turn unknown function red or give some kind of error # Wrap the input of the function with parens or braces. inner = children[1].latex if fname == "sqrt": inner = u"{{{expr}}}".format(expr=inner) else: if children[1].tall: inner = ur"\left({expr}\right)".format(expr=inner) else: inner = u"({expr})".format(expr=inner) # Correctly format the name of the function. if fname == "sqrt": fname = ur"\sqrt" elif fname == "log10": fname = ur"\log_{10}" elif fname == "log2": fname = ur"\log_2" else: fname = ur"\text{{{fname}}}".format(fname=fname) # Put it together. latex = fname + inner return LatexRendered(latex, tall=children[1].tall) # Return the function within the closure. return render_function def render_power(children): """ Combine powers so that the latex is wrapped in curly braces correctly. Also, if you have 'a^(b+c)' don't include that last set of parens: 'a^{b+c}' is correct, whereas 'a^{(b+c)}' is extraneous. """ if len(children) == 1: return children[0] children_latex = [k.latex for k in children if k.latex != "^"] children_latex[-1] = children[-1].sans_parens raise_power = lambda x, y: u"{}^{{{}}}".format(y, x) latex = reduce(raise_power, reversed(children_latex)) return LatexRendered(latex, tall=True) def render_parallel(children): """ Simply join the child nodes with a double vertical line. """ if len(children) == 1: return children[0] children_latex = [k.latex for k in children if k.latex != "||"] latex = r"\|".join(children_latex) tall = any(k.tall for k in children) return LatexRendered(latex, tall=tall) def render_frac(numerator, denominator): r""" Given a list of elements in the numerator and denominator, return a '\frac' Avoid parens if they are unnecessary (i.e. the only thing in that part). """ if len(numerator) == 1: num_latex = numerator[0].sans_parens else: num_latex = r"\cdot ".join(k.latex for k in numerator) if len(denominator) == 1: den_latex = denominator[0].sans_parens else: den_latex = r"\cdot ".join(k.latex for k in denominator) latex = ur"\frac{{{num}}}{{{den}}}".format(num=num_latex, den=den_latex) return latex def render_product(children): r""" Format products and division nicely. Group bunches of adjacent, equal operators. Every time it switches from denominator to the next numerator, call `render_frac`. Join these groupings together with '\cdot's, ending on a numerator if needed. Examples: (`children` is formed indirectly by the string on the left) 'a*b' -> 'a\cdot b' 'a/b' -> '\frac{a}{b}' 'a*b/c/d' -> '\frac{a\cdot b}{c\cdot d}' 'a/b*c/d*e' -> '\frac{a}{b}\cdot \frac{c}{d}\cdot e' """ if len(children) == 1: return children[0] position = "numerator" # or denominator fraction_mode_ever = False numerator = [] denominator = [] latex = "" for kid in children: if position == "numerator": if kid.latex == "*": pass # Don't explicitly add the '\cdot' yet. elif kid.latex == "/": # Switch to denominator mode. fraction_mode_ever = True position = "denominator" else: numerator.append(kid) else: if kid.latex == "*": # Switch back to numerator mode. # First, render the current fraction and add it to the latex. latex += render_frac(numerator, denominator) + r"\cdot " # Reset back to beginning state position = "numerator" numerator = [] denominator = [] elif kid.latex == "/": pass # Don't explicitly add a '\frac' yet. else: denominator.append(kid) # Add the fraction/numerator that we ended on. if position == "denominator": latex += render_frac(numerator, denominator) else: # We ended on a numerator--act like normal multiplication. num_latex = r"\cdot ".join(k.latex for k in numerator) latex += num_latex tall = fraction_mode_ever or any(k.tall for k in children) return LatexRendered(latex, tall=tall) def render_sum(children): """ Concatenate elements, including the operators. """ if len(children) == 1: return children[0] children_latex = [k.latex for k in children] latex = "".join(children_latex) tall = any(k.tall for k in children) return LatexRendered(latex, tall=tall) def render_atom(children): """ Properly handle parens, otherwise this is trivial. """ if len(children) == 3: return LatexRendered( children[1].latex, parens=children[0].latex, tall=children[1].tall ) else: return children[0] def add_defaults(var, fun, case_sensitive=False): """ Create sets with both the default and user-defined variables. Compare to calc.add_defaults """ var_items = set(DEFAULT_VARIABLES) fun_items = set(DEFAULT_FUNCTIONS) var_items.update(var) fun_items.update(fun) if not case_sensitive: var_items = set(k.lower() for k in var_items) fun_items = set(k.lower() for k in fun_items) return var_items, fun_items def latex_preview(math_expr, variables=(), functions=(), case_sensitive=False): """ Convert `math_expr` into latex, guaranteeing its parse-ability. Analagous to `evaluator`. """ # No need to go further if math_expr.strip() == "": return "" # Parse tree latex_interpreter = ParseAugmenter(math_expr, case_sensitive) latex_interpreter.parse_algebra() # Get our variables together. variables, functions = add_defaults(variables, functions, case_sensitive) # Create a recursion to evaluate the tree. if case_sensitive: casify = lambda x: x else: casify = lambda x: x.lower() # Lowercase for case insens. render_actions = { 'number': render_number, 'variable': variable_closure(variables, casify), 'function': function_closure(functions, casify), 'atom': render_atom, 'power': render_power, 'parallel': render_parallel, 'product': render_product, 'sum': render_sum } backslash = "\\" wrap_escaped_strings = lambda s: LatexRendered( s.replace(backslash, backslash * 2) ) output = latex_interpreter.reduce_tree( render_actions, terminal_converter=wrap_escaped_strings ) return output.latex
agpl-3.0
[ 624, 199, 25107, 282, 658, 7572, 63, 7780, 64, 1083, 8545, 315, 6302, 370, 658, 27406, 2313, 199, 199, 17231, 365, 12, 1627, 282, 3473, 1059, 12, 2198, 652, 436, 3795, 1924, 5246, 402, 314, 754, 12, 199, 9223, 8152, 1686, 15571, 14, 199, 199, 3655, 2651, 13197, 1338, 402, 314, 3795, 1395, 1655, 666, 2419, 9329, 314, 199, 875, 402, 15571, 12, 3877, 652, 315, 282, 3537, 1021, 658, 16500, 88, 5349, 2995, 2313, 199, 624, 199, 199, 504, 12831, 492, 6077, 21640, 28826, 12, 6186, 63, 21161, 12, 6186, 63, 29865, 12, 5698, 1665, 3867, 654, 421, 199, 533, 491, 24026, 5349, 2995, 8, 785, 304, 272, 408, 272, 3918, 5523, 370, 10266, 282, 730, 409, 6025, 402, 2005, 3473, 14, 339, 16424, 26, 1362, 446, 64, 7572, 64, 365, 282, 4046, 12, 1686, 15571, 1059, 334, 305, 340, 652, 4898, 18042, 680, 1362, 446, 64, 26052, 63, 31910, 64, 365, 9987, 314, 2011, 465, 658, 7572, 64, 871, 1928, 314, 6890, 2786, 489, 32029, 334, 692, 3964, 680, 1362, 446, 64, 84, 452, 64, 365, 282, 5046, 6144, 340, 314, 15571, 965, 1263, 4008, 2178, 1098, 489, 3432, 503, 5084, 282, 3293, 4569, 12, 22543, 7645, 402, 314, 1824, 283, 65, 62, 66, 7, 436, 489, 1557, 10865, 91, 65, 8847, 66, 5285, 961, 29476, 314, 4569, 402, 19696, 32002, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 15571, 12, 32029, 29, 403, 12, 307, 452, 29, 797, 304, 267, 408, 267, 32092, 543, 314, 15571, 6144, 314, 3473, 14, 398, 22383, 2387, 32002, 370, 4816, 6818, 652, 436, 314, 4569, 14, 267, 658, 31910, 64, 1471, 506, 1373, 402, 283, 5102, 22640, 503, 5041, 1370, 267, 658, 84, 452, 64, 365, 282, 5046, 334, 3239, 5317, 3432, 680, 267, 408, 267, 291, 14, 7572, 275, 15571, 267, 291, 14, 26052, 63, 31910, 275, 15571, 267, 291, 14, 84, 452, 275, 307, 452, 398, 327, 7958, 32029, 436, 8970, 658, 277, 14, 7572, 2313, 267, 340, 32029, 365, 440, 488, 26, 288, 3602, 63, 31910, 275, 32029, 288, 340, 3602, 63, 31910, 508, 5041, 356, 355, 3602, 63, 31910, 275, 519, 1154, 1445, 953, 6342, 275, 791, 6176, 283, 3196, 2151, 6730, 356, 283, 4300, 2151, 519, 1154, 91, 356, 519, 1154, 93, 936, 288, 340, 3602, 63, 31910, 440, 315, 6342, 26, 355, 746, 2186, 8, 490, 399, 2, 5912, 32002, 9005, 356, 1233, 82, 1125, 1674, 908, 8, 3039, 63, 31910, 9, 355, 776, 288, 2451, 63, 31910, 275, 6342, 59, 3039, 63, 31910, 61, 953, 340, 291, 14, 84, 452, 26, 355, 3602, 63, 31910, 275, 519, 3212, 3039, 2, 435, 3602, 63, 31910, 355, 2451, 63, 31910, 275, 519, 3212, 1019, 2, 435, 2451, 63, 31910, 953, 291, 14, 7572, 275, 399, 14381, 3039, 8847, 3684, 8847, 1019, 5469, 908, 8, 355, 3602, 29, 3039, 63, 31910, 12, 355, 5348, 29, 7572, 12, 355, 2451, 29, 1019, 63, 31910, 288, 776, 339, 347, 636, 2722, 721, 277, 304, 221, 327, 11942, 26, 949, 8486, 267, 408, 267, 25495, 282, 27962, 6025, 402, 314, 909, 14, 398, 982, 658, 26052, 63, 31910, 64, 365, 3365, 12, 2387, 3865, 14, 267, 982, 658, 84, 452, 64, 2066, 1172, 2650, 8607, 3524, 6818, 314, 1233, 12, 4257, 2650, 22936, 267, 408, 267, 340, 291, 14, 7572, 508, 291, 14, 26052, 63, 31910, 26, 288, 15571, 63, 2722, 275, 399, 4065, 2440, 2, 1370, 908, 8, 277, 14, 7572, 9, 267, 587, 26, 288, 15571, 63, 2722, 275, 399, 4065, 2440, 2, 503, 28168, 1370, 908, 8, 277, 14, 7572, 12, 291, 14, 26052, 63, 31910, 9, 398, 340, 291, 14, 84, 452, 26, 288, 4816, 275, 399, 7601, 59, 27922, 3524, 267, 587, 26, 288, 4816, 275, 399, 7601, 2440, 3524, 398, 372, 4816, 14, 908, 8, 7572, 63, 2722, 9, 421, 199, 318, 3795, 63, 1955, 8, 3223, 304, 272, 408, 272, 26353, 314, 4008, 1824, 316, 314, 1329, 12, 21375, 314, 4739, 340, 4346, 14, 272, 408, 272, 4978, 63, 7572, 275, 359, 75, 14, 7572, 367, 1022, 315, 4978, 61, 339, 4739, 275, 3087, 272, 340, 4978, 63, 7572, 1988, 17, 61, 315, 5698, 1665, 3867, 654, 26, 267, 4739, 275, 4978, 63, 7572, 14, 1935, 342, 267, 4739, 275, 7629, 3212, 505, 3638, 91, 83, 4863, 5469, 908, 8, 83, 29, 4511, 9, 339, 327, 1316, 11819, 15843, 306, 314, 298, 37, 2, 19115, 314, 2169, 280, 28023, 436, 16588, 272, 340, 298, 37, 2, 315, 4978, 63, 7572, 26, 267, 2086, 275, 4978, 63, 7572, 14, 1080, 480, 37, 531, 267, 2169, 280, 28023, 275, 10587, 904, 8, 3223, 63, 7572, 1491, 1712, 566, 267, 16588, 275, 10587, 904, 8, 3223, 63, 7572, 59, 1712, 435, 413, 5728, 267, 15571, 275, 7629, 14381, 77, 4988, 12525, 4508, 60, 1, 709, 62, 3638, 91, 69, 4863, 8847, 83, 5469, 908, 8, 288, 333, 29, 1237, 280, 28023, 12, 325, 29, 23475, 12, 308, 29, 4511, 267, 776, 267, 372, 491, 24026, 5349, 2995, 8, 7572, 12, 307, 452, 29, 549, 9, 272, 587, 26, 267, 8837, 63, 1955, 275, 10587, 904, 8, 3223, 63, 7572, 9, 267, 372, 491, 24026, 5349, 2995, 8, 13581, 63, 1955, 435, 4739, 9, 421, 199, 318, 655, 10399, 63, 16043, 8, 16043, 304, 272, 408, 272, 510, 1155, 500, 282, 13831, 340, 781, 3984, 1627, 282, 30529, 4528, 14, 272, 408, 272, 30529, 275, 1689, 4468, 8201, 10169, 5762, 14030, 25819, 1155, 8746, 1315, 1841, 20356, 12724, 298, 1467, 298, 1391, 9337, 284, 12041, 1022, 15999, 2400, 8504, 15699, 19905, 6682, 17908, 10819, 19188, 1536, 8746, 298, 1467, 298, 10909, 2729, 10909, 23275, 20742, 29566, 3471, 1294, 342, 339, 327, 1050, 17094, 30529, 14435, 272, 30529, 847, 359, 88, 14, 18351, 342, 367, 671, 315, 30529, 61, 339, 327, 1050, 394, 1700, 367, 1413, 45, 272, 30529, 14, 740, 360, 72, 1700, 358, 339, 327, 1050, 23573, 272, 30529, 14, 740, 360, 4904, 369, 358, 339, 340, 22071, 315, 30529, 26, 267, 372, 7629, 3212, 91, 9269, 5469, 908, 8, 9269, 29, 16043, 9, 272, 587, 26, 267, 372, 22071, 14, 1814, 11008, 401, 519, 3212, 29443, 421 ]
[ 199, 25107, 282, 658, 7572, 63, 7780, 64, 1083, 8545, 315, 6302, 370, 658, 27406, 2313, 199, 199, 17231, 365, 12, 1627, 282, 3473, 1059, 12, 2198, 652, 436, 3795, 1924, 5246, 402, 314, 754, 12, 199, 9223, 8152, 1686, 15571, 14, 199, 199, 3655, 2651, 13197, 1338, 402, 314, 3795, 1395, 1655, 666, 2419, 9329, 314, 199, 875, 402, 15571, 12, 3877, 652, 315, 282, 3537, 1021, 658, 16500, 88, 5349, 2995, 2313, 199, 624, 199, 199, 504, 12831, 492, 6077, 21640, 28826, 12, 6186, 63, 21161, 12, 6186, 63, 29865, 12, 5698, 1665, 3867, 654, 421, 199, 533, 491, 24026, 5349, 2995, 8, 785, 304, 272, 408, 272, 3918, 5523, 370, 10266, 282, 730, 409, 6025, 402, 2005, 3473, 14, 339, 16424, 26, 1362, 446, 64, 7572, 64, 365, 282, 4046, 12, 1686, 15571, 1059, 334, 305, 340, 652, 4898, 18042, 680, 1362, 446, 64, 26052, 63, 31910, 64, 365, 9987, 314, 2011, 465, 658, 7572, 64, 871, 1928, 314, 6890, 2786, 489, 32029, 334, 692, 3964, 680, 1362, 446, 64, 84, 452, 64, 365, 282, 5046, 6144, 340, 314, 15571, 965, 1263, 4008, 2178, 1098, 489, 3432, 503, 5084, 282, 3293, 4569, 12, 22543, 7645, 402, 314, 1824, 283, 65, 62, 66, 7, 436, 489, 1557, 10865, 91, 65, 8847, 66, 5285, 961, 29476, 314, 4569, 402, 19696, 32002, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 15571, 12, 32029, 29, 403, 12, 307, 452, 29, 797, 304, 267, 408, 267, 32092, 543, 314, 15571, 6144, 314, 3473, 14, 398, 22383, 2387, 32002, 370, 4816, 6818, 652, 436, 314, 4569, 14, 267, 658, 31910, 64, 1471, 506, 1373, 402, 283, 5102, 22640, 503, 5041, 1370, 267, 658, 84, 452, 64, 365, 282, 5046, 334, 3239, 5317, 3432, 680, 267, 408, 267, 291, 14, 7572, 275, 15571, 267, 291, 14, 26052, 63, 31910, 275, 15571, 267, 291, 14, 84, 452, 275, 307, 452, 398, 327, 7958, 32029, 436, 8970, 658, 277, 14, 7572, 2313, 267, 340, 32029, 365, 440, 488, 26, 288, 3602, 63, 31910, 275, 32029, 288, 340, 3602, 63, 31910, 508, 5041, 356, 355, 3602, 63, 31910, 275, 519, 1154, 1445, 953, 6342, 275, 791, 6176, 283, 3196, 2151, 6730, 356, 283, 4300, 2151, 519, 1154, 91, 356, 519, 1154, 93, 936, 288, 340, 3602, 63, 31910, 440, 315, 6342, 26, 355, 746, 2186, 8, 490, 399, 2, 5912, 32002, 9005, 356, 1233, 82, 1125, 1674, 908, 8, 3039, 63, 31910, 9, 355, 776, 288, 2451, 63, 31910, 275, 6342, 59, 3039, 63, 31910, 61, 953, 340, 291, 14, 84, 452, 26, 355, 3602, 63, 31910, 275, 519, 3212, 3039, 2, 435, 3602, 63, 31910, 355, 2451, 63, 31910, 275, 519, 3212, 1019, 2, 435, 2451, 63, 31910, 953, 291, 14, 7572, 275, 399, 14381, 3039, 8847, 3684, 8847, 1019, 5469, 908, 8, 355, 3602, 29, 3039, 63, 31910, 12, 355, 5348, 29, 7572, 12, 355, 2451, 29, 1019, 63, 31910, 288, 776, 339, 347, 636, 2722, 721, 277, 304, 221, 327, 11942, 26, 949, 8486, 267, 408, 267, 25495, 282, 27962, 6025, 402, 314, 909, 14, 398, 982, 658, 26052, 63, 31910, 64, 365, 3365, 12, 2387, 3865, 14, 267, 982, 658, 84, 452, 64, 2066, 1172, 2650, 8607, 3524, 6818, 314, 1233, 12, 4257, 2650, 22936, 267, 408, 267, 340, 291, 14, 7572, 508, 291, 14, 26052, 63, 31910, 26, 288, 15571, 63, 2722, 275, 399, 4065, 2440, 2, 1370, 908, 8, 277, 14, 7572, 9, 267, 587, 26, 288, 15571, 63, 2722, 275, 399, 4065, 2440, 2, 503, 28168, 1370, 908, 8, 277, 14, 7572, 12, 291, 14, 26052, 63, 31910, 9, 398, 340, 291, 14, 84, 452, 26, 288, 4816, 275, 399, 7601, 59, 27922, 3524, 267, 587, 26, 288, 4816, 275, 399, 7601, 2440, 3524, 398, 372, 4816, 14, 908, 8, 7572, 63, 2722, 9, 421, 199, 318, 3795, 63, 1955, 8, 3223, 304, 272, 408, 272, 26353, 314, 4008, 1824, 316, 314, 1329, 12, 21375, 314, 4739, 340, 4346, 14, 272, 408, 272, 4978, 63, 7572, 275, 359, 75, 14, 7572, 367, 1022, 315, 4978, 61, 339, 4739, 275, 3087, 272, 340, 4978, 63, 7572, 1988, 17, 61, 315, 5698, 1665, 3867, 654, 26, 267, 4739, 275, 4978, 63, 7572, 14, 1935, 342, 267, 4739, 275, 7629, 3212, 505, 3638, 91, 83, 4863, 5469, 908, 8, 83, 29, 4511, 9, 339, 327, 1316, 11819, 15843, 306, 314, 298, 37, 2, 19115, 314, 2169, 280, 28023, 436, 16588, 272, 340, 298, 37, 2, 315, 4978, 63, 7572, 26, 267, 2086, 275, 4978, 63, 7572, 14, 1080, 480, 37, 531, 267, 2169, 280, 28023, 275, 10587, 904, 8, 3223, 63, 7572, 1491, 1712, 566, 267, 16588, 275, 10587, 904, 8, 3223, 63, 7572, 59, 1712, 435, 413, 5728, 267, 15571, 275, 7629, 14381, 77, 4988, 12525, 4508, 60, 1, 709, 62, 3638, 91, 69, 4863, 8847, 83, 5469, 908, 8, 288, 333, 29, 1237, 280, 28023, 12, 325, 29, 23475, 12, 308, 29, 4511, 267, 776, 267, 372, 491, 24026, 5349, 2995, 8, 7572, 12, 307, 452, 29, 549, 9, 272, 587, 26, 267, 8837, 63, 1955, 275, 10587, 904, 8, 3223, 63, 7572, 9, 267, 372, 491, 24026, 5349, 2995, 8, 13581, 63, 1955, 435, 4739, 9, 421, 199, 318, 655, 10399, 63, 16043, 8, 16043, 304, 272, 408, 272, 510, 1155, 500, 282, 13831, 340, 781, 3984, 1627, 282, 30529, 4528, 14, 272, 408, 272, 30529, 275, 1689, 4468, 8201, 10169, 5762, 14030, 25819, 1155, 8746, 1315, 1841, 20356, 12724, 298, 1467, 298, 1391, 9337, 284, 12041, 1022, 15999, 2400, 8504, 15699, 19905, 6682, 17908, 10819, 19188, 1536, 8746, 298, 1467, 298, 10909, 2729, 10909, 23275, 20742, 29566, 3471, 1294, 342, 339, 327, 1050, 17094, 30529, 14435, 272, 30529, 847, 359, 88, 14, 18351, 342, 367, 671, 315, 30529, 61, 339, 327, 1050, 394, 1700, 367, 1413, 45, 272, 30529, 14, 740, 360, 72, 1700, 358, 339, 327, 1050, 23573, 272, 30529, 14, 740, 360, 4904, 369, 358, 339, 340, 22071, 315, 30529, 26, 267, 372, 7629, 3212, 91, 9269, 5469, 908, 8, 9269, 29, 16043, 9, 272, 587, 26, 267, 372, 22071, 14, 1814, 11008, 401, 519, 3212, 29443, 421, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Silvian/Blog
blog/migrations/0001_initial.py
1
1053
# -*- coding: utf-8 -*- # Generated by Django 1.9.1 on 2016-03-31 00:50 from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Blog', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=200)), ('created_date', models.DateTimeField(default=django.utils.timezone.now)), ('published_date', models.DateTimeField(blank=True, null=True)), ('content', models.TextField()), ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), ]
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 5634, 413, 14, 25, 14, 17, 641, 7800, 13, 1644, 13, 2192, 8733, 26, 1400, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 199, 646, 1639, 14, 1208, 14, 7145, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 2536, 275, 715, 339, 5124, 275, 359, 267, 6180, 14, 31925, 63, 8575, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 395, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 26081, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 1213, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 1826, 355, 661, 3966, 63, 602, 297, 1709, 14, 4626, 8, 885, 29, 1176, 14, 1208, 14, 7145, 14, 2131, 1826, 355, 661, 8987, 63, 602, 297, 1709, 14, 4626, 8, 2500, 29, 549, 12, 2973, 29, 549, 1826, 355, 661, 1317, 297, 1709, 14, 6254, 4000, 355, 661, 2502, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 1826, 288, 2156, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 17065, 701, 5634, 413, 14, 25, 14, 17, 641, 7800, 13, 1644, 13, 2192, 8733, 26, 1400, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 199, 646, 1639, 14, 1208, 14, 7145, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 2536, 275, 715, 339, 5124, 275, 359, 267, 6180, 14, 31925, 63, 8575, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 395, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 26081, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 1213, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 1826, 355, 661, 3966, 63, 602, 297, 1709, 14, 4626, 8, 885, 29, 1176, 14, 1208, 14, 7145, 14, 2131, 1826, 355, 661, 8987, 63, 602, 297, 1709, 14, 4626, 8, 2500, 29, 549, 12, 2973, 29, 549, 1826, 355, 661, 1317, 297, 1709, 14, 6254, 4000, 355, 661, 2502, 297, 1709, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 1826, 288, 2156, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
benjaminbrinkman/open-ad-platform
.venv/lib/python3.4/site-packages/pip/commands/uninstall.py
798
2884
from __future__ import absolute_import import pip from pip.wheel import WheelCache from pip.req import InstallRequirement, RequirementSet, parse_requirements from pip.basecommand import Command from pip.exceptions import InstallationError class UninstallCommand(Command): """ Uninstall packages. pip is able to uninstall most installed packages. Known exceptions are: - Pure distutils packages installed with ``python setup.py install``, which leave behind no metadata to determine what files were installed. - Script wrappers installed by ``python setup.py develop``. """ name = 'uninstall' usage = """ %prog [options] <package> ... %prog [options] -r <requirements file> ...""" summary = 'Uninstall packages.' def __init__(self, *args, **kw): super(UninstallCommand, self).__init__(*args, **kw) self.cmd_opts.add_option( '-r', '--requirement', dest='requirements', action='append', default=[], metavar='file', help='Uninstall all the packages listed in the given requirements ' 'file. This option can be used multiple times.', ) self.cmd_opts.add_option( '-y', '--yes', dest='yes', action='store_true', help="Don't ask for confirmation of uninstall deletions.") self.parser.insert_option_group(0, self.cmd_opts) def run(self, options, args): with self._build_session(options) as session: format_control = pip.index.FormatControl(set(), set()) wheel_cache = WheelCache(options.cache_dir, format_control) requirement_set = RequirementSet( build_dir=None, src_dir=None, download_dir=None, isolated=options.isolated_mode, session=session, wheel_cache=wheel_cache, ) for name in args: requirement_set.add_requirement( InstallRequirement.from_line( name, isolated=options.isolated_mode, wheel_cache=wheel_cache ) ) for filename in options.requirements: for req in parse_requirements( filename, options=options, session=session, wheel_cache=wheel_cache): requirement_set.add_requirement(req) if not requirement_set.has_requirements: raise InstallationError( 'You must give at least one requirement to %(name)s (see ' '"pip help %(name)s")' % dict(name=self.name) ) requirement_set.uninstall(auto_confirm=options.yes)
mit
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 7305, 199, 504, 7305, 14, 11798, 492, 26161, 4437, 199, 504, 7305, 14, 2103, 492, 13276, 17947, 12, 25013, 1084, 12, 2198, 63, 7538, 199, 504, 7305, 14, 1095, 1531, 492, 5817, 199, 504, 7305, 14, 3924, 492, 26866, 547, 421, 199, 533, 1910, 3174, 3110, 8, 3110, 304, 272, 408, 272, 1910, 3174, 6117, 14, 339, 7305, 365, 7688, 370, 22199, 4750, 4903, 6117, 14, 31862, 4967, 787, 26, 339, 446, 510, 608, 7065, 6117, 4903, 543, 1124, 1548, 3272, 14, 647, 3907, 4542, 1314, 489, 10137, 22172, 949, 3341, 370, 6705, 4052, 1584, 4898, 4903, 14, 272, 446, 14914, 17995, 4903, 701, 1124, 1548, 3272, 14, 647, 477, 7549, 4345, 272, 408, 272, 536, 275, 283, 19502, 7, 272, 4503, 275, 408, 489, 450, 6595, 359, 1419, 61, 665, 2491, 30, 2263, 489, 450, 6595, 359, 1419, 61, 446, 82, 665, 7538, 570, 30, 2508, 1041, 272, 6212, 275, 283, 1358, 3174, 6117, 3530, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1613, 8, 1358, 3174, 3110, 12, 291, 2843, 826, 9308, 589, 12, 1011, 829, 9, 267, 291, 14, 1760, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 82, 297, 2850, 12434, 297, 288, 2053, 534, 7538, 297, 288, 1595, 534, 740, 297, 288, 849, 6034, 288, 8214, 534, 493, 297, 288, 1720, 534, 1358, 3174, 1006, 314, 6117, 10532, 315, 314, 1627, 9760, 283, 326, 283, 493, 14, 221, 961, 945, 883, 506, 1202, 3663, 5431, 3130, 267, 776, 267, 291, 14, 1760, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 89, 297, 2850, 5066, 297, 288, 2053, 534, 5066, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 16932, 1133, 7198, 367, 18791, 402, 22199, 6070, 852, 2685, 398, 291, 14, 2087, 14, 3176, 63, 1422, 63, 923, 8, 16, 12, 291, 14, 1760, 63, 3291, 9, 339, 347, 1255, 8, 277, 12, 1511, 12, 1249, 304, 267, 543, 291, 423, 1506, 63, 1730, 8, 1419, 9, 465, 2351, 26, 288, 1475, 63, 2785, 275, 7305, 14, 1080, 14, 3484, 3717, 8, 409, 1062, 663, 1012, 288, 9989, 63, 1637, 275, 26161, 4437, 8, 1419, 14, 1637, 63, 694, 12, 1475, 63, 2785, 9, 288, 10685, 63, 409, 275, 25013, 1084, 8, 355, 1900, 63, 694, 29, 403, 12, 355, 2928, 63, 694, 29, 403, 12, 355, 5235, 63, 694, 29, 403, 12, 355, 23348, 29, 1419, 14, 21748, 63, 632, 12, 355, 2351, 29, 1730, 12, 355, 9989, 63, 1637, 29, 11798, 63, 1637, 12, 288, 776, 288, 367, 536, 315, 1249, 26, 355, 10685, 63, 409, 14, 525, 63, 12434, 8, 490, 13276, 17947, 14, 504, 63, 604, 8, 717, 536, 12, 23348, 29, 1419, 14, 21748, 63, 632, 12, 717, 9989, 63, 1637, 29, 11798, 63, 1637, 490, 776, 355, 776, 288, 367, 1788, 315, 1511, 14, 7538, 26, 355, 367, 2648, 315, 2198, 63, 7538, 8, 717, 1788, 12, 717, 1511, 29, 1419, 12, 717, 2351, 29, 1730, 12, 717, 9989, 63, 1637, 29, 11798, 63, 1637, 304, 490, 10685, 63, 409, 14, 525, 63, 12434, 8, 2103, 9, 288, 340, 440, 10685, 63, 409, 14, 1989, 63, 7538, 26, 355, 746, 26866, 547, 8, 490, 283, 5556, 1471, 8120, 737, 5210, 1373, 10685, 370, 2818, 354, 9, 83, 334, 3239, 283, 490, 5522, 9983, 1720, 2818, 354, 9, 83, 32292, 450, 1211, 8, 354, 29, 277, 14, 354, 9, 355, 776, 288, 10685, 63, 409, 14, 19502, 8, 2495, 63, 9548, 29, 1419, 14, 5066, 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 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 7305, 199, 504, 7305, 14, 11798, 492, 26161, 4437, 199, 504, 7305, 14, 2103, 492, 13276, 17947, 12, 25013, 1084, 12, 2198, 63, 7538, 199, 504, 7305, 14, 1095, 1531, 492, 5817, 199, 504, 7305, 14, 3924, 492, 26866, 547, 421, 199, 533, 1910, 3174, 3110, 8, 3110, 304, 272, 408, 272, 1910, 3174, 6117, 14, 339, 7305, 365, 7688, 370, 22199, 4750, 4903, 6117, 14, 31862, 4967, 787, 26, 339, 446, 510, 608, 7065, 6117, 4903, 543, 1124, 1548, 3272, 14, 647, 3907, 4542, 1314, 489, 10137, 22172, 949, 3341, 370, 6705, 4052, 1584, 4898, 4903, 14, 272, 446, 14914, 17995, 4903, 701, 1124, 1548, 3272, 14, 647, 477, 7549, 4345, 272, 408, 272, 536, 275, 283, 19502, 7, 272, 4503, 275, 408, 489, 450, 6595, 359, 1419, 61, 665, 2491, 30, 2263, 489, 450, 6595, 359, 1419, 61, 446, 82, 665, 7538, 570, 30, 2508, 1041, 272, 6212, 275, 283, 1358, 3174, 6117, 3530, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1613, 8, 1358, 3174, 3110, 12, 291, 2843, 826, 9308, 589, 12, 1011, 829, 9, 267, 291, 14, 1760, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 82, 297, 2850, 12434, 297, 288, 2053, 534, 7538, 297, 288, 1595, 534, 740, 297, 288, 849, 6034, 288, 8214, 534, 493, 297, 288, 1720, 534, 1358, 3174, 1006, 314, 6117, 10532, 315, 314, 1627, 9760, 283, 326, 283, 493, 14, 221, 961, 945, 883, 506, 1202, 3663, 5431, 3130, 267, 776, 267, 291, 14, 1760, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 89, 297, 2850, 5066, 297, 288, 2053, 534, 5066, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 628, 16932, 1133, 7198, 367, 18791, 402, 22199, 6070, 852, 2685, 398, 291, 14, 2087, 14, 3176, 63, 1422, 63, 923, 8, 16, 12, 291, 14, 1760, 63, 3291, 9, 339, 347, 1255, 8, 277, 12, 1511, 12, 1249, 304, 267, 543, 291, 423, 1506, 63, 1730, 8, 1419, 9, 465, 2351, 26, 288, 1475, 63, 2785, 275, 7305, 14, 1080, 14, 3484, 3717, 8, 409, 1062, 663, 1012, 288, 9989, 63, 1637, 275, 26161, 4437, 8, 1419, 14, 1637, 63, 694, 12, 1475, 63, 2785, 9, 288, 10685, 63, 409, 275, 25013, 1084, 8, 355, 1900, 63, 694, 29, 403, 12, 355, 2928, 63, 694, 29, 403, 12, 355, 5235, 63, 694, 29, 403, 12, 355, 23348, 29, 1419, 14, 21748, 63, 632, 12, 355, 2351, 29, 1730, 12, 355, 9989, 63, 1637, 29, 11798, 63, 1637, 12, 288, 776, 288, 367, 536, 315, 1249, 26, 355, 10685, 63, 409, 14, 525, 63, 12434, 8, 490, 13276, 17947, 14, 504, 63, 604, 8, 717, 536, 12, 23348, 29, 1419, 14, 21748, 63, 632, 12, 717, 9989, 63, 1637, 29, 11798, 63, 1637, 490, 776, 355, 776, 288, 367, 1788, 315, 1511, 14, 7538, 26, 355, 367, 2648, 315, 2198, 63, 7538, 8, 717, 1788, 12, 717, 1511, 29, 1419, 12, 717, 2351, 29, 1730, 12, 717, 9989, 63, 1637, 29, 11798, 63, 1637, 304, 490, 10685, 63, 409, 14, 525, 63, 12434, 8, 2103, 9, 288, 340, 440, 10685, 63, 409, 14, 1989, 63, 7538, 26, 355, 746, 26866, 547, 8, 490, 283, 5556, 1471, 8120, 737, 5210, 1373, 10685, 370, 2818, 354, 9, 83, 334, 3239, 283, 490, 5522, 9983, 1720, 2818, 354, 9, 83, 32292, 450, 1211, 8, 354, 29, 277, 14, 354, 9, 355, 776, 288, 10685, 63, 409, 14, 19502, 8, 2495, 63, 9548, 29, 1419, 14, 5066, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
petricm/DIRAC
FrameworkSystem/scripts/dirac-admin-get-proxy.py
2
4433
#!/usr/bin/env python ######################################################################## # File : dirac-admin-get-proxy # Author : Stuart Paterson ######################################################################## """ Retrieve a delegated proxy for the given user and group """ from __future__ import print_function import os import DIRAC from DIRAC.Core.Base import Script from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager from DIRAC.ConfigurationSystem.Client.Helpers import Registry __RCSID__ = "$Id$" class Params: limited = False proxyPath = False proxyLifeTime = 86400 enableVOMS = False vomsAttr = False def setLimited( self, args ): self.limited = True return DIRAC.S_OK() def setProxyLocation( self, args ): self.proxyPath = args return DIRAC.S_OK() def setProxyLifeTime( self, arg ): try: fields = [ f.strip() for f in arg.split( ":" ) ] self.proxyLifeTime = int( fields[0] ) * 3600 + int( fields[1] ) * 60 except: print("Can't parse %s time! Is it a HH:MM?" % arg) return DIRAC.S_ERROR( "Can't parse time argument" ) return DIRAC.S_OK() def automaticVOMS( self, arg ): self.enableVOMS = True return DIRAC.S_OK() def setVOMSAttr( self, arg ): self.enableVOMS = True self.vomsAttr = arg return DIRAC.S_OK() def registerCLISwitches( self ): Script.registerSwitch( "v:", "valid=", "Valid HH:MM for the proxy. By default is 24 hours", self.setProxyLifeTime ) Script.registerSwitch( "l", "limited", "Get a limited proxy", self.setLimited ) Script.registerSwitch( "u:", "out=", "File to write as proxy", self.setProxyLocation ) Script.registerSwitch( "a", "voms", "Get proxy with VOMS extension mapped to the DIRAC group", self.automaticVOMS ) Script.registerSwitch( "m:", "vomsAttr=", "VOMS attribute to require", self.setVOMSAttr ) params = Params() params.registerCLISwitches() Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1], 'Usage:', ' %s [option|cfgfile] ... <DN|user> group' % Script.scriptName, 'Arguments:', ' DN: DN of the user', ' user: DIRAC user name (will fail if there is more than 1 DN registered)', ' group: DIRAC group name' ] ) ) Script.parseCommandLine( ignoreErrors = True ) args = Script.getPositionalArgs() if len( args ) != 2: Script.showHelp() userGroup = str( args[1] ) userDN = str( args[0] ) userName = False if userDN.find( "/" ) != 0: userName = userDN retVal = Registry.getDNForUsername( userName ) if not retVal[ 'OK' ]: print("Cannot discover DN for username %s\n\t%s" % (userName, retVal['Message'])) DIRAC.exit( 2 ) DNList = retVal[ 'Value' ] if len( DNList ) > 1: print("Username %s has more than one DN registered" % userName) ind = 0 for dn in DNList: print("%d %s" % (ind, dn)) ind += 1 inp = raw_input( "Which DN do you want to download? [default 0] " ) if not inp: inp = 0 else: inp = int( inp ) userDN = DNList[inp] else: userDN = DNList[0] if not params.proxyPath: if not userName: result = Registry.getUsernameForDN( userDN ) if not result[ 'OK' ]: print("DN '%s' is not registered in DIRAC" % userDN) DIRAC.exit( 2 ) userName = result[ 'Value' ] params.proxyPath = "%s/proxy.%s.%s" % ( os.getcwd(), userName, userGroup ) if params.enableVOMS: result = gProxyManager.downloadVOMSProxy( userDN, userGroup, limited = params.limited, requiredTimeLeft = params.proxyLifeTime, requiredVOMSAttribute = params.vomsAttr ) else: result = gProxyManager.downloadProxy( userDN, userGroup, limited = params.limited, requiredTimeLeft = params.proxyLifeTime ) if not result['OK']: print('Proxy file cannot be retrieved: %s' % result['Message']) DIRAC.exit( 2 ) chain = result[ 'Value' ] result = chain.dumpAllToFile( params.proxyPath ) if not result['OK']: print('Proxy file cannot be written to %s: %s' % (params.proxyPath, result['Message'])) DIRAC.exit( 2 ) print("Proxy downloaded to %s" % params.proxyPath) DIRAC.exit( 0 )
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3949, 199, 3, 3814, 520, 259, 487, 6457, 13, 2113, 13, 362, 13, 3280, 199, 3, 6529, 520, 221, 1933, 85, 580, 510, 6618, 834, 199, 3949, 199, 624, 523, 13939, 282, 29598, 4566, 367, 314, 1627, 922, 436, 1572, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 747, 199, 646, 26565, 199, 504, 26565, 14, 5402, 14, 1563, 492, 14914, 199, 504, 26565, 14, 16442, 3989, 14, 3041, 14, 4936, 2988, 3041, 492, 486, 4936, 2988, 199, 504, 26565, 14, 5688, 3989, 14, 3041, 14, 4433, 83, 492, 20738, 199, 199, 363, 50, 3298, 998, 363, 275, 7880, 1304, 17351, 199, 199, 533, 30370, 26, 819, 13988, 275, 756, 523, 4566, 2042, 275, 756, 523, 4566, 22637, 1366, 275, 31200, 523, 4756, 10662, 3053, 275, 756, 523, 373, 22491, 7144, 275, 756, 819, 347, 663, 7219, 5703, 8, 291, 12, 1249, 3461, 272, 291, 14, 14136, 275, 715, 272, 372, 26565, 14, 51, 63, 3593, 342, 819, 347, 663, 4936, 6592, 8, 291, 12, 1249, 3461, 272, 291, 14, 3280, 2042, 275, 1249, 272, 372, 26565, 14, 51, 63, 3593, 342, 819, 347, 663, 4936, 22637, 1366, 8, 291, 12, 1680, 3461, 272, 862, 26, 489, 1504, 275, 359, 289, 14, 1913, 342, 367, 289, 315, 1680, 14, 1294, 8, 14725, 776, 1622, 489, 291, 14, 3280, 22637, 1366, 275, 1109, 8, 1504, 59, 16, 61, 776, 627, 15751, 435, 1109, 8, 1504, 59, 17, 61, 776, 627, 5212, 272, 871, 26, 489, 870, 480, 6049, 1133, 2198, 450, 83, 900, 1, 6596, 652, 282, 26922, 26, 3218, 13472, 450, 1680, 9, 489, 372, 26565, 14, 51, 63, 3170, 8, 298, 6049, 1133, 2198, 900, 1423, 2, 776, 272, 372, 26565, 14, 51, 63, 3593, 342, 819, 347, 4834, 10662, 3053, 8, 291, 12, 1680, 3461, 272, 291, 14, 4296, 10662, 3053, 275, 715, 272, 372, 26565, 14, 51, 63, 3593, 342, 819, 347, 663, 10662, 3053, 7144, 8, 291, 12, 1680, 3461, 272, 291, 14, 4296, 10662, 3053, 275, 715, 272, 291, 14, 86, 22491, 7144, 275, 1680, 272, 372, 26565, 14, 51, 63, 3593, 342, 819, 347, 2274, 1981, 1311, 3111, 397, 8, 291, 3461, 272, 14914, 14, 2683, 10167, 8, 298, 86, 6783, 298, 1078, 11107, 298, 3490, 26922, 26, 3218, 367, 314, 4566, 14, 4885, 849, 365, 5504, 10857, 401, 291, 14, 409, 4936, 22637, 1366, 776, 272, 14914, 14, 2683, 10167, 8, 298, 76, 401, 298, 14136, 401, 298, 1002, 282, 13988, 4566, 401, 291, 14, 409, 7219, 5703, 776, 272, 14914, 14, 2683, 10167, 8, 298, 85, 6783, 298, 548, 11107, 298, 1173, 370, 2218, 465, 4566, 401, 291, 14, 409, 4936, 6592, 776, 272, 14914, 14, 2683, 10167, 8, 298, 65, 401, 298, 86, 22491, 401, 298, 1002, 4566, 543, 812, 47, 3053, 3329, 9994, 370, 314, 26565, 1572, 401, 291, 14, 23292, 10662, 3053, 776, 272, 14914, 14, 2683, 10167, 8, 298, 77, 6783, 298, 86, 22491, 7144, 11107, 298, 10662, 3053, 2225, 370, 4409, 401, 291, 14, 409, 10662, 3053, 7144, 776, 199, 199, 1162, 275, 30370, 342, 199, 1162, 14, 2683, 1981, 1311, 3111, 397, 342, 199, 199, 5229, 14, 409, 7692, 2209, 8, 1557, 78, 1370, 904, 8, 359, 636, 1301, 4343, 1294, 8, 1557, 78, 7, 29688, 17, 467, 3660, 283, 7692, 6536, 3660, 283, 221, 450, 83, 359, 1422, 92, 4128, 493, 61, 2263, 665, 10872, 92, 751, 30, 1572, 7, 450, 14914, 14, 1579, 985, 12, 3660, 283, 14517, 6536, 3660, 283, 221, 24842, 26, 755, 24842, 402, 314, 922, 297, 3660, 283, 221, 922, 26, 258, 26565, 922, 536, 334, 14117, 2449, 340, 2337, 365, 1655, 2419, 413, 24842, 7264, 3196, 3660, 283, 221, 1572, 26, 259, 26565, 1572, 536, 7, 1622, 776, 776, 199, 199, 5229, 14, 1122, 16926, 8, 3686, 9298, 275, 715, 776, 199, 589, 275, 14914, 14, 362, 5625, 279, 6213, 342, 199, 199, 692, 822, 8, 1249, 776, 1137, 499, 26, 523, 14914, 14, 2384, 8673, 342, 199, 199, 751, 2448, 275, 620, 8, 1249, 59, 17, 61, 776, 199, 751, 10872, 275, 620, 8, 1249, 59, 16, 61, 776, 199, 751, 985, 275, 756, 199, 692, 922, 10872, 14, 1623, 8, 10609, 776, 1137, 378, 26, 523, 922, 985, 275, 922, 10872, 523, 15011, 275, 20738, 14, 362, 10872, 1858, 13355, 8, 922, 985, 776, 523, 340, 440, 15011, 59, 283, 3593, 7, 16246, 272, 870, 480, 6612, 20131, 24842, 367, 3434, 450, 83, 60, 78, 60, 84, 5, 83, 2, 450, 334, 751, 985, 12, 15011, 459, 2209, 5156, 272, 26565, 14, 2224, 8, 499, 776, 523, 24842, 1296, 275, 15011, 59, 283, 1110, 7, 1622, 523, 340, 822, 8, 24842, 1296, 776, 690, 413, 26, 272, 870, 480, 13355, 450, 83, 965, 1655, 2419, 1373, 24842, 7264, 2, 450, 922, 985, 9, 272, 7654, 275, 378, 272, 367, 14052, 315, 24842, 1296, 26, 489, 870, 3647, 68, 450, 83, 2, 450, 334, 688, 12, 14052, 430, 489, 7654, 847, 413, 272, 10702, 275, 3066, 63, 1210, 8, 298, 31619, 24842, 886, 1265, 2934, 370, 5235, 31, 359, 885, 378, 61, 298, 776, 272, 340, 440, 10702, 26, 489, 10702, 275, 378, 272, 587, 26, 489, 10702, 275, 1109, 8, 10702, 776, 272, 922, 10872, 275, 24842, 1296, 59, 11416, 61, 523, 587, 26, 272, 922, 10872, 275, 24842, 1296, 59, 16, 61, 199, 199, 692, 440, 1862, 14, 3280, 2042, 26, 523, 340, 440, 922, 985, 26, 272, 754, 275, 20738, 14, 362, 13355, 1858, 10872, 8, 922, 10872, 776, 272, 340, 440, 754, 59, 283, 3593, 7, 16246, 489, 870, 480, 10872, 1543, 83, 7, 365, 440, 7264, 315, 26565, 2, 450, 922, 10872, 9, 489, 26565, 14, 2224, 8, 499, 776, 272, 922, 985, 275, 754, 59, 283, 1110, 7, 1622, 523, 1862, 14, 3280, 2042, 275, 2071, 83, 15, 3280, 4111, 83, 4111, 83, 2, 450, 334, 747, 14, 9458, 1062, 922, 985, 12, 922, 2448, 776, 199, 199, 692, 1862, 14, 4296, 10662, 3053, 26, 523, 754, 275, 486, 4936, 2988, 14, 4249, 10662, 3053, 4936, 8, 922, 10872, 12, 922, 2448, 12 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3949, 199, 3, 3814, 520, 259, 487, 6457, 13, 2113, 13, 362, 13, 3280, 199, 3, 6529, 520, 221, 1933, 85, 580, 510, 6618, 834, 199, 3949, 199, 624, 523, 13939, 282, 29598, 4566, 367, 314, 1627, 922, 436, 1572, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 747, 199, 646, 26565, 199, 504, 26565, 14, 5402, 14, 1563, 492, 14914, 199, 504, 26565, 14, 16442, 3989, 14, 3041, 14, 4936, 2988, 3041, 492, 486, 4936, 2988, 199, 504, 26565, 14, 5688, 3989, 14, 3041, 14, 4433, 83, 492, 20738, 199, 199, 363, 50, 3298, 998, 363, 275, 7880, 1304, 17351, 199, 199, 533, 30370, 26, 819, 13988, 275, 756, 523, 4566, 2042, 275, 756, 523, 4566, 22637, 1366, 275, 31200, 523, 4756, 10662, 3053, 275, 756, 523, 373, 22491, 7144, 275, 756, 819, 347, 663, 7219, 5703, 8, 291, 12, 1249, 3461, 272, 291, 14, 14136, 275, 715, 272, 372, 26565, 14, 51, 63, 3593, 342, 819, 347, 663, 4936, 6592, 8, 291, 12, 1249, 3461, 272, 291, 14, 3280, 2042, 275, 1249, 272, 372, 26565, 14, 51, 63, 3593, 342, 819, 347, 663, 4936, 22637, 1366, 8, 291, 12, 1680, 3461, 272, 862, 26, 489, 1504, 275, 359, 289, 14, 1913, 342, 367, 289, 315, 1680, 14, 1294, 8, 14725, 776, 1622, 489, 291, 14, 3280, 22637, 1366, 275, 1109, 8, 1504, 59, 16, 61, 776, 627, 15751, 435, 1109, 8, 1504, 59, 17, 61, 776, 627, 5212, 272, 871, 26, 489, 870, 480, 6049, 1133, 2198, 450, 83, 900, 1, 6596, 652, 282, 26922, 26, 3218, 13472, 450, 1680, 9, 489, 372, 26565, 14, 51, 63, 3170, 8, 298, 6049, 1133, 2198, 900, 1423, 2, 776, 272, 372, 26565, 14, 51, 63, 3593, 342, 819, 347, 4834, 10662, 3053, 8, 291, 12, 1680, 3461, 272, 291, 14, 4296, 10662, 3053, 275, 715, 272, 372, 26565, 14, 51, 63, 3593, 342, 819, 347, 663, 10662, 3053, 7144, 8, 291, 12, 1680, 3461, 272, 291, 14, 4296, 10662, 3053, 275, 715, 272, 291, 14, 86, 22491, 7144, 275, 1680, 272, 372, 26565, 14, 51, 63, 3593, 342, 819, 347, 2274, 1981, 1311, 3111, 397, 8, 291, 3461, 272, 14914, 14, 2683, 10167, 8, 298, 86, 6783, 298, 1078, 11107, 298, 3490, 26922, 26, 3218, 367, 314, 4566, 14, 4885, 849, 365, 5504, 10857, 401, 291, 14, 409, 4936, 22637, 1366, 776, 272, 14914, 14, 2683, 10167, 8, 298, 76, 401, 298, 14136, 401, 298, 1002, 282, 13988, 4566, 401, 291, 14, 409, 7219, 5703, 776, 272, 14914, 14, 2683, 10167, 8, 298, 85, 6783, 298, 548, 11107, 298, 1173, 370, 2218, 465, 4566, 401, 291, 14, 409, 4936, 6592, 776, 272, 14914, 14, 2683, 10167, 8, 298, 65, 401, 298, 86, 22491, 401, 298, 1002, 4566, 543, 812, 47, 3053, 3329, 9994, 370, 314, 26565, 1572, 401, 291, 14, 23292, 10662, 3053, 776, 272, 14914, 14, 2683, 10167, 8, 298, 77, 6783, 298, 86, 22491, 7144, 11107, 298, 10662, 3053, 2225, 370, 4409, 401, 291, 14, 409, 10662, 3053, 7144, 776, 199, 199, 1162, 275, 30370, 342, 199, 1162, 14, 2683, 1981, 1311, 3111, 397, 342, 199, 199, 5229, 14, 409, 7692, 2209, 8, 1557, 78, 1370, 904, 8, 359, 636, 1301, 4343, 1294, 8, 1557, 78, 7, 29688, 17, 467, 3660, 283, 7692, 6536, 3660, 283, 221, 450, 83, 359, 1422, 92, 4128, 493, 61, 2263, 665, 10872, 92, 751, 30, 1572, 7, 450, 14914, 14, 1579, 985, 12, 3660, 283, 14517, 6536, 3660, 283, 221, 24842, 26, 755, 24842, 402, 314, 922, 297, 3660, 283, 221, 922, 26, 258, 26565, 922, 536, 334, 14117, 2449, 340, 2337, 365, 1655, 2419, 413, 24842, 7264, 3196, 3660, 283, 221, 1572, 26, 259, 26565, 1572, 536, 7, 1622, 776, 776, 199, 199, 5229, 14, 1122, 16926, 8, 3686, 9298, 275, 715, 776, 199, 589, 275, 14914, 14, 362, 5625, 279, 6213, 342, 199, 199, 692, 822, 8, 1249, 776, 1137, 499, 26, 523, 14914, 14, 2384, 8673, 342, 199, 199, 751, 2448, 275, 620, 8, 1249, 59, 17, 61, 776, 199, 751, 10872, 275, 620, 8, 1249, 59, 16, 61, 776, 199, 751, 985, 275, 756, 199, 692, 922, 10872, 14, 1623, 8, 10609, 776, 1137, 378, 26, 523, 922, 985, 275, 922, 10872, 523, 15011, 275, 20738, 14, 362, 10872, 1858, 13355, 8, 922, 985, 776, 523, 340, 440, 15011, 59, 283, 3593, 7, 16246, 272, 870, 480, 6612, 20131, 24842, 367, 3434, 450, 83, 60, 78, 60, 84, 5, 83, 2, 450, 334, 751, 985, 12, 15011, 459, 2209, 5156, 272, 26565, 14, 2224, 8, 499, 776, 523, 24842, 1296, 275, 15011, 59, 283, 1110, 7, 1622, 523, 340, 822, 8, 24842, 1296, 776, 690, 413, 26, 272, 870, 480, 13355, 450, 83, 965, 1655, 2419, 1373, 24842, 7264, 2, 450, 922, 985, 9, 272, 7654, 275, 378, 272, 367, 14052, 315, 24842, 1296, 26, 489, 870, 3647, 68, 450, 83, 2, 450, 334, 688, 12, 14052, 430, 489, 7654, 847, 413, 272, 10702, 275, 3066, 63, 1210, 8, 298, 31619, 24842, 886, 1265, 2934, 370, 5235, 31, 359, 885, 378, 61, 298, 776, 272, 340, 440, 10702, 26, 489, 10702, 275, 378, 272, 587, 26, 489, 10702, 275, 1109, 8, 10702, 776, 272, 922, 10872, 275, 24842, 1296, 59, 11416, 61, 523, 587, 26, 272, 922, 10872, 275, 24842, 1296, 59, 16, 61, 199, 199, 692, 440, 1862, 14, 3280, 2042, 26, 523, 340, 440, 922, 985, 26, 272, 754, 275, 20738, 14, 362, 13355, 1858, 10872, 8, 922, 10872, 776, 272, 340, 440, 754, 59, 283, 3593, 7, 16246, 489, 870, 480, 10872, 1543, 83, 7, 365, 440, 7264, 315, 26565, 2, 450, 922, 10872, 9, 489, 26565, 14, 2224, 8, 499, 776, 272, 922, 985, 275, 754, 59, 283, 1110, 7, 1622, 523, 1862, 14, 3280, 2042, 275, 2071, 83, 15, 3280, 4111, 83, 4111, 83, 2, 450, 334, 747, 14, 9458, 1062, 922, 985, 12, 922, 2448, 776, 199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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 ]
Microvellum/Fluid-Designer
win64-vc/2.78/python/lib/site-packages/sqlalchemy/testing/runner.py
55
1607
#!/usr/bin/env python # testing/runner.py # Copyright (C) 2005-2016 the SQLAlchemy authors and contributors # <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """ Nose test runner module. This script is a front-end to "nosetests" which installs SQLAlchemy's testing plugin into the local environment. The script is intended to be used by third-party dialects and extensions that run within SQLAlchemy's testing framework. The runner can be invoked via:: python -m sqlalchemy.testing.runner The script is then essentially the same as the "nosetests" script, including all of the usual Nose options. The test environment requires that a setup.cfg is locally present including various required options. Note that when using this runner, Nose's "coverage" plugin will not be able to provide coverage for SQLAlchemy itself, since SQLAlchemy is imported into sys.modules before coverage is started. The special script sqla_nose.py is provided as a top-level script which loads the plugin in a special (somewhat hacky) way so that coverage against SQLAlchemy itself is possible. """ from .plugin.noseplugin import NoseSQLAlchemy import nose def main(): nose.main(addplugins=[NoseSQLAlchemy()]) def setup_py_test(): """Runner to use for the 'test_suite' entry of your setup.py. Prevents any name clash shenanigans from the command line argument "test" that the "setup.py test" command sends to nose. """ nose.main(addplugins=[NoseSQLAlchemy()], argv=['runner'])
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 5343, 15, 5933, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 9261, 314, 14303, 11462, 436, 8417, 199, 3, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 624, 199, 1944, 261, 511, 7876, 859, 14, 199, 199, 2765, 2884, 365, 282, 13738, 13, 500, 370, 298, 21085, 2219, 2, 1314, 199, 3174, 83, 14303, 1159, 5343, 3589, 1901, 314, 2257, 3734, 14, 199, 199, 1918, 2884, 365, 11619, 370, 506, 1202, 701, 10919, 13, 7522, 10982, 83, 436, 5478, 199, 9099, 1255, 4453, 14303, 1159, 5343, 10059, 14, 259, 710, 7876, 883, 199, 1235, 10302, 4799, 447, 339, 2366, 446, 77, 8335, 14, 4776, 14, 5933, 199, 199, 1918, 2884, 365, 2066, 28891, 314, 2011, 465, 314, 298, 21085, 2219, 2, 2884, 12, 5893, 199, 452, 402, 314, 20195, 3091, 261, 1511, 14, 257, 710, 511, 3734, 5074, 626, 282, 199, 2758, 14, 4128, 365, 17738, 3451, 5893, 7750, 1415, 1511, 14, 199, 199, 7443, 626, 1380, 1808, 642, 7876, 12, 3091, 261, 1159, 298, 10828, 2, 3589, 911, 440, 506, 199, 461, 370, 5647, 11745, 367, 14303, 6337, 12, 3967, 14303, 365, 199, 17932, 1901, 984, 14, 3112, 2544, 11745, 365, 8239, 14, 257, 710, 4539, 199, 1579, 5295, 416, 63, 21085, 14, 647, 365, 2741, 465, 282, 2746, 13, 1896, 2884, 1314, 14404, 314, 199, 2718, 315, 282, 4539, 334, 3972, 10058, 11176, 89, 9, 4340, 880, 626, 11745, 6169, 199, 4657, 12800, 6337, 365, 3962, 14, 199, 199, 624, 199, 199, 504, 1275, 2718, 14, 21085, 2718, 492, 3091, 261, 4657, 12800, 199, 199, 646, 11354, 421, 199, 318, 2446, 837, 272, 11354, 14, 973, 8, 525, 5265, 1524, 1944, 261, 4657, 12800, 9383, 421, 199, 318, 3272, 63, 647, 63, 396, 837, 272, 408, 7446, 370, 675, 367, 314, 283, 396, 63, 5768, 7, 2397, 402, 2195, 3272, 14, 647, 14, 339, 29861, 83, 1263, 536, 30109, 1033, 287, 290, 528, 796, 687, 314, 1414, 1004, 272, 1423, 298, 396, 2, 626, 314, 298, 2758, 14, 647, 511, 2, 1414, 16178, 272, 370, 11354, 14, 339, 408, 272, 11354, 14, 973, 8, 525, 5265, 1524, 1944, 261, 4657, 12800, 15618, 9238, 2968, 5933, 1105, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 5343, 15, 5933, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 9261, 314, 14303, 11462, 436, 8417, 199, 3, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 624, 199, 1944, 261, 511, 7876, 859, 14, 199, 199, 2765, 2884, 365, 282, 13738, 13, 500, 370, 298, 21085, 2219, 2, 1314, 199, 3174, 83, 14303, 1159, 5343, 3589, 1901, 314, 2257, 3734, 14, 199, 199, 1918, 2884, 365, 11619, 370, 506, 1202, 701, 10919, 13, 7522, 10982, 83, 436, 5478, 199, 9099, 1255, 4453, 14303, 1159, 5343, 10059, 14, 259, 710, 7876, 883, 199, 1235, 10302, 4799, 447, 339, 2366, 446, 77, 8335, 14, 4776, 14, 5933, 199, 199, 1918, 2884, 365, 2066, 28891, 314, 2011, 465, 314, 298, 21085, 2219, 2, 2884, 12, 5893, 199, 452, 402, 314, 20195, 3091, 261, 1511, 14, 257, 710, 511, 3734, 5074, 626, 282, 199, 2758, 14, 4128, 365, 17738, 3451, 5893, 7750, 1415, 1511, 14, 199, 199, 7443, 626, 1380, 1808, 642, 7876, 12, 3091, 261, 1159, 298, 10828, 2, 3589, 911, 440, 506, 199, 461, 370, 5647, 11745, 367, 14303, 6337, 12, 3967, 14303, 365, 199, 17932, 1901, 984, 14, 3112, 2544, 11745, 365, 8239, 14, 257, 710, 4539, 199, 1579, 5295, 416, 63, 21085, 14, 647, 365, 2741, 465, 282, 2746, 13, 1896, 2884, 1314, 14404, 314, 199, 2718, 315, 282, 4539, 334, 3972, 10058, 11176, 89, 9, 4340, 880, 626, 11745, 6169, 199, 4657, 12800, 6337, 365, 3962, 14, 199, 199, 624, 199, 199, 504, 1275, 2718, 14, 21085, 2718, 492, 3091, 261, 4657, 12800, 199, 199, 646, 11354, 421, 199, 318, 2446, 837, 272, 11354, 14, 973, 8, 525, 5265, 1524, 1944, 261, 4657, 12800, 9383, 421, 199, 318, 3272, 63, 647, 63, 396, 837, 272, 408, 7446, 370, 675, 367, 314, 283, 396, 63, 5768, 7, 2397, 402, 2195, 3272, 14, 647, 14, 339, 29861, 83, 1263, 536, 30109, 1033, 287, 290, 528, 796, 687, 314, 1414, 1004, 272, 1423, 298, 396, 2, 626, 314, 298, 2758, 14, 647, 511, 2, 1414, 16178, 272, 370, 11354, 14, 339, 408, 272, 11354, 14, 973, 8, 525, 5265, 1524, 1944, 261, 4657, 12800, 15618, 9238, 2968, 5933, 1105, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
whitehorse-io/encarnia
pyenv/lib/python2.7/site-packages/future/backports/email/encoders.py
82
2800
# Copyright (C) 2001-2006 Python Software Foundation # Author: Barry Warsaw # Contact: email-sig@python.org """Encodings and related functions.""" from __future__ import unicode_literals from __future__ import division from __future__ import absolute_import from future.builtins import str __all__ = [ 'encode_7or8bit', 'encode_base64', 'encode_noop', 'encode_quopri', ] try: from base64 import encodebytes as _bencode except ImportError: # Py2 compatibility. TODO: test this! from base64 import encodestring as _bencode from quopri import encodestring as _encodestring def _qencode(s): enc = _encodestring(s, quotetabs=True) # Must encode spaces, which quopri.encodestring() doesn't do return enc.replace(' ', '=20') def encode_base64(msg): """Encode the message's payload in Base64. Also, add an appropriate Content-Transfer-Encoding header. """ orig = msg.get_payload() encdata = str(_bencode(orig), 'ascii') msg.set_payload(encdata) msg['Content-Transfer-Encoding'] = 'base64' def encode_quopri(msg): """Encode the message's payload in quoted-printable. Also, add an appropriate Content-Transfer-Encoding header. """ orig = msg.get_payload() encdata = _qencode(orig) msg.set_payload(encdata) msg['Content-Transfer-Encoding'] = 'quoted-printable' def encode_7or8bit(msg): """Set the Content-Transfer-Encoding header to 7bit or 8bit.""" orig = msg.get_payload() if orig is None: # There's no payload. For backwards compatibility we use 7bit msg['Content-Transfer-Encoding'] = '7bit' return # We play a trick to make this go fast. If encoding/decode to ASCII # succeeds, we know the data must be 7bit, otherwise treat it as 8bit. try: if isinstance(orig, str): orig.encode('ascii') else: orig.decode('ascii') except UnicodeError: charset = msg.get_charset() output_cset = charset and charset.output_charset # iso-2022-* is non-ASCII but encodes to a 7-bit representation if output_cset and output_cset.lower().startswith('iso-2022-'): msg['Content-Transfer-Encoding'] = '7bit' else: msg['Content-Transfer-Encoding'] = '8bit' else: msg['Content-Transfer-Encoding'] = '7bit' if not isinstance(orig, str): msg.set_payload(orig.decode('ascii', 'surrogateescape')) def encode_noop(msg): """Do nothing.""" # Well, not quite *nothing*: in Python3 we have to turn bytes into a string # in our internal surrogateescaped form in order to keep the model # consistent. orig = msg.get_payload() if not isinstance(orig, str): msg.set_payload(orig.decode('ascii', 'surrogateescape'))
mit
[ 3, 1898, 334, 35, 9, 12521, 13, 7968, 2018, 2290, 2752, 199, 3, 6529, 26, 12377, 651, 644, 285, 2231, 87, 199, 3, 18684, 26, 3031, 13, 4093, 32, 1548, 14, 1308, 199, 199, 624, 30046, 436, 4048, 3423, 1041, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 6466, 14, 10372, 492, 620, 199, 199, 363, 452, 363, 275, 359, 272, 283, 2143, 63, 23, 269, 24, 2075, 297, 272, 283, 2143, 63, 1095, 772, 297, 272, 283, 2143, 63, 12921, 297, 272, 283, 2143, 63, 392, 21993, 297, 272, 1622, 421, 199, 893, 26, 272, 687, 1300, 772, 492, 3752, 2394, 465, 485, 66, 2143, 199, 2590, 3545, 26, 272, 327, 1611, 18, 7163, 14, 3254, 26, 511, 642, 1, 272, 687, 1300, 772, 492, 3752, 875, 465, 485, 66, 2143, 199, 504, 2173, 21993, 492, 3752, 875, 465, 485, 2143, 875, 421, 199, 318, 485, 81, 2143, 8, 83, 304, 272, 12011, 275, 485, 2143, 875, 8, 83, 12, 6313, 8741, 29, 549, 9, 272, 327, 9498, 3752, 7883, 12, 1314, 2173, 21993, 14, 2143, 875, 342, 3181, 1133, 886, 272, 372, 12011, 14, 1814, 360, 1656, 26143, 1165, 358, 421, 199, 318, 3752, 63, 1095, 772, 8, 1328, 304, 272, 408, 9686, 314, 1245, 1159, 4886, 315, 3523, 772, 14, 339, 6121, 12, 1050, 376, 5827, 6646, 13, 11761, 13, 7630, 1406, 14, 272, 408, 272, 2306, 275, 1499, 14, 362, 63, 4749, 342, 272, 12011, 576, 275, 620, 1547, 66, 2143, 8, 2981, 395, 283, 4371, 358, 272, 1499, 14, 409, 63, 4749, 8, 10945, 576, 9, 272, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 1095, 772, 7, 421, 199, 318, 3752, 63, 392, 21993, 8, 1328, 304, 272, 408, 9686, 314, 1245, 1159, 4886, 315, 10999, 13, 20557, 14, 339, 6121, 12, 1050, 376, 5827, 6646, 13, 11761, 13, 7630, 1406, 14, 272, 408, 272, 2306, 275, 1499, 14, 362, 63, 4749, 342, 272, 12011, 576, 275, 485, 81, 2143, 8, 2981, 9, 272, 1499, 14, 409, 63, 4749, 8, 10945, 576, 9, 272, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 9888, 13, 20557, 7, 421, 199, 318, 3752, 63, 23, 269, 24, 2075, 8, 1328, 304, 272, 408, 1084, 314, 6646, 13, 11761, 13, 7630, 1406, 370, 1520, 2075, 503, 1695, 2075, 1041, 272, 2306, 275, 1499, 14, 362, 63, 4749, 342, 272, 340, 2306, 365, 488, 26, 267, 327, 6006, 1159, 949, 4886, 14, 221, 2104, 8552, 7163, 781, 675, 1520, 2075, 267, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 23, 2075, 7, 267, 372, 272, 327, 2136, 5232, 282, 20907, 370, 1852, 642, 2621, 7377, 14, 221, 982, 2644, 15, 2708, 370, 10485, 272, 327, 24611, 12, 781, 5715, 314, 666, 1471, 506, 1520, 2075, 12, 4257, 14312, 652, 465, 1695, 2075, 14, 272, 862, 26, 267, 340, 1228, 8, 2981, 12, 620, 304, 288, 2306, 14, 2143, 360, 4371, 358, 267, 587, 26, 288, 2306, 14, 2708, 360, 4371, 358, 272, 871, 20872, 26, 267, 5960, 275, 1499, 14, 362, 63, 6043, 342, 267, 1072, 63, 67, 409, 275, 5960, 436, 5960, 14, 1199, 63, 6043, 267, 327, 11601, 13, 13859, 13, 10, 365, 2222, 13, 12292, 1325, 3752, 83, 370, 282, 1520, 13, 2075, 6025, 267, 340, 1072, 63, 67, 409, 436, 1072, 63, 67, 409, 14, 2325, 1252, 2460, 360, 4595, 13, 13859, 13, 735, 288, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 23, 2075, 7, 267, 587, 26, 288, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 24, 2075, 7, 272, 587, 26, 267, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 23, 2075, 7, 272, 340, 440, 1228, 8, 2981, 12, 620, 304, 267, 1499, 14, 409, 63, 4749, 8, 2981, 14, 2708, 360, 4371, 297, 283, 16380, 3765, 1333, 421, 199, 318, 3752, 63, 12921, 8, 1328, 304, 272, 408, 2585, 6548, 1041, 272, 327, 644, 1697, 12, 440, 18794, 627, 16323, 19429, 315, 2018, 19, 781, 1172, 370, 7485, 2783, 1901, 282, 1059, 272, 327, 315, 4154, 5007, 6296, 13095, 13572, 1824, 315, 1865, 370, 4215, 314, 1402, 272, 327, 12137, 14, 272, 2306, 275, 1499, 14, 362, 63, 4749, 342, 272, 340, 440, 1228, 8, 2981, 12, 620, 304, 267, 1499, 14, 409, 63, 4749, 8, 2981, 14, 2708, 360, 4371, 297, 283, 16380, 3765, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 35, 9, 12521, 13, 7968, 2018, 2290, 2752, 199, 3, 6529, 26, 12377, 651, 644, 285, 2231, 87, 199, 3, 18684, 26, 3031, 13, 4093, 32, 1548, 14, 1308, 199, 199, 624, 30046, 436, 4048, 3423, 1041, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 6466, 14, 10372, 492, 620, 199, 199, 363, 452, 363, 275, 359, 272, 283, 2143, 63, 23, 269, 24, 2075, 297, 272, 283, 2143, 63, 1095, 772, 297, 272, 283, 2143, 63, 12921, 297, 272, 283, 2143, 63, 392, 21993, 297, 272, 1622, 421, 199, 893, 26, 272, 687, 1300, 772, 492, 3752, 2394, 465, 485, 66, 2143, 199, 2590, 3545, 26, 272, 327, 1611, 18, 7163, 14, 3254, 26, 511, 642, 1, 272, 687, 1300, 772, 492, 3752, 875, 465, 485, 66, 2143, 199, 504, 2173, 21993, 492, 3752, 875, 465, 485, 2143, 875, 421, 199, 318, 485, 81, 2143, 8, 83, 304, 272, 12011, 275, 485, 2143, 875, 8, 83, 12, 6313, 8741, 29, 549, 9, 272, 327, 9498, 3752, 7883, 12, 1314, 2173, 21993, 14, 2143, 875, 342, 3181, 1133, 886, 272, 372, 12011, 14, 1814, 360, 1656, 26143, 1165, 358, 421, 199, 318, 3752, 63, 1095, 772, 8, 1328, 304, 272, 408, 9686, 314, 1245, 1159, 4886, 315, 3523, 772, 14, 339, 6121, 12, 1050, 376, 5827, 6646, 13, 11761, 13, 7630, 1406, 14, 272, 408, 272, 2306, 275, 1499, 14, 362, 63, 4749, 342, 272, 12011, 576, 275, 620, 1547, 66, 2143, 8, 2981, 395, 283, 4371, 358, 272, 1499, 14, 409, 63, 4749, 8, 10945, 576, 9, 272, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 1095, 772, 7, 421, 199, 318, 3752, 63, 392, 21993, 8, 1328, 304, 272, 408, 9686, 314, 1245, 1159, 4886, 315, 10999, 13, 20557, 14, 339, 6121, 12, 1050, 376, 5827, 6646, 13, 11761, 13, 7630, 1406, 14, 272, 408, 272, 2306, 275, 1499, 14, 362, 63, 4749, 342, 272, 12011, 576, 275, 485, 81, 2143, 8, 2981, 9, 272, 1499, 14, 409, 63, 4749, 8, 10945, 576, 9, 272, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 9888, 13, 20557, 7, 421, 199, 318, 3752, 63, 23, 269, 24, 2075, 8, 1328, 304, 272, 408, 1084, 314, 6646, 13, 11761, 13, 7630, 1406, 370, 1520, 2075, 503, 1695, 2075, 1041, 272, 2306, 275, 1499, 14, 362, 63, 4749, 342, 272, 340, 2306, 365, 488, 26, 267, 327, 6006, 1159, 949, 4886, 14, 221, 2104, 8552, 7163, 781, 675, 1520, 2075, 267, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 23, 2075, 7, 267, 372, 272, 327, 2136, 5232, 282, 20907, 370, 1852, 642, 2621, 7377, 14, 221, 982, 2644, 15, 2708, 370, 10485, 272, 327, 24611, 12, 781, 5715, 314, 666, 1471, 506, 1520, 2075, 12, 4257, 14312, 652, 465, 1695, 2075, 14, 272, 862, 26, 267, 340, 1228, 8, 2981, 12, 620, 304, 288, 2306, 14, 2143, 360, 4371, 358, 267, 587, 26, 288, 2306, 14, 2708, 360, 4371, 358, 272, 871, 20872, 26, 267, 5960, 275, 1499, 14, 362, 63, 6043, 342, 267, 1072, 63, 67, 409, 275, 5960, 436, 5960, 14, 1199, 63, 6043, 267, 327, 11601, 13, 13859, 13, 10, 365, 2222, 13, 12292, 1325, 3752, 83, 370, 282, 1520, 13, 2075, 6025, 267, 340, 1072, 63, 67, 409, 436, 1072, 63, 67, 409, 14, 2325, 1252, 2460, 360, 4595, 13, 13859, 13, 735, 288, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 23, 2075, 7, 267, 587, 26, 288, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 24, 2075, 7, 272, 587, 26, 267, 1499, 459, 2714, 13, 11761, 13, 7630, 418, 275, 283, 23, 2075, 7, 272, 340, 440, 1228, 8, 2981, 12, 620, 304, 267, 1499, 14, 409, 63, 4749, 8, 2981, 14, 2708, 360, 4371, 297, 283, 16380, 3765, 1333, 421, 199, 318, 3752, 63, 12921, 8, 1328, 304, 272, 408, 2585, 6548, 1041, 272, 327, 644, 1697, 12, 440, 18794, 627, 16323, 19429, 315, 2018, 19, 781, 1172, 370, 7485, 2783, 1901, 282, 1059, 272, 327, 315, 4154, 5007, 6296, 13095, 13572, 1824, 315, 1865, 370, 4215, 314, 1402, 272, 327, 12137, 14, 272, 2306, 275, 1499, 14, 362, 63, 4749, 342, 272, 340, 440, 1228, 8, 2981, 12, 620, 304, 267, 1499, 14, 409, 63, 4749, 8, 2981, 14, 2708, 360, 4371, 297, 283, 16380, 3765, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
ryancoleman/autodock-vina
boost_1_54_0/libs/python/test/voidptr.py
46
1114
# Copyright Niall Douglas 2005. # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) """ >>> from voidptr_ext import * Check for correct conversion >>> use(get()) Check that None is converted to a NULL void pointer >>> useany(get()) 1 >>> useany(None) 0 Check that we don't lose type information by converting NULL opaque pointers to None >>> assert getnull() is None >>> useany(getnull()) 0 Check that there is no conversion from integers ... >>> try: use(0) ... except TypeError: pass ... else: print 'expected a TypeError' ... and from strings to opaque objects >>> try: use("") ... except TypeError: pass ... else: print 'expected a TypeError' """ def run(args = None): import sys import doctest if args is not None: sys.argv = args return doctest.testmod(sys.modules.get(__name__)) if __name__ == '__main__': print "running..." import sys status = run()[0] if (status == 0): print "Done." sys.exit(status)
apache-2.0
[ 3, 1898, 30650, 452, 577, 810, 3528, 305, 11811, 14, 199, 3, 17484, 1334, 314, 30470, 2290, 844, 12, 3394, 413, 14, 16, 14, 199, 3, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1331, 737, 199, 3, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 421, 199, 624, 199, 6071, 687, 2309, 4695, 63, 832, 492, 627, 2378, 2670, 367, 3211, 8603, 1362, 199, 6071, 675, 8, 362, 1012, 339, 2670, 626, 488, 365, 6702, 370, 282, 5962, 2309, 7849, 1362, 199, 6071, 675, 1629, 8, 362, 1012, 199, 17, 199, 6071, 675, 1629, 8, 403, 9, 199, 16, 339, 2670, 626, 781, 2793, 1133, 27332, 730, 2556, 701, 13806, 5962, 272, 15058, 21116, 370, 488, 1362, 199, 6071, 702, 664, 2307, 342, 365, 488, 199, 6071, 675, 1629, 8, 362, 2307, 1012, 199, 16, 8410, 2670, 626, 2337, 365, 949, 8603, 687, 9446, 2263, 272, 199, 6071, 862, 26, 675, 8, 16, 9, 199, 1396, 871, 3146, 26, 986, 199, 1396, 587, 26, 870, 283, 2062, 282, 3146, 7, 8410, 2263, 436, 687, 3326, 370, 15058, 2251, 272, 199, 6071, 862, 26, 675, 10804, 199, 1396, 871, 3146, 26, 986, 199, 1396, 587, 26, 870, 283, 2062, 282, 3146, 7, 199, 624, 199, 318, 1255, 8, 589, 275, 488, 304, 272, 492, 984, 272, 492, 8868, 339, 340, 1249, 365, 440, 488, 26, 267, 984, 14, 3020, 275, 1249, 272, 372, 8868, 14, 29446, 8, 1274, 14, 3112, 14, 362, 3460, 354, 8964, 1362, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 870, 298, 5720, 11500, 272, 492, 984, 272, 2004, 275, 1255, 3430, 16, 61, 272, 340, 334, 1205, 508, 378, 304, 870, 298, 10759, 2122, 272, 984, 14, 2224, 8, 1205, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 30650, 452, 577, 810, 3528, 305, 11811, 14, 199, 3, 17484, 1334, 314, 30470, 2290, 844, 12, 3394, 413, 14, 16, 14, 199, 3, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1331, 737, 199, 3, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 421, 199, 624, 199, 6071, 687, 2309, 4695, 63, 832, 492, 627, 2378, 2670, 367, 3211, 8603, 1362, 199, 6071, 675, 8, 362, 1012, 339, 2670, 626, 488, 365, 6702, 370, 282, 5962, 2309, 7849, 1362, 199, 6071, 675, 1629, 8, 362, 1012, 199, 17, 199, 6071, 675, 1629, 8, 403, 9, 199, 16, 339, 2670, 626, 781, 2793, 1133, 27332, 730, 2556, 701, 13806, 5962, 272, 15058, 21116, 370, 488, 1362, 199, 6071, 702, 664, 2307, 342, 365, 488, 199, 6071, 675, 1629, 8, 362, 2307, 1012, 199, 16, 8410, 2670, 626, 2337, 365, 949, 8603, 687, 9446, 2263, 272, 199, 6071, 862, 26, 675, 8, 16, 9, 199, 1396, 871, 3146, 26, 986, 199, 1396, 587, 26, 870, 283, 2062, 282, 3146, 7, 8410, 2263, 436, 687, 3326, 370, 15058, 2251, 272, 199, 6071, 862, 26, 675, 10804, 199, 1396, 871, 3146, 26, 986, 199, 1396, 587, 26, 870, 283, 2062, 282, 3146, 7, 199, 624, 199, 318, 1255, 8, 589, 275, 488, 304, 272, 492, 984, 272, 492, 8868, 339, 340, 1249, 365, 440, 488, 26, 267, 984, 14, 3020, 275, 1249, 272, 372, 8868, 14, 29446, 8, 1274, 14, 3112, 14, 362, 3460, 354, 8964, 1362, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 870, 298, 5720, 11500, 272, 492, 984, 272, 2004, 275, 1255, 3430, 16, 61, 272, 340, 334, 1205, 508, 378, 304, 870, 298, 10759, 2122, 272, 984, 14, 2224, 8, 1205, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ms-iot/python
cpython/Tools/scripts/fixnotice.py
64
3059
#! /usr/bin/env python3 """(Ostensibly) fix copyright notices in files. Actually, this script will simply replace a block of text in a file from one string to another. It will only do this once though, i.e. not globally throughout the file. It writes a backup file and then does an os.rename() dance for atomicity. Usage: fixnotices.py [options] [filenames] Options: -h / --help Print this message and exit --oldnotice=file Use the notice in the file as the old (to be replaced) string, instead of the hard coded value in the script. --newnotice=file Use the notice in the file as the new (replacement) string, instead of the hard coded value in the script. --dry-run Don't actually make the changes, but print out the list of files that would change. When used with -v, a status will be printed for every file. -v / --verbose Print a message for every file looked at, indicating whether the file is changed or not. """ OLD_NOTICE = """/*********************************************************** Copyright (c) 2000, BeOpen.com. Copyright (c) 1995-2000, Corporation for National Research Initiatives. Copyright (c) 1990-1995, Stichting Mathematisch Centrum. All rights reserved. See the file "Misc/COPYRIGHT" for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. ******************************************************************/ """ import os import sys import getopt NEW_NOTICE = "" DRYRUN = 0 VERBOSE = 0 def usage(code, msg=''): print(__doc__ % globals()) if msg: print(msg) sys.exit(code) def main(): global DRYRUN, OLD_NOTICE, NEW_NOTICE, VERBOSE try: opts, args = getopt.getopt(sys.argv[1:], 'hv', ['help', 'oldnotice=', 'newnotice=', 'dry-run', 'verbose']) except getopt.error as msg: usage(1, msg) for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-v', '--verbose'): VERBOSE = 1 elif opt == '--dry-run': DRYRUN = 1 elif opt == '--oldnotice': fp = open(arg) OLD_NOTICE = fp.read() fp.close() elif opt == '--newnotice': fp = open(arg) NEW_NOTICE = fp.read() fp.close() for arg in args: process(arg) def process(file): f = open(file) data = f.read() f.close() i = data.find(OLD_NOTICE) if i < 0: if VERBOSE: print('no change:', file) return elif DRYRUN or VERBOSE: print(' change:', file) if DRYRUN: # Don't actually change the file return data = data[:i] + NEW_NOTICE + data[i+len(OLD_NOTICE):] new = file + ".new" backup = file + ".bak" f = open(new, "w") f.write(data) f.close() os.rename(file, backup) os.rename(new, file) if __name__ == '__main__': main()
bsd-3-clause
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 8, 47, 4081, 9312, 9, 5325, 4248, 949, 7724, 315, 1584, 14, 199, 199, 19348, 3163, 12, 642, 2884, 911, 9329, 3350, 282, 1853, 402, 1318, 315, 282, 570, 687, 1373, 199, 875, 370, 4573, 14, 221, 2779, 911, 1454, 886, 642, 5403, 10617, 12, 284, 14, 69, 14, 440, 26662, 199, 273, 22366, 314, 570, 14, 221, 2779, 14511, 282, 6902, 570, 436, 2066, 1630, 376, 747, 14, 8165, 342, 199, 20327, 367, 15374, 1209, 14, 199, 199, 7692, 26, 5325, 889, 7724, 14, 647, 359, 1419, 61, 359, 10309, 61, 199, 4558, 26, 272, 446, 72, 1182, 1553, 3437, 267, 9101, 642, 1245, 436, 4458, 339, 1553, 1753, 20556, 29, 493, 267, 3645, 314, 4245, 315, 314, 570, 465, 314, 2269, 334, 475, 506, 8717, 9, 1059, 12, 3140, 267, 402, 314, 7508, 1233, 68, 574, 315, 314, 2884, 14, 339, 1553, 1222, 20556, 29, 493, 267, 3645, 314, 4245, 315, 314, 570, 465, 314, 892, 334, 15895, 9, 1059, 12, 3140, 402, 267, 314, 7508, 1233, 68, 574, 315, 314, 2884, 14, 339, 1553, 10481, 13, 1065, 267, 7529, 1133, 5965, 1852, 314, 4493, 12, 1325, 870, 734, 314, 769, 402, 1584, 626, 267, 3955, 1570, 14, 221, 3979, 1202, 543, 446, 86, 12, 282, 2004, 911, 506, 12487, 367, 4036, 267, 570, 14, 339, 446, 86, 1182, 1553, 3832, 267, 9101, 282, 1245, 367, 4036, 570, 21182, 737, 12, 9297, 3775, 314, 570, 267, 365, 2896, 503, 440, 14, 199, 624, 199, 199, 5104, 63, 4609, 4047, 275, 408, 15, 5815, 30948, 9153, 199, 7384, 334, 67, 9, 12293, 12, 6423, 4299, 14, 957, 14, 199, 7384, 334, 67, 9, 9013, 21, 13, 8269, 12, 11098, 367, 20548, 26993, 21412, 10661, 14, 199, 7384, 334, 67, 9, 9013, 16, 13, 7155, 21, 12, 428, 280, 335, 1337, 16593, 24508, 280, 15820, 445, 18626, 453, 14, 199, 2422, 4481, 4644, 14, 199, 199, 9295, 314, 570, 298, 29926, 15, 32324, 5716, 2, 367, 2556, 641, 4503, 436, 199, 264, 4972, 402, 642, 570, 12, 436, 367, 282, 8990, 540, 1634, 11727, 2990, 14, 199, 12360, 538, 15, 199, 624, 199, 646, 747, 199, 646, 984, 199, 646, 12733, 199, 199, 11365, 63, 4609, 4047, 275, 3087, 199, 4564, 3763, 1734, 275, 378, 199, 16075, 275, 378, 421, 199, 318, 4503, 8, 600, 12, 1499, 9280, 272, 870, 3460, 1301, 363, 450, 7992, 1012, 272, 340, 1499, 26, 267, 870, 8, 1328, 9, 272, 984, 14, 2224, 8, 600, 9, 421, 199, 318, 2446, 837, 272, 2288, 577, 50, 3763, 1734, 12, 593, 6533, 63, 4609, 4047, 12, 18689, 63, 4609, 4047, 12, 12348, 14607, 272, 862, 26, 267, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 283, 22926, 297, 3521, 788, 3437, 297, 283, 1753, 20556, 4009, 283, 1222, 20556, 4009, 2511, 283, 10481, 13, 1065, 297, 283, 3832, 1105, 272, 871, 12733, 14, 705, 465, 1499, 26, 267, 4503, 8, 17, 12, 1499, 9, 339, 367, 2450, 12, 1680, 315, 3999, 26, 267, 340, 2450, 315, 12291, 72, 297, 2850, 3437, 735, 288, 4503, 8, 16, 9, 267, 916, 2450, 315, 12291, 86, 297, 2850, 3832, 735, 288, 12348, 14607, 275, 413, 267, 916, 2450, 508, 2850, 10481, 13, 1065, 356, 288, 577, 50, 3763, 1734, 275, 413, 267, 916, 2450, 508, 2850, 1753, 20556, 356, 288, 4090, 275, 1551, 8, 1273, 9, 288, 593, 6533, 63, 4609, 4047, 275, 4090, 14, 739, 342, 288, 4090, 14, 1600, 342, 267, 916, 2450, 508, 2850, 1222, 20556, 356, 288, 4090, 275, 1551, 8, 1273, 9, 288, 18689, 63, 4609, 4047, 275, 4090, 14, 739, 342, 288, 4090, 14, 1600, 342, 339, 367, 1680, 315, 1249, 26, 267, 2112, 8, 1273, 9, 421, 199, 318, 2112, 8, 493, 304, 272, 289, 275, 1551, 8, 493, 9, 272, 666, 275, 289, 14, 739, 342, 272, 289, 14, 1600, 342, 272, 284, 275, 666, 14, 1623, 8, 5104, 63, 4609, 4047, 9, 272, 340, 284, 665, 378, 26, 267, 340, 12348, 14607, 26, 288, 870, 360, 889, 1570, 6536, 570, 9, 267, 372, 272, 916, 577, 50, 3763, 1734, 503, 12348, 14607, 26, 267, 870, 360, 257, 1570, 6536, 570, 9, 272, 340, 577, 50, 3763, 1734, 26, 267, 327, 7529, 1133, 5965, 1570, 314, 570, 267, 372, 272, 666, 275, 666, 1491, 73, 61, 435, 18689, 63, 4609, 4047, 435, 666, 59, 73, 11, 552, 8, 5104, 63, 4609, 4047, 15405, 272, 892, 275, 570, 435, 3680, 1222, 2, 272, 6902, 275, 570, 435, 3680, 27162, 2, 272, 289, 275, 1551, 8, 1222, 12, 298, 87, 531, 272, 289, 14, 952, 8, 576, 9, 272, 289, 14, 1600, 342, 272, 747, 14, 8165, 8, 493, 12, 6902, 9, 272, 747, 14, 8165, 8, 1222, 12, 570, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 8, 47, 4081, 9312, 9, 5325, 4248, 949, 7724, 315, 1584, 14, 199, 199, 19348, 3163, 12, 642, 2884, 911, 9329, 3350, 282, 1853, 402, 1318, 315, 282, 570, 687, 1373, 199, 875, 370, 4573, 14, 221, 2779, 911, 1454, 886, 642, 5403, 10617, 12, 284, 14, 69, 14, 440, 26662, 199, 273, 22366, 314, 570, 14, 221, 2779, 14511, 282, 6902, 570, 436, 2066, 1630, 376, 747, 14, 8165, 342, 199, 20327, 367, 15374, 1209, 14, 199, 199, 7692, 26, 5325, 889, 7724, 14, 647, 359, 1419, 61, 359, 10309, 61, 199, 4558, 26, 272, 446, 72, 1182, 1553, 3437, 267, 9101, 642, 1245, 436, 4458, 339, 1553, 1753, 20556, 29, 493, 267, 3645, 314, 4245, 315, 314, 570, 465, 314, 2269, 334, 475, 506, 8717, 9, 1059, 12, 3140, 267, 402, 314, 7508, 1233, 68, 574, 315, 314, 2884, 14, 339, 1553, 1222, 20556, 29, 493, 267, 3645, 314, 4245, 315, 314, 570, 465, 314, 892, 334, 15895, 9, 1059, 12, 3140, 402, 267, 314, 7508, 1233, 68, 574, 315, 314, 2884, 14, 339, 1553, 10481, 13, 1065, 267, 7529, 1133, 5965, 1852, 314, 4493, 12, 1325, 870, 734, 314, 769, 402, 1584, 626, 267, 3955, 1570, 14, 221, 3979, 1202, 543, 446, 86, 12, 282, 2004, 911, 506, 12487, 367, 4036, 267, 570, 14, 339, 446, 86, 1182, 1553, 3832, 267, 9101, 282, 1245, 367, 4036, 570, 21182, 737, 12, 9297, 3775, 314, 570, 267, 365, 2896, 503, 440, 14, 199, 624, 199, 199, 5104, 63, 4609, 4047, 275, 408, 15, 5815, 30948, 9153, 199, 7384, 334, 67, 9, 12293, 12, 6423, 4299, 14, 957, 14, 199, 7384, 334, 67, 9, 9013, 21, 13, 8269, 12, 11098, 367, 20548, 26993, 21412, 10661, 14, 199, 7384, 334, 67, 9, 9013, 16, 13, 7155, 21, 12, 428, 280, 335, 1337, 16593, 24508, 280, 15820, 445, 18626, 453, 14, 199, 2422, 4481, 4644, 14, 199, 199, 9295, 314, 570, 298, 29926, 15, 32324, 5716, 2, 367, 2556, 641, 4503, 436, 199, 264, 4972, 402, 642, 570, 12, 436, 367, 282, 8990, 540, 1634, 11727, 2990, 14, 199, 12360, 538, 15, 199, 624, 199, 646, 747, 199, 646, 984, 199, 646, 12733, 199, 199, 11365, 63, 4609, 4047, 275, 3087, 199, 4564, 3763, 1734, 275, 378, 199, 16075, 275, 378, 421, 199, 318, 4503, 8, 600, 12, 1499, 9280, 272, 870, 3460, 1301, 363, 450, 7992, 1012, 272, 340, 1499, 26, 267, 870, 8, 1328, 9, 272, 984, 14, 2224, 8, 600, 9, 421, 199, 318, 2446, 837, 272, 2288, 577, 50, 3763, 1734, 12, 593, 6533, 63, 4609, 4047, 12, 18689, 63, 4609, 4047, 12, 12348, 14607, 272, 862, 26, 267, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 283, 22926, 297, 3521, 788, 3437, 297, 283, 1753, 20556, 4009, 283, 1222, 20556, 4009, 2511, 283, 10481, 13, 1065, 297, 283, 3832, 1105, 272, 871, 12733, 14, 705, 465, 1499, 26, 267, 4503, 8, 17, 12, 1499, 9, 339, 367, 2450, 12, 1680, 315, 3999, 26, 267, 340, 2450, 315, 12291, 72, 297, 2850, 3437, 735, 288, 4503, 8, 16, 9, 267, 916, 2450, 315, 12291, 86, 297, 2850, 3832, 735, 288, 12348, 14607, 275, 413, 267, 916, 2450, 508, 2850, 10481, 13, 1065, 356, 288, 577, 50, 3763, 1734, 275, 413, 267, 916, 2450, 508, 2850, 1753, 20556, 356, 288, 4090, 275, 1551, 8, 1273, 9, 288, 593, 6533, 63, 4609, 4047, 275, 4090, 14, 739, 342, 288, 4090, 14, 1600, 342, 267, 916, 2450, 508, 2850, 1222, 20556, 356, 288, 4090, 275, 1551, 8, 1273, 9, 288, 18689, 63, 4609, 4047, 275, 4090, 14, 739, 342, 288, 4090, 14, 1600, 342, 339, 367, 1680, 315, 1249, 26, 267, 2112, 8, 1273, 9, 421, 199, 318, 2112, 8, 493, 304, 272, 289, 275, 1551, 8, 493, 9, 272, 666, 275, 289, 14, 739, 342, 272, 289, 14, 1600, 342, 272, 284, 275, 666, 14, 1623, 8, 5104, 63, 4609, 4047, 9, 272, 340, 284, 665, 378, 26, 267, 340, 12348, 14607, 26, 288, 870, 360, 889, 1570, 6536, 570, 9, 267, 372, 272, 916, 577, 50, 3763, 1734, 503, 12348, 14607, 26, 267, 870, 360, 257, 1570, 6536, 570, 9, 272, 340, 577, 50, 3763, 1734, 26, 267, 327, 7529, 1133, 5965, 1570, 314, 570, 267, 372, 272, 666, 275, 666, 1491, 73, 61, 435, 18689, 63, 4609, 4047, 435, 666, 59, 73, 11, 552, 8, 5104, 63, 4609, 4047, 15405, 272, 892, 275, 570, 435, 3680, 1222, 2, 272, 6902, 275, 570, 435, 3680, 27162, 2, 272, 289, 275, 1551, 8, 1222, 12, 298, 87, 531, 272, 289, 14, 952, 8, 576, 9, 272, 289, 14, 1600, 342, 272, 747, 14, 8165, 8, 493, 12, 6902, 9, 272, 747, 14, 8165, 8, 1222, 12, 570, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rtucker-mozilla/inventory
mozdns/tests/utils.py
2
1247
import random import string from mozdns.create_zone.views import create_zone_ajax from django.test import RequestFactory # TODO This should be used everywhere def get_post_data(random_str, suffix): """Return a valid set of data""" return { 'root_domain': '{0}{1}'.format(random_str, suffix), 'soa_primary': 'ns1.mozilla.com', 'soa_contact': 'noc.mozilla.com', 'nameserver_1': 'ns1.mozilla.com', 'private_view_1': 'on', 'public_view_1': 'on', 'ttl_1': '1234' } def create_fake_zone(random_str, suffix=".mozilla.com"): factory = RequestFactory() post_data = get_post_data(random_str, suffix=suffix) request = factory.post("/dont/matter", post_data) create_zone_ajax(request) from mozdns.domain.models import Domain return Domain.objects.get(name=post_data['root_domain']) def random_label(): """ Utility function to generate a random *valid* label. """ label = '' for i in range(random.randint(5, 30)): label += string.letters[random.randint(0, len(string.letters) - 1)] return label def random_byte(): """ Utility function to generate a random byte for random IPs """ return random.randint(1, 255)
bsd-3-clause
[ 646, 2196, 199, 646, 1059, 199, 199, 504, 1303, 90, 5797, 14, 981, 63, 2619, 14, 4196, 492, 1218, 63, 2619, 63, 12774, 199, 504, 1639, 14, 396, 492, 18638, 421, 199, 3, 3254, 961, 1077, 506, 1202, 4036, 4509, 199, 199, 318, 664, 63, 1932, 63, 576, 8, 2355, 63, 495, 12, 4739, 304, 272, 408, 1767, 282, 1686, 663, 402, 666, 624, 272, 372, 469, 267, 283, 1231, 63, 2261, 356, 5041, 16, 8847, 17, 5285, 908, 8, 2355, 63, 495, 12, 4739, 395, 267, 283, 1152, 65, 63, 3327, 356, 283, 561, 17, 14, 12102, 14, 957, 297, 267, 283, 1152, 65, 63, 7811, 356, 283, 23507, 14, 12102, 14, 957, 297, 267, 283, 354, 1000, 63, 17, 356, 283, 561, 17, 14, 12102, 14, 957, 297, 267, 283, 4239, 63, 1345, 63, 17, 356, 283, 265, 297, 267, 283, 3455, 63, 1345, 63, 17, 356, 283, 265, 297, 267, 283, 12130, 63, 17, 356, 283, 4321, 7, 272, 789, 421, 199, 318, 1218, 63, 3183, 63, 2619, 8, 2355, 63, 495, 12, 4739, 25356, 12102, 14, 957, 2349, 272, 6434, 275, 18638, 342, 272, 2963, 63, 576, 275, 664, 63, 1932, 63, 576, 8, 2355, 63, 495, 12, 4739, 29, 4511, 9, 272, 1056, 275, 6434, 14, 1932, 4769, 18671, 15, 569, 351, 401, 2963, 63, 576, 9, 272, 1218, 63, 2619, 63, 12774, 8, 1069, 9, 272, 687, 1303, 90, 5797, 14, 2261, 14, 992, 492, 14061, 272, 372, 14061, 14, 1462, 14, 362, 8, 354, 29, 1932, 63, 576, 459, 1231, 63, 2261, 1105, 421, 199, 318, 2196, 63, 1302, 837, 272, 408, 272, 20511, 805, 370, 3550, 282, 2196, 627, 1078, 10, 1768, 14, 272, 408, 272, 1768, 275, 2125, 272, 367, 284, 315, 1425, 8, 2355, 14, 8393, 8, 21, 12, 4233, 2298, 267, 1768, 847, 1059, 14, 16415, 59, 2355, 14, 8393, 8, 16, 12, 822, 8, 875, 14, 16415, 9, 446, 413, 1874, 272, 372, 1768, 421, 199, 318, 2196, 63, 4414, 837, 272, 408, 272, 20511, 805, 370, 3550, 282, 2196, 3696, 367, 2196, 30657, 272, 408, 272, 372, 2196, 14, 8393, 8, 17, 12, 5450, 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 ]
[ 2196, 199, 646, 1059, 199, 199, 504, 1303, 90, 5797, 14, 981, 63, 2619, 14, 4196, 492, 1218, 63, 2619, 63, 12774, 199, 504, 1639, 14, 396, 492, 18638, 421, 199, 3, 3254, 961, 1077, 506, 1202, 4036, 4509, 199, 199, 318, 664, 63, 1932, 63, 576, 8, 2355, 63, 495, 12, 4739, 304, 272, 408, 1767, 282, 1686, 663, 402, 666, 624, 272, 372, 469, 267, 283, 1231, 63, 2261, 356, 5041, 16, 8847, 17, 5285, 908, 8, 2355, 63, 495, 12, 4739, 395, 267, 283, 1152, 65, 63, 3327, 356, 283, 561, 17, 14, 12102, 14, 957, 297, 267, 283, 1152, 65, 63, 7811, 356, 283, 23507, 14, 12102, 14, 957, 297, 267, 283, 354, 1000, 63, 17, 356, 283, 561, 17, 14, 12102, 14, 957, 297, 267, 283, 4239, 63, 1345, 63, 17, 356, 283, 265, 297, 267, 283, 3455, 63, 1345, 63, 17, 356, 283, 265, 297, 267, 283, 12130, 63, 17, 356, 283, 4321, 7, 272, 789, 421, 199, 318, 1218, 63, 3183, 63, 2619, 8, 2355, 63, 495, 12, 4739, 25356, 12102, 14, 957, 2349, 272, 6434, 275, 18638, 342, 272, 2963, 63, 576, 275, 664, 63, 1932, 63, 576, 8, 2355, 63, 495, 12, 4739, 29, 4511, 9, 272, 1056, 275, 6434, 14, 1932, 4769, 18671, 15, 569, 351, 401, 2963, 63, 576, 9, 272, 1218, 63, 2619, 63, 12774, 8, 1069, 9, 272, 687, 1303, 90, 5797, 14, 2261, 14, 992, 492, 14061, 272, 372, 14061, 14, 1462, 14, 362, 8, 354, 29, 1932, 63, 576, 459, 1231, 63, 2261, 1105, 421, 199, 318, 2196, 63, 1302, 837, 272, 408, 272, 20511, 805, 370, 3550, 282, 2196, 627, 1078, 10, 1768, 14, 272, 408, 272, 1768, 275, 2125, 272, 367, 284, 315, 1425, 8, 2355, 14, 8393, 8, 21, 12, 4233, 2298, 267, 1768, 847, 1059, 14, 16415, 59, 2355, 14, 8393, 8, 16, 12, 822, 8, 875, 14, 16415, 9, 446, 413, 1874, 272, 372, 1768, 421, 199, 318, 2196, 63, 4414, 837, 272, 408, 272, 20511, 805, 370, 3550, 282, 2196, 3696, 367, 2196, 30657, 272, 408, 272, 372, 2196, 14, 8393, 8, 17, 12, 5450, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
2014cdag7/2014cdag7
wsgi/programs/cdag7/__init__.py
12
23366
import cherrypy # 這是 CDAG7 類別的定義 class CDAG7(object): # 各組利用 index 引導隨後的程式執行 @cherrypy.expose def index(self, *args, **kwargs): outstring = ''' 這是 2014CDA 協同專案下的 cdag7 分組程式開發網頁, 以下為 W12 的任務執行內容.<br /> <!-- 這裡採用相對連結, 而非網址的絕對連結 (這一段為 html 註解) --> <a href="cube1">cdag5 正方體參數繪圖</a>(尺寸變數 a, b, c)<br /><br /> <a href="fourbar1">cdag5 四連桿組立</a><br /><br /> 請確定下列連桿位於 V:/home/fourbar 目錄中, 且開啟空白 Creo 組立檔案.<br /> <a href="/static/fourbar.7z">fourbar.7z</a>(滑鼠右鍵存成 .7z 檔案)<br /> ''' return outstring ''' 假如採用下列規畫 import programs.cdag5 as cdag5 root.cdag5 = cdag5.CDAG5() 則程式啟動後, 可以利用 /cdag5/cube1 呼叫函式執行 ''' @cherrypy.expose def cube1(self, *args, **kwargs): ''' // 假如要自行打開特定零件檔案 // 若第三輸入為 false, 表示僅載入 session, 但是不顯示 // ret 為 model open return var ret = document.pwl.pwlMdlOpen("axle_5.prt", "v:/tmp", false); if (!ret.Status) { alert("pwlMdlOpen failed (" + ret.ErrorCode + ")"); } //將 ProE 執行階段設為變數 session var session = pfcGetProESession(); // 在視窗中打開零件檔案, 並且顯示出來 var window = session.OpenFile(pfcCreate("pfcModelDescriptor").CreateFromFileName("axle_5.prt")); var solid = session.GetModel("axle_5.prt",pfcCreate("pfcModelType").MDL_PART); ''' outstring = ''' <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script type="text/javascript" src="/static/weblink/examples/jscript/pfcUtils.js"></script> <script type="text/javascript" src="/static/weblink/examples/jscript/pfcParameterExamples.js"></script> <script type="text/javascript" src="/static/weblink/examples/jscript/pfcComponentFeatExamples.js"></script> </head> <body> <script type="text/javascript"> var session = pfcGetProESession (); // 以目前所開啟的檔案為 solid model // for volume var solid = session.CurrentModel; var a, b, c, i, j, aValue, bValue, cValue, volume, count; // 將模型檔中的 a 變數設為 javascript 中的 a 變數 a = solid.GetParam("a"); b = solid.GetParam("b"); c = solid.GetParam("c"); volume=0; count=0; try { for(i=0;i<5;i++) { myf = 100; myn = myf + i*10; // 設定變數值, 利用 ModelItem 中的 CreateDoubleParamValue 轉換成 Pro/Web.Link 所需要的浮點數值 aValue = pfcCreate ("MpfcModelItem").CreateDoubleParamValue(myn); bValue = pfcCreate ("MpfcModelItem").CreateDoubleParamValue(myn); cValue = pfcCreate ("MpfcModelItem").CreateDoubleParamValue(myn); // 將處理好的變數值, 指定給對應的零件變數 a.Value = aValue; b.Value = bValue; c.Value = cValue; //零件尺寸重新設定後, 呼叫 Regenerate 更新模型 solid.Regenerate(void null); //利用 GetMassProperty 取得模型的質量相關物件 properties = solid.GetMassProperty(void null); volume = properties.Volume; count = count + 1; alert("執行第"+count+"次,零件總體積:"+volume); // 將零件存為新檔案 //var newfile = document.pwl.pwlMdlSaveAs("filename.prt", "v:/tmp", "filename_5_"+count+".prt"); // 測試 stl 轉檔 //var stl_csys = "PRT_CSYS_DEF"; //var stl_instrs = new pfcCreate ("pfcSTLASCIIExportInstructions").Create(stl_csys); //stl_instrs.SetQuality(10); //solid.Export("v:/tmp/filename_5_"+count+".stl", stl_instrs); // 結束測試轉檔 //if (!newfile.Status) { //alert("pwlMdlSaveAs failed (" + newfile.ErrorCode + ")"); //} } // for loop } catch (err) { alert ("Exception occurred: "+pfcGetExceptionType (err)); } </script> </body> </html> ''' return outstring @cherrypy.expose def fourbar1(self, *args, **kwargs): outstring = ''' <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script type="text/javascript" src="/static/weblink/examples/jscript/pfcUtils.js"></script> </head> <body> <script type="text/javascript"> if (!pfcIsWindows()) netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var session = pfcGetProESession(); // 設定 config option, 不要使用元件組立流程中內建的假設約束條件 session.SetConfigOption("comp_placement_assumptions","no"); // 建立擺放零件的位置矩陣, Pro/Web.Link 中的變數無法直接建立, 必須透過 pfcCreate 建立 var identityMatrix = pfcCreate("pfcMatrix3D"); // 建立 identity 位置矩陣 for (var x = 0; x < 4; x++) for (var y = 0; y < 4; y++) { if (x == y) identityMatrix.Set(x, y, 1.0); else identityMatrix.Set(x, y, 0.0); } // 利用 identityMatrix 建立 transf var transf = pfcCreate("pfcTransform3D").Create(identityMatrix); // 取得目前的工作目錄 var currentDir = session.getCurrentDirectory(); // 以目前已開檔的空白組立檔案, 作為 model var model = session.CurrentModel; // 查驗有無 model, 或 model 類別是否為組立件 if (model == void null || model.Type != pfcCreate("pfcModelType").MDL_ASSEMBLY) throw new Error (0, "Current model is not an assembly."); // 將此模型設為組立物件 var assembly = model; /**----------------------------------------------- link0 -------------------------------------------------------------**/ //檔案目錄,建議將圖檔放置工作目錄下較方便使用 var descr = pfcCreate("pfcModelDescriptor").CreateFromFileName("v:/home/fourbar/link0.prt"); // 若 link1.prt 在 session 則直接取用 var componentModel = session.GetModelFromDescr(descr); // 若 link1.prt 不在 session 則從工作目錄中載入 session var componentModel = session.RetrieveModel(descr); // 若 link1.prt 已經在 session 則放入組立檔中 if (componentModel != void null) { //注意這個 asmcomp 即為設定約束條件的本體 //asmcomp 為特徵物件, 直接將零件, 以 transf 座標轉換放入組立檔案中 var asmcomp = assembly.AssembleComponent(componentModel, transf); } // 建立約束條件變數 var constrs = pfcCreate("pfcComponentConstraints"); // 設定組立檔中的三個定位面, 注意內定名稱與 Pro/E WF 中的 ASM_D_FRONT 不同, 而是 ASM_FRONT // 組立檔案中的 Datum 名稱可以利用 View->plane tag display 查詢名稱 // 建立組立參考面所組成的陣列 var asmDatums = new Array("ASM_FRONT", "ASM_TOP", "ASM_RIGHT"); // 設定零件檔中的三個定位面, 名稱與 Pro/E WF 中相同 var compDatums = new Array("FRONT", "TOP", "RIGHT"); // 建立 ids 變數, intseq 為 sequence of integers 為資料類別, 使用者可以經由整數索引擷取此資料類別的元件, 第一個索引為 0 // intseq 等同 Python 的數列資料? var ids = pfcCreate("intseq"); // 建立路徑變數 var path = pfcCreate("MpfcAssembly").CreateComponentPath(assembly, ids); // 採用互動式設定相關的變數 var MpfcSelect = pfcCreate("MpfcSelect"); // 利用迴圈分別約束組立與零件檔中的三個定位平面 for (var i = 0; i < 3; i++) { // 設定組立參考面 var asmItem = assembly.GetItemByName (pfcCreate("pfcModelItemType").ITEM_SURFACE, asmDatums[i]); // 若無對應的組立參考面, 則啟用互動式平面選擇表單 flag if (asmItem == void null) { interactFlag = true; continue; } // 設定零件參考面 var compItem = componentModel.GetItemByName (pfcCreate ("pfcModelItemType").ITEM_SURFACE, compDatums[i]); // 若無對應的零件參考面, 則啟用互動式平面選擇表單 flag if (compItem == void null) { interactFlag = true; continue; } var asmSel = MpfcSelect.CreateModelItemSelection(asmItem, path); var compSel = MpfcSelect.CreateModelItemSelection(compItem, void null); var constr = pfcCreate("pfcComponentConstraint").Create (pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_ALIGN); constr.AssemblyReference = asmSel; constr.ComponentReference = compSel; constr.Attributes = pfcCreate("pfcConstraintAttributes").Create (false, false); // 將互動選擇相關資料, 附加在程式約束變數之後 constrs.Append(constr); } // 設定組立約束條件 asmcomp.SetConstraints (constrs, void null); /**-------------------------------------------------------------------------------------------------------------------**/ /**----------------------------------------------- link1 -------------------------------------------------------------**/ var descr = pfcCreate ("pfcModelDescriptor").CreateFromFileName ("v:/home/fourbar/link1.prt"); var componentModel = session.GetModelFromDescr(descr); var componentModel = session.RetrieveModel(descr); if (componentModel != void null) { // 注意這個 asmcomp 即為設定約束條件的本體 // asmcomp 為特徵物件,直接將零件, 以 transf 座標轉換放入組立檔案中 var asmcomp = assembly.AssembleComponent (componentModel, transf); } // 取得 assembly 項下的元件 id, 因為只有一個零件, 採用 index 0 取出其 featID var components = assembly.ListFeaturesByType(true, pfcCreate ("pfcFeatureType").FEATTYPE_COMPONENT); var featID = components.Item(0).Id; ids.Append(featID); // 在 assembly 模型中建立子零件所對應的路徑 var subPath = pfcCreate("MpfcAssembly").CreateComponentPath(assembly, ids); subassembly = subPath.Leaf; var asmDatums = new Array("A_1", "TOP", "ASM_TOP"); var compDatums = new Array("A_1", "TOP", "TOP"); var relation = new Array (pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_ALIGN, pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_MATE); var relationItem = new Array(pfcCreate("pfcModelItemType").ITEM_AXIS,pfcCreate("pfcModelItemType").ITEM_SURFACE); // 建立約束條件變數 var constrs = pfcCreate ("pfcComponentConstraints"); for (var i = 0; i < 2; i++) { // 設定組立參考面, asmItem 為 model item var asmItem = subassembly.GetItemByName (relationItem[i], asmDatums [i]); // 若無對應的組立參考面, 則啟用互動式平面選擇表單 flag if (asmItem == void null) { interactFlag = true; continue; } // 設定零件參考面, compItem 為 model item var compItem = componentModel.GetItemByName (relationItem[i], compDatums [i]); if (compItem == void null) { interactFlag = true; continue; } // 採用互動式設定相關的變數 var MpfcSelect = pfcCreate ("MpfcSelect"); var asmSel = MpfcSelect.CreateModelItemSelection (asmItem, subPath); var compSel = MpfcSelect.CreateModelItemSelection (compItem, void null); var constr = pfcCreate("pfcComponentConstraint").Create (relation[i]); constr.AssemblyReference = asmSel; constr.ComponentReference = compSel; constr.Attributes = pfcCreate("pfcConstraintAttributes").Create (true, false); // 將互動選擇相關資料, 附加在程式約束變數之後 constrs.Append(constr); } // 設定組立約束條件, 以 asmcomp 特徵進行約束條件設定 // 請注意, 第二個變數必須為 void null 表示零件對零件進行約束, 若為 subPath, 則零件會與原始零件的平面進行約束 asmcomp.SetConstraints (constrs, void null); /**-------------------------------------------------------------------------------------------------------------------**/ /**----------------------------------------------- link2 -------------------------------------------------------------**/ var descr = pfcCreate ("pfcModelDescriptor").CreateFromFileName ("v:/home/fourbar/link2.prt"); var componentModel = session.GetModelFromDescr (descr); var componentModel = session.RetrieveModel(descr); if (componentModel != void null) { var asmcomp = assembly.AssembleComponent (componentModel, transf); } var ids = pfcCreate ("intseq"); ids.Append(featID+1); var subPath = pfcCreate ("MpfcAssembly").CreateComponentPath( assembly, ids ); subassembly = subPath.Leaf; var asmDatums = new Array ("A_2", "TOP", "ASM_TOP"); var compDatums = new Array ("A_1", "TOP", "TOP"); var relation = new Array (pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_ALIGN, pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_MATE); var relationItem = new Array(pfcCreate("pfcModelItemType").ITEM_AXIS,pfcCreate("pfcModelItemType").ITEM_SURFACE); var constrs = pfcCreate ("pfcComponentConstraints"); for (var i = 0; i < 2; i++) { var asmItem = subassembly.GetItemByName (relationItem[i], asmDatums [i]); if (asmItem == void null) { interactFlag = true; continue; } var compItem = componentModel.GetItemByName (relationItem[i], compDatums [i]); if (compItem == void null) { interactFlag = true; continue; } var MpfcSelect = pfcCreate ("MpfcSelect"); var asmSel = MpfcSelect.CreateModelItemSelection (asmItem, subPath); var compSel = MpfcSelect.CreateModelItemSelection (compItem, void null); var constr = pfcCreate ("pfcComponentConstraint").Create (relation[i]); constr.AssemblyReference = asmSel; constr.ComponentReference = compSel; constr.Attributes = pfcCreate ("pfcConstraintAttributes").Create (true, false); constrs.Append (constr); } asmcomp.SetConstraints (constrs, void null); /**-------------------------------------------------------------------------------------------------------------------**/ /**----------------------------------------------- link3 -------------------------------------------------------------**/ var descr = pfcCreate ("pfcModelDescriptor").CreateFromFileName ("v:/home/fourbar/link3.prt"); var componentModel = session.GetModelFromDescr (descr); var componentModel = session.RetrieveModel(descr); if (componentModel != void null) { var asmcomp = assembly.AssembleComponent (componentModel, transf); } var relation = new Array (pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_ALIGN, pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_MATE); var relationItem = new Array(pfcCreate("pfcModelItemType").ITEM_AXIS,pfcCreate("pfcModelItemType").ITEM_SURFACE); var constrs = pfcCreate ("pfcComponentConstraints"); var ids = pfcCreate ("intseq"); ids.Append(featID+2); var subPath = pfcCreate ("MpfcAssembly").CreateComponentPath( assembly, ids ); subassembly = subPath.Leaf; var asmDatums = new Array ("A_2"); var compDatums = new Array ("A_1"); for (var i = 0; i < 1; i++) { var asmItem = subassembly.GetItemByName (relationItem[i], asmDatums [i]); if (asmItem == void null) { interactFlag = true; continue; } var compItem = componentModel.GetItemByName (relationItem[i], compDatums [i]); if (compItem == void null) { interactFlag = true; continue; } var MpfcSelect = pfcCreate ("MpfcSelect"); var asmSel = MpfcSelect.CreateModelItemSelection (asmItem, subPath); var compSel = MpfcSelect.CreateModelItemSelection (compItem, void null); var constr = pfcCreate ("pfcComponentConstraint").Create (relation[i]); constr.AssemblyReference = asmSel; constr.ComponentReference = compSel; constr.Attributes = pfcCreate ("pfcConstraintAttributes").Create (true, false); constrs.Append (constr); } asmcomp.SetConstraints (constrs, void null); var ids = pfcCreate ("intseq"); ids.Append(featID); var subPath = pfcCreate ("MpfcAssembly").CreateComponentPath( assembly, ids ); subassembly = subPath.Leaf; var asmDatums = new Array ("A_2", "TOP"); var compDatums = new Array ("A_2", "BOTTON"); for (var i = 0; i < 2; i++) { var asmItem = subassembly.GetItemByName (relationItem[i], asmDatums [i]); if (asmItem == void null) { interactFlag = true; continue; } var compItem = componentModel.GetItemByName (relationItem[i], compDatums [i]); if (compItem == void null) { interactFlag = true; continue; } var MpfcSelect = pfcCreate ("MpfcSelect"); var asmSel = MpfcSelect.CreateModelItemSelection (asmItem, subPath); var compSel = MpfcSelect.CreateModelItemSelection (compItem, void null); var constr = pfcCreate ("pfcComponentConstraint").Create (relation[i]); constr.AssemblyReference = asmSel; constr.ComponentReference = compSel; constr.Attributes = pfcCreate ("pfcConstraintAttributes").Create (true, true); constrs.Append (constr); } asmcomp.SetConstraints (constrs, void null); /**-------------------------------------------------------------------------------------------------------------------**/ var session = pfcGetProESession (); var solid = session.CurrentModel; properties = solid.GetMassProperty(void null); var COG = properties.GravityCenter; document.write("MassProperty:<br />"); document.write("Mass:"+(properties.Mass.toFixed(2))+" pound<br />"); document.write("Average Density:"+(properties.Density.toFixed(2))+" pound/inch^3<br />"); document.write("Surface area:"+(properties.SurfaceArea.toFixed(2))+" inch^2<br />"); document.write("Volume:"+(properties.Volume.toFixed(2))+" inch^3<br />"); document.write("COG_X:"+COG.Item(0).toFixed(2)+"<br />"); document.write("COG_Y:"+COG.Item(1).toFixed(2)+"<br />"); document.write("COG_Z:"+COG.Item(2).toFixed(2)+"<br />"); try { document.write("Current Directory:<br />"+currentDir); } catch (err) { alert ("Exception occurred: "+pfcGetExceptionType (err)); } assembly.Regenerate (void null); session.GetModelWindow (assembly).Repaint(); </script> </body> </html> ''' return outstring ''' 執行 twentylinks 必須先開一個組立檔案, 放入 link1.prt 之後再執行 Web.Link 程式 ''' @cherrypy.expose def twentylinks(self, *args, **kwargs): outstring = ''' <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <script type="text/javascript" src="/static/weblink/examples/jscript/pfcUtils.js"></script> </head> <body> </script><script language="JavaScript"> if (!pfcIsWindows()) netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var session = pfcGetProESession(); // 設定 config option session.SetConfigOption("comp_placement_assumptions","no"); // 建立擺放零件的位置矩陣 var identityMatrix = pfcCreate ("pfcMatrix3D"); for (var x = 0; x < 4; x++) for (var y = 0; y < 4; y++) { if (x == y) identityMatrix.Set (x, y, 1.0); else identityMatrix.Set (x, y, 0.0); } var transf = pfcCreate ("pfcTransform3D").Create (identityMatrix); // 取得目前的工作目錄 var currentDir = session.getCurrentDirectory(); // 以目前已開檔, 作為 model var model = session.CurrentModel; // 查驗有無 model, 或 model 類別是否為組立件 if (model == void null || model.Type != pfcCreate ("pfcModelType").MDL_ASSEMBLY) throw new Error (0, "Current model is not an assembly."); var assembly = model; var descr = pfcCreate ("pfcModelDescriptor").CreateFromFileName ("link1.prt"); for (var partnum = 0; partnum < 20; partnum++) { // 若 link1.prt 在 session 則直接取用 var componentModel = session.GetModelFromDescr (descr); // 若 link1.prt 不在 session 則從工作目錄中載入 session var componentModel = session.RetrieveModel(descr); // 若 link1.prt 已經在 session 則放入組立檔中 if (componentModel != void null) { var asmcomp = assembly.AssembleComponent (componentModel, transf); } // 取得 assembly 項下的元件 id, 因為只有一個零件, 採用 index 0 取出其 featID var components = assembly.ListFeaturesByType(true, pfcCreate ("pfcFeatureType").FEATTYPE_COMPONENT); var featID = components.Item(0).Id; document.write("目前 featID:"+featID); var ids = pfcCreate ("intseq"); ids.Append(featID+partnum); // 在 assembly 模型中建立子零件所對應的路徑 var subPath = pfcCreate ("MpfcAssembly").CreateComponentPath( assembly, ids ); document.write("id 為:"+subPath.ComponentIds(0)); subassembly = subPath.Leaf; // 設定組立檔中的三個定位面, 注意內定名稱與 Pro/E WF 中的 ASM_D_FRONT 不同, 而是 ASM_FRONT var asmDatums = new Array ("A_3", "TOP", "ASM_RIGHT"); // 設定零件檔中的三個定位面, 名稱與 Pro/E WF 中相同 var compDatums = new Array ("A_4", "BUTTOM", "RIGHT"); // 各參考組立關係陣列 var relation = new Array (pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_ALIGN, pfcCreate ("pfcComponentConstraintType").ASM_CONSTRAINT_MATE); var relationItem = new Array(pfcCreate("pfcModelItemType").ITEM_AXIS,pfcCreate("pfcModelItemType").ITEM_SURFACE); // 建立約束條件變數 var constrs = pfcCreate ("pfcComponentConstraints"); // 利用迴圈分別約束組立與零件檔中的三個定位平面 for (var i = 0; i < 2; i++) { // 設定組立參考面 var asmItem = subassembly.GetItemByName (relationItem[i], asmDatums [i]); // 若無對應的組立參考面, 則啟用互動式平面選擇表單 flag if (asmItem == void null) { interactFlag = true; continue; } // 設定零件參考面 var compItem = componentModel.GetItemByName (relationItem[i], compDatums [i]); // 若無對應的零件參考面, 則啟用互動式平面選擇表單 flag if (compItem == void null) { interactFlag = true; continue; } // 採用互動式設定相關的變數 var MpfcSelect = pfcCreate ("MpfcSelect"); var asmSel = MpfcSelect.CreateModelItemSelection (asmItem, subPath); var compSel = MpfcSelect.CreateModelItemSelection (compItem, void null); var constr = pfcCreate ("pfcComponentConstraint").Create (relation[i]); constr.AssemblyReference = asmSel; constr.ComponentReference = compSel; // static pfcConstraintAttributes Create (boolean Force, boolean Ignore) // 必須 Force execution of this constraint 才會抑制 comp_placement_assumptions 為 yes 的作動? constr.Attributes = pfcCreate ("pfcConstraintAttributes").Create (true, false); // 將互動選擇相關資料, 附加在程式約束變數之後 constrs.Append (constr); } // 設定組立約束條件 asmcomp.SetConstraints (constrs, void null); try { document.write("目前 Creo 的工作目錄:<br />"+currentDir); } catch (err) { alert ("Exception occurred: "+pfcGetExceptionType (err)); } } assembly.Regenerate (void null); session.GetModelWindow (assembly).Repaint(); </script> </body> </html> ''' return outstring
gpl-2.0
[ 646, 13397, 199, 199, 3, 10469, 223, 248, 9729, 445, 28211, 23, 10469, 95, 253, 9051, 99, 8106, 20766, 164, 123, 103, 199, 533, 445, 28211, 23, 8, 785, 304, 272, 327, 7094, 239, 227, 23767, 227, 9051, 103, 11428, 1478, 7094, 121, 244, 15348, 237, 166, 249, 102, 19073, 235, 8106, 30664, 21041, 25056, 116, 12609, 272, 768, 23438, 14, 20586, 272, 347, 1478, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 32508, 275, 1449, 199, 14333, 248, 9729, 6927, 7695, 33, 7094, 236, 243, 28956, 15348, 231, 31333, 231, 24233, 8106, 286, 7406, 23, 7094, 231, 229, 23767, 227, 30664, 21041, 31834, 234, 23460, 121, 164, 115, 111, 166, 8774, 12, 221, 23681, 24233, 24889, 644, 713, 221, 8106, 5498, 8698, 234, 248, 25056, 116, 12609, 8379, 101, 10270, 118, 21455, 3289, 7082, 199, 25273, 10469, 223, 248, 29655, 95, 17797, 95, 11428, 15545, 117, 15348, 236, 14333, 97, 23767, 239, 12, 9065, 223, 235, 26398, 253, 164, 115, 111, 30899, 223, 8106, 23767, 244, 15348, 236, 14333, 97, 23767, 239, 334, 14333, 248, 9372, 163, 107, 114, 24889, 3517, 9065, 102, 120, 21482, 97, 9, 10541, 199, 28, 65, 4369, 628, 11477, 17, 1743, 2866, 643, 21, 8853, 256, 97, 24302, 166, 105, 243, 6075, 226, 24814, 164, 118, 104, 11987, 245, 1108, 65, 13661, 15348, 119, 15150, 117, 14082, 233, 24814, 282, 12, 330, 12, 286, 21528, 3289, 21671, 3289, 7082, 199, 28, 65, 4369, 628, 13672, 1700, 17, 1743, 2866, 643, 21, 7094, 250, 250, 14333, 97, 31333, 124, 23767, 227, 21341, 234, 1108, 65, 2535, 3289, 21671, 3289, 7082, 199, 165, 105, 234, 164, 96, 119, 20766, 24233, 32551, 14333, 97, 31333, 124, 30555, 10310, 121, 812, 11254, 4219, 15, 13672, 1700, 9112, 250, 107, 166, 235, 227, 17088, 12, 221, 4344, 243, 31834, 234, 29548, 254, 30413, 119, 23460, 122, 9750, 79, 9112, 114, 227, 21341, 234, 163, 104, 243, 31333, 231, 21455, 3289, 7082, 199, 28, 65, 4369, 9555, 1986, 15, 13672, 1700, 14, 23, 90, 1743, 13672, 1700, 14, 23, 90, 1108, 65, 13661, 163, 120, 240, 166, 121, 255, 6075, 112, 166, 236, 114, 29846, 16888, 1275, 23, 90, 8853, 104, 243, 31333, 231, 21528, 3289, 7082, 199, 2344, 267, 372, 32508, 2286, 1449, 5591, 7094, 224, 230, 162, 100, 225, 17797, 95, 11428, 24233, 32551, 18019, 238, 26546, 105, 2286, 492, 18572, 14, 2866, 643, 21, 465, 286, 7406, 21, 272, 1738, 14, 2866, 643, 21, 275, 286, 7406, 21, 14, 7695, 1254, 21, 342, 2286, 7094, 232, 230, 30664, 21041, 29548, 254, 162, 234, 244, 19073, 235, 12, 221, 25521, 23681, 9051, 103, 11428, 1182, 2866, 643, 21, 15, 11477, 17, 7094, 240, 121, 6075, 105, 15977, 122, 21041, 25056, 116, 12609, 272, 1449, 272, 768, 23438, 14, 20586, 272, 347, 15681, 17, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1449, 272, 5001, 7094, 224, 230, 162, 100, 225, 22274, 27345, 104, 12609, 10862, 242, 31834, 234, 19431, 118, 20766, 22982, 115, 15054, 163, 104, 243, 31333, 231, 272, 5001, 9065, 234, 99, 25238, 106, 4344, 232, 25624, 117, 18236, 24889, 3055, 12, 9065, 95, 102, 29875, 119, 162, 226, 228, 25624, 232, 18236, 2351, 12, 221, 11046, 229, 9729, 19594, 27513, 108, 29875, 119, 272, 5001, 2203, 9112, 18760, 1402, 1551, 372, 272, 2729, 2203, 275, 2213, 14, 8796, 76, 14, 8796, 76, 45, 5030, 4299, 480, 1219, 274, 63, 21, 14, 80, 2591, 401, 298, 86, 11254, 2791, 401, 3055, 2736, 272, 340, 19452, 3292, 14, 3694, 9, 469, 267, 10459, 480, 8796, 76, 45, 5030, 4299, 3405, 1689, 435, 2203, 14, 547, 3034, 435, 6099, 3547, 272, 789, 272, 5001, 15348, 230, 2165, 37, 7094, 254, 116, 12609, 166, 249, 237, 163, 107, 114, 20278, 256, 24889, 14082, 233, 24814, 2351, 272, 2729, 2351, 275, 299, 3003, 1002, 919, 654, 3552, 7303, 272, 5001, 7094, 251, 102, 18019, 245, 164, 104, 246, 17088, 10862, 242, 31834, 234, 22982, 115, 15054, 163, 104, 243, 31333, 231, 12, 221, 4344, 100, 4344, 243, 27513, 108, 29875, 119, 22914, 25439, 229, 272, 2729, 4353, 275, 2351, 14, 4299, 1173, 8, 24419, 2499, 480, 24419, 1685, 4311, 3471, 2499, 2532, 7733, 480, 1219, 274, 63, 21, 14, 80, 2591, 2237, 27, 272, 2729, 18609, 275, 2351, 14, 1002, 1685, 480, 1219, 274, 63, 21, 14, 80, 2591, 401, 24419, 2499, 480, 24419, 1685, 804, 3471, 5127, 44, 63, 14848, 2736, 267, 1449, 267, 32508, 275, 1449, 272, 31513, 16556, 3517, 30, 5591, 665, 1360, 30, 272, 665, 2993, 30, 272, 665, 2024, 1455, 13, 20146, 628, 1317, 13, 466, 2, 1564, 628, 505, 15, 1360, 27, 6043, 29, 1624, 13, 24, 1743, 272, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 1986, 15, 2520, 1073, 15, 8589, 15, 74, 1579, 15, 24419, 7535, 14, 3596, 10070, 1579, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 1986, 15, 2520, 1073, 15, 8589, 15, 74, 1579, 15, 24419, 4720, 22787, 14, 3596, 10070, 1579, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 1986, 15, 2520, 1073, 15, 8589, 15, 74, 1579, 15, 24419, 7004, 24927, 22787, 14, 3596, 10070, 1579, 30, 272, 3068, 2993, 30, 272, 665, 2030, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 1743, 199, 1391, 2351, 275, 299, 3003, 1002, 919, 654, 3552, 334, 2736, 199, 199, 501, 221, 23681, 31869, 27284, 16570, 31834, 234, 29548, 254, 8106, 163, 104, 243, 31333, 231, 24889, 18609, 1402, 199, 501, 367, 3301, 199, 1391, 18609, 275, 2351, 14, 5639, 1685, 27, 199, 199, 1391, 282, 12, 330, 12, 286, 12, 284, 12, 1335, 12, 282, 1110, 12, 330, 1110, 12, 286, 1110, 12, 3301, 12, 2338, 27, 199, 501, 7094, 109, 230, 29887, 162, 9809, 163, 104, 243, 17088, 8106, 282, 9065, 107, 233, 24814, 20278, 256, 24889, 18910, 221, 17088, 8106, 282, 9065, 107, 233, 24814, 199, 65, 275, 18609, 14, 1002, 4098, 480, 65, 3547, 199, 66, 275, 18609, 14, 1002, 4098, 480, 66, 3547, 199, 67, 275, 18609, 14, 1002, 4098, 480, 67, 3547, 199, 2405, 29, 16, 27, 199, 835, 29, 16, 27 ]
[ 13397, 199, 199, 3, 10469, 223, 248, 9729, 445, 28211, 23, 10469, 95, 253, 9051, 99, 8106, 20766, 164, 123, 103, 199, 533, 445, 28211, 23, 8, 785, 304, 272, 327, 7094, 239, 227, 23767, 227, 9051, 103, 11428, 1478, 7094, 121, 244, 15348, 237, 166, 249, 102, 19073, 235, 8106, 30664, 21041, 25056, 116, 12609, 272, 768, 23438, 14, 20586, 272, 347, 1478, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 32508, 275, 1449, 199, 14333, 248, 9729, 6927, 7695, 33, 7094, 236, 243, 28956, 15348, 231, 31333, 231, 24233, 8106, 286, 7406, 23, 7094, 231, 229, 23767, 227, 30664, 21041, 31834, 234, 23460, 121, 164, 115, 111, 166, 8774, 12, 221, 23681, 24233, 24889, 644, 713, 221, 8106, 5498, 8698, 234, 248, 25056, 116, 12609, 8379, 101, 10270, 118, 21455, 3289, 7082, 199, 25273, 10469, 223, 248, 29655, 95, 17797, 95, 11428, 15545, 117, 15348, 236, 14333, 97, 23767, 239, 12, 9065, 223, 235, 26398, 253, 164, 115, 111, 30899, 223, 8106, 23767, 244, 15348, 236, 14333, 97, 23767, 239, 334, 14333, 248, 9372, 163, 107, 114, 24889, 3517, 9065, 102, 120, 21482, 97, 9, 10541, 199, 28, 65, 4369, 628, 11477, 17, 1743, 2866, 643, 21, 8853, 256, 97, 24302, 166, 105, 243, 6075, 226, 24814, 164, 118, 104, 11987, 245, 1108, 65, 13661, 15348, 119, 15150, 117, 14082, 233, 24814, 282, 12, 330, 12, 286, 21528, 3289, 21671, 3289, 7082, 199, 28, 65, 4369, 628, 13672, 1700, 17, 1743, 2866, 643, 21, 7094, 250, 250, 14333, 97, 31333, 124, 23767, 227, 21341, 234, 1108, 65, 2535, 3289, 21671, 3289, 7082, 199, 165, 105, 234, 164, 96, 119, 20766, 24233, 32551, 14333, 97, 31333, 124, 30555, 10310, 121, 812, 11254, 4219, 15, 13672, 1700, 9112, 250, 107, 166, 235, 227, 17088, 12, 221, 4344, 243, 31834, 234, 29548, 254, 30413, 119, 23460, 122, 9750, 79, 9112, 114, 227, 21341, 234, 163, 104, 243, 31333, 231, 21455, 3289, 7082, 199, 28, 65, 4369, 9555, 1986, 15, 13672, 1700, 14, 23, 90, 1743, 13672, 1700, 14, 23, 90, 1108, 65, 13661, 163, 120, 240, 166, 121, 255, 6075, 112, 166, 236, 114, 29846, 16888, 1275, 23, 90, 8853, 104, 243, 31333, 231, 21528, 3289, 7082, 199, 2344, 267, 372, 32508, 2286, 1449, 5591, 7094, 224, 230, 162, 100, 225, 17797, 95, 11428, 24233, 32551, 18019, 238, 26546, 105, 2286, 492, 18572, 14, 2866, 643, 21, 465, 286, 7406, 21, 272, 1738, 14, 2866, 643, 21, 275, 286, 7406, 21, 14, 7695, 1254, 21, 342, 2286, 7094, 232, 230, 30664, 21041, 29548, 254, 162, 234, 244, 19073, 235, 12, 221, 25521, 23681, 9051, 103, 11428, 1182, 2866, 643, 21, 15, 11477, 17, 7094, 240, 121, 6075, 105, 15977, 122, 21041, 25056, 116, 12609, 272, 1449, 272, 768, 23438, 14, 20586, 272, 347, 15681, 17, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1449, 272, 5001, 7094, 224, 230, 162, 100, 225, 22274, 27345, 104, 12609, 10862, 242, 31834, 234, 19431, 118, 20766, 22982, 115, 15054, 163, 104, 243, 31333, 231, 272, 5001, 9065, 234, 99, 25238, 106, 4344, 232, 25624, 117, 18236, 24889, 3055, 12, 9065, 95, 102, 29875, 119, 162, 226, 228, 25624, 232, 18236, 2351, 12, 221, 11046, 229, 9729, 19594, 27513, 108, 29875, 119, 272, 5001, 2203, 9112, 18760, 1402, 1551, 372, 272, 2729, 2203, 275, 2213, 14, 8796, 76, 14, 8796, 76, 45, 5030, 4299, 480, 1219, 274, 63, 21, 14, 80, 2591, 401, 298, 86, 11254, 2791, 401, 3055, 2736, 272, 340, 19452, 3292, 14, 3694, 9, 469, 267, 10459, 480, 8796, 76, 45, 5030, 4299, 3405, 1689, 435, 2203, 14, 547, 3034, 435, 6099, 3547, 272, 789, 272, 5001, 15348, 230, 2165, 37, 7094, 254, 116, 12609, 166, 249, 237, 163, 107, 114, 20278, 256, 24889, 14082, 233, 24814, 2351, 272, 2729, 2351, 275, 299, 3003, 1002, 919, 654, 3552, 7303, 272, 5001, 7094, 251, 102, 18019, 245, 164, 104, 246, 17088, 10862, 242, 31834, 234, 22982, 115, 15054, 163, 104, 243, 31333, 231, 12, 221, 4344, 100, 4344, 243, 27513, 108, 29875, 119, 22914, 25439, 229, 272, 2729, 4353, 275, 2351, 14, 4299, 1173, 8, 24419, 2499, 480, 24419, 1685, 4311, 3471, 2499, 2532, 7733, 480, 1219, 274, 63, 21, 14, 80, 2591, 2237, 27, 272, 2729, 18609, 275, 2351, 14, 1002, 1685, 480, 1219, 274, 63, 21, 14, 80, 2591, 401, 24419, 2499, 480, 24419, 1685, 804, 3471, 5127, 44, 63, 14848, 2736, 267, 1449, 267, 32508, 275, 1449, 272, 31513, 16556, 3517, 30, 5591, 665, 1360, 30, 272, 665, 2993, 30, 272, 665, 2024, 1455, 13, 20146, 628, 1317, 13, 466, 2, 1564, 628, 505, 15, 1360, 27, 6043, 29, 1624, 13, 24, 1743, 272, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 1986, 15, 2520, 1073, 15, 8589, 15, 74, 1579, 15, 24419, 7535, 14, 3596, 10070, 1579, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 1986, 15, 2520, 1073, 15, 8589, 15, 74, 1579, 15, 24419, 4720, 22787, 14, 3596, 10070, 1579, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 2, 2928, 9555, 1986, 15, 2520, 1073, 15, 8589, 15, 74, 1579, 15, 24419, 7004, 24927, 22787, 14, 3596, 10070, 1579, 30, 272, 3068, 2993, 30, 272, 665, 2030, 30, 272, 665, 1579, 730, 628, 505, 15, 9554, 1743, 199, 1391, 2351, 275, 299, 3003, 1002, 919, 654, 3552, 334, 2736, 199, 199, 501, 221, 23681, 31869, 27284, 16570, 31834, 234, 29548, 254, 8106, 163, 104, 243, 31333, 231, 24889, 18609, 1402, 199, 501, 367, 3301, 199, 1391, 18609, 275, 2351, 14, 5639, 1685, 27, 199, 199, 1391, 282, 12, 330, 12, 286, 12, 284, 12, 1335, 12, 282, 1110, 12, 330, 1110, 12, 286, 1110, 12, 3301, 12, 2338, 27, 199, 501, 7094, 109, 230, 29887, 162, 9809, 163, 104, 243, 17088, 8106, 282, 9065, 107, 233, 24814, 20278, 256, 24889, 18910, 221, 17088, 8106, 282, 9065, 107, 233, 24814, 199, 65, 275, 18609, 14, 1002, 4098, 480, 65, 3547, 199, 66, 275, 18609, 14, 1002, 4098, 480, 66, 3547, 199, 67, 275, 18609, 14, 1002, 4098, 480, 67, 3547, 199, 2405, 29, 16, 27, 199, 835, 29, 16, 27, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cnsoft/kbengine-cocos2dx
kbe/src/lib/python/Lib/test/mock_socket.py
57
3149
"""Mock socket module used by the smtpd and smtplib tests. """ # imported for _GLOBAL_DEFAULT_TIMEOUT import socket as socket_module # Mock socket module _defaulttimeout = None _reply_data = None # This is used to queue up data to be read through socket.makefile, typically # *before* the socket object is even created. It is intended to handle a single # line which the socket will feed on recv() or makefile(). def reply_with(line): global _reply_data _reply_data = line class MockFile: """Mock file object returned by MockSocket.makefile(). """ def __init__(self, lines): self.lines = lines def readline(self): return self.lines.pop(0) + b'\r\n' def close(self): pass class MockSocket: """Mock socket object used by smtpd and smtplib tests. """ def __init__(self): global _reply_data self.output = [] self.lines = [] if _reply_data: self.lines.append(_reply_data) _reply_data = None self.conn = None self.timeout = None def queue_recv(self, line): self.lines.append(line) def recv(self, bufsize, flags=None): data = self.lines.pop(0) + b'\r\n' return data def fileno(self): return 0 def settimeout(self, timeout): if timeout is None: self.timeout = _defaulttimeout else: self.timeout = timeout def gettimeout(self): return self.timeout def setsockopt(self, level, optname, value): pass def getsockopt(self, level, optname, buflen=None): return 0 def bind(self, address): pass def accept(self): self.conn = MockSocket() return self.conn, 'c' def getsockname(self): return ('0.0.0.0', 0) def setblocking(self, flag): pass def listen(self, backlog): pass def makefile(self, mode='r', bufsize=-1): handle = MockFile(self.lines) return handle def sendall(self, buffer, flags=None): self.last = data self.output.append(data) return len(data) def send(self, data, flags=None): self.last = data self.output.append(data) return len(data) def getpeername(self): return 'peer' def close(self): pass def socket(family=None, type=None, proto=None): return MockSocket() def create_connection(address, timeout=socket_module._GLOBAL_DEFAULT_TIMEOUT): try: int_port = int(address[1]) except ValueError: raise error ms = MockSocket() if timeout is socket_module._GLOBAL_DEFAULT_TIMEOUT: timeout = getdefaulttimeout() ms.settimeout(timeout) return ms def setdefaulttimeout(timeout): global _defaulttimeout _defaulttimeout = timeout def getdefaulttimeout(): return _defaulttimeout def getfqdn(): return "" def gethostname(): pass def gethostbyname(name): return "" class gaierror(Exception): pass class error(Exception): pass # Constants AF_INET = None SOCK_STREAM = None SOL_SOCKET = None SO_REUSEADDR = None
lgpl-3.0
[ 624, 3346, 2838, 859, 1202, 701, 314, 14400, 68, 436, 30475, 2295, 14, 199, 624, 199, 199, 3, 8439, 367, 485, 13808, 63, 3472, 63, 8899, 199, 646, 2838, 465, 2838, 63, 578, 199, 199, 3, 4420, 2838, 859, 199, 63, 885, 2593, 275, 488, 199, 63, 8102, 63, 576, 275, 488, 199, 199, 3, 961, 365, 1202, 370, 4126, 1536, 666, 370, 506, 1586, 4012, 2838, 14, 13941, 12, 13609, 199, 3, 627, 5182, 10, 314, 2838, 909, 365, 2755, 2737, 14, 2779, 365, 11619, 370, 2429, 282, 2849, 199, 3, 1004, 1314, 314, 2838, 911, 4733, 641, 11904, 342, 503, 16818, 1252, 199, 318, 9351, 63, 1045, 8, 604, 304, 272, 2288, 485, 8102, 63, 576, 272, 485, 8102, 63, 576, 275, 1004, 421, 199, 533, 4420, 1173, 26, 272, 408, 3346, 570, 909, 2138, 701, 4420, 3869, 14, 13941, 1252, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2385, 304, 267, 291, 14, 1278, 275, 2385, 272, 347, 14441, 8, 277, 304, 267, 372, 291, 14, 1278, 14, 1935, 8, 16, 9, 435, 330, 1154, 82, 60, 78, 7, 272, 347, 4002, 8, 277, 304, 267, 986, 421, 199, 533, 4420, 3869, 26, 272, 408, 3346, 2838, 909, 1202, 701, 14400, 68, 436, 30475, 2295, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 2288, 485, 8102, 63, 576, 267, 291, 14, 1199, 275, 942, 267, 291, 14, 1278, 275, 942, 267, 340, 485, 8102, 63, 576, 26, 288, 291, 14, 1278, 14, 740, 1547, 8102, 63, 576, 9, 288, 485, 8102, 63, 576, 275, 488, 267, 291, 14, 1631, 275, 488, 267, 291, 14, 2593, 275, 488, 339, 347, 4126, 63, 7637, 8, 277, 12, 1004, 304, 267, 291, 14, 1278, 14, 740, 8, 604, 9, 339, 347, 11904, 8, 277, 12, 17080, 12, 3285, 29, 403, 304, 267, 666, 275, 291, 14, 1278, 14, 1935, 8, 16, 9, 435, 330, 1154, 82, 60, 78, 7, 267, 372, 666, 339, 347, 25255, 8, 277, 304, 267, 372, 378, 339, 347, 663, 2593, 8, 277, 12, 2653, 304, 267, 340, 2653, 365, 488, 26, 288, 291, 14, 2593, 275, 485, 885, 2593, 267, 587, 26, 288, 291, 14, 2593, 275, 2653, 339, 347, 664, 2593, 8, 277, 304, 267, 372, 291, 14, 2593, 339, 347, 663, 5096, 2992, 8, 277, 12, 2166, 12, 2450, 354, 12, 574, 304, 267, 986, 339, 347, 664, 5096, 2992, 8, 277, 12, 2166, 12, 2450, 354, 12, 4123, 552, 29, 403, 304, 267, 372, 378, 339, 347, 5398, 8, 277, 12, 2287, 304, 267, 986, 339, 347, 4729, 8, 277, 304, 267, 291, 14, 1631, 275, 4420, 3869, 342, 267, 372, 291, 14, 1631, 12, 283, 67, 7, 339, 347, 664, 5096, 354, 8, 277, 304, 267, 372, 661, 16, 14, 16, 14, 16, 14, 16, 297, 378, 9, 339, 347, 663, 13091, 8, 277, 12, 3305, 304, 267, 986, 339, 347, 6938, 8, 277, 12, 1771, 793, 304, 267, 986, 339, 347, 16818, 8, 277, 12, 818, 534, 82, 297, 17080, 4022, 17, 304, 267, 2429, 275, 4420, 1173, 8, 277, 14, 1278, 9, 267, 372, 2429, 339, 347, 3222, 452, 8, 277, 12, 3335, 12, 3285, 29, 403, 304, 267, 291, 14, 2019, 275, 666, 267, 291, 14, 1199, 14, 740, 8, 576, 9, 267, 372, 822, 8, 576, 9, 339, 347, 3222, 8, 277, 12, 666, 12, 3285, 29, 403, 304, 267, 291, 14, 2019, 275, 666, 267, 291, 14, 1199, 14, 740, 8, 576, 9, 267, 372, 822, 8, 576, 9, 339, 347, 664, 7866, 354, 8, 277, 304, 267, 372, 283, 7866, 7, 339, 347, 4002, 8, 277, 304, 267, 986, 421, 199, 318, 2838, 8, 6606, 29, 403, 12, 730, 29, 403, 12, 4104, 29, 403, 304, 272, 372, 4420, 3869, 342, 421, 199, 318, 1218, 63, 2105, 8, 1562, 12, 2653, 29, 3450, 63, 578, 423, 13808, 63, 3472, 63, 8899, 304, 272, 862, 26, 267, 1109, 63, 719, 275, 1109, 8, 1562, 59, 17, 566, 272, 871, 1722, 26, 267, 746, 1125, 272, 6605, 275, 4420, 3869, 342, 272, 340, 2653, 365, 2838, 63, 578, 423, 13808, 63, 3472, 63, 8899, 26, 267, 2653, 275, 664, 885, 2593, 342, 272, 6605, 14, 24630, 8, 2593, 9, 272, 372, 6605, 421, 199, 318, 29408, 2593, 8, 2593, 304, 272, 2288, 485, 885, 2593, 272, 485, 885, 2593, 275, 2653, 421, 199, 318, 664, 885, 2593, 837, 272, 372, 485, 885, 2593, 421, 199, 318, 664, 18364, 837, 272, 372, 3087, 421, 199, 318, 2312, 15157, 354, 837, 272, 986, 421, 199, 318, 2312, 15157, 24810, 8, 354, 304, 272, 372, 3087, 421, 199, 533, 486, 5789, 705, 8, 1726, 304, 272, 986, 421, 199, 533, 1125, 8, 1726, 304, 272, 986, 421, 199, 3, 22296, 199, 5699, 63, 11367, 275, 488, 199, 9469, 63, 9484, 275, 488, 199, 15096, 63, 17462, 275, 488, 199, 4118, 63, 907, 4701, 7803, 275, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3346, 2838, 859, 1202, 701, 314, 14400, 68, 436, 30475, 2295, 14, 199, 624, 199, 199, 3, 8439, 367, 485, 13808, 63, 3472, 63, 8899, 199, 646, 2838, 465, 2838, 63, 578, 199, 199, 3, 4420, 2838, 859, 199, 63, 885, 2593, 275, 488, 199, 63, 8102, 63, 576, 275, 488, 199, 199, 3, 961, 365, 1202, 370, 4126, 1536, 666, 370, 506, 1586, 4012, 2838, 14, 13941, 12, 13609, 199, 3, 627, 5182, 10, 314, 2838, 909, 365, 2755, 2737, 14, 2779, 365, 11619, 370, 2429, 282, 2849, 199, 3, 1004, 1314, 314, 2838, 911, 4733, 641, 11904, 342, 503, 16818, 1252, 199, 318, 9351, 63, 1045, 8, 604, 304, 272, 2288, 485, 8102, 63, 576, 272, 485, 8102, 63, 576, 275, 1004, 421, 199, 533, 4420, 1173, 26, 272, 408, 3346, 570, 909, 2138, 701, 4420, 3869, 14, 13941, 1252, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2385, 304, 267, 291, 14, 1278, 275, 2385, 272, 347, 14441, 8, 277, 304, 267, 372, 291, 14, 1278, 14, 1935, 8, 16, 9, 435, 330, 1154, 82, 60, 78, 7, 272, 347, 4002, 8, 277, 304, 267, 986, 421, 199, 533, 4420, 3869, 26, 272, 408, 3346, 2838, 909, 1202, 701, 14400, 68, 436, 30475, 2295, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 2288, 485, 8102, 63, 576, 267, 291, 14, 1199, 275, 942, 267, 291, 14, 1278, 275, 942, 267, 340, 485, 8102, 63, 576, 26, 288, 291, 14, 1278, 14, 740, 1547, 8102, 63, 576, 9, 288, 485, 8102, 63, 576, 275, 488, 267, 291, 14, 1631, 275, 488, 267, 291, 14, 2593, 275, 488, 339, 347, 4126, 63, 7637, 8, 277, 12, 1004, 304, 267, 291, 14, 1278, 14, 740, 8, 604, 9, 339, 347, 11904, 8, 277, 12, 17080, 12, 3285, 29, 403, 304, 267, 666, 275, 291, 14, 1278, 14, 1935, 8, 16, 9, 435, 330, 1154, 82, 60, 78, 7, 267, 372, 666, 339, 347, 25255, 8, 277, 304, 267, 372, 378, 339, 347, 663, 2593, 8, 277, 12, 2653, 304, 267, 340, 2653, 365, 488, 26, 288, 291, 14, 2593, 275, 485, 885, 2593, 267, 587, 26, 288, 291, 14, 2593, 275, 2653, 339, 347, 664, 2593, 8, 277, 304, 267, 372, 291, 14, 2593, 339, 347, 663, 5096, 2992, 8, 277, 12, 2166, 12, 2450, 354, 12, 574, 304, 267, 986, 339, 347, 664, 5096, 2992, 8, 277, 12, 2166, 12, 2450, 354, 12, 4123, 552, 29, 403, 304, 267, 372, 378, 339, 347, 5398, 8, 277, 12, 2287, 304, 267, 986, 339, 347, 4729, 8, 277, 304, 267, 291, 14, 1631, 275, 4420, 3869, 342, 267, 372, 291, 14, 1631, 12, 283, 67, 7, 339, 347, 664, 5096, 354, 8, 277, 304, 267, 372, 661, 16, 14, 16, 14, 16, 14, 16, 297, 378, 9, 339, 347, 663, 13091, 8, 277, 12, 3305, 304, 267, 986, 339, 347, 6938, 8, 277, 12, 1771, 793, 304, 267, 986, 339, 347, 16818, 8, 277, 12, 818, 534, 82, 297, 17080, 4022, 17, 304, 267, 2429, 275, 4420, 1173, 8, 277, 14, 1278, 9, 267, 372, 2429, 339, 347, 3222, 452, 8, 277, 12, 3335, 12, 3285, 29, 403, 304, 267, 291, 14, 2019, 275, 666, 267, 291, 14, 1199, 14, 740, 8, 576, 9, 267, 372, 822, 8, 576, 9, 339, 347, 3222, 8, 277, 12, 666, 12, 3285, 29, 403, 304, 267, 291, 14, 2019, 275, 666, 267, 291, 14, 1199, 14, 740, 8, 576, 9, 267, 372, 822, 8, 576, 9, 339, 347, 664, 7866, 354, 8, 277, 304, 267, 372, 283, 7866, 7, 339, 347, 4002, 8, 277, 304, 267, 986, 421, 199, 318, 2838, 8, 6606, 29, 403, 12, 730, 29, 403, 12, 4104, 29, 403, 304, 272, 372, 4420, 3869, 342, 421, 199, 318, 1218, 63, 2105, 8, 1562, 12, 2653, 29, 3450, 63, 578, 423, 13808, 63, 3472, 63, 8899, 304, 272, 862, 26, 267, 1109, 63, 719, 275, 1109, 8, 1562, 59, 17, 566, 272, 871, 1722, 26, 267, 746, 1125, 272, 6605, 275, 4420, 3869, 342, 272, 340, 2653, 365, 2838, 63, 578, 423, 13808, 63, 3472, 63, 8899, 26, 267, 2653, 275, 664, 885, 2593, 342, 272, 6605, 14, 24630, 8, 2593, 9, 272, 372, 6605, 421, 199, 318, 29408, 2593, 8, 2593, 304, 272, 2288, 485, 885, 2593, 272, 485, 885, 2593, 275, 2653, 421, 199, 318, 664, 885, 2593, 837, 272, 372, 485, 885, 2593, 421, 199, 318, 664, 18364, 837, 272, 372, 3087, 421, 199, 318, 2312, 15157, 354, 837, 272, 986, 421, 199, 318, 2312, 15157, 24810, 8, 354, 304, 272, 372, 3087, 421, 199, 533, 486, 5789, 705, 8, 1726, 304, 272, 986, 421, 199, 533, 1125, 8, 1726, 304, 272, 986, 421, 199, 3, 22296, 199, 5699, 63, 11367, 275, 488, 199, 9469, 63, 9484, 275, 488, 199, 15096, 63, 17462, 275, 488, 199, 4118, 63, 907, 4701, 7803, 275, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ramyfarid922/Quiz-Program
vendor/bundle/ruby/2.2.0/gems/libv8-3.16.14.7/vendor/gyp/pylib/gyp/easy_xml.py
1049
4803
# Copyright (c) 2011 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. import re import os def XmlToString(content, encoding='utf-8', pretty=False): """ Writes the XML content to disk, touching the file only if it has changed. Visual Studio files have a lot of pre-defined structures. This function makes it easy to represent these structures as Python data structures, instead of having to create a lot of function calls. Each XML element of the content is represented as a list composed of: 1. The name of the element, a string, 2. The attributes of the element, a dictionary (optional), and 3+. The content of the element, if any. Strings are simple text nodes and lists are child elements. Example 1: <test/> becomes ['test'] Example 2: <myelement a='value1' b='value2'> <childtype>This is</childtype> <childtype>it!</childtype> </myelement> becomes ['myelement', {'a':'value1', 'b':'value2'}, ['childtype', 'This is'], ['childtype', 'it!'], ] Args: content: The structured content to be converted. encoding: The encoding to report on the first XML line. pretty: True if we want pretty printing with indents and new lines. Returns: The XML content as a string. """ # We create a huge list of all the elements of the file. xml_parts = ['<?xml version="1.0" encoding="%s"?>' % encoding] if pretty: xml_parts.append('\n') _ConstructContentList(xml_parts, content, pretty) # Convert it to a string return ''.join(xml_parts) def _ConstructContentList(xml_parts, specification, pretty, level=0): """ Appends the XML parts corresponding to the specification. Args: xml_parts: A list of XML parts to be appended to. specification: The specification of the element. See EasyXml docs. pretty: True if we want pretty printing with indents and new lines. level: Indentation level. """ # The first item in a specification is the name of the element. if pretty: indentation = ' ' * level new_line = '\n' else: indentation = '' new_line = '' name = specification[0] if not isinstance(name, str): raise Exception('The first item of an EasyXml specification should be ' 'a string. Specification was ' + str(specification)) xml_parts.append(indentation + '<' + name) # Optionally in second position is a dictionary of the attributes. rest = specification[1:] if rest and isinstance(rest[0], dict): for at, val in sorted(rest[0].iteritems()): xml_parts.append(' %s="%s"' % (at, _XmlEscape(val, attr=True))) rest = rest[1:] if rest: xml_parts.append('>') all_strings = reduce(lambda x, y: x and isinstance(y, str), rest, True) multi_line = not all_strings if multi_line and new_line: xml_parts.append(new_line) for child_spec in rest: # If it's a string, append a text node. # Otherwise recurse over that child definition if isinstance(child_spec, str): xml_parts.append(_XmlEscape(child_spec)) else: _ConstructContentList(xml_parts, child_spec, pretty, level + 1) if multi_line and indentation: xml_parts.append(indentation) xml_parts.append('</%s>%s' % (name, new_line)) else: xml_parts.append('/>%s' % new_line) def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False, win32=False): """ Writes the XML content to disk, touching the file only if it has changed. Args: content: The structured content to be written. path: Location of the file. encoding: The encoding to report on the first line of the XML file. pretty: True if we want pretty printing with indents and new lines. """ xml_string = XmlToString(content, encoding, pretty) if win32 and os.linesep != '\r\n': xml_string = xml_string.replace('\n', '\r\n') # Get the old content try: f = open(path, 'r') existing = f.read() f.close() except: existing = None # It has changed, write it if existing != xml_string: f = open(path, 'w') f.write(xml_string) f.close() _xml_escape_map = { '"': '&quot;', "'": '&apos;', '<': '&lt;', '>': '&gt;', '&': '&amp;', '\n': '&#xA;', '\r': '&#xD;', } _xml_escape_re = re.compile( "(%s)" % "|".join(map(re.escape, _xml_escape_map.keys()))) def _XmlEscape(value, attr=False): """ Escape a string for inclusion in XML.""" def replace(match): m = match.string[match.start() : match.end()] # don't replace single quotes in attrs if attr and m == "'": return m return _xml_escape_map[m] return _xml_escape_re.sub(replace, value)
cc0-1.0
[ 3, 1898, 334, 67, 9, 7760, 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, 646, 295, 199, 646, 747, 421, 199, 318, 24881, 7756, 8, 1317, 12, 2644, 534, 1624, 13, 24, 297, 7268, 29, 797, 304, 523, 408, 30753, 314, 4692, 1564, 370, 4543, 12, 12943, 316, 314, 570, 1454, 340, 652, 965, 2896, 14, 819, 14702, 13225, 1584, 1172, 282, 13918, 402, 876, 13, 4037, 13955, 14, 221, 961, 805, 7704, 523, 652, 8837, 370, 2954, 3520, 13955, 465, 2018, 666, 13955, 12, 3140, 402, 523, 9445, 370, 1218, 282, 13918, 402, 805, 4882, 14, 819, 7048, 4692, 1819, 402, 314, 1564, 365, 11159, 465, 282, 769, 26356, 402, 26, 523, 413, 14, 710, 536, 402, 314, 1819, 12, 282, 1059, 12, 523, 499, 14, 710, 3004, 402, 314, 1819, 12, 282, 2600, 334, 4144, 395, 436, 523, 650, 26240, 710, 1564, 402, 314, 1819, 12, 340, 1263, 14, 221, 24361, 787, 3486, 1318, 3380, 436, 489, 5548, 787, 1982, 4008, 14, 819, 5679, 413, 26, 489, 665, 396, 3133, 523, 15410, 489, 788, 396, 418, 819, 5679, 499, 26, 489, 665, 1662, 2108, 282, 534, 585, 17, 7, 330, 534, 585, 18, 8423, 268, 665, 1739, 466, 30, 2765, 365, 1108, 1739, 466, 30, 268, 665, 1739, 466, 30, 390, 28718, 1739, 466, 30, 489, 3068, 1662, 2108, 30, 819, 15410, 489, 788, 1662, 2108, 297, 791, 65, 5242, 585, 17, 297, 283, 66, 5242, 585, 18, 2267, 268, 788, 1739, 466, 297, 283, 2765, 365, 995, 268, 788, 1739, 466, 297, 283, 390, 1, 995, 489, 1622, 819, 3033, 26, 272, 1564, 26, 221, 710, 21781, 1564, 370, 506, 6702, 14, 272, 2644, 26, 710, 2644, 370, 3622, 641, 314, 1642, 4692, 1004, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31140, 436, 892, 2385, 14, 819, 1803, 26, 272, 710, 4692, 1564, 465, 282, 1059, 14, 523, 408, 523, 327, 2136, 1218, 282, 27791, 769, 402, 1006, 314, 4008, 402, 314, 570, 14, 523, 2748, 63, 4181, 275, 12329, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 5961, 83, 14863, 3524, 450, 2644, 61, 523, 340, 7268, 26, 272, 2748, 63, 4181, 14, 740, 2258, 78, 358, 523, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 1564, 12, 7268, 9, 819, 327, 7905, 652, 370, 282, 1059, 523, 372, 6522, 904, 8, 1652, 63, 4181, 9, 421, 199, 318, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 8929, 12, 7268, 12, 2166, 29, 16, 304, 523, 408, 4693, 3198, 314, 4692, 4184, 5226, 370, 314, 8929, 14, 819, 3033, 26, 272, 2748, 63, 4181, 26, 437, 769, 402, 4692, 4184, 370, 506, 11544, 370, 14, 272, 8929, 26, 221, 710, 8929, 402, 314, 1819, 14, 221, 1666, 18951, 8672, 9149, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31140, 436, 892, 2385, 14, 272, 2166, 26, 1010, 1326, 425, 2166, 14, 523, 408, 523, 327, 710, 1642, 1242, 315, 282, 8929, 365, 314, 536, 402, 314, 1819, 14, 523, 340, 7268, 26, 272, 14311, 275, 283, 221, 283, 627, 2166, 272, 892, 63, 604, 275, 1557, 78, 7, 523, 587, 26, 272, 14311, 275, 2125, 272, 892, 63, 604, 275, 2125, 523, 536, 275, 8929, 59, 16, 61, 523, 340, 440, 1228, 8, 354, 12, 620, 304, 272, 746, 2186, 360, 1918, 1642, 1242, 402, 376, 18951, 8672, 8929, 1077, 506, 283, 490, 283, 65, 1059, 14, 221, 5367, 3477, 1990, 283, 435, 620, 8, 22271, 430, 523, 2748, 63, 4181, 14, 740, 8, 25152, 435, 24958, 435, 536, 9, 819, 327, 22383, 315, 3499, 3421, 365, 282, 2600, 402, 314, 3004, 14, 523, 4618, 275, 8929, 59, 17, 2938, 523, 340, 4618, 436, 1228, 8, 3911, 59, 16, 467, 1211, 304, 272, 367, 737, 12, 1139, 315, 3355, 8, 3911, 59, 16, 1055, 4611, 5109, 489, 2748, 63, 4181, 14, 740, 360, 450, 83, 5961, 83, 4507, 450, 334, 292, 12, 485, 8672, 10260, 8, 637, 12, 1921, 29, 549, 1724, 272, 4618, 275, 4618, 59, 17, 2938, 523, 340, 4618, 26, 272, 2748, 63, 4181, 14, 740, 28781, 272, 1006, 63, 5465, 275, 7114, 8, 2734, 671, 12, 612, 26, 671, 436, 1228, 8, 89, 12, 620, 395, 4618, 12, 715, 9, 272, 3510, 63, 604, 275, 440, 1006, 63, 5465, 272, 340, 3510, 63, 604, 436, 892, 63, 604, 26, 489, 2748, 63, 4181, 14, 740, 8, 1222, 63, 604, 9, 272, 367, 1982, 63, 1650, 315, 4618, 26, 489, 327, 982, 652, 1159, 282, 1059, 12, 5666, 282, 1318, 1031, 14, 489, 327, 6630, 18011, 1806, 626, 1982, 5492, 489, 340, 1228, 8, 1739, 63, 1650, 12, 620, 304, 2126, 2748, 63, 4181, 14, 740, 1547, 8672, 10260, 8, 1739, 63, 1650, 430, 489, 587, 26, 267, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 1982, 63, 1650, 12, 7268, 12, 2166, 435, 413, 9, 272, 340, 3510, 63, 604, 436, 14311, 26, 489, 2748, 63, 4181, 14, 740, 8, 25152, 9, 272, 2748, 63, 4181, 14, 740, 26576, 83, 6598, 83, 7, 450, 334, 354, 12, 892, 63, 604, 430, 523, 587, 26, 272, 2748, 63, 4181, 14, 740, 2336, 6598, 83, 7, 450, 892, 63, 604, 9, 421, 199, 318, 6990, 8672, 3917, 6970, 8, 1317, 12, 931, 12, 2644, 534, 1624, 13, 24, 297, 7268, 29, 797, 12, 1993, 4747, 708, 29, 797, 304, 523, 408, 30753, 314, 4692, 1564, 370, 4543, 12, 12943, 316, 314, 570, 1454, 340, 652, 965, 2896, 14, 819, 3033, 26, 272, 1564, 26, 221, 710, 21781, 1564, 370, 506, 5313, 14, 272, 931, 26, 12625, 402, 314, 570, 14, 272, 2644, 26, 710, 2644, 370, 3622, 641, 314, 1642, 1004, 402, 314, 4692, 570, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31140, 436, 892, 2385, 14, 523, 408, 523, 2748, 63, 875, 275, 24881, 7756, 8, 1317, 12, 2644, 12, 7268, 9, 523, 340, 4747, 708, 436, 747, 14, 19254, 1137, 1557, 82, 60, 78 ]
[ 1898, 334, 67, 9, 7760, 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, 646, 295, 199, 646, 747, 421, 199, 318, 24881, 7756, 8, 1317, 12, 2644, 534, 1624, 13, 24, 297, 7268, 29, 797, 304, 523, 408, 30753, 314, 4692, 1564, 370, 4543, 12, 12943, 316, 314, 570, 1454, 340, 652, 965, 2896, 14, 819, 14702, 13225, 1584, 1172, 282, 13918, 402, 876, 13, 4037, 13955, 14, 221, 961, 805, 7704, 523, 652, 8837, 370, 2954, 3520, 13955, 465, 2018, 666, 13955, 12, 3140, 402, 523, 9445, 370, 1218, 282, 13918, 402, 805, 4882, 14, 819, 7048, 4692, 1819, 402, 314, 1564, 365, 11159, 465, 282, 769, 26356, 402, 26, 523, 413, 14, 710, 536, 402, 314, 1819, 12, 282, 1059, 12, 523, 499, 14, 710, 3004, 402, 314, 1819, 12, 282, 2600, 334, 4144, 395, 436, 523, 650, 26240, 710, 1564, 402, 314, 1819, 12, 340, 1263, 14, 221, 24361, 787, 3486, 1318, 3380, 436, 489, 5548, 787, 1982, 4008, 14, 819, 5679, 413, 26, 489, 665, 396, 3133, 523, 15410, 489, 788, 396, 418, 819, 5679, 499, 26, 489, 665, 1662, 2108, 282, 534, 585, 17, 7, 330, 534, 585, 18, 8423, 268, 665, 1739, 466, 30, 2765, 365, 1108, 1739, 466, 30, 268, 665, 1739, 466, 30, 390, 28718, 1739, 466, 30, 489, 3068, 1662, 2108, 30, 819, 15410, 489, 788, 1662, 2108, 297, 791, 65, 5242, 585, 17, 297, 283, 66, 5242, 585, 18, 2267, 268, 788, 1739, 466, 297, 283, 2765, 365, 995, 268, 788, 1739, 466, 297, 283, 390, 1, 995, 489, 1622, 819, 3033, 26, 272, 1564, 26, 221, 710, 21781, 1564, 370, 506, 6702, 14, 272, 2644, 26, 710, 2644, 370, 3622, 641, 314, 1642, 4692, 1004, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31140, 436, 892, 2385, 14, 819, 1803, 26, 272, 710, 4692, 1564, 465, 282, 1059, 14, 523, 408, 523, 327, 2136, 1218, 282, 27791, 769, 402, 1006, 314, 4008, 402, 314, 570, 14, 523, 2748, 63, 4181, 275, 12329, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 5961, 83, 14863, 3524, 450, 2644, 61, 523, 340, 7268, 26, 272, 2748, 63, 4181, 14, 740, 2258, 78, 358, 523, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 1564, 12, 7268, 9, 819, 327, 7905, 652, 370, 282, 1059, 523, 372, 6522, 904, 8, 1652, 63, 4181, 9, 421, 199, 318, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 8929, 12, 7268, 12, 2166, 29, 16, 304, 523, 408, 4693, 3198, 314, 4692, 4184, 5226, 370, 314, 8929, 14, 819, 3033, 26, 272, 2748, 63, 4181, 26, 437, 769, 402, 4692, 4184, 370, 506, 11544, 370, 14, 272, 8929, 26, 221, 710, 8929, 402, 314, 1819, 14, 221, 1666, 18951, 8672, 9149, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31140, 436, 892, 2385, 14, 272, 2166, 26, 1010, 1326, 425, 2166, 14, 523, 408, 523, 327, 710, 1642, 1242, 315, 282, 8929, 365, 314, 536, 402, 314, 1819, 14, 523, 340, 7268, 26, 272, 14311, 275, 283, 221, 283, 627, 2166, 272, 892, 63, 604, 275, 1557, 78, 7, 523, 587, 26, 272, 14311, 275, 2125, 272, 892, 63, 604, 275, 2125, 523, 536, 275, 8929, 59, 16, 61, 523, 340, 440, 1228, 8, 354, 12, 620, 304, 272, 746, 2186, 360, 1918, 1642, 1242, 402, 376, 18951, 8672, 8929, 1077, 506, 283, 490, 283, 65, 1059, 14, 221, 5367, 3477, 1990, 283, 435, 620, 8, 22271, 430, 523, 2748, 63, 4181, 14, 740, 8, 25152, 435, 24958, 435, 536, 9, 819, 327, 22383, 315, 3499, 3421, 365, 282, 2600, 402, 314, 3004, 14, 523, 4618, 275, 8929, 59, 17, 2938, 523, 340, 4618, 436, 1228, 8, 3911, 59, 16, 467, 1211, 304, 272, 367, 737, 12, 1139, 315, 3355, 8, 3911, 59, 16, 1055, 4611, 5109, 489, 2748, 63, 4181, 14, 740, 360, 450, 83, 5961, 83, 4507, 450, 334, 292, 12, 485, 8672, 10260, 8, 637, 12, 1921, 29, 549, 1724, 272, 4618, 275, 4618, 59, 17, 2938, 523, 340, 4618, 26, 272, 2748, 63, 4181, 14, 740, 28781, 272, 1006, 63, 5465, 275, 7114, 8, 2734, 671, 12, 612, 26, 671, 436, 1228, 8, 89, 12, 620, 395, 4618, 12, 715, 9, 272, 3510, 63, 604, 275, 440, 1006, 63, 5465, 272, 340, 3510, 63, 604, 436, 892, 63, 604, 26, 489, 2748, 63, 4181, 14, 740, 8, 1222, 63, 604, 9, 272, 367, 1982, 63, 1650, 315, 4618, 26, 489, 327, 982, 652, 1159, 282, 1059, 12, 5666, 282, 1318, 1031, 14, 489, 327, 6630, 18011, 1806, 626, 1982, 5492, 489, 340, 1228, 8, 1739, 63, 1650, 12, 620, 304, 2126, 2748, 63, 4181, 14, 740, 1547, 8672, 10260, 8, 1739, 63, 1650, 430, 489, 587, 26, 267, 485, 11493, 2714, 1296, 8, 1652, 63, 4181, 12, 1982, 63, 1650, 12, 7268, 12, 2166, 435, 413, 9, 272, 340, 3510, 63, 604, 436, 14311, 26, 489, 2748, 63, 4181, 14, 740, 8, 25152, 9, 272, 2748, 63, 4181, 14, 740, 26576, 83, 6598, 83, 7, 450, 334, 354, 12, 892, 63, 604, 430, 523, 587, 26, 272, 2748, 63, 4181, 14, 740, 2336, 6598, 83, 7, 450, 892, 63, 604, 9, 421, 199, 318, 6990, 8672, 3917, 6970, 8, 1317, 12, 931, 12, 2644, 534, 1624, 13, 24, 297, 7268, 29, 797, 12, 1993, 4747, 708, 29, 797, 304, 523, 408, 30753, 314, 4692, 1564, 370, 4543, 12, 12943, 316, 314, 570, 1454, 340, 652, 965, 2896, 14, 819, 3033, 26, 272, 1564, 26, 221, 710, 21781, 1564, 370, 506, 5313, 14, 272, 931, 26, 12625, 402, 314, 570, 14, 272, 2644, 26, 710, 2644, 370, 3622, 641, 314, 1642, 1004, 402, 314, 4692, 570, 14, 272, 7268, 26, 715, 340, 781, 2934, 7268, 16116, 543, 31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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
priyankarani/sale
invoice.py
1
5078
# This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. from functools import wraps from sql import Table from trytond.model import Workflow, fields from trytond.pool import Pool, PoolMeta from trytond.transaction import Transaction from trytond import backend __all__ = ['Invoice', 'InvoiceLine'] __metaclass__ = PoolMeta def process_sale(func): @wraps(func) def wrapper(cls, invoices): pool = Pool() Sale = pool.get('sale.sale') with Transaction().set_context(_check_access=False): sales = [s for i in cls.browse(invoices) for s in i.sales] func(cls, invoices) with Transaction().set_context(_check_access=False): Sale.process(sales) return wrapper class Invoice: __name__ = 'account.invoice' sale_exception_state = fields.Function(fields.Selection([ ('', ''), ('ignored', 'Ignored'), ('recreated', 'Recreated'), ], 'Exception State'), 'get_sale_exception_state') sales = fields.Function(fields.One2Many('sale.sale', None, 'Sales'), 'get_sales', searcher='search_sales') @classmethod def __setup__(cls): super(Invoice, cls).__setup__() cls._error_messages.update({ 'reset_invoice_sale': ('You cannot reset to draft ' 'an invoice generated by a sale.'), }) @classmethod def get_sale_exception_state(cls, invoices, name): Sale = Pool().get('sale.sale') sales = Sale.search([ ('invoices', 'in', [i.id for i in invoices]), ]) recreated = tuple(i for p in sales for i in p.invoices_recreated) ignored = tuple(i for p in sales for i in p.invoices_ignored) states = {} for invoice in invoices: states[invoice.id] = '' if invoice in recreated: states[invoice.id] = 'recreated' elif invoice.id in ignored: states[invoice.id] = 'ignored' return states def get_sales(self, name): pool = Pool() SaleLine = pool.get('sale.line') sales = set() for line in self.lines: if isinstance(line.origin, SaleLine): sales.add(line.origin.sale.id) return list(sales) @classmethod def search_sales(cls, name, clause): return [('lines.origin.sale.id',) + tuple(clause[1:]) + ('sale.line',)] @classmethod def copy(cls, invoices, default=None): if default is None: default = {} default = default.copy() default.setdefault('sales', None) return super(Invoice, cls).copy(invoices, default=default) @classmethod @process_sale def delete(cls, invoices): super(Invoice, cls).delete(invoices) @classmethod @process_sale def post(cls, invoices): super(Invoice, cls).post(invoices) @classmethod @process_sale def paid(cls, invoices): super(Invoice, cls).paid(invoices) @classmethod @process_sale def cancel(cls, invoices): super(Invoice, cls).cancel(invoices) @classmethod @Workflow.transition('draft') def draft(cls, invoices): Sale = Pool().get('sale.sale') sales = Sale.search([ ('invoices', 'in', [i.id for i in invoices]), ]) if sales and any(i.state == 'cancel' for i in invoices): cls.raise_user_error('reset_invoice_sale') return super(Invoice, cls).draft(invoices) class InvoiceLine: __name__ = 'account.invoice.line' @classmethod def __register__(cls, module_name): TableHandler = backend.get('TableHandler') cursor = Transaction().cursor sql_table = cls.__table__() super(InvoiceLine, cls).__register__(module_name) # Migration from 2.6: remove sale_lines rel_table_name = 'sale_line_invoice_lines_rel' if TableHandler.table_exist(cursor, rel_table_name): rel_table = Table(rel_table_name) cursor.execute(*rel_table.select( rel_table.sale_line, rel_table.invoice_line)) for sale_line, invoice_line in cursor.fetchall(): cursor.execute(*sql_table.update( columns=[sql_table.origin], values=['sale.line,%s' % sale_line], where=sql_table.id == invoice_line)) TableHandler.drop_table(cursor, 'sale.line-account.invoice.line', rel_table_name) @property def origin_name(self): pool = Pool() SaleLine = pool.get('sale.line') name = super(InvoiceLine, self).origin_name if isinstance(self.origin, SaleLine): name = self.origin.sale.rec_name return name @classmethod def _get_origin(cls): models = super(InvoiceLine, cls)._get_origin() models.append('sale.line') return models
gpl-3.0
[ 3, 961, 570, 365, 1777, 402, 7649, 1860, 14, 221, 710, 5877, 570, 737, 314, 2746, 2166, 402, 199, 3, 642, 7611, 3509, 314, 2615, 4248, 949, 7724, 436, 4190, 2895, 14, 199, 504, 9143, 492, 14018, 199, 504, 3875, 492, 6957, 199, 199, 504, 862, 1860, 68, 14, 1238, 492, 27282, 12, 1504, 199, 504, 862, 1860, 68, 14, 2293, 492, 15553, 12, 15553, 3396, 199, 504, 862, 1860, 68, 14, 5945, 492, 18244, 199, 504, 862, 1860, 68, 492, 4865, 199, 199, 363, 452, 363, 275, 788, 21092, 297, 283, 21092, 3049, 418, 199, 363, 6577, 363, 275, 15553, 3396, 421, 199, 318, 2112, 63, 8515, 8, 1532, 304, 272, 768, 13582, 8, 1532, 9, 272, 347, 4975, 8, 1886, 12, 26175, 304, 267, 4203, 275, 15553, 342, 267, 428, 1895, 275, 4203, 14, 362, 360, 8515, 14, 8515, 358, 267, 543, 18244, 1252, 409, 63, 1100, 1547, 1074, 63, 2732, 29, 797, 304, 288, 21702, 275, 359, 83, 367, 284, 315, 843, 14, 4570, 8, 28809, 9, 367, 308, 315, 284, 14, 16175, 61, 267, 2562, 8, 1886, 12, 26175, 9, 267, 543, 18244, 1252, 409, 63, 1100, 1547, 1074, 63, 2732, 29, 797, 304, 288, 428, 1895, 14, 1412, 8, 16175, 9, 272, 372, 4975, 421, 199, 533, 19868, 26, 272, 636, 354, 363, 275, 283, 2048, 14, 5404, 7, 272, 13590, 63, 1971, 63, 929, 275, 1504, 14, 3481, 8, 955, 14, 7713, 779, 267, 13134, 9929, 267, 661, 11996, 297, 283, 19399, 2908, 659, 267, 661, 264, 3966, 297, 283, 497, 3966, 659, 267, 2156, 283, 1726, 8511, 659, 283, 362, 63, 8515, 63, 1971, 63, 929, 358, 272, 21702, 275, 1504, 14, 3481, 8, 955, 14, 4395, 18, 4089, 360, 8515, 14, 8515, 297, 488, 12, 283, 18220, 659, 267, 283, 362, 63, 16175, 297, 2754, 281, 534, 1733, 63, 16175, 358, 339, 768, 3744, 272, 347, 636, 2758, 721, 1886, 304, 267, 1613, 8, 21092, 12, 843, 2843, 2758, 4533, 267, 843, 423, 705, 63, 3431, 14, 873, 2561, 355, 283, 3958, 63, 5404, 63, 8515, 356, 661, 5556, 3913, 5305, 370, 11872, 283, 490, 283, 290, 8485, 4046, 701, 282, 13590, 8038, 355, 3828, 339, 768, 3744, 272, 347, 664, 63, 8515, 63, 1971, 63, 929, 8, 1886, 12, 26175, 12, 536, 304, 267, 428, 1895, 275, 15553, 1252, 362, 360, 8515, 14, 8515, 358, 267, 21702, 275, 428, 1895, 14, 1733, 779, 355, 661, 28809, 297, 283, 262, 297, 359, 73, 14, 344, 367, 284, 315, 26175, 2522, 355, 4794, 398, 295, 3966, 275, 2008, 8, 73, 367, 299, 315, 21702, 367, 284, 315, 299, 14, 28809, 63, 264, 3966, 9, 267, 5525, 275, 2008, 8, 73, 367, 299, 315, 21702, 367, 284, 315, 299, 14, 28809, 63, 11996, 9, 398, 6363, 275, 1052, 267, 367, 8485, 315, 26175, 26, 288, 6363, 59, 5404, 14, 344, 61, 275, 2125, 288, 340, 8485, 315, 295, 3966, 26, 355, 6363, 59, 5404, 14, 344, 61, 275, 283, 264, 3966, 7, 288, 916, 8485, 14, 344, 315, 5525, 26, 355, 6363, 59, 5404, 14, 344, 61, 275, 283, 11996, 7, 267, 372, 6363, 339, 347, 664, 63, 16175, 8, 277, 12, 536, 304, 267, 4203, 275, 15553, 342, 267, 428, 1895, 3049, 275, 4203, 14, 362, 360, 8515, 14, 604, 358, 267, 21702, 275, 663, 342, 267, 367, 1004, 315, 291, 14, 1278, 26, 288, 340, 1228, 8, 604, 14, 6493, 12, 428, 1895, 3049, 304, 355, 21702, 14, 525, 8, 604, 14, 6493, 14, 8515, 14, 344, 9, 267, 372, 769, 8, 16175, 9, 339, 768, 3744, 272, 347, 2754, 63, 16175, 8, 1886, 12, 536, 12, 8502, 304, 267, 372, 4274, 1278, 14, 6493, 14, 8515, 14, 344, 9538, 435, 2008, 8, 8501, 59, 17, 5728, 288, 435, 661, 8515, 14, 604, 297, 1874, 339, 768, 3744, 272, 347, 1331, 8, 1886, 12, 26175, 12, 849, 29, 403, 304, 267, 340, 849, 365, 488, 26, 288, 849, 275, 1052, 267, 849, 275, 849, 14, 1574, 342, 267, 849, 14, 5486, 360, 16175, 297, 488, 9, 267, 372, 1613, 8, 21092, 12, 843, 680, 1574, 8, 28809, 12, 849, 29, 885, 9, 339, 768, 3744, 272, 768, 1412, 63, 8515, 272, 347, 3145, 8, 1886, 12, 26175, 304, 267, 1613, 8, 21092, 12, 843, 680, 1807, 8, 28809, 9, 339, 768, 3744, 272, 768, 1412, 63, 8515, 272, 347, 2963, 8, 1886, 12, 26175, 304, 267, 1613, 8, 21092, 12, 843, 680, 1932, 8, 28809, 9, 339, 768, 3744, 272, 768, 1412, 63, 8515, 272, 347, 30677, 8, 1886, 12, 26175, 304, 267, 1613, 8, 21092, 12, 843, 680, 16555, 8, 28809, 9, 339, 768, 3744, 272, 768, 1412, 63, 8515, 272, 347, 9311, 8, 1886, 12, 26175, 304, 267, 1613, 8, 21092, 12, 843, 680, 6406, 8, 28809, 9, 339, 768, 3744, 272, 768, 17527, 14, 14143, 360, 7185, 358, 272, 347, 11872, 8, 1886, 12, 26175, 304, 267, 428, 1895, 275, 15553, 1252, 362, 360, 8515, 14, 8515, 358, 267, 21702, 275, 428, 1895, 14, 1733, 779, 355, 661, 28809, 297, 283, 262, 297, 359, 73, 14, 344, 367, 284, 315, 26175, 2522, 355, 4794, 267, 340, 21702, 436, 1263, 8, 73, 14, 929, 508, 283, 6406, 7, 367, 284, 315, 26175, 304, 288, 843, 14, 3730, 63, 751, 63, 705, 360, 3958, 63, 5404, 63, 8515, 358, 398, 372, 1613, 8, 21092, 12, 843, 680, 7185, 8, 28809, 9, 421, 199, 533, 19868, 3049, 26, 272, 636, 354, 363, 275, 283, 2048, 14, 5404, 14, 604, 7, 339, 768, 3744, 272, 347, 636, 2683, 721, 1886, 12, 859, 63, 354, 304, 267, 6957, 2461, 275, 4865, 14, 362, 360, 3186, 2461, 358, 267, 3920, 275, 18244, 1252, 3937, 267, 3875, 63, 1224, 275, 843, 855, 1224, 4533, 398, 1613, 8, 21092, 3049, 12, 843, 2843, 2683, 721, 578, 63, 354, 9, 398, 327, 12090, 687, 499, 14, 22, 26, 2813, 13590, 63, 1278, 267, 4668, 63, 1224, 63, 354, 275, 283, 8515, 63, 604, 63, 5404, 63, 1278, 63, 3369, 7, 267, 340, 6957, 2461, 14, 1224, 63, 4494, 8, 3937, 12, 4668, 63, 1224, 63, 354, 304, 288, 4668, 63, 1224, 275 ]
[ 961, 570, 365, 1777, 402, 7649, 1860, 14, 221, 710, 5877, 570, 737, 314, 2746, 2166, 402, 199, 3, 642, 7611, 3509, 314, 2615, 4248, 949, 7724, 436, 4190, 2895, 14, 199, 504, 9143, 492, 14018, 199, 504, 3875, 492, 6957, 199, 199, 504, 862, 1860, 68, 14, 1238, 492, 27282, 12, 1504, 199, 504, 862, 1860, 68, 14, 2293, 492, 15553, 12, 15553, 3396, 199, 504, 862, 1860, 68, 14, 5945, 492, 18244, 199, 504, 862, 1860, 68, 492, 4865, 199, 199, 363, 452, 363, 275, 788, 21092, 297, 283, 21092, 3049, 418, 199, 363, 6577, 363, 275, 15553, 3396, 421, 199, 318, 2112, 63, 8515, 8, 1532, 304, 272, 768, 13582, 8, 1532, 9, 272, 347, 4975, 8, 1886, 12, 26175, 304, 267, 4203, 275, 15553, 342, 267, 428, 1895, 275, 4203, 14, 362, 360, 8515, 14, 8515, 358, 267, 543, 18244, 1252, 409, 63, 1100, 1547, 1074, 63, 2732, 29, 797, 304, 288, 21702, 275, 359, 83, 367, 284, 315, 843, 14, 4570, 8, 28809, 9, 367, 308, 315, 284, 14, 16175, 61, 267, 2562, 8, 1886, 12, 26175, 9, 267, 543, 18244, 1252, 409, 63, 1100, 1547, 1074, 63, 2732, 29, 797, 304, 288, 428, 1895, 14, 1412, 8, 16175, 9, 272, 372, 4975, 421, 199, 533, 19868, 26, 272, 636, 354, 363, 275, 283, 2048, 14, 5404, 7, 272, 13590, 63, 1971, 63, 929, 275, 1504, 14, 3481, 8, 955, 14, 7713, 779, 267, 13134, 9929, 267, 661, 11996, 297, 283, 19399, 2908, 659, 267, 661, 264, 3966, 297, 283, 497, 3966, 659, 267, 2156, 283, 1726, 8511, 659, 283, 362, 63, 8515, 63, 1971, 63, 929, 358, 272, 21702, 275, 1504, 14, 3481, 8, 955, 14, 4395, 18, 4089, 360, 8515, 14, 8515, 297, 488, 12, 283, 18220, 659, 267, 283, 362, 63, 16175, 297, 2754, 281, 534, 1733, 63, 16175, 358, 339, 768, 3744, 272, 347, 636, 2758, 721, 1886, 304, 267, 1613, 8, 21092, 12, 843, 2843, 2758, 4533, 267, 843, 423, 705, 63, 3431, 14, 873, 2561, 355, 283, 3958, 63, 5404, 63, 8515, 356, 661, 5556, 3913, 5305, 370, 11872, 283, 490, 283, 290, 8485, 4046, 701, 282, 13590, 8038, 355, 3828, 339, 768, 3744, 272, 347, 664, 63, 8515, 63, 1971, 63, 929, 8, 1886, 12, 26175, 12, 536, 304, 267, 428, 1895, 275, 15553, 1252, 362, 360, 8515, 14, 8515, 358, 267, 21702, 275, 428, 1895, 14, 1733, 779, 355, 661, 28809, 297, 283, 262, 297, 359, 73, 14, 344, 367, 284, 315, 26175, 2522, 355, 4794, 398, 295, 3966, 275, 2008, 8, 73, 367, 299, 315, 21702, 367, 284, 315, 299, 14, 28809, 63, 264, 3966, 9, 267, 5525, 275, 2008, 8, 73, 367, 299, 315, 21702, 367, 284, 315, 299, 14, 28809, 63, 11996, 9, 398, 6363, 275, 1052, 267, 367, 8485, 315, 26175, 26, 288, 6363, 59, 5404, 14, 344, 61, 275, 2125, 288, 340, 8485, 315, 295, 3966, 26, 355, 6363, 59, 5404, 14, 344, 61, 275, 283, 264, 3966, 7, 288, 916, 8485, 14, 344, 315, 5525, 26, 355, 6363, 59, 5404, 14, 344, 61, 275, 283, 11996, 7, 267, 372, 6363, 339, 347, 664, 63, 16175, 8, 277, 12, 536, 304, 267, 4203, 275, 15553, 342, 267, 428, 1895, 3049, 275, 4203, 14, 362, 360, 8515, 14, 604, 358, 267, 21702, 275, 663, 342, 267, 367, 1004, 315, 291, 14, 1278, 26, 288, 340, 1228, 8, 604, 14, 6493, 12, 428, 1895, 3049, 304, 355, 21702, 14, 525, 8, 604, 14, 6493, 14, 8515, 14, 344, 9, 267, 372, 769, 8, 16175, 9, 339, 768, 3744, 272, 347, 2754, 63, 16175, 8, 1886, 12, 536, 12, 8502, 304, 267, 372, 4274, 1278, 14, 6493, 14, 8515, 14, 344, 9538, 435, 2008, 8, 8501, 59, 17, 5728, 288, 435, 661, 8515, 14, 604, 297, 1874, 339, 768, 3744, 272, 347, 1331, 8, 1886, 12, 26175, 12, 849, 29, 403, 304, 267, 340, 849, 365, 488, 26, 288, 849, 275, 1052, 267, 849, 275, 849, 14, 1574, 342, 267, 849, 14, 5486, 360, 16175, 297, 488, 9, 267, 372, 1613, 8, 21092, 12, 843, 680, 1574, 8, 28809, 12, 849, 29, 885, 9, 339, 768, 3744, 272, 768, 1412, 63, 8515, 272, 347, 3145, 8, 1886, 12, 26175, 304, 267, 1613, 8, 21092, 12, 843, 680, 1807, 8, 28809, 9, 339, 768, 3744, 272, 768, 1412, 63, 8515, 272, 347, 2963, 8, 1886, 12, 26175, 304, 267, 1613, 8, 21092, 12, 843, 680, 1932, 8, 28809, 9, 339, 768, 3744, 272, 768, 1412, 63, 8515, 272, 347, 30677, 8, 1886, 12, 26175, 304, 267, 1613, 8, 21092, 12, 843, 680, 16555, 8, 28809, 9, 339, 768, 3744, 272, 768, 1412, 63, 8515, 272, 347, 9311, 8, 1886, 12, 26175, 304, 267, 1613, 8, 21092, 12, 843, 680, 6406, 8, 28809, 9, 339, 768, 3744, 272, 768, 17527, 14, 14143, 360, 7185, 358, 272, 347, 11872, 8, 1886, 12, 26175, 304, 267, 428, 1895, 275, 15553, 1252, 362, 360, 8515, 14, 8515, 358, 267, 21702, 275, 428, 1895, 14, 1733, 779, 355, 661, 28809, 297, 283, 262, 297, 359, 73, 14, 344, 367, 284, 315, 26175, 2522, 355, 4794, 267, 340, 21702, 436, 1263, 8, 73, 14, 929, 508, 283, 6406, 7, 367, 284, 315, 26175, 304, 288, 843, 14, 3730, 63, 751, 63, 705, 360, 3958, 63, 5404, 63, 8515, 358, 398, 372, 1613, 8, 21092, 12, 843, 680, 7185, 8, 28809, 9, 421, 199, 533, 19868, 3049, 26, 272, 636, 354, 363, 275, 283, 2048, 14, 5404, 14, 604, 7, 339, 768, 3744, 272, 347, 636, 2683, 721, 1886, 12, 859, 63, 354, 304, 267, 6957, 2461, 275, 4865, 14, 362, 360, 3186, 2461, 358, 267, 3920, 275, 18244, 1252, 3937, 267, 3875, 63, 1224, 275, 843, 855, 1224, 4533, 398, 1613, 8, 21092, 3049, 12, 843, 2843, 2683, 721, 578, 63, 354, 9, 398, 327, 12090, 687, 499, 14, 22, 26, 2813, 13590, 63, 1278, 267, 4668, 63, 1224, 63, 354, 275, 283, 8515, 63, 604, 63, 5404, 63, 1278, 63, 3369, 7, 267, 340, 6957, 2461, 14, 1224, 63, 4494, 8, 3937, 12, 4668, 63, 1224, 63, 354, 304, 288, 4668, 63, 1224, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
rahushen/ansible
lib/ansible/modules/network/aci/aci_contract_subject_to_filter.py
2
9148
#!/usr/bin/python # -*- coding: utf-8 -*- # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: aci_contract_subject_to_filter short_description: Bind Contract Subjects to Filters (vz:RsSubjFiltAtt) description: - Bind Contract Subjects to Filters on Cisco ACI fabrics. notes: - The C(tenant), C(contract), C(subject), and C(filter_name) must exist before using this module in your playbook. - The M(aci_tenant), M(aci_contract), M(aci_contract_subject), and M(aci_filter) modules can be used for these. - More information about the internal APIC class B(vz:RsSubjFiltAtt) from L(the APIC Management Information Model reference,https://developer.cisco.com/docs/apic-mim-ref/). author: - Jacob McGill (@jmcgill298) version_added: '2.4' options: contract: description: - The name of the contract. aliases: [ contract_name ] filter: description: - The name of the Filter to bind to the Subject. aliases: [ filter_name ] log: description: - Determines if the binding should be set to log. - The APIC defaults new Subject to Filter bindings to C(none). choices: [ log, none ] aliases: [ directive ] default: none subject: description: - The name of the Contract Subject. aliases: [ contract_subject, subject_name ] state: description: - Use C(present) or C(absent) for adding or removing. - Use C(query) for listing an object or multiple objects. choices: [ absent, present, query ] default: present tenant: description: - The name of the tenant. required: yes aliases: [ tenant_name ] extends_documentation_fragment: aci ''' EXAMPLES = r''' - name: Add a new contract subject to filer binding aci_contract_subject_to_filter: host: apic username: admin password: SomeSecretPassword tenant: production contract: web_to_db subject: test filter: '{{ filter }}' log: '{{ log }}' state: present - name: Remove an existing contract subject to filter binding aci_contract_subject_to_filter: host: apic username: admin password: SomeSecretPassword tenant: production contract: web_to_db subject: test filter: '{{ filter }}' log: '{{ log }}' state: present - name: Query a specific contract subject to filter binding aci_contract_subject_to_filter: host: apic username: admin password: SomeSecretPassword tenant: production contract: web_to_db subject: test filter: '{{ filter }}' state: query - name: Query all contract subject to filter bindings aci_contract_subject_to_filter: host: apic username: admin password: SomeSecretPassword tenant: production contract: web_to_db subject: test state: query ''' RETURN = r''' current: description: The existing configuration from the APIC after the module has finished returned: success type: list sample: [ { "fvTenant": { "attributes": { "descr": "Production environment", "dn": "uni/tn-production", "name": "production", "nameAlias": "", "ownerKey": "", "ownerTag": "" } } } ] error: description: The error information as returned from the APIC returned: failure type: dict sample: { "code": "122", "text": "unknown managed object class foo" } raw: description: The raw output returned by the APIC REST API (xml or json) returned: parse error type: string sample: '<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>' sent: description: The actual/minimal configuration pushed to the APIC returned: info type: list sample: { "fvTenant": { "attributes": { "descr": "Production environment" } } } previous: description: The original configuration from the APIC before the module has started returned: info type: list sample: [ { "fvTenant": { "attributes": { "descr": "Production", "dn": "uni/tn-production", "name": "production", "nameAlias": "", "ownerKey": "", "ownerTag": "" } } } ] proposed: description: The assembled configuration from the user-provided parameters returned: info type: dict sample: { "fvTenant": { "attributes": { "descr": "Production environment", "name": "production" } } } filter_string: description: The filter string used for the request returned: failure or debug type: string sample: ?rsp-prop-include=config-only method: description: The HTTP method used for the request to the APIC returned: failure or debug type: string sample: POST response: description: The HTTP response from the APIC returned: failure or debug type: string sample: OK (30 bytes) status: description: The HTTP status from the APIC returned: failure or debug type: int sample: 200 url: description: The HTTP url used for the request to the APIC returned: failure or debug type: string sample: https://10.11.12.13/api/mo/uni/tn-production.json ''' from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec from ansible.module_utils.basic import AnsibleModule def main(): argument_spec = aci_argument_spec() argument_spec.update( contract=dict(type='str', aliases=['contract_name']), # Not required for querying all objects filter=dict(type='str', aliases=['filter_name']), # Not required for querying all objects log=dict(tyep='str', choices=['log', 'none'], aliases=['directive']), subject=dict(type='str', aliases=['contract_subject', 'subject_name']), # Not required for querying all objects tenant=dict(type='str', aliases=['tenant_name']), # Not required for querying all objects state=dict(type='str', default='present', choices=['absent', 'present', 'query']), method=dict(type='str', choices=['delete', 'get', 'post'], aliases=['action'], removed_in_version='2.6'), # Deprecated starting from v2.6 protocol=dict(type='str', removed_in_version='2.6'), # Deprecated in v2.6 ) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, required_if=[ ['state', 'absent', ['contract', 'filter', 'subject', 'tenant']], ['state', 'present', ['contract', 'filter', 'subject', 'tenant']], ], ) contract = module.params['contract'] filter_name = module.params['filter'] log = module.params['log'] subject = module.params['subject'] tenant = module.params['tenant'] state = module.params['state'] # Add subject_filter key to modul.params for building the URL module.params['subject_filter'] = filter_name # Convert log to empty string if none, as that is what API expects. An empty string is not a good option to present the user. if log == 'none': log = '' aci = ACIModule(module) aci.construct_url( root_class=dict( aci_class='fvTenant', aci_rn='tn-{0}'.format(tenant), filter_target='eq(fvTenant.name, "{0}")'.format(tenant), module_object=tenant, ), subclass_1=dict( aci_class='vzBrCP', aci_rn='brc-{0}'.format(contract), filter_target='eq(vzBrCP.name, "{0}")'.format(contract), module_object=contract, ), subclass_2=dict( aci_class='vzSubj', aci_rn='subj-{0}'.format(subject), filter_target='eq(vzSubj.name, "{0}")'.format(subject), module_object=subject, ), subclass_3=dict( aci_class='vzRsSubjFiltAtt', aci_rn='rssubjFiltAtt-{0}'.format(filter_name), filter_target='eq(vzRsSubjFiltAtt.tnVzFilterName, "{0}")'.format(filter_name), module_object=filter_name, ), ) aci.get_existing() if state == 'present': aci.payload( aci_class='vzRsSubjFiltAtt', class_config=dict( tnVzFilterName=filter_name, directives=log, ), ) aci.get_diff(aci_class='vzRsSubjFiltAtt') aci.post_config() elif state == 'absent': aci.delete_config() # Remove subject_filter used to build URL from module.params module.params.pop('subject_filter') aci.exit_json() if __name__ == "__main__": main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 19631, 63, 14624, 63, 5875, 63, 475, 63, 1541, 199, 3612, 63, 1802, 26, 22630, 1448, 6908, 26793, 83, 370, 21240, 334, 31007, 26, 28868, 2610, 74, 38, 4803, 1271, 84, 9, 199, 1802, 26, 199, 13, 22630, 1448, 6908, 26793, 83, 370, 21240, 641, 28356, 437, 3553, 31507, 11818, 14, 199, 5983, 26, 199, 13, 710, 445, 8, 4647, 395, 445, 8, 14624, 395, 445, 8, 5875, 395, 436, 445, 8, 1541, 63, 354, 9, 1471, 2187, 2544, 1808, 642, 859, 315, 2195, 15695, 14, 199, 13, 710, 603, 8, 22832, 63, 4647, 395, 603, 8, 22832, 63, 14624, 395, 603, 8, 22832, 63, 14624, 63, 5875, 395, 436, 603, 8, 22832, 63, 1541, 9, 4621, 883, 506, 1202, 367, 3520, 14, 199, 13, 16917, 2556, 3595, 314, 5007, 25418, 1021, 699, 8, 31007, 26, 28868, 2610, 74, 38, 4803, 1271, 84, 9, 687, 523, 491, 8, 1589, 25418, 8259, 17064, 5822, 3659, 12, 2859, 921, 11071, 14, 19597, 14, 957, 15, 4757, 15, 20789, 13, 77, 1017, 13, 1121, 15, 680, 199, 2502, 26, 199, 13, 1603, 13286, 66, 22895, 39, 778, 8593, 74, 5466, 71, 778, 12877, 9, 199, 1023, 63, 3270, 26, 283, 18, 14, 20, 7, 199, 1419, 26, 523, 16077, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 16077, 14, 272, 5481, 26, 359, 16077, 63, 354, 1622, 523, 2457, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 9388, 370, 5398, 370, 314, 26793, 14, 272, 5481, 26, 359, 2457, 63, 354, 1622, 523, 943, 26, 272, 1369, 26, 272, 446, 22391, 340, 314, 11696, 1077, 506, 663, 370, 943, 14, 272, 446, 710, 25418, 4243, 892, 26793, 370, 9388, 17792, 370, 445, 8, 3592, 680, 272, 3415, 26, 359, 943, 12, 7179, 1622, 272, 5481, 26, 359, 13613, 1622, 272, 849, 26, 7179, 523, 5420, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 1448, 6908, 26793, 14, 272, 5481, 26, 359, 16077, 63, 5875, 12, 5420, 63, 354, 1622, 523, 1174, 26, 272, 1369, 26, 272, 446, 3645, 445, 8, 1881, 9, 503, 445, 8, 5575, 9, 367, 7791, 503, 12881, 14, 272, 446, 3645, 445, 8, 1131, 9, 367, 13778, 376, 909, 503, 3663, 2251, 14, 272, 3415, 26, 359, 9552, 12, 3451, 12, 1827, 1622, 272, 849, 26, 3451, 523, 8261, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 8261, 14, 272, 1415, 26, 9456, 272, 5481, 26, 359, 8261, 63, 354, 1622, 199, 11036, 63, 9970, 63, 7677, 26, 19631, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2654, 282, 892, 16077, 5420, 370, 570, 82, 11696, 523, 19631, 63, 14624, 63, 5875, 63, 475, 63, 1541, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 9920, 272, 16077, 26, 3330, 63, 475, 63, 697, 272, 5420, 26, 511, 272, 2457, 26, 11400, 2457, 16339, 272, 943, 26, 11400, 943, 16339, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 5852, 376, 3411, 16077, 5420, 370, 2457, 11696, 523, 19631, 63, 14624, 63, 5875, 63, 475, 63, 1541, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 9920, 272, 16077, 26, 3330, 63, 475, 63, 697, 272, 5420, 26, 511, 272, 2457, 26, 11400, 2457, 16339, 272, 943, 26, 11400, 943, 16339, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 8133, 282, 2488, 16077, 5420, 370, 2457, 11696, 523, 19631, 63, 14624, 63, 5875, 63, 475, 63, 1541, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 9920, 272, 16077, 26, 3330, 63, 475, 63, 697, 272, 5420, 26, 511, 272, 2457, 26, 11400, 2457, 16339, 272, 1174, 26, 1827, 199, 199, 13, 536, 26, 8133, 1006, 16077, 5420, 370, 2457, 17792, 523, 19631, 63, 14624, 63, 5875, 63, 475, 63, 1541, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 9920, 272, 16077, 26, 3330, 63, 475, 63, 697, 272, 5420, 26, 511, 272, 1174, 26, 1827, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 1818, 26, 523, 1369, 26, 710, 3411, 2897, 687, 314, 25418, 2410, 314, 859, 965, 9158, 523, 2138, 26, 3182, 523, 730, 26, 769, 523, 2690, 26, 272, 359, 267, 469, 288, 298, 13692, 27807, 582, 469, 355, 298, 2987, 582, 469, 490, 298, 12113, 582, 298, 26432, 3734, 401, 490, 298, 4272, 582, 298, 5411, 15, 5889, 13, 10777, 401, 490, 298, 354, 582, 298, 10777, 401, 490, 298, 354, 14149, 582, 4873, 490, 298, 4597, 1197, 582, 4873, 490, 298, 4597, 1931, 582, 3087, 355, 789, 288, 789, 267, 789, 272, 1622, 199, 705, 26, 523, 1369, 26, 710, 1125, 2556, 465, 2138, 687, 314, 25418, 523, 2138, 26, 5988, 523, 730, 26, 1211, 523, 2690, 26, 272, 469, 267, 298, 600, 582, 298, 7507, 401, 267, 298, 505, 582, 298, 5187, 12883, 909, 1021, 3925, 2, 272, 789, 199, 1773, 26, 523, 1369, 26, 710, 3066, 1072, 2138, 701, 314, 25418, 14880, 3261, 334, 1652, 503, 2022, 9, 523, 2138, 26, 2198, 1125, 523, 730, 26, 1059, 523, 2690, 26, 2650, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 14863, 2535, 1017, 576, 3141, 2353, 628, 17, 8186, 705, 1233, 628, 7507, 2, 1318, 628, 5187, 12883, 909, 1021, 3925, 15313, 2957 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 19631, 63, 14624, 63, 5875, 63, 475, 63, 1541, 199, 3612, 63, 1802, 26, 22630, 1448, 6908, 26793, 83, 370, 21240, 334, 31007, 26, 28868, 2610, 74, 38, 4803, 1271, 84, 9, 199, 1802, 26, 199, 13, 22630, 1448, 6908, 26793, 83, 370, 21240, 641, 28356, 437, 3553, 31507, 11818, 14, 199, 5983, 26, 199, 13, 710, 445, 8, 4647, 395, 445, 8, 14624, 395, 445, 8, 5875, 395, 436, 445, 8, 1541, 63, 354, 9, 1471, 2187, 2544, 1808, 642, 859, 315, 2195, 15695, 14, 199, 13, 710, 603, 8, 22832, 63, 4647, 395, 603, 8, 22832, 63, 14624, 395, 603, 8, 22832, 63, 14624, 63, 5875, 395, 436, 603, 8, 22832, 63, 1541, 9, 4621, 883, 506, 1202, 367, 3520, 14, 199, 13, 16917, 2556, 3595, 314, 5007, 25418, 1021, 699, 8, 31007, 26, 28868, 2610, 74, 38, 4803, 1271, 84, 9, 687, 523, 491, 8, 1589, 25418, 8259, 17064, 5822, 3659, 12, 2859, 921, 11071, 14, 19597, 14, 957, 15, 4757, 15, 20789, 13, 77, 1017, 13, 1121, 15, 680, 199, 2502, 26, 199, 13, 1603, 13286, 66, 22895, 39, 778, 8593, 74, 5466, 71, 778, 12877, 9, 199, 1023, 63, 3270, 26, 283, 18, 14, 20, 7, 199, 1419, 26, 523, 16077, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 16077, 14, 272, 5481, 26, 359, 16077, 63, 354, 1622, 523, 2457, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 9388, 370, 5398, 370, 314, 26793, 14, 272, 5481, 26, 359, 2457, 63, 354, 1622, 523, 943, 26, 272, 1369, 26, 272, 446, 22391, 340, 314, 11696, 1077, 506, 663, 370, 943, 14, 272, 446, 710, 25418, 4243, 892, 26793, 370, 9388, 17792, 370, 445, 8, 3592, 680, 272, 3415, 26, 359, 943, 12, 7179, 1622, 272, 5481, 26, 359, 13613, 1622, 272, 849, 26, 7179, 523, 5420, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 1448, 6908, 26793, 14, 272, 5481, 26, 359, 16077, 63, 5875, 12, 5420, 63, 354, 1622, 523, 1174, 26, 272, 1369, 26, 272, 446, 3645, 445, 8, 1881, 9, 503, 445, 8, 5575, 9, 367, 7791, 503, 12881, 14, 272, 446, 3645, 445, 8, 1131, 9, 367, 13778, 376, 909, 503, 3663, 2251, 14, 272, 3415, 26, 359, 9552, 12, 3451, 12, 1827, 1622, 272, 849, 26, 3451, 523, 8261, 26, 272, 1369, 26, 272, 446, 710, 536, 402, 314, 8261, 14, 272, 1415, 26, 9456, 272, 5481, 26, 359, 8261, 63, 354, 1622, 199, 11036, 63, 9970, 63, 7677, 26, 19631, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2654, 282, 892, 16077, 5420, 370, 570, 82, 11696, 523, 19631, 63, 14624, 63, 5875, 63, 475, 63, 1541, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 9920, 272, 16077, 26, 3330, 63, 475, 63, 697, 272, 5420, 26, 511, 272, 2457, 26, 11400, 2457, 16339, 272, 943, 26, 11400, 943, 16339, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 5852, 376, 3411, 16077, 5420, 370, 2457, 11696, 523, 19631, 63, 14624, 63, 5875, 63, 475, 63, 1541, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 9920, 272, 16077, 26, 3330, 63, 475, 63, 697, 272, 5420, 26, 511, 272, 2457, 26, 11400, 2457, 16339, 272, 943, 26, 11400, 943, 16339, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 8133, 282, 2488, 16077, 5420, 370, 2457, 11696, 523, 19631, 63, 14624, 63, 5875, 63, 475, 63, 1541, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 9920, 272, 16077, 26, 3330, 63, 475, 63, 697, 272, 5420, 26, 511, 272, 2457, 26, 11400, 2457, 16339, 272, 1174, 26, 1827, 199, 199, 13, 536, 26, 8133, 1006, 16077, 5420, 370, 2457, 17792, 523, 19631, 63, 14624, 63, 5875, 63, 475, 63, 1541, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 2505, 26, 6601, 13790, 6139, 272, 8261, 26, 9920, 272, 16077, 26, 3330, 63, 475, 63, 697, 272, 5420, 26, 511, 272, 1174, 26, 1827, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 1818, 26, 523, 1369, 26, 710, 3411, 2897, 687, 314, 25418, 2410, 314, 859, 965, 9158, 523, 2138, 26, 3182, 523, 730, 26, 769, 523, 2690, 26, 272, 359, 267, 469, 288, 298, 13692, 27807, 582, 469, 355, 298, 2987, 582, 469, 490, 298, 12113, 582, 298, 26432, 3734, 401, 490, 298, 4272, 582, 298, 5411, 15, 5889, 13, 10777, 401, 490, 298, 354, 582, 298, 10777, 401, 490, 298, 354, 14149, 582, 4873, 490, 298, 4597, 1197, 582, 4873, 490, 298, 4597, 1931, 582, 3087, 355, 789, 288, 789, 267, 789, 272, 1622, 199, 705, 26, 523, 1369, 26, 710, 1125, 2556, 465, 2138, 687, 314, 25418, 523, 2138, 26, 5988, 523, 730, 26, 1211, 523, 2690, 26, 272, 469, 267, 298, 600, 582, 298, 7507, 401, 267, 298, 505, 582, 298, 5187, 12883, 909, 1021, 3925, 2, 272, 789, 199, 1773, 26, 523, 1369, 26, 710, 3066, 1072, 2138, 701, 314, 25418, 14880, 3261, 334, 1652, 503, 2022, 9, 523, 2138, 26, 2198, 1125, 523, 730, 26, 1059, 523, 2690, 26, 2650, 31, 1652, 1015, 628, 17, 14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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
csitarichie/boost_msm_bare_metal
boost/libs/python/pyste/src/Pyste/CppParser.py
54
8553
# Copyright Bruno da Silva de Oliveira 2003. Use, modification and # distribution is subject to the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) from GCCXMLParser import ParseDeclarations import tempfile import shutil import os import sys import os.path import settings import shutil import shelve from cPickle import dump, load #============================================================================== # exceptions #============================================================================== class CppParserError(Exception): pass #============================================================================== # CppParser #============================================================================== class CppParser: 'Parses a header file and returns a list of declarations' def __init__(self, includes=None, defines=None, cache_dir=None, version=None, gccxml_path = 'gccxml'): 'includes and defines ar the directives given to gcc' if includes is None: includes = [] if defines is None: defines = [] self.includes = includes self.gccxml_path = gccxml_path self.defines = defines self.version = version #if cache_dir is None: # cache_dir = tempfile.mktemp() # self.delete_cache = True #else: # self.delete_cache = False self.delete_cache = False self.cache_dir = cache_dir self.cache_files = [] self.mem_cache = {} # create the cache dir if cache_dir: try: os.makedirs(cache_dir) except OSError: pass def __del__(self): self.Close() def _IncludeParams(self, filename): includes = self.includes[:] filedir = os.path.dirname(filename) if not filedir: filedir = '.' includes.insert(0, filedir) includes = ['-I "%s"' % self.Unixfy(x) for x in includes] return ' '.join(includes) def _DefineParams(self): defines = ['-D "%s"' % x for x in self.defines] return ' '.join(defines) def FindHeader(self, header): if os.path.isfile(header): return header for path in self.includes: filename = os.path.join(path, header) if os.path.isfile(filename): return filename else: name = os.path.basename(header) raise RuntimeError, 'Header file "%s" not found!' % name def AppendTail(self, filename, tail): '''Creates a temporary file, appends the text tail to it, and returns the filename of the file. ''' if hasattr(tempfile, 'mkstemp'): f_no, temp = tempfile.mkstemp('.h') f = file(temp, 'a') os.close(f_no) else: temp = tempfile.mktemp('.h') f = file(temp, 'a') f.write('#include "%s"\n\n' % os.path.abspath(filename)) f.write(tail) f.write('\n') f.close() return temp def Unixfy(self, path): return path.replace('\\', '/') def ParseWithGCCXML(self, header, tail): '''Parses the given header using gccxml and GCCXMLParser. ''' header = self.FindHeader(header) if tail: filename = self.AppendTail(header, tail) else: filename = header xmlfile = tempfile.mktemp('.xml') try: # get the params includes = self._IncludeParams(filename) defines = self._DefineParams() # call gccxml cmd = '%s %s %s "%s" -fxml=%s' filename = self.Unixfy(filename) xmlfile = self.Unixfy(xmlfile) status = os.system(cmd % (self.gccxml_path, includes, defines, filename, xmlfile)) if status != 0 or not os.path.isfile(xmlfile): raise CppParserError, 'Error executing gccxml' # parse the resulting xml declarations = ParseDeclarations(xmlfile) # make the declarations' location to point to the original file if tail: for decl in declarations: decl_filename = os.path.normpath(os.path.normcase(decl.location[0])) filename = os.path.normpath(os.path.normcase(filename)) if decl_filename == filename: decl.location = header, decl.location[1] # return the declarations return declarations finally: if settings.DEBUG and os.path.isfile(xmlfile): debugname = os.path.basename(header) debugname = os.path.splitext(debugname)[0] + '.xml' print 'DEBUG:', debugname shutil.copy(xmlfile, debugname) # delete the temporary files try: os.remove(xmlfile) if tail: os.remove(filename) except OSError: pass def Parse(self, header, interface, tail=None): '''Parses the given filename related to the given interface and returns the (declarations, headerfile). The header returned is normally the same as the given to this method (except that it is the full path), except if tail is not None: in this case, the header is copied to a temp filename and the tail code is appended to it before being passed on to gccxml. This temp filename is then returned. ''' if tail is None: tail = '' tail = tail.strip() declarations = self.GetCache(header, interface, tail) if declarations is None: declarations = self.ParseWithGCCXML(header, tail) self.CreateCache(header, interface, tail, declarations) header_fullpath = os.path.abspath(self.FindHeader(header)) return declarations, header_fullpath def CacheFileName(self, interface): interface_name = os.path.basename(interface) cache_file = os.path.splitext(interface_name)[0] + '.pystec' cache_file = os.path.join(self.cache_dir, cache_file) return cache_file def GetCache(self, header, interface, tail): key = (header, interface, tail) # try memory cache first if key in self.mem_cache: return self.mem_cache[key] # get the cache from the disk if self.cache_dir is None: return None header = self.FindHeader(header) cache_file = self.CacheFileName(interface) if os.path.isfile(cache_file): f = file(cache_file, 'rb') try: version = load(f) if version != self.version: return None cache = load(f) if cache.has_key(key): self.cache_files.append(cache_file) return cache[key] else: return None finally: f.close() else: return None def CreateCache(self, header, interface, tail, declarations): key = (header, interface, tail) # our memory cache only holds one item self.mem_cache.clear() self.mem_cache[key] = declarations # save the cache in the disk if self.cache_dir is None: return header = self.FindHeader(header) cache_file = self.CacheFileName(interface) if os.path.isfile(cache_file): f = file(cache_file, 'rb') try: version = load(f) cache = load(f) finally: f.close() else: cache = {} cache[key] = declarations self.cache_files.append(cache_file) f = file(cache_file, 'wb') try: dump(self.version, f, 1) dump(cache, f, 1) finally: f.close() return cache_file def Close(self): if self.delete_cache and self.cache_files: for filename in self.cache_files: try: os.remove(filename) except OSError: pass self.cache_files = [] shutil.rmtree(self.cache_dir)
gpl-2.0
[ 3, 1898, 699, 1065, 79, 12927, 428, 382, 3042, 477, 593, 6442, 20936, 13004, 14, 3645, 12, 7100, 436, 221, 199, 3, 4084, 365, 5420, 370, 314, 30470, 2290, 844, 12, 3394, 413, 14, 16, 14, 199, 3, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1331, 737, 221, 199, 3, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 199, 199, 504, 598, 2571, 4317, 2842, 492, 6077, 31963, 1298, 199, 646, 5549, 199, 646, 5145, 199, 646, 747, 199, 646, 984, 199, 646, 747, 14, 515, 199, 646, 2202, 199, 646, 5145, 199, 646, 1033, 15320, 199, 504, 17572, 492, 5461, 12, 2248, 199, 199, 31436, 199, 3, 4967, 199, 31436, 199, 533, 445, 802, 21811, 8, 1726, 304, 986, 199, 199, 31436, 199, 3, 445, 802, 2842, 199, 31436, 199, 533, 445, 802, 2842, 26, 272, 283, 23400, 282, 1406, 570, 436, 2529, 282, 769, 402, 18707, 7, 2286, 347, 636, 826, 721, 277, 12, 6952, 29, 403, 12, 7890, 29, 403, 12, 2581, 63, 694, 29, 403, 12, 1015, 29, 403, 12, 19443, 1652, 63, 515, 275, 283, 13112, 1652, 735, 4960, 283, 9441, 436, 7890, 601, 314, 13502, 1627, 370, 19443, 7, 267, 340, 6952, 365, 488, 26, 288, 6952, 275, 942, 267, 340, 7890, 365, 488, 26, 288, 7890, 275, 942, 267, 291, 14, 9441, 275, 6952, 267, 291, 14, 13112, 1652, 63, 515, 275, 19443, 1652, 63, 515, 4960, 291, 14, 14334, 275, 7890, 267, 291, 14, 1023, 275, 1015, 267, 327, 692, 2581, 63, 694, 365, 488, 26, 267, 327, 259, 2581, 63, 694, 275, 5549, 14, 22136, 342, 267, 327, 259, 291, 14, 1807, 63, 1637, 275, 715, 267, 327, 2836, 26, 267, 327, 259, 291, 14, 1807, 63, 1637, 275, 756, 267, 291, 14, 1807, 63, 1637, 275, 756, 267, 291, 14, 1637, 63, 694, 275, 2581, 63, 694, 267, 291, 14, 1637, 63, 1725, 275, 942, 267, 291, 14, 5286, 63, 1637, 275, 1052, 267, 327, 1218, 314, 2581, 2935, 267, 340, 2581, 63, 694, 26, 288, 862, 26, 355, 747, 14, 8347, 8, 1637, 63, 694, 9, 288, 871, 6440, 26, 986, 257, 2378, 347, 636, 2264, 721, 277, 304, 267, 291, 14, 4724, 342, 199, 5493, 347, 485, 7826, 6007, 8, 277, 12, 1788, 304, 267, 6952, 275, 291, 14, 9441, 5873, 267, 570, 694, 275, 747, 14, 515, 14, 3475, 8, 1501, 9, 267, 340, 440, 570, 694, 26, 288, 570, 694, 275, 7815, 267, 6952, 14, 3176, 8, 16, 12, 570, 694, 9, 267, 6952, 275, 11573, 41, 2071, 83, 4507, 450, 291, 14, 21607, 1399, 8, 88, 9, 367, 671, 315, 6952, 61, 267, 372, 283, 1987, 904, 8, 9441, 9, 2378, 347, 485, 16213, 6007, 8, 277, 304, 267, 7890, 275, 11573, 36, 2071, 83, 4507, 450, 671, 367, 671, 315, 291, 14, 14334, 61, 267, 372, 283, 1987, 904, 8, 14334, 9, 17635, 347, 6668, 2567, 8, 277, 12, 1406, 304, 267, 340, 747, 14, 515, 14, 6292, 8, 1291, 304, 288, 372, 1406, 267, 367, 931, 315, 291, 14, 9441, 26, 288, 1788, 275, 747, 14, 515, 14, 904, 8, 515, 12, 1406, 9, 257, 288, 340, 747, 14, 515, 14, 6292, 8, 1501, 304, 355, 372, 1788, 267, 587, 26, 288, 536, 275, 747, 14, 515, 14, 4846, 8, 1291, 9, 288, 746, 6064, 12, 283, 2567, 570, 2071, 83, 2, 440, 1911, 11213, 450, 536, 1362, 15567, 347, 18726, 52, 1054, 8, 277, 12, 1788, 12, 9483, 304, 267, 1449, 10607, 282, 7937, 570, 12, 1145, 3198, 314, 1318, 9483, 370, 652, 12, 436, 2529, 267, 314, 1788, 402, 314, 570, 14, 267, 1449, 267, 340, 2688, 8, 17336, 12, 283, 17721, 735, 288, 289, 63, 889, 12, 2388, 275, 5549, 14, 17721, 5175, 72, 358, 288, 289, 275, 570, 8, 808, 12, 283, 65, 358, 288, 747, 14, 1600, 8, 70, 63, 889, 9, 267, 587, 26, 288, 2388, 275, 5549, 14, 22136, 5175, 72, 358, 7205, 289, 275, 570, 8, 808, 12, 283, 65, 358, 267, 289, 14, 952, 7863, 2613, 2071, 83, 3212, 78, 60, 78, 7, 450, 747, 14, 515, 14, 4832, 8, 1501, 430, 267, 289, 14, 952, 8, 1521, 9, 267, 289, 14, 952, 2258, 78, 358, 267, 289, 14, 1600, 342, 259, 267, 372, 2388, 2378, 347, 13074, 1399, 8, 277, 12, 931, 304, 267, 372, 931, 14, 1814, 20786, 15107, 2378, 347, 6077, 3007, 10566, 4317, 8, 277, 12, 1406, 12, 9483, 304, 267, 1449, 23400, 314, 1627, 1406, 1808, 19443, 1652, 436, 598, 2571, 4317, 2842, 14, 267, 1449, 267, 1406, 275, 291, 14, 6591, 2567, 8, 1291, 9, 4960, 340, 9483, 26, 288, 1788, 275, 291, 14, 8310, 52, 1054, 8, 1291, 12, 9483, 9, 267, 587, 26, 288, 1788, 275, 1406, 267, 17725, 12059, 275, 5549, 14, 22136, 5175, 1652, 358, 267, 862, 26, 3777, 288, 327, 664, 314, 1862, 288, 6952, 275, 291, 423, 7826, 6007, 8, 1501, 9, 288, 7890, 275, 291, 423, 16213, 6007, 342, 288, 327, 1240, 19443, 1652, 288, 2088, 275, 1543, 83, 450, 83, 450, 83, 2071, 83, 2, 446, 70, 1652, 2458, 83, 7, 7205, 1788, 275, 291, 14, 21607, 1399, 8, 1501, 9, 288, 17725, 12059, 275, 291, 14, 21607, 1399, 8, 10198, 12059, 9, 288, 2004, 275, 747, 14, 2253, 8, 1760, 450, 334, 277, 14, 13112, 1652, 63, 515, 12, 6952, 12, 7890, 12, 1788, 12, 17725, 12059, 430, 288, 340, 2004, 1137, 378, 503, 440, 747, 14, 515, 14, 6292, 8, 10198, 12059, 304, 355, 746, 445, 802, 21811, 12, 283, 547, 14043, 19443, 1652, 7, 288, 327, 2198, 314, 9183, 2748, 288, 18707, 275, 6077, 31963, 1298, 8, 10198, 12059, 9, 288, 327, 1852, 314, 18707, 7, 2909, 370, 2376, 370, 314, 3379, 570, 288, 340, 9483, 26, 355, 367, 15021, 315, 18707, 26, 490, 15021, 63, 1501, 275, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 21288, 8, 9427, 14, 1985, 59, 16, 2459, 490, 1788, 275, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 21288, 8, 1501, 430, 490, 340, 15021, 63, 1501 ]
[ 1898, 699, 1065, 79, 12927, 428, 382, 3042, 477, 593, 6442, 20936, 13004, 14, 3645, 12, 7100, 436, 221, 199, 3, 4084, 365, 5420, 370, 314, 30470, 2290, 844, 12, 3394, 413, 14, 16, 14, 199, 3, 334, 9295, 23073, 570, 5113, 63, 17, 63, 16, 14, 2424, 503, 1331, 737, 221, 199, 3, 1455, 921, 1544, 14, 15589, 14, 1308, 15, 3961, 63, 17, 63, 16, 14, 2424, 9, 199, 199, 504, 598, 2571, 4317, 2842, 492, 6077, 31963, 1298, 199, 646, 5549, 199, 646, 5145, 199, 646, 747, 199, 646, 984, 199, 646, 747, 14, 515, 199, 646, 2202, 199, 646, 5145, 199, 646, 1033, 15320, 199, 504, 17572, 492, 5461, 12, 2248, 199, 199, 31436, 199, 3, 4967, 199, 31436, 199, 533, 445, 802, 21811, 8, 1726, 304, 986, 199, 199, 31436, 199, 3, 445, 802, 2842, 199, 31436, 199, 533, 445, 802, 2842, 26, 272, 283, 23400, 282, 1406, 570, 436, 2529, 282, 769, 402, 18707, 7, 2286, 347, 636, 826, 721, 277, 12, 6952, 29, 403, 12, 7890, 29, 403, 12, 2581, 63, 694, 29, 403, 12, 1015, 29, 403, 12, 19443, 1652, 63, 515, 275, 283, 13112, 1652, 735, 4960, 283, 9441, 436, 7890, 601, 314, 13502, 1627, 370, 19443, 7, 267, 340, 6952, 365, 488, 26, 288, 6952, 275, 942, 267, 340, 7890, 365, 488, 26, 288, 7890, 275, 942, 267, 291, 14, 9441, 275, 6952, 267, 291, 14, 13112, 1652, 63, 515, 275, 19443, 1652, 63, 515, 4960, 291, 14, 14334, 275, 7890, 267, 291, 14, 1023, 275, 1015, 267, 327, 692, 2581, 63, 694, 365, 488, 26, 267, 327, 259, 2581, 63, 694, 275, 5549, 14, 22136, 342, 267, 327, 259, 291, 14, 1807, 63, 1637, 275, 715, 267, 327, 2836, 26, 267, 327, 259, 291, 14, 1807, 63, 1637, 275, 756, 267, 291, 14, 1807, 63, 1637, 275, 756, 267, 291, 14, 1637, 63, 694, 275, 2581, 63, 694, 267, 291, 14, 1637, 63, 1725, 275, 942, 267, 291, 14, 5286, 63, 1637, 275, 1052, 267, 327, 1218, 314, 2581, 2935, 267, 340, 2581, 63, 694, 26, 288, 862, 26, 355, 747, 14, 8347, 8, 1637, 63, 694, 9, 288, 871, 6440, 26, 986, 257, 2378, 347, 636, 2264, 721, 277, 304, 267, 291, 14, 4724, 342, 199, 5493, 347, 485, 7826, 6007, 8, 277, 12, 1788, 304, 267, 6952, 275, 291, 14, 9441, 5873, 267, 570, 694, 275, 747, 14, 515, 14, 3475, 8, 1501, 9, 267, 340, 440, 570, 694, 26, 288, 570, 694, 275, 7815, 267, 6952, 14, 3176, 8, 16, 12, 570, 694, 9, 267, 6952, 275, 11573, 41, 2071, 83, 4507, 450, 291, 14, 21607, 1399, 8, 88, 9, 367, 671, 315, 6952, 61, 267, 372, 283, 1987, 904, 8, 9441, 9, 2378, 347, 485, 16213, 6007, 8, 277, 304, 267, 7890, 275, 11573, 36, 2071, 83, 4507, 450, 671, 367, 671, 315, 291, 14, 14334, 61, 267, 372, 283, 1987, 904, 8, 14334, 9, 17635, 347, 6668, 2567, 8, 277, 12, 1406, 304, 267, 340, 747, 14, 515, 14, 6292, 8, 1291, 304, 288, 372, 1406, 267, 367, 931, 315, 291, 14, 9441, 26, 288, 1788, 275, 747, 14, 515, 14, 904, 8, 515, 12, 1406, 9, 257, 288, 340, 747, 14, 515, 14, 6292, 8, 1501, 304, 355, 372, 1788, 267, 587, 26, 288, 536, 275, 747, 14, 515, 14, 4846, 8, 1291, 9, 288, 746, 6064, 12, 283, 2567, 570, 2071, 83, 2, 440, 1911, 11213, 450, 536, 1362, 15567, 347, 18726, 52, 1054, 8, 277, 12, 1788, 12, 9483, 304, 267, 1449, 10607, 282, 7937, 570, 12, 1145, 3198, 314, 1318, 9483, 370, 652, 12, 436, 2529, 267, 314, 1788, 402, 314, 570, 14, 267, 1449, 267, 340, 2688, 8, 17336, 12, 283, 17721, 735, 288, 289, 63, 889, 12, 2388, 275, 5549, 14, 17721, 5175, 72, 358, 288, 289, 275, 570, 8, 808, 12, 283, 65, 358, 288, 747, 14, 1600, 8, 70, 63, 889, 9, 267, 587, 26, 288, 2388, 275, 5549, 14, 22136, 5175, 72, 358, 7205, 289, 275, 570, 8, 808, 12, 283, 65, 358, 267, 289, 14, 952, 7863, 2613, 2071, 83, 3212, 78, 60, 78, 7, 450, 747, 14, 515, 14, 4832, 8, 1501, 430, 267, 289, 14, 952, 8, 1521, 9, 267, 289, 14, 952, 2258, 78, 358, 267, 289, 14, 1600, 342, 259, 267, 372, 2388, 2378, 347, 13074, 1399, 8, 277, 12, 931, 304, 267, 372, 931, 14, 1814, 20786, 15107, 2378, 347, 6077, 3007, 10566, 4317, 8, 277, 12, 1406, 12, 9483, 304, 267, 1449, 23400, 314, 1627, 1406, 1808, 19443, 1652, 436, 598, 2571, 4317, 2842, 14, 267, 1449, 267, 1406, 275, 291, 14, 6591, 2567, 8, 1291, 9, 4960, 340, 9483, 26, 288, 1788, 275, 291, 14, 8310, 52, 1054, 8, 1291, 12, 9483, 9, 267, 587, 26, 288, 1788, 275, 1406, 267, 17725, 12059, 275, 5549, 14, 22136, 5175, 1652, 358, 267, 862, 26, 3777, 288, 327, 664, 314, 1862, 288, 6952, 275, 291, 423, 7826, 6007, 8, 1501, 9, 288, 7890, 275, 291, 423, 16213, 6007, 342, 288, 327, 1240, 19443, 1652, 288, 2088, 275, 1543, 83, 450, 83, 450, 83, 2071, 83, 2, 446, 70, 1652, 2458, 83, 7, 7205, 1788, 275, 291, 14, 21607, 1399, 8, 1501, 9, 288, 17725, 12059, 275, 291, 14, 21607, 1399, 8, 10198, 12059, 9, 288, 2004, 275, 747, 14, 2253, 8, 1760, 450, 334, 277, 14, 13112, 1652, 63, 515, 12, 6952, 12, 7890, 12, 1788, 12, 17725, 12059, 430, 288, 340, 2004, 1137, 378, 503, 440, 747, 14, 515, 14, 6292, 8, 10198, 12059, 304, 355, 746, 445, 802, 21811, 12, 283, 547, 14043, 19443, 1652, 7, 288, 327, 2198, 314, 9183, 2748, 288, 18707, 275, 6077, 31963, 1298, 8, 10198, 12059, 9, 288, 327, 1852, 314, 18707, 7, 2909, 370, 2376, 370, 314, 3379, 570, 288, 340, 9483, 26, 355, 367, 15021, 315, 18707, 26, 490, 15021, 63, 1501, 275, 747, 14, 515, 14, 9267, 8, 736, 14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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
samba-team/samba
source4/torture/drs/python/getnc_schema.py
2
11114
import drs_base import ldb import time from samba.dcerpc import misc from samba.drs_utils import drs_Replicate, drsException import samba import random import time import os break_me = os.getenv("PLEASE_BREAK_MY_WINDOWS") == "1" assert break_me, ("This test breaks Windows active directory after " "a few runs. Set PLEASE_BREAK_MY_WINDOWS=1 to run.") # This test runs against Windows. To run, set up two Windows AD DCs, join one # to the other, and make sure the passwords are the same. SMB_CONF_PATH must # also be set to any smb.conf file. Set DC1 to the PDC's hostname, and DC2 to # the join'd DC's hostname. Example: # PLEASE_BREAK_MY_WINDOWS=1 # DC1=pdc DC2=joindc # SMB_CONF_PATH=st/ad_dc/etc/smb.conf # PYTHONPATH=$PYTHONPATH:./source4/torture/drs/python # python3 ./source4/scripting/bin/subunitrun getnc_schema # -UAdministrator%Password class SchemaReplicationTests(drs_base.DrsBaseTestCase): def setUp(self): super(SchemaReplicationTests, self).setUp() self.creds = self.get_credentials() self.cmdline_auth = "-U{}%{}".format(self.creds.get_username(), self.creds.get_password()) self.from_ldb = self.ldb_dc1 self.dest_ldb = self.ldb_dc2 self._disable_inbound_repl(self.url_dc1) self._disable_all_repl(self.url_dc1) self.free_offset = 0 def tearDown(self): self._enable_inbound_repl(self.url_dc1) self._enable_all_repl(self.url_dc1) def do_repl(self, partition_dn): self._enable_inbound_repl(self.url_dc1) self._enable_all_repl(self.url_dc1) samba_tool_cmd = ["drs", "replicate", self.url_dc2, self.url_dc1] samba_tool_cmd += [partition_dn] username = self.creds.get_username() password = self.creds.get_password() samba_tool_cmd += ["-U{0}%{1}".format(username, password)] (result, out, err) = self.runsubcmd(*samba_tool_cmd) try: self.assertCmdSuccess(result, out, err) except AssertionError: print("Failed repl, retrying in 10s") time.sleep(10) (result, out, err) = self.runsubcmd(*samba_tool_cmd) self._disable_inbound_repl(self.url_dc1) self._disable_all_repl(self.url_dc1) self.assertCmdSuccess(result, out, err) # Get a unique prefix for some search expression like "([att]=[pref]{i}*)" def get_unique(self, expr_templ): found = True while found: i = random.randint(0, 65535) res = self.from_ldb.search(base=self.schema_dn, scope=ldb.SCOPE_SUBTREE, expression=expr_templ.format(i=i)) found = len(res) > 0 return str(i) def unique_gov_id_prefix(self): prefix = "1.3.6.1.4.1.7165.4.6.2.8." return prefix + self.get_unique("(governsId=" + prefix + "{i}.*)") def unique_cn_prefix(self, prefix="testobj"): return prefix + self.get_unique("(cn=" + prefix + "{i}x*)") + "x" # Make test schema classes linked to each other in a line, then modify # them in reverse order so when we repl, a link crosses the chunk # boundary. Chunk size is 133 by default so we do 150. def test_poss_superiors_across_chunk(self): num_schema_objects_to_add = 150 class_name = self.unique_cn_prefix() ldif_template = """ dn: CN={class_name}{i},{schema_dn} objectClass: top objectClass: classSchema adminDescription: {class_name}{i} adminDisplayName: {class_name}{i} cn: {class_name}{i} governsId: {gov_id}.{i} instanceType: 4 objectClassCategory: 1 systemFlags: 16 systemOnly: FALSE """ ldif_kwargs = {'class_name': class_name, 'schema_dn': self.schema_dn} gov_id = self.unique_gov_id_prefix() ldif = ldif_template.format(i=0, gov_id=gov_id, **ldif_kwargs) self.from_ldb.add_ldif(ldif) ldif_template += "systemPossSuperiors: {possSup}\n" ids = list(range(num_schema_objects_to_add)) got_no_such_attrib = False for i in ids[1:]: last_class_name = class_name + str(i-1) ldif = ldif_template.format(i=i, gov_id=gov_id, possSup=last_class_name, **ldif_kwargs) try: self.from_ldb.add_ldif(ldif) if got_no_such_attrib: self.from_ldb.set_schema_update_now() except ldb.LdbError as e: if e.args[0] != ldb.ERR_NO_SUCH_ATTRIBUTE: self.fail(e) if got_no_such_attrib: self.fail(("got NO_SUCH_ATTRIB even after " "setting schemaUpdateNow", str(e))) print("got NO_SUCH_ATTRIB, trying schemaUpdateNow") got_no_such_attrib = True self.from_ldb.set_schema_update_now() self.from_ldb.add_ldif(ldif) self.from_ldb.set_schema_update_now() ldif_template = """ dn: CN={class_name}{i},{schema_dn} changetype: modify replace: adminDescription adminDescription: new_description """ for i in reversed(ids): ldif = ldif_template.format(i=i, **ldif_kwargs) self.from_ldb.modify_ldif(ldif) self.do_repl(self.schema_dn) dn_templ = "CN={class_name}{i},{schema_dn}" for i in ids: dn = dn_templ.format(i=i, **ldif_kwargs) res = self.dest_ldb.search(base=dn, scope=ldb.SCOPE_BASE) self.assertEqual(len(res), 1) # Test for method of adding linked attributes in schema partition # required by other tests. def test_create_linked_attribute_in_schema(self): # Make an object outside of the schema partition that we can link to user_name = self.unique_cn_prefix("user") user_dn = "CN={},CN=Users,{}".format(user_name, self.domain_dn) ldif_template = """ dn: {user_dn} objectClass: person objectClass: user""" ldif = ldif_template.format(user_dn=user_dn) self.from_ldb.add_ldif(ldif) # Make test class name unique so test can run multiple times class_name = self.unique_cn_prefix("class") kwargs = {'class_name': class_name, 'schema_dn': self.schema_dn, 'user_dn': user_dn} # Add an auxiliary schemaClass (cat 3) class and give it managedBy # so we can create schema objects with linked attributes. ldif_template = """ dn: CN={class_name},{schema_dn} objectClass: classSchema governsId: {gov_id}.0 instanceType: 4 systemFlags: 16 systemOnly: FALSE objectClassCategory: 3 mayContain: managedBy """ gov_id = self.unique_gov_id_prefix() ldif = ldif_template.format(gov_id=gov_id, **kwargs) self.from_ldb.add_ldif(ldif) # Now make an instance that points back to the user with managedBy, # thus creating an object in the schema with a linked attribute ldif_template = """ dn: CN=link{class_name},{schema_dn} objectClass: classSchema objectClass: {class_name} instanceType: 4 governsId: {gov_id}.0 systemFlags: 16 managedBy: {user_dn} """ gov_id = self.unique_gov_id_prefix() ldif = ldif_template.format(gov_id=gov_id, **kwargs) self.from_ldb.add_ldif(ldif) # Check link exists on test schema object dn_templ = "CN=link{class_name},{schema_dn}" dn = dn_templ.format(**kwargs) res = self.from_ldb.search(base=dn, scope=ldb.SCOPE_BASE) self.assertEqual(len(res), 1) self.assertIsNotNone(res[0].get("managedBy")) self.assertEqual(str(res[0].get("managedBy")[0]), user_dn) # Check backlink on user object res = self.from_ldb.search(base=user_dn, scope=ldb.SCOPE_BASE) self.assertEqual(len(res), 1) managed_objs = res[0].get("managedObjects") self.assertEqual(len(managed_objs), 1) managed_objs = [str(o) for o in managed_objs] self.assertEqual(managed_objs, [dn_templ.format(**kwargs)]) def test_schema_linked_attributes(self): num_test_objects = 9 # Make an object outside of the schema partition that we can link to user_name = self.unique_cn_prefix("user") user_dn = "CN={},CN=Users,{}".format(user_name, self.domain_dn) ldif_template = """ dn: {user_dn} objectClass: person objectClass: user""" ldif = ldif_template.format(user_dn=user_dn) self.from_ldb.add_ldif(ldif) self.do_repl(self.domain_dn) # Make test object name prefixes unique so test can run multiple times # in a single testenv (can't delete schema objects) class_name = self.unique_cn_prefix("class") link_class_name = self.unique_cn_prefix("linkClass") kwargs = {'class_name': class_name, 'schema_dn': self.schema_dn, 'link_class_name': link_class_name, 'user_dn': user_dn} # Add an auxiliary schemaClass (cat 3) class and give it managedBy # so we can create schema objects with linked attributes. ldif_template = """ dn: CN={class_name},{schema_dn} objectClass: classSchema governsId: {gov_id}.0 instanceType: 4 systemFlags: 16 systemOnly: FALSE objectClassCategory: 3 mayContain: managedBy """ gov_id = self.unique_gov_id_prefix() ldif = ldif_template.format(gov_id=gov_id, **kwargs) self.from_ldb.add_ldif(ldif) # Now make instances that point back to the user with managedBy, # thus creating objects in the schema with linked attributes ldif_template = """ dn: CN={link_class_name}{i},{schema_dn} objectClass: classSchema objectClass: {class_name} instanceType: 4 governsId: {gov_id}.0 systemFlags: 16 managedBy: {user_dn} """ id_range = list(range(num_test_objects)) for i in id_range: gov_id = self.unique_gov_id_prefix() ldif = ldif_template.format(i=i, gov_id=gov_id, **kwargs) self.from_ldb.add_ldif(ldif) self.do_repl(self.schema_dn) # Check link exists in each test schema objects at destination DC dn_templ = "CN={link_class_name}{i},{schema_dn}" for i in id_range: dn = dn_templ.format(i=i, **kwargs) res = self.dest_ldb.search(base=dn, scope=ldb.SCOPE_BASE) self.assertEqual(len(res), 1) self.assertIsNotNone(res[0].get("managedBy")) self.assertEqual(str(res[0].get("managedBy")[0]), user_dn) # Check backlinks list on user object contains DNs of test objects. res = self.dest_ldb.search(base=user_dn, scope=ldb.SCOPE_BASE) self.assertEqual(len(res), 1) managed_objs = res[0].get("managedObjects") self.assertIsNotNone(managed_objs) managed_objs_set = {str(el) for el in managed_objs} expected = {dn_templ.format(i=i, **kwargs) for i in id_range} self.assertEqual(managed_objs_set, expected)
gpl-3.0
[ 646, 366, 2393, 63, 1095, 199, 646, 634, 697, 199, 646, 900, 199, 504, 31710, 14, 68, 2247, 2352, 492, 18576, 199, 504, 31710, 14, 68, 2393, 63, 1208, 492, 366, 2393, 63, 6875, 19117, 12, 366, 2393, 1726, 199, 646, 31710, 199, 646, 2196, 199, 646, 900, 199, 646, 747, 199, 199, 4785, 63, 278, 275, 747, 14, 12959, 480, 48, 17177, 63, 14731, 63, 12339, 63, 20509, 531, 508, 298, 17, 2, 199, 479, 2059, 63, 278, 12, 1689, 2765, 511, 18277, 5417, 4702, 2082, 2410, 298, 2116, 298, 65, 9284, 7858, 14, 221, 2494, 510, 17177, 63, 14731, 63, 12339, 63, 20509, 29, 17, 370, 1255, 2685, 199, 199, 3, 961, 511, 7858, 6169, 5417, 14, 221, 4005, 1255, 12, 663, 1536, 2877, 5417, 16271, 577, 13912, 12, 4263, 1373, 199, 3, 370, 314, 1163, 12, 436, 1852, 3238, 314, 19572, 787, 314, 2011, 14, 221, 2389, 34, 63, 3103, 63, 3243, 1471, 199, 3, 2597, 506, 663, 370, 1263, 22717, 14, 2190, 570, 14, 2494, 30592, 17, 370, 314, 510, 5196, 1159, 6246, 12, 436, 30592, 18, 370, 199, 3, 314, 4263, 5121, 30592, 1159, 6246, 14, 5679, 26, 199, 3, 510, 17177, 63, 14731, 63, 12339, 63, 20509, 29, 17, 199, 3, 30592, 17, 29, 80, 3833, 30592, 18, 29, 743, 688, 67, 199, 3, 2389, 34, 63, 3103, 63, 3243, 29, 270, 15, 350, 63, 3833, 15, 6839, 15, 23323, 14, 2190, 199, 3, 31176, 28617, 29266, 26, 13186, 1365, 20, 15, 84, 361, 608, 15, 68, 2393, 15, 1548, 199, 3, 2366, 19, 16605, 1365, 20, 15, 1579, 316, 15, 1393, 15, 954, 3248, 1065, 664, 7966, 63, 3629, 199, 3, 446, 53, 31972, 5, 6139, 199, 199, 533, 13268, 31320, 2925, 8, 68, 2393, 63, 1095, 14, 36, 2393, 20760, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 6700, 31320, 2925, 12, 291, 680, 5996, 342, 267, 291, 14, 15226, 275, 291, 14, 362, 63, 6942, 342, 267, 291, 14, 15612, 63, 1178, 275, 3905, 53, 2440, 5, 13536, 908, 8, 277, 14, 15226, 14, 362, 63, 2473, 1062, 6163, 291, 14, 15226, 14, 362, 63, 2060, 1012, 398, 291, 14, 504, 63, 15793, 275, 291, 14, 15793, 63, 3833, 17, 267, 291, 14, 2614, 63, 15793, 275, 291, 14, 15793, 63, 3833, 18, 267, 291, 423, 5993, 63, 26108, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 267, 291, 423, 5993, 63, 452, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 267, 291, 14, 4624, 63, 2743, 275, 378, 339, 347, 6766, 8, 277, 304, 267, 291, 423, 4296, 63, 26108, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 267, 291, 423, 4296, 63, 452, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 339, 347, 886, 63, 16349, 8, 277, 12, 6484, 63, 4272, 304, 267, 291, 423, 4296, 63, 26108, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 267, 291, 423, 4296, 63, 452, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 398, 31710, 63, 3557, 63, 1760, 275, 2097, 68, 2393, 401, 298, 1155, 19117, 401, 291, 14, 633, 63, 3833, 18, 12, 291, 14, 633, 63, 3833, 17, 61, 267, 31710, 63, 3557, 63, 1760, 847, 359, 5312, 63, 4272, 61, 267, 3434, 275, 291, 14, 15226, 14, 362, 63, 2473, 342, 267, 2505, 275, 291, 14, 15226, 14, 362, 63, 2060, 342, 267, 31710, 63, 3557, 63, 1760, 847, 16984, 53, 91, 16, 22109, 91, 17, 5469, 908, 8, 2473, 12, 2505, 1874, 398, 334, 1099, 12, 734, 12, 2329, 9, 275, 291, 14, 1065, 954, 1760, 2031, 21693, 63, 3557, 63, 1760, 9, 398, 862, 26, 288, 291, 14, 479, 7874, 8300, 8, 1099, 12, 734, 12, 2329, 9, 267, 871, 9070, 26, 288, 870, 480, 4276, 20265, 12, 7269, 316, 315, 1616, 83, 531, 288, 900, 14, 4532, 8, 709, 9, 288, 334, 1099, 12, 734, 12, 2329, 9, 275, 291, 14, 1065, 954, 1760, 2031, 21693, 63, 3557, 63, 1760, 9, 398, 291, 423, 5993, 63, 26108, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 267, 291, 423, 5993, 63, 452, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 398, 291, 14, 479, 7874, 8300, 8, 1099, 12, 734, 12, 2329, 9, 339, 327, 2372, 282, 3747, 2403, 367, 2005, 2754, 3965, 2839, 298, 779, 6796, 61, 1524, 13829, 8194, 73, 93, 25952, 272, 347, 664, 63, 3235, 8, 277, 12, 5348, 63, 808, 76, 304, 267, 1911, 275, 715, 267, 1830, 1911, 26, 288, 284, 275, 2196, 14, 8393, 8, 16, 12, 18247, 9, 288, 522, 275, 291, 14, 504, 63, 15793, 14, 1733, 8, 1095, 29, 277, 14, 3629, 63, 4272, 12, 4318, 4194, 29, 15793, 14, 17998, 63, 6348, 22841, 12, 4318, 3965, 29, 3684, 63, 808, 76, 14, 908, 8, 73, 29, 73, 430, 288, 1911, 275, 822, 8, 470, 9, 690, 378, 398, 372, 620, 8, 73, 9, 339, 347, 3747, 63, 16294, 63, 344, 63, 1861, 8, 277, 304, 267, 2403, 275, 298, 17, 14, 19, 14, 22, 14, 17, 14, 20, 14, 17, 14, 23, 10355, 14, 20, 14, 22, 14, 18, 14, 24, 2122, 267, 372, 2403, 435, 291, 14, 362, 63, 3235, 18353, 71, 1883, 561, 1304, 628, 435, 2403, 435, 5310, 73, 93, 2795, 6320, 339, 347, 3747, 63, 6413, 63, 1861, 8, 277, 12, 2403, 628, 396, 1113, 2349, 267, 372, 2403, 435, 291, 14, 362, 63, 3235, 18353, 6413, 628, 435, 2403, 435, 5310, 73, 93, 88, 10, 6320, 435, 298, 88, 2, 339, 327, 4155, 511, 4177, 3992, 10632, 370, 1924, 1163, 315, 282, 1004, 12, 2066, 2811, 272, 327, 3062, 315, 3837, 1865, 880, 1380, 781, 20265, 12, 282, 2142, 25532, 874, 314, 3728, 272, 327, 8424, 14, 221, 25246, 1568, 365, 28416, 701, 849, 880, 781, 886, 14711, 14, 272, 347, 511, 63, 555, 385, 63, 4792, 73, 1384, 63, 32293, 63, 4604, 8, 277, 304, 267, 1967, 63, 3629, 63, 1462, 63, 475, 63, 525, 275, 14711, 267, 1021, 63, 354, 275, 291, 14, 3235, 63, 6413, 63, 1861, 342, 398, 634, 7330, 63 ]
[ 366, 2393, 63, 1095, 199, 646, 634, 697, 199, 646, 900, 199, 504, 31710, 14, 68, 2247, 2352, 492, 18576, 199, 504, 31710, 14, 68, 2393, 63, 1208, 492, 366, 2393, 63, 6875, 19117, 12, 366, 2393, 1726, 199, 646, 31710, 199, 646, 2196, 199, 646, 900, 199, 646, 747, 199, 199, 4785, 63, 278, 275, 747, 14, 12959, 480, 48, 17177, 63, 14731, 63, 12339, 63, 20509, 531, 508, 298, 17, 2, 199, 479, 2059, 63, 278, 12, 1689, 2765, 511, 18277, 5417, 4702, 2082, 2410, 298, 2116, 298, 65, 9284, 7858, 14, 221, 2494, 510, 17177, 63, 14731, 63, 12339, 63, 20509, 29, 17, 370, 1255, 2685, 199, 199, 3, 961, 511, 7858, 6169, 5417, 14, 221, 4005, 1255, 12, 663, 1536, 2877, 5417, 16271, 577, 13912, 12, 4263, 1373, 199, 3, 370, 314, 1163, 12, 436, 1852, 3238, 314, 19572, 787, 314, 2011, 14, 221, 2389, 34, 63, 3103, 63, 3243, 1471, 199, 3, 2597, 506, 663, 370, 1263, 22717, 14, 2190, 570, 14, 2494, 30592, 17, 370, 314, 510, 5196, 1159, 6246, 12, 436, 30592, 18, 370, 199, 3, 314, 4263, 5121, 30592, 1159, 6246, 14, 5679, 26, 199, 3, 510, 17177, 63, 14731, 63, 12339, 63, 20509, 29, 17, 199, 3, 30592, 17, 29, 80, 3833, 30592, 18, 29, 743, 688, 67, 199, 3, 2389, 34, 63, 3103, 63, 3243, 29, 270, 15, 350, 63, 3833, 15, 6839, 15, 23323, 14, 2190, 199, 3, 31176, 28617, 29266, 26, 13186, 1365, 20, 15, 84, 361, 608, 15, 68, 2393, 15, 1548, 199, 3, 2366, 19, 16605, 1365, 20, 15, 1579, 316, 15, 1393, 15, 954, 3248, 1065, 664, 7966, 63, 3629, 199, 3, 446, 53, 31972, 5, 6139, 199, 199, 533, 13268, 31320, 2925, 8, 68, 2393, 63, 1095, 14, 36, 2393, 20760, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 6700, 31320, 2925, 12, 291, 680, 5996, 342, 267, 291, 14, 15226, 275, 291, 14, 362, 63, 6942, 342, 267, 291, 14, 15612, 63, 1178, 275, 3905, 53, 2440, 5, 13536, 908, 8, 277, 14, 15226, 14, 362, 63, 2473, 1062, 6163, 291, 14, 15226, 14, 362, 63, 2060, 1012, 398, 291, 14, 504, 63, 15793, 275, 291, 14, 15793, 63, 3833, 17, 267, 291, 14, 2614, 63, 15793, 275, 291, 14, 15793, 63, 3833, 18, 267, 291, 423, 5993, 63, 26108, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 267, 291, 423, 5993, 63, 452, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 267, 291, 14, 4624, 63, 2743, 275, 378, 339, 347, 6766, 8, 277, 304, 267, 291, 423, 4296, 63, 26108, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 267, 291, 423, 4296, 63, 452, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 339, 347, 886, 63, 16349, 8, 277, 12, 6484, 63, 4272, 304, 267, 291, 423, 4296, 63, 26108, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 267, 291, 423, 4296, 63, 452, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 398, 31710, 63, 3557, 63, 1760, 275, 2097, 68, 2393, 401, 298, 1155, 19117, 401, 291, 14, 633, 63, 3833, 18, 12, 291, 14, 633, 63, 3833, 17, 61, 267, 31710, 63, 3557, 63, 1760, 847, 359, 5312, 63, 4272, 61, 267, 3434, 275, 291, 14, 15226, 14, 362, 63, 2473, 342, 267, 2505, 275, 291, 14, 15226, 14, 362, 63, 2060, 342, 267, 31710, 63, 3557, 63, 1760, 847, 16984, 53, 91, 16, 22109, 91, 17, 5469, 908, 8, 2473, 12, 2505, 1874, 398, 334, 1099, 12, 734, 12, 2329, 9, 275, 291, 14, 1065, 954, 1760, 2031, 21693, 63, 3557, 63, 1760, 9, 398, 862, 26, 288, 291, 14, 479, 7874, 8300, 8, 1099, 12, 734, 12, 2329, 9, 267, 871, 9070, 26, 288, 870, 480, 4276, 20265, 12, 7269, 316, 315, 1616, 83, 531, 288, 900, 14, 4532, 8, 709, 9, 288, 334, 1099, 12, 734, 12, 2329, 9, 275, 291, 14, 1065, 954, 1760, 2031, 21693, 63, 3557, 63, 1760, 9, 398, 291, 423, 5993, 63, 26108, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 267, 291, 423, 5993, 63, 452, 63, 16349, 8, 277, 14, 633, 63, 3833, 17, 9, 398, 291, 14, 479, 7874, 8300, 8, 1099, 12, 734, 12, 2329, 9, 339, 327, 2372, 282, 3747, 2403, 367, 2005, 2754, 3965, 2839, 298, 779, 6796, 61, 1524, 13829, 8194, 73, 93, 25952, 272, 347, 664, 63, 3235, 8, 277, 12, 5348, 63, 808, 76, 304, 267, 1911, 275, 715, 267, 1830, 1911, 26, 288, 284, 275, 2196, 14, 8393, 8, 16, 12, 18247, 9, 288, 522, 275, 291, 14, 504, 63, 15793, 14, 1733, 8, 1095, 29, 277, 14, 3629, 63, 4272, 12, 4318, 4194, 29, 15793, 14, 17998, 63, 6348, 22841, 12, 4318, 3965, 29, 3684, 63, 808, 76, 14, 908, 8, 73, 29, 73, 430, 288, 1911, 275, 822, 8, 470, 9, 690, 378, 398, 372, 620, 8, 73, 9, 339, 347, 3747, 63, 16294, 63, 344, 63, 1861, 8, 277, 304, 267, 2403, 275, 298, 17, 14, 19, 14, 22, 14, 17, 14, 20, 14, 17, 14, 23, 10355, 14, 20, 14, 22, 14, 18, 14, 24, 2122, 267, 372, 2403, 435, 291, 14, 362, 63, 3235, 18353, 71, 1883, 561, 1304, 628, 435, 2403, 435, 5310, 73, 93, 2795, 6320, 339, 347, 3747, 63, 6413, 63, 1861, 8, 277, 12, 2403, 628, 396, 1113, 2349, 267, 372, 2403, 435, 291, 14, 362, 63, 3235, 18353, 6413, 628, 435, 2403, 435, 5310, 73, 93, 88, 10, 6320, 435, 298, 88, 2, 339, 327, 4155, 511, 4177, 3992, 10632, 370, 1924, 1163, 315, 282, 1004, 12, 2066, 2811, 272, 327, 3062, 315, 3837, 1865, 880, 1380, 781, 20265, 12, 282, 2142, 25532, 874, 314, 3728, 272, 327, 8424, 14, 221, 25246, 1568, 365, 28416, 701, 849, 880, 781, 886, 14711, 14, 272, 347, 511, 63, 555, 385, 63, 4792, 73, 1384, 63, 32293, 63, 4604, 8, 277, 304, 267, 1967, 63, 3629, 63, 1462, 63, 475, 63, 525, 275, 14711, 267, 1021, 63, 354, 275, 291, 14, 3235, 63, 6413, 63, 1861, 342, 398, 634, 7330, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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 2003-2017 Nominum, Inc. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose with or without fee is hereby granted, # provided that the above copyright notice and this permission notice # appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. from io import StringIO import select import sys import socket import time try: import unittest2 as unittest except ImportError: import unittest import dns.message import dns.name import dns.rdataclass import dns.rdatatype import dns.resolver from dns._compat import xrange # Some tests require the internet to be available to run, so let's # skip those if it's not there. _network_available = True try: socket.gethostbyname('dnspython.org') except socket.gaierror: _network_available = False resolv_conf = u""" /t/t # comment 1 ; comment 2 domain foo nameserver 10.0.0.1 nameserver 10.0.0.2 """ message_text = """id 1234 opcode QUERY rcode NOERROR flags QR AA RD ;QUESTION example. IN A ;ANSWER example. 1 IN A 10.0.0.1 ;AUTHORITY ;ADDITIONAL """ dangling_cname_0_message_text = """id 10000 opcode QUERY rcode NOERROR flags QR AA RD RA ;QUESTION 91.11.17.172.in-addr.arpa.none. IN PTR ;ANSWER ;AUTHORITY ;ADDITIONAL """ dangling_cname_1_message_text = """id 10001 opcode QUERY rcode NOERROR flags QR AA RD RA ;QUESTION 91.11.17.172.in-addr.arpa. IN PTR ;ANSWER 11.17.172.in-addr.arpa. 86400 IN DNAME 11.8-22.17.172.in-addr.arpa. 91.11.17.172.in-addr.arpa. 86400 IN CNAME 91.11.8-22.17.172.in-addr.arpa. ;AUTHORITY ;ADDITIONAL """ dangling_cname_2_message_text = """id 10002 opcode QUERY rcode NOERROR flags QR AA RD RA ;QUESTION 91.11.17.172.in-addr.arpa.example. IN PTR ;ANSWER 91.11.17.172.in-addr.arpa.example. 86400 IN CNAME 91.11.17.172.in-addr.arpa.base. 91.11.17.172.in-addr.arpa.base. 86400 IN CNAME 91.11.17.172.clients.example. 91.11.17.172.clients.example. 86400 IN CNAME 91-11-17-172.dynamic.example. ;AUTHORITY ;ADDITIONAL """ class FakeAnswer(object): def __init__(self, expiration): self.expiration = expiration class BaseResolverTests(unittest.TestCase): if sys.platform != 'win32': def testRead(self): f = StringIO(resolv_conf) r = dns.resolver.Resolver(f) self.failUnless(r.nameservers == ['10.0.0.1', '10.0.0.2'] and r.domain == dns.name.from_text('foo')) def testCacheExpiration(self): message = dns.message.from_text(message_text) name = dns.name.from_text('example.') answer = dns.resolver.Answer(name, dns.rdatatype.A, dns.rdataclass.IN, message) cache = dns.resolver.Cache() cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) time.sleep(2) self.failUnless(cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) is None) def testCacheCleaning(self): message = dns.message.from_text(message_text) name = dns.name.from_text('example.') answer = dns.resolver.Answer(name, dns.rdatatype.A, dns.rdataclass.IN, message) cache = dns.resolver.Cache(cleaning_interval=1.0) cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) time.sleep(2) self.failUnless(cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) is None) def testIndexErrorOnEmptyRRsetAccess(self): def bad(): message = dns.message.from_text(message_text) name = dns.name.from_text('example.') answer = dns.resolver.Answer(name, dns.rdatatype.MX, dns.rdataclass.IN, message, False) return answer[0] self.failUnlessRaises(IndexError, bad) def testIndexErrorOnEmptyRRsetDelete(self): def bad(): message = dns.message.from_text(message_text) name = dns.name.from_text('example.') answer = dns.resolver.Answer(name, dns.rdatatype.MX, dns.rdataclass.IN, message, False) del answer[0] self.failUnlessRaises(IndexError, bad) @unittest.skipIf(not _network_available, "Internet not reachable") def testZoneForName1(self): name = dns.name.from_text('www.dnspython.org.') ezname = dns.name.from_text('dnspython.org.') zname = dns.resolver.zone_for_name(name) self.failUnless(zname == ezname) @unittest.skipIf(not _network_available, "Internet not reachable") def testZoneForName2(self): name = dns.name.from_text('a.b.www.dnspython.org.') ezname = dns.name.from_text('dnspython.org.') zname = dns.resolver.zone_for_name(name) self.failUnless(zname == ezname) @unittest.skipIf(not _network_available, "Internet not reachable") def testZoneForName3(self): name = dns.name.from_text('dnspython.org.') ezname = dns.name.from_text('dnspython.org.') zname = dns.resolver.zone_for_name(name) self.failUnless(zname == ezname) def testZoneForName4(self): def bad(): name = dns.name.from_text('dnspython.org', None) dns.resolver.zone_for_name(name) self.failUnlessRaises(dns.resolver.NotAbsolute, bad) def testLRUReplace(self): cache = dns.resolver.LRUCache(4) for i in xrange(0, 5): name = dns.name.from_text('example%d.' % i) answer = FakeAnswer(time.time() + 1) cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) for i in xrange(0, 5): name = dns.name.from_text('example%d.' % i) if i == 0: self.failUnless(cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) is None) else: self.failUnless(not cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) is None) def testLRUDoesLRU(self): cache = dns.resolver.LRUCache(4) for i in xrange(0, 4): name = dns.name.from_text('example%d.' % i) answer = FakeAnswer(time.time() + 1) cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) name = dns.name.from_text('example0.') cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) # The LRU is now example1. name = dns.name.from_text('example4.') answer = FakeAnswer(time.time() + 1) cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) for i in xrange(0, 5): name = dns.name.from_text('example%d.' % i) if i == 1: self.failUnless(cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) is None) else: self.failUnless(not cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) is None) def testLRUExpiration(self): cache = dns.resolver.LRUCache(4) for i in xrange(0, 4): name = dns.name.from_text('example%d.' % i) answer = FakeAnswer(time.time() + 1) cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer) time.sleep(2) for i in xrange(0, 4): name = dns.name.from_text('example%d.' % i) self.failUnless(cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) is None) def testEmptyAnswerSection(self): # TODO: dangling_cname_0_message_text was the only sample message # with an empty answer section. Other than that it doesn't # apply. message = dns.message.from_text(dangling_cname_0_message_text) name = dns.name.from_text('example.') answer = dns.resolver.Answer(name, dns.rdatatype.A, dns.rdataclass.IN, message, raise_on_no_answer=False) def test_python_internal_truth(answer): if answer: return True else: return False self.assertFalse(test_python_internal_truth(answer)) for a in answer: pass class PollingMonkeyPatchMixin(object): def setUp(self): self.__native_polling_backend = dns.query._polling_backend dns.query._set_polling_backend(self.polling_backend()) unittest.TestCase.setUp(self) def tearDown(self): dns.query._set_polling_backend(self.__native_polling_backend) unittest.TestCase.tearDown(self) class SelectResolverTestCase(PollingMonkeyPatchMixin, BaseResolverTests, unittest.TestCase): def polling_backend(self): return dns.query._select_for if hasattr(select, 'poll'): class PollResolverTestCase(PollingMonkeyPatchMixin, BaseResolverTests, unittest.TestCase): def polling_backend(self): return dns.query._poll_for class NXDOMAINExceptionTestCase(unittest.TestCase): # pylint: disable=broad-except,exception-message-attribute def test_nxdomain_compatible(self): n1 = dns.name.Name(('a', 'b', '')) n2 = dns.name.Name(('a', 'b', 's', '')) py3 = (sys.version_info[0] > 2) try: raise dns.resolver.NXDOMAIN except dns.exception.DNSException as e: if not py3: self.assertTrue((e.message == e.__doc__)) self.assertTrue((e.args == (e.__doc__,))) self.assertTrue(('kwargs' in dir(e))) self.assertTrue((str(e) == e.__doc__), str(e)) self.assertTrue(('qnames' not in e.kwargs)) self.assertTrue(('responses' not in e.kwargs)) try: raise dns.resolver.NXDOMAIN("errmsg") except dns.exception.DNSException as e: if not py3: self.assertTrue((e.message == "errmsg")) self.assertTrue((e.args == ("errmsg",))) self.assertTrue(('kwargs' in dir(e))) self.assertTrue((str(e) == "errmsg"), str(e)) self.assertTrue(('qnames' not in e.kwargs)) self.assertTrue(('responses' not in e.kwargs)) try: raise dns.resolver.NXDOMAIN("errmsg", -1) except dns.exception.DNSException as e: if not py3: self.assertTrue((e.message == "")) self.assertTrue((e.args == ("errmsg", -1))) self.assertTrue(('kwargs' in dir(e))) self.assertTrue((str(e) == "('errmsg', -1)"), str(e)) self.assertTrue(('qnames' not in e.kwargs)) self.assertTrue(('responses' not in e.kwargs)) try: raise dns.resolver.NXDOMAIN(qnames=None) except Exception as e: self.assertTrue((isinstance(e, AttributeError))) try: raise dns.resolver.NXDOMAIN(qnames=n1) except Exception as e: self.assertTrue((isinstance(e, AttributeError))) try: raise dns.resolver.NXDOMAIN(qnames=[]) except Exception as e: self.assertTrue((isinstance(e, AttributeError))) try: raise dns.resolver.NXDOMAIN(qnames=[n1]) except dns.exception.DNSException as e: MSG = "The DNS query name does not exist: a.b." if not py3: self.assertTrue((e.message == MSG), e.message) self.assertTrue((e.args == (MSG,)), repr(e.args)) self.assertTrue(('kwargs' in dir(e))) self.assertTrue((str(e) == MSG), str(e)) self.assertTrue(('qnames' in e.kwargs)) self.assertTrue((e.kwargs['qnames'] == [n1])) self.assertTrue(('responses' in e.kwargs)) self.assertTrue((e.kwargs['responses'] == {})) try: raise dns.resolver.NXDOMAIN(qnames=[n2, n1]) except Exception as e: e0 = dns.resolver.NXDOMAIN("errmsg") e = e0 + e MSG = "None of DNS query names exist: a.b.s., a.b." if not py3: self.assertTrue((e.message == MSG), e.message) self.assertTrue((e.args == (MSG,)), repr(e.args)) self.assertTrue(('kwargs' in dir(e))) self.assertTrue((str(e) == MSG), str(e)) self.assertTrue(('qnames' in e.kwargs)) self.assertTrue((e.kwargs['qnames'] == [n2, n1])) self.assertTrue(('responses' in e.kwargs)) self.assertTrue((e.kwargs['responses'] == {})) try: raise dns.resolver.NXDOMAIN(qnames=[n1], responses=['r1.1']) except Exception as e: self.assertTrue((isinstance(e, AttributeError))) try: raise dns.resolver.NXDOMAIN(qnames=[n1], responses={n1: 'r1.1'}) except Exception as e: MSG = "The DNS query name does not exist: a.b." if not py3: self.assertTrue((e.message == MSG), e.message) self.assertTrue((e.args == (MSG,)), repr(e.args)) self.assertTrue(('kwargs' in dir(e))) self.assertTrue((str(e) == MSG), str(e)) self.assertTrue(('qnames' in e.kwargs)) self.assertTrue((e.kwargs['qnames'] == [n1])) self.assertTrue(('responses' in e.kwargs)) self.assertTrue((e.kwargs['responses'] == {n1: 'r1.1'})) def test_nxdomain_merge(self): n1 = dns.name.Name(('a', 'b', '')) n2 = dns.name.Name(('a', 'b', '')) n3 = dns.name.Name(('a', 'b', 'c', '')) n4 = dns.name.Name(('a', 'b', 'd', '')) responses1 = {n1: 'r1.1', n2: 'r1.2', n4: 'r1.4'} qnames1 = [n1, n4] # n2 == n1 responses2 = {n2: 'r2.2', n3: 'r2.3'} qnames2 = [n2, n3] e0 = dns.resolver.NXDOMAIN() e1 = dns.resolver.NXDOMAIN(qnames=qnames1, responses=responses1) e2 = dns.resolver.NXDOMAIN(qnames=qnames2, responses=responses2) e = e1 + e0 + e2 self.assertRaises(AttributeError, lambda: e0 + e0) self.assertTrue(e.kwargs['qnames'] == [n1, n4, n3], repr(e.kwargs['qnames'])) self.assertTrue(e.kwargs['responses'][n1].startswith('r2.')) self.assertTrue(e.kwargs['responses'][n2].startswith('r2.')) self.assertTrue(e.kwargs['responses'][n3].startswith('r2.')) self.assertTrue(e.kwargs['responses'][n4].startswith('r1.')) def test_nxdomain_canonical_name(self): cname1 = "91.11.8-22.17.172.in-addr.arpa." cname2 = "91-11-17-172.dynamic.example." message0 = dns.message.from_text(dangling_cname_0_message_text) message1 = dns.message.from_text(dangling_cname_1_message_text) message2 = dns.message.from_text(dangling_cname_2_message_text) qname0 = message0.question[0].name qname1 = message1.question[0].name qname2 = message2.question[0].name responses = {qname0: message0, qname1: message1, qname2: message2} eX = dns.resolver.NXDOMAIN() e0 = dns.resolver.NXDOMAIN(qnames=[qname0], responses=responses) e1 = dns.resolver.NXDOMAIN(qnames=[qname0, qname1, qname2], responses=responses) e2 = dns.resolver.NXDOMAIN(qnames=[qname0, qname2, qname1], responses=responses) self.assertRaises(TypeError, lambda: eX.canonical_name) self.assertTrue(e0.canonical_name == qname0) self.assertTrue(e1.canonical_name == dns.name.from_text(cname1)) self.assertTrue(e2.canonical_name == dns.name.from_text(cname2)) if __name__ == '__main__': unittest.main()
isc
[ 3, 1898, 334, 35, 9, 13004, 13, 10680, 653, 676, 262, 453, 12, 3277, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 504, 5890, 492, 5228, 199, 646, 3504, 199, 646, 984, 199, 646, 2838, 199, 646, 900, 199, 893, 26, 272, 492, 2882, 18, 465, 2882, 199, 2590, 3545, 26, 272, 492, 2882, 199, 199, 646, 6715, 14, 1188, 199, 646, 6715, 14, 354, 199, 646, 6715, 14, 23203, 533, 199, 646, 6715, 14, 82, 14184, 199, 646, 6715, 14, 7717, 199, 504, 6715, 423, 5819, 492, 4945, 199, 199, 3, 6601, 2295, 4409, 314, 21408, 370, 506, 2808, 370, 1255, 12, 880, 4691, 1159, 199, 3, 3372, 5204, 340, 652, 1159, 440, 2337, 14, 199, 63, 1200, 63, 4561, 275, 715, 199, 893, 26, 272, 2838, 14, 20256, 24810, 360, 5797, 1548, 14, 1308, 358, 199, 2590, 2838, 14, 5294, 73, 705, 26, 272, 485, 1200, 63, 4561, 275, 756, 199, 199, 26702, 86, 63, 2190, 275, 399, 624, 272, 1182, 84, 15, 84, 199, 3, 3721, 413, 199, 27, 3721, 499, 199, 2261, 3925, 199, 354, 1000, 1616, 14, 16, 14, 16, 14, 17, 199, 354, 1000, 1616, 14, 16, 14, 16, 14, 18, 199, 624, 199, 199, 1188, 63, 505, 275, 408, 344, 14763, 199, 14325, 7813, 9418, 199, 82, 600, 4825, 3170, 199, 2469, 1413, 50, 437, 33, 820, 36, 199, 27, 2328, 19212, 199, 2694, 14, 1621, 437, 199, 27, 5622, 12018, 199, 2694, 14, 413, 1621, 437, 1616, 14, 16, 14, 16, 14, 17, 199, 27, 29039, 199, 27, 1554, 3841, 21518, 199, 624, 199, 199, 68, 26896, 63, 11690, 63, 16, 63, 1188, 63, 505, 275, 408, 344, 11630, 199, 14325, 7813, 9418, 199, 82, 600, 4825, 3170, 199, 2469, 1413, 50, 437, 33, 820, 36, 31632, 199, 27, 2328, 19212, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 3592, 14, 1621, 510, 1766, 199, 27, 5622, 12018, 199, 27, 29039, 199, 27, 1554, 3841, 21518, 199, 624, 199, 199, 68, 26896, 63, 11690, 63, 17, 63, 1188, 63, 505, 275, 408, 344, 2948, 614, 199, 14325, 7813, 9418, 199, 82, 600, 4825, 3170, 199, 2469, 1413, 50, 437, 33, 820, 36, 31632, 199, 27, 2328, 19212, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 1621, 510, 1766, 199, 27, 5622, 12018, 199, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 31200, 1621, 577, 2339, 4119, 14, 24, 13, 1081, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 31200, 1621, 445, 2339, 21358, 14, 845, 14, 24, 13, 1081, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 199, 27, 29039, 199, 27, 1554, 3841, 21518, 199, 624, 199, 199, 68, 26896, 63, 11690, 63, 18, 63, 1188, 63, 505, 275, 408, 344, 2948, 996, 199, 14325, 7813, 9418, 199, 82, 600, 4825, 3170, 199, 2469, 1413, 50, 437, 33, 820, 36, 31632, 199, 27, 2328, 19212, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 2694, 14, 1621, 510, 1766, 199, 27, 5622, 12018, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 2694, 14, 31200, 1621, 445, 2339, 21358, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 1095, 14, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 1095, 14, 31200, 1621, 445, 2339, 21358, 14, 845, 14, 1196, 14, 10419, 14, 14555, 14, 2694, 14, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 14555, 14, 2694, 14, 31200, 1621, 445, 2339, 21358, 13, 845, 13, 1196, 13, 10419, 14, 7764, 14, 2694, 14, 199, 27, 29039, 199, 27, 1554, 3841, 21518, 199, 624, 421, 199, 533, 7777, 19104, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 15399, 304, 267, 291, 14, 15469, 275, 15399, 421, 199, 533, 3523, 12407, 2925, 8, 2796, 14, 1746, 304, 339, 340, 984, 14, 3246, 1137, 283, 2676, 708, 356, 267, 347, 511, 3284, 8, 277, 304, 288, 289, 275, 5228, 8, 26702, 86, 63, 2190, 9, 288, 519, 275, 6715, 14, 7717, 14, 12407, 8, 70, 9, 288, 291, 14, 7589, 8, 82, 14, 28620, 508, 788, 709, 14, 16, 14, 16, 14, 17, 297, 283, 709, 14, 16, 14, 16, 14, 18, 418, 436, 1169, 519, 14, 2261, 508, 6715, 14, 354, 14, 504, 63, 505, 360, 1421, 1333, 339, 347, 511, 4437, 14000, 1754, 8, 277, 304, 267, 1245, 275, 6715, 14, 1188, 14, 504, 63, 505, 8, 1188, 63, 505, 9, 267, 536, 275, 6715, 14, 354, 14, 504, 63, 505, 360, 2694, 2659, 267, 6385, 275, 6715, 14, 7717, 14, 19104, 8, 354, 12, 6715, 14, 82, 14184, 14, 33, 12, 6715, 14, 23203, 533, 14, 568, 12, 3660, 1245, 9, 267, 2581, 275, 6715, 14, 7717, 14, 4437, 342, 267, 2581, 14, 524, 1332, 354, 12, 6715, 14, 82, 14184, 14, 33, 12, 6715, 14, 23203, 533, 14 ]
[ 1898, 334, 35, 9, 13004, 13, 10680, 653, 676, 262, 453, 12, 3277, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 504, 5890, 492, 5228, 199, 646, 3504, 199, 646, 984, 199, 646, 2838, 199, 646, 900, 199, 893, 26, 272, 492, 2882, 18, 465, 2882, 199, 2590, 3545, 26, 272, 492, 2882, 199, 199, 646, 6715, 14, 1188, 199, 646, 6715, 14, 354, 199, 646, 6715, 14, 23203, 533, 199, 646, 6715, 14, 82, 14184, 199, 646, 6715, 14, 7717, 199, 504, 6715, 423, 5819, 492, 4945, 199, 199, 3, 6601, 2295, 4409, 314, 21408, 370, 506, 2808, 370, 1255, 12, 880, 4691, 1159, 199, 3, 3372, 5204, 340, 652, 1159, 440, 2337, 14, 199, 63, 1200, 63, 4561, 275, 715, 199, 893, 26, 272, 2838, 14, 20256, 24810, 360, 5797, 1548, 14, 1308, 358, 199, 2590, 2838, 14, 5294, 73, 705, 26, 272, 485, 1200, 63, 4561, 275, 756, 199, 199, 26702, 86, 63, 2190, 275, 399, 624, 272, 1182, 84, 15, 84, 199, 3, 3721, 413, 199, 27, 3721, 499, 199, 2261, 3925, 199, 354, 1000, 1616, 14, 16, 14, 16, 14, 17, 199, 354, 1000, 1616, 14, 16, 14, 16, 14, 18, 199, 624, 199, 199, 1188, 63, 505, 275, 408, 344, 14763, 199, 14325, 7813, 9418, 199, 82, 600, 4825, 3170, 199, 2469, 1413, 50, 437, 33, 820, 36, 199, 27, 2328, 19212, 199, 2694, 14, 1621, 437, 199, 27, 5622, 12018, 199, 2694, 14, 413, 1621, 437, 1616, 14, 16, 14, 16, 14, 17, 199, 27, 29039, 199, 27, 1554, 3841, 21518, 199, 624, 199, 199, 68, 26896, 63, 11690, 63, 16, 63, 1188, 63, 505, 275, 408, 344, 11630, 199, 14325, 7813, 9418, 199, 82, 600, 4825, 3170, 199, 2469, 1413, 50, 437, 33, 820, 36, 31632, 199, 27, 2328, 19212, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 3592, 14, 1621, 510, 1766, 199, 27, 5622, 12018, 199, 27, 29039, 199, 27, 1554, 3841, 21518, 199, 624, 199, 199, 68, 26896, 63, 11690, 63, 17, 63, 1188, 63, 505, 275, 408, 344, 2948, 614, 199, 14325, 7813, 9418, 199, 82, 600, 4825, 3170, 199, 2469, 1413, 50, 437, 33, 820, 36, 31632, 199, 27, 2328, 19212, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 1621, 510, 1766, 199, 27, 5622, 12018, 199, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 31200, 1621, 577, 2339, 4119, 14, 24, 13, 1081, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 31200, 1621, 445, 2339, 21358, 14, 845, 14, 24, 13, 1081, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 199, 27, 29039, 199, 27, 1554, 3841, 21518, 199, 624, 199, 199, 68, 26896, 63, 11690, 63, 18, 63, 1188, 63, 505, 275, 408, 344, 2948, 996, 199, 14325, 7813, 9418, 199, 82, 600, 4825, 3170, 199, 2469, 1413, 50, 437, 33, 820, 36, 31632, 199, 27, 2328, 19212, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 2694, 14, 1621, 510, 1766, 199, 27, 5622, 12018, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 2694, 14, 31200, 1621, 445, 2339, 21358, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 1095, 14, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 262, 13, 2697, 14, 285, 387, 14, 1095, 14, 31200, 1621, 445, 2339, 21358, 14, 845, 14, 1196, 14, 10419, 14, 14555, 14, 2694, 14, 199, 3328, 14, 845, 14, 1196, 14, 10419, 14, 14555, 14, 2694, 14, 31200, 1621, 445, 2339, 21358, 13, 845, 13, 1196, 13, 10419, 14, 7764, 14, 2694, 14, 199, 27, 29039, 199, 27, 1554, 3841, 21518, 199, 624, 421, 199, 533, 7777, 19104, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 15399, 304, 267, 291, 14, 15469, 275, 15399, 421, 199, 533, 3523, 12407, 2925, 8, 2796, 14, 1746, 304, 339, 340, 984, 14, 3246, 1137, 283, 2676, 708, 356, 267, 347, 511, 3284, 8, 277, 304, 288, 289, 275, 5228, 8, 26702, 86, 63, 2190, 9, 288, 519, 275, 6715, 14, 7717, 14, 12407, 8, 70, 9, 288, 291, 14, 7589, 8, 82, 14, 28620, 508, 788, 709, 14, 16, 14, 16, 14, 17, 297, 283, 709, 14, 16, 14, 16, 14, 18, 418, 436, 1169, 519, 14, 2261, 508, 6715, 14, 354, 14, 504, 63, 505, 360, 1421, 1333, 339, 347, 511, 4437, 14000, 1754, 8, 277, 304, 267, 1245, 275, 6715, 14, 1188, 14, 504, 63, 505, 8, 1188, 63, 505, 9, 267, 536, 275, 6715, 14, 354, 14, 504, 63, 505, 360, 2694, 2659, 267, 6385, 275, 6715, 14, 7717, 14, 19104, 8, 354, 12, 6715, 14, 82, 14184, 14, 33, 12, 6715, 14, 23203, 533, 14, 568, 12, 3660, 1245, 9, 267, 2581, 275, 6715, 14, 7717, 14, 4437, 342, 267, 2581, 14, 524, 1332, 354, 12, 6715, 14, 82, 14184, 14, 33, 12, 6715, 14, 23203, 533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 1, 1, 1, 1 ]
drewandersonnz/openshift-tools
openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_openshift/src/class/oc_adm_manage_node.py
46
8788
# pylint: skip-file # flake8: noqa class ManageNodeException(Exception): ''' manage-node exception class ''' pass class ManageNodeConfig(OpenShiftCLIConfig): ''' ManageNodeConfig is a DTO for the manage-node command.''' def __init__(self, kubeconfig, node_options): super(ManageNodeConfig, self).__init__(None, None, kubeconfig, node_options) # pylint: disable=too-many-instance-attributes class ManageNode(OpenShiftCLI): ''' Class to wrap the oc command line tools ''' # pylint allows 5 # pylint: disable=too-many-arguments def __init__(self, config, verbose=False): ''' Constructor for ManageNode ''' super(ManageNode, self).__init__(None, kubeconfig=config.kubeconfig, verbose=verbose) self.config = config def evacuate(self): ''' formulate the params and run oadm manage-node ''' return self._evacuate(node=self.config.config_options['node']['value'], selector=self.config.config_options['selector']['value'], pod_selector=self.config.config_options['pod_selector']['value'], dry_run=self.config.config_options['dry_run']['value'], grace_period=self.config.config_options['grace_period']['value'], force=self.config.config_options['force']['value'], ) def get_nodes(self, node=None, selector=''): '''perform oc get node''' _node = None _sel = None if node: _node = node if selector: _sel = selector results = self._get('node', name=_node, selector=_sel) if results['returncode'] != 0: return results nodes = [] items = None if results['results'][0]['kind'] == 'List': items = results['results'][0]['items'] else: items = results['results'] for node in items: _node = {} _node['name'] = node['metadata']['name'] _node['schedulable'] = True if 'unschedulable' in node['spec']: _node['schedulable'] = False nodes.append(_node) return nodes def get_pods_from_node(self, node, pod_selector=None): '''return pods for a node''' results = self._list_pods(node=[node], pod_selector=pod_selector) if results['returncode'] != 0: return results # When a selector or node is matched it is returned along with the json. # We are going to split the results based on the regexp and then # load the json for each matching node. # Before we return we are going to loop over the results and pull out the node names. # {'node': [pod, pod], 'node': [pod, pod]} # 3.2 includes the following lines in stdout: "Listing matched pods on node:" all_pods = [] if "Listing matched" in results['results']: listing_match = re.compile('\n^Listing matched.*$\n', flags=re.MULTILINE) pods = listing_match.split(results['results']) for pod in pods: if pod: all_pods.extend(json.loads(pod)['items']) # 3.3 specific else: # this is gross but I filed a bug... # https://bugzilla.redhat.com/show_bug.cgi?id=1381621 # build our own json from the output. all_pods = json.loads(results['results'])['items'] return all_pods def list_pods(self): ''' run oadm manage-node --list-pods''' _nodes = self.config.config_options['node']['value'] _selector = self.config.config_options['selector']['value'] _pod_selector = self.config.config_options['pod_selector']['value'] if not _nodes: _nodes = self.get_nodes(selector=_selector) else: _nodes = [{'name': name} for name in _nodes] all_pods = {} for node in _nodes: results = self.get_pods_from_node(node['name'], pod_selector=_pod_selector) if isinstance(results, dict): return results all_pods[node['name']] = results results = {} results['nodes'] = all_pods results['returncode'] = 0 return results def schedulable(self): '''oadm manage-node call for making nodes unschedulable''' nodes = self.config.config_options['node']['value'] selector = self.config.config_options['selector']['value'] if not nodes: nodes = self.get_nodes(selector=selector) else: tmp_nodes = [] for name in nodes: tmp_result = self.get_nodes(name) if isinstance(tmp_result, dict): tmp_nodes.append(tmp_result) continue tmp_nodes.extend(tmp_result) nodes = tmp_nodes # This is a short circuit based on the way we fetch nodes. # If node is a dict/list then we've already fetched them. for node in nodes: if isinstance(node, dict) and 'returncode' in node: return {'results': nodes, 'returncode': node['returncode']} if isinstance(node, list) and 'returncode' in node[0]: return {'results': nodes, 'returncode': node[0]['returncode']} # check all the nodes that were returned and verify they are: # node['schedulable'] == self.config.config_options['schedulable']['value'] if any([node['schedulable'] != self.config.config_options['schedulable']['value'] for node in nodes]): results = self._schedulable(node=self.config.config_options['node']['value'], selector=self.config.config_options['selector']['value'], schedulable=self.config.config_options['schedulable']['value']) # 'NAME STATUS AGE\\nip-172-31-49-140.ec2.internal Ready 4h\\n' # E501 # normalize formatting with previous return objects if results['results'].startswith('NAME'): nodes = [] # removing header line and trailing new line character of node lines for node_results in results['results'].split('\n')[1:-1]: parts = node_results.split() nodes.append({'name': parts[0], 'schedulable': parts[1] == 'Ready'}) results['nodes'] = nodes return results results = {} results['returncode'] = 0 results['changed'] = False results['nodes'] = nodes return results @staticmethod def run_ansible(params, check_mode): '''run the idempotent ansible code''' nconfig = ManageNodeConfig(params['kubeconfig'], {'node': {'value': params['node'], 'include': True}, 'selector': {'value': params['selector'], 'include': True}, 'pod_selector': {'value': params['pod_selector'], 'include': True}, 'schedulable': {'value': params['schedulable'], 'include': True}, 'list_pods': {'value': params['list_pods'], 'include': True}, 'evacuate': {'value': params['evacuate'], 'include': True}, 'dry_run': {'value': params['dry_run'], 'include': True}, 'force': {'value': params['force'], 'include': True}, 'grace_period': {'value': params['grace_period'], 'include': True}, }) oadm_mn = ManageNode(nconfig) # Run the oadm manage-node commands results = None changed = False if params['schedulable'] != None: if check_mode: # schedulable returns results after the fact. # We need to redo how this works to support check_mode completely. return {'changed': True, 'msg': 'CHECK_MODE: would have called schedulable.'} results = oadm_mn.schedulable() if 'changed' not in results: changed = True if params['evacuate']: results = oadm_mn.evacuate() changed = True elif params['list_pods']: results = oadm_mn.list_pods() if not results or results['returncode'] != 0: return {'failed': True, 'msg': results} return {'changed': changed, 'results': results, 'state': "present"}
apache-2.0
[ 3, 4287, 26, 3372, 13, 493, 199, 3, 27510, 24, 26, 8151, 421, 199, 533, 14944, 1716, 1726, 8, 1726, 304, 272, 1449, 9635, 13, 932, 1919, 1021, 1449, 272, 986, 421, 199, 533, 14944, 1716, 2028, 8, 4299, 14379, 7802, 2028, 304, 272, 1449, 14944, 1716, 2028, 365, 282, 577, 2566, 367, 314, 9635, 13, 932, 1414, 10595, 272, 347, 636, 826, 721, 277, 12, 23091, 888, 12, 1031, 63, 1419, 304, 267, 1613, 8, 20588, 1716, 2028, 12, 291, 2843, 826, 721, 403, 12, 488, 12, 23091, 888, 12, 1031, 63, 1419, 9, 421, 199, 3, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 842, 13, 2987, 199, 533, 14944, 1716, 8, 4299, 14379, 7802, 304, 272, 1449, 8089, 370, 4816, 314, 4244, 1414, 1004, 7249, 1449, 339, 327, 4287, 6127, 959, 272, 327, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 4958, 272, 347, 636, 826, 721, 277, 12, 326, 1101, 12, 326, 3376, 29, 797, 304, 267, 1449, 20297, 367, 14944, 1716, 1449, 267, 1613, 8, 20588, 1716, 12, 291, 2843, 826, 721, 403, 12, 23091, 888, 29, 888, 14, 29192, 12, 3376, 29, 3832, 9, 267, 291, 14, 888, 275, 1101, 339, 347, 8145, 645, 4767, 8, 277, 304, 267, 1449, 1824, 5434, 314, 1862, 436, 1255, 312, 14464, 9635, 13, 932, 1449, 267, 372, 291, 423, 6857, 645, 4767, 8, 932, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 932, 2545, 585, 995, 2892, 9759, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 6662, 2545, 585, 995, 2892, 15329, 63, 6662, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 12656, 63, 6662, 2545, 585, 995, 2892, 9951, 63, 1065, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 10481, 63, 1065, 2545, 585, 995, 2892, 19756, 63, 5191, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 20631, 63, 5191, 2545, 585, 995, 2892, 3542, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 3990, 2545, 585, 995, 2490, 776, 272, 347, 664, 63, 2415, 8, 277, 12, 1031, 29, 403, 12, 9759, 9280, 267, 1449, 15795, 4244, 664, 1031, 2344, 267, 485, 932, 275, 488, 267, 485, 5891, 275, 488, 267, 340, 1031, 26, 288, 485, 932, 275, 1031, 267, 340, 9759, 26, 288, 485, 5891, 275, 9759, 398, 2058, 275, 291, 423, 362, 360, 932, 297, 536, 3699, 932, 12, 9759, 3699, 5891, 9, 267, 340, 2058, 459, 9913, 418, 1137, 378, 26, 288, 372, 2058, 398, 3380, 275, 942, 267, 2974, 275, 488, 267, 340, 2058, 459, 2604, 3488, 16, 2733, 5091, 418, 508, 283, 1296, 356, 288, 2974, 275, 2058, 459, 2604, 3488, 16, 2733, 1744, 418, 267, 587, 26, 288, 2974, 275, 2058, 459, 2604, 418, 398, 367, 1031, 315, 2974, 26, 288, 485, 932, 275, 1052, 288, 485, 932, 459, 354, 418, 275, 1031, 459, 2343, 2545, 354, 418, 288, 485, 932, 459, 10487, 348, 461, 418, 275, 715, 288, 340, 283, 324, 10487, 348, 461, 7, 315, 1031, 459, 1650, 2565, 355, 485, 932, 459, 10487, 348, 461, 418, 275, 756, 288, 3380, 14, 740, 1547, 932, 9, 398, 372, 3380, 339, 347, 664, 63, 12656, 83, 63, 504, 63, 932, 8, 277, 12, 1031, 12, 15329, 63, 6662, 29, 403, 304, 267, 1449, 1107, 15329, 83, 367, 282, 1031, 2344, 267, 2058, 275, 291, 423, 513, 63, 12656, 83, 8, 932, 1524, 932, 467, 15329, 63, 6662, 29, 12656, 63, 6662, 9, 398, 340, 2058, 459, 9913, 418, 1137, 378, 26, 288, 372, 2058, 398, 327, 3979, 282, 9759, 503, 1031, 365, 7838, 652, 365, 2138, 3180, 543, 314, 2022, 14, 267, 327, 2136, 787, 9995, 370, 3715, 314, 2058, 4079, 641, 314, 13156, 436, 2066, 267, 327, 2248, 314, 2022, 367, 1924, 4877, 1031, 14, 267, 327, 21467, 781, 372, 781, 787, 9995, 370, 4438, 1806, 314, 2058, 436, 10299, 734, 314, 1031, 1561, 14, 267, 327, 791, 932, 356, 359, 12656, 12, 15329, 467, 283, 932, 356, 359, 12656, 12, 15329, 9420, 267, 327, 650, 14, 18, 6952, 314, 2569, 2385, 315, 3839, 26, 298, 26138, 7838, 15329, 83, 641, 1031, 5424, 267, 1006, 63, 12656, 83, 275, 942, 267, 340, 298, 26138, 7838, 2, 315, 2058, 459, 2604, 2565, 288, 13778, 63, 1431, 275, 295, 14, 2014, 2258, 78, 62, 26138, 7838, 2795, 16827, 78, 297, 3285, 29, 264, 14, 16661, 9, 288, 15329, 83, 275, 13778, 63, 1431, 14, 1294, 8, 2604, 459, 2604, 1105, 288, 367, 15329, 315, 15329, 83, 26, 355, 340, 15329, 26, 490, 1006, 63, 12656, 83, 14, 2880, 8, 1001, 14, 3640, 8, 12656, 11820, 1744, 1105, 398, 327, 650, 14, 19, 2488, 267, 587, 26, 288, 327, 642, 365, 486, 3685, 1325, 473, 570, 68, 282, 6519, 1396, 288, 327, 4178, 921, 29220, 14, 17164, 14, 957, 15, 2384, 63, 1266, 14, 13814, 31, 344, 29, 8527, 975, 2025, 288, 327, 1900, 4154, 5705, 2022, 687, 314, 1072, 14, 288, 1006, 63, 12656, 83, 275, 2022, 14, 3640, 8, 2604, 459, 2604, 1105, 459, 1744, 418, 398, 372, 1006, 63, 12656, 83, 339, 347, 769, 63, 12656, 83, 8, 277, 304, 267, 1449, 1255, 312, 14464, 9635, 13, 932, 1553, 513, 13, 12656, 83, 2344, 267, 485, 2415, 275, 291, 14, 888, 14, 888, 63, 1419, 459, 932, 2545, 585, 418, 267, 485, 6662, 275, 291, 14, 888, 14, 888, 63, 1419, 459, 6662, 2545, 585, 418, 267, 485, 12656, 63, 6662, 275, 291, 14, 888, 14, 888, 63, 1419, 459, 12656, 63, 6662, 2545, 585, 418, 398, 340, 440, 485, 2415, 26, 288, 485, 2415, 275, 291, 14, 362, 63, 2415, 8, 6662, 3699, 6662, 9, 267, 587, 26, 288, 485, 2415, 275, 9016, 354, 356, 536, 93, 367, 536, 315, 485, 2415, 61, 398, 1006, 63, 12656, 83, 275, 1052, 267, 367, 1031, 315, 485, 2415, 26, 288, 2058, 275, 291, 14, 362, 63, 12656, 83, 63, 504, 63, 932, 8, 932, 459, 354, 995, 15329, 63, 6662, 3699, 12656, 63, 6662, 9, 288, 340, 1228, 8, 2604, 12, 1211, 304, 355, 372, 2058, 288, 1006, 63, 12656, 83, 59, 932, 459, 354, 6538, 275, 2058, 398, 2058, 275, 1052, 267, 2058, 459, 2415, 418 ]
[ 4287, 26, 3372, 13, 493, 199, 3, 27510, 24, 26, 8151, 421, 199, 533, 14944, 1716, 1726, 8, 1726, 304, 272, 1449, 9635, 13, 932, 1919, 1021, 1449, 272, 986, 421, 199, 533, 14944, 1716, 2028, 8, 4299, 14379, 7802, 2028, 304, 272, 1449, 14944, 1716, 2028, 365, 282, 577, 2566, 367, 314, 9635, 13, 932, 1414, 10595, 272, 347, 636, 826, 721, 277, 12, 23091, 888, 12, 1031, 63, 1419, 304, 267, 1613, 8, 20588, 1716, 2028, 12, 291, 2843, 826, 721, 403, 12, 488, 12, 23091, 888, 12, 1031, 63, 1419, 9, 421, 199, 3, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 842, 13, 2987, 199, 533, 14944, 1716, 8, 4299, 14379, 7802, 304, 272, 1449, 8089, 370, 4816, 314, 4244, 1414, 1004, 7249, 1449, 339, 327, 4287, 6127, 959, 272, 327, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 4958, 272, 347, 636, 826, 721, 277, 12, 326, 1101, 12, 326, 3376, 29, 797, 304, 267, 1449, 20297, 367, 14944, 1716, 1449, 267, 1613, 8, 20588, 1716, 12, 291, 2843, 826, 721, 403, 12, 23091, 888, 29, 888, 14, 29192, 12, 3376, 29, 3832, 9, 267, 291, 14, 888, 275, 1101, 339, 347, 8145, 645, 4767, 8, 277, 304, 267, 1449, 1824, 5434, 314, 1862, 436, 1255, 312, 14464, 9635, 13, 932, 1449, 267, 372, 291, 423, 6857, 645, 4767, 8, 932, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 932, 2545, 585, 995, 2892, 9759, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 6662, 2545, 585, 995, 2892, 15329, 63, 6662, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 12656, 63, 6662, 2545, 585, 995, 2892, 9951, 63, 1065, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 10481, 63, 1065, 2545, 585, 995, 2892, 19756, 63, 5191, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 20631, 63, 5191, 2545, 585, 995, 2892, 3542, 29, 277, 14, 888, 14, 888, 63, 1419, 459, 3990, 2545, 585, 995, 2490, 776, 272, 347, 664, 63, 2415, 8, 277, 12, 1031, 29, 403, 12, 9759, 9280, 267, 1449, 15795, 4244, 664, 1031, 2344, 267, 485, 932, 275, 488, 267, 485, 5891, 275, 488, 267, 340, 1031, 26, 288, 485, 932, 275, 1031, 267, 340, 9759, 26, 288, 485, 5891, 275, 9759, 398, 2058, 275, 291, 423, 362, 360, 932, 297, 536, 3699, 932, 12, 9759, 3699, 5891, 9, 267, 340, 2058, 459, 9913, 418, 1137, 378, 26, 288, 372, 2058, 398, 3380, 275, 942, 267, 2974, 275, 488, 267, 340, 2058, 459, 2604, 3488, 16, 2733, 5091, 418, 508, 283, 1296, 356, 288, 2974, 275, 2058, 459, 2604, 3488, 16, 2733, 1744, 418, 267, 587, 26, 288, 2974, 275, 2058, 459, 2604, 418, 398, 367, 1031, 315, 2974, 26, 288, 485, 932, 275, 1052, 288, 485, 932, 459, 354, 418, 275, 1031, 459, 2343, 2545, 354, 418, 288, 485, 932, 459, 10487, 348, 461, 418, 275, 715, 288, 340, 283, 324, 10487, 348, 461, 7, 315, 1031, 459, 1650, 2565, 355, 485, 932, 459, 10487, 348, 461, 418, 275, 756, 288, 3380, 14, 740, 1547, 932, 9, 398, 372, 3380, 339, 347, 664, 63, 12656, 83, 63, 504, 63, 932, 8, 277, 12, 1031, 12, 15329, 63, 6662, 29, 403, 304, 267, 1449, 1107, 15329, 83, 367, 282, 1031, 2344, 267, 2058, 275, 291, 423, 513, 63, 12656, 83, 8, 932, 1524, 932, 467, 15329, 63, 6662, 29, 12656, 63, 6662, 9, 398, 340, 2058, 459, 9913, 418, 1137, 378, 26, 288, 372, 2058, 398, 327, 3979, 282, 9759, 503, 1031, 365, 7838, 652, 365, 2138, 3180, 543, 314, 2022, 14, 267, 327, 2136, 787, 9995, 370, 3715, 314, 2058, 4079, 641, 314, 13156, 436, 2066, 267, 327, 2248, 314, 2022, 367, 1924, 4877, 1031, 14, 267, 327, 21467, 781, 372, 781, 787, 9995, 370, 4438, 1806, 314, 2058, 436, 10299, 734, 314, 1031, 1561, 14, 267, 327, 791, 932, 356, 359, 12656, 12, 15329, 467, 283, 932, 356, 359, 12656, 12, 15329, 9420, 267, 327, 650, 14, 18, 6952, 314, 2569, 2385, 315, 3839, 26, 298, 26138, 7838, 15329, 83, 641, 1031, 5424, 267, 1006, 63, 12656, 83, 275, 942, 267, 340, 298, 26138, 7838, 2, 315, 2058, 459, 2604, 2565, 288, 13778, 63, 1431, 275, 295, 14, 2014, 2258, 78, 62, 26138, 7838, 2795, 16827, 78, 297, 3285, 29, 264, 14, 16661, 9, 288, 15329, 83, 275, 13778, 63, 1431, 14, 1294, 8, 2604, 459, 2604, 1105, 288, 367, 15329, 315, 15329, 83, 26, 355, 340, 15329, 26, 490, 1006, 63, 12656, 83, 14, 2880, 8, 1001, 14, 3640, 8, 12656, 11820, 1744, 1105, 398, 327, 650, 14, 19, 2488, 267, 587, 26, 288, 327, 642, 365, 486, 3685, 1325, 473, 570, 68, 282, 6519, 1396, 288, 327, 4178, 921, 29220, 14, 17164, 14, 957, 15, 2384, 63, 1266, 14, 13814, 31, 344, 29, 8527, 975, 2025, 288, 327, 1900, 4154, 5705, 2022, 687, 314, 1072, 14, 288, 1006, 63, 12656, 83, 275, 2022, 14, 3640, 8, 2604, 459, 2604, 1105, 459, 1744, 418, 398, 372, 1006, 63, 12656, 83, 339, 347, 769, 63, 12656, 83, 8, 277, 304, 267, 1449, 1255, 312, 14464, 9635, 13, 932, 1553, 513, 13, 12656, 83, 2344, 267, 485, 2415, 275, 291, 14, 888, 14, 888, 63, 1419, 459, 932, 2545, 585, 418, 267, 485, 6662, 275, 291, 14, 888, 14, 888, 63, 1419, 459, 6662, 2545, 585, 418, 267, 485, 12656, 63, 6662, 275, 291, 14, 888, 14, 888, 63, 1419, 459, 12656, 63, 6662, 2545, 585, 418, 398, 340, 440, 485, 2415, 26, 288, 485, 2415, 275, 291, 14, 362, 63, 2415, 8, 6662, 3699, 6662, 9, 267, 587, 26, 288, 485, 2415, 275, 9016, 354, 356, 536, 93, 367, 536, 315, 485, 2415, 61, 398, 1006, 63, 12656, 83, 275, 1052, 267, 367, 1031, 315, 485, 2415, 26, 288, 2058, 275, 291, 14, 362, 63, 12656, 83, 63, 504, 63, 932, 8, 932, 459, 354, 995, 15329, 63, 6662, 3699, 12656, 63, 6662, 9, 288, 340, 1228, 8, 2604, 12, 1211, 304, 355, 372, 2058, 288, 1006, 63, 12656, 83, 59, 932, 459, 354, 6538, 275, 2058, 398, 2058, 275, 1052, 267, 2058, 459, 2415, 418, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ngokevin/zamboni
docs/conf.py
2
7565
# -*- coding: utf-8 -*- # # zamboni documentation build configuration file, created by # sphinx-quickstart on Thu Oct 22 20:39:35 2009. # # 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.append(os.path.abspath('.')) sys.path.append(os.path.abspath('..')) # -- General configuration ----------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'extensions.src_role', 'sphinxcontrib.httpdomain'] # 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' # The master toctree document. master_doc = 'index' # General information about the project. project = u'zamboni' copyright = u'2014, The Marketplace Crew' # 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 = '0.9' # The full version, including alpha/beta/rc tags. release = '0.9' # 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 documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directory, that shouldn't be searched # for source files. exclude_trees = ['_build'] # 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. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. #html_theme_path = ['_themes'] #html_theme = 'mozilla' # 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_use_modindex = 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, 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 = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'zambonidoc' # -- 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', 'zamboni.tex', u'zamboni Documentation', u'Jeff Balogh', '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 # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True # Intersphinx links to the local _intersphinx cache. intersphinx_mapping = { 'http://docs.python.org/': 'python.inv', 'http://docs.djangoproject.com/en/dev': 'django.inv', 'http://jinja.pocoo.org/2/documentation/': 'jinja.inv', 'http://sphinx.pocoo.org/': 'jinja.inv', 'http://somethingaboutorange.com/mrl/projects/nose/0.11.1/': 'nose.inv', } for key, val in intersphinx_mapping.items(): intersphinx_mapping[key] = '_intersphinx/' + val # Root url where source files can be browsed online. src_base_url = 'http://github.com/mozilla/zamboni/tree/master/' # https://github.com/snide/sphinx_rtd_theme # on_rtd is whether we are on readthedocs.org, this line of code grabbed from # docs.readthedocs.org on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if not on_rtd: # only import and set the theme if we're building docs locally import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1315, 11020, 265, 73, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 3868, 85, 18365, 6928, 3388, 26, 1355, 26, 1276, 8937, 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, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 24535, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 24893, 1333, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 11390, 297, 1598, 283, 8008, 14, 832, 14, 1058, 8008, 297, 283, 8008, 14, 832, 14, 11396, 297, 1598, 283, 8008, 14, 832, 14, 10828, 297, 283, 5359, 14, 2164, 63, 3756, 297, 1598, 283, 8008, 2828, 14, 1014, 2261, 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, 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, 90, 11020, 265, 73, 7, 199, 7307, 275, 399, 7, 7280, 12, 710, 7173, 386, 2778, 445, 5257, 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, 16, 14, 25, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 16, 14, 25, 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, 8247, 626, 9296, 1133, 506, 5120, 315, 314, 1900, 14, 199, 3, 8618, 63, 4757, 275, 942, 199, 199, 3, 3820, 402, 6602, 12, 3847, 370, 1350, 2082, 12, 626, 9296, 1133, 506, 17543, 199, 3, 367, 1350, 1584, 14, 199, 5473, 63, 14635, 275, 4044, 1506, 418, 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, 16593, 5857, 17915, 626, 11492, 543, 199, 3, 10229, 787, 5544, 283, 885, 7, 436, 283, 8008, 1301, 1370, 199, 3, 1360, 63, 7915, 63, 515, 275, 4044, 23900, 418, 199, 3, 1360, 63, 7915, 275, 283, 12102, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1315, 11020, 265, 73, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 3868, 85, 18365, 6928, 3388, 26, 1355, 26, 1276, 8937, 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, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 24535, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 24893, 1333, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 11390, 297, 1598, 283, 8008, 14, 832, 14, 1058, 8008, 297, 283, 8008, 14, 832, 14, 11396, 297, 1598, 283, 8008, 14, 832, 14, 10828, 297, 283, 5359, 14, 2164, 63, 3756, 297, 1598, 283, 8008, 2828, 14, 1014, 2261, 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, 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, 90, 11020, 265, 73, 7, 199, 7307, 275, 399, 7, 7280, 12, 710, 7173, 386, 2778, 445, 5257, 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, 16, 14, 25, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 16, 14, 25, 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, 8247, 626, 9296, 1133, 506, 5120, 315, 314, 1900, 14, 199, 3, 8618, 63, 4757, 275, 942, 199, 199, 3, 3820, 402, 6602, 12, 3847, 370, 1350, 2082, 12, 626, 9296, 1133, 506, 17543, 199, 3, 367, 1350, 1584, 14, 199, 5473, 63, 14635, 275, 4044, 1506, 418, 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, 16593, 5857, 17915, 626, 11492, 543, 199, 3, 10229, 787, 5544, 283, 885, 7, 436, 283, 8008, 1301, 1370, 199, 3, 1360, 63, 7915, 63, 515, 275, 4044, 23900, 418, 199, 3, 1360, 63, 7915, 275, 283, 12102, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wavefrontHQ/python-client
test/test_azure_configuration.py
1
1314
# coding: utf-8 """ Wavefront REST API <p>The Wavefront REST API enables you to interact with Wavefront servers using standard REST API tools. You can use the REST API to automate commonly executed operations such as automatically tagging sources.</p><p>When you make REST API calls outside the Wavefront REST API documentation you must add the header \"Authorization: Bearer &lt;&lt;API-TOKEN&gt;&gt;\" to your HTTP requests.</p> # noqa: E501 OpenAPI spec version: v2 Contact: chitimba@wavefront.com Generated by: https://github.com/swagger-api/swagger-codegen.git """ from __future__ import absolute_import import unittest import wavefront_api_client from wavefront_api_client.models.azure_configuration import AzureConfiguration # noqa: E501 from wavefront_api_client.rest import ApiException class TestAzureConfiguration(unittest.TestCase): """AzureConfiguration unit test stubs""" def setUp(self): pass def tearDown(self): pass def testAzureConfiguration(self): """Test AzureConfiguration""" # FIXME: construct object with mandatory attributes with example values # model = wavefront_api_client.models.azure_configuration.AzureConfiguration() # noqa: E501 pass if __name__ == '__main__': unittest.main()
apache-2.0
[ 3, 2803, 26, 2774, 13, 24, 199, 199, 624, 272, 644, 811, 14708, 14880, 3261, 339, 665, 80, 30, 1918, 644, 811, 14708, 14880, 3261, 22741, 1265, 370, 17232, 543, 644, 811, 14708, 8037, 1808, 4465, 14880, 3261, 7249, 14, 2047, 883, 675, 314, 14880, 3261, 370, 6384, 676, 323, 28829, 7934, 5331, 4066, 465, 5847, 1947, 1540, 5274, 9758, 80, 2535, 80, 30, 11423, 1265, 1852, 14880, 3261, 4882, 9682, 314, 644, 811, 14708, 14880, 3261, 3794, 1265, 1471, 1050, 314, 1406, 8441, 11626, 26, 6423, 21462, 1253, 4116, 15337, 4116, 27, 3735, 13, 8803, 6, 3308, 15337, 3308, 3779, 2, 370, 2195, 3101, 4145, 9758, 80, 30, 221, 327, 8151, 26, 662, 8216, 339, 3232, 3735, 3158, 1015, 26, 373, 18, 272, 18684, 26, 682, 5277, 887, 65, 32, 10024, 14708, 14, 957, 272, 17065, 701, 26, 4178, 921, 5031, 14, 957, 15, 29940, 13, 1246, 15, 29940, 13, 600, 2268, 14, 3187, 199, 624, 421, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2882, 199, 199, 646, 12204, 14708, 63, 1246, 63, 1258, 199, 504, 12204, 14708, 63, 1246, 63, 1258, 14, 992, 14, 9078, 63, 4758, 492, 15474, 5688, 221, 327, 8151, 26, 662, 8216, 199, 504, 12204, 14708, 63, 1246, 63, 1258, 14, 3911, 492, 13986, 1726, 421, 199, 533, 1379, 22386, 5688, 8, 2796, 14, 1746, 304, 272, 408, 22386, 5688, 4137, 511, 22312, 624, 339, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 22386, 5688, 8, 277, 304, 267, 408, 774, 15474, 5688, 624, 267, 327, 7600, 26, 6982, 909, 543, 15230, 3004, 543, 2893, 1338, 267, 327, 1402, 275, 12204, 14708, 63, 1246, 63, 1258, 14, 992, 14, 9078, 63, 4758, 14, 22386, 5688, 342, 221, 327, 8151, 26, 662, 8216, 267, 986, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 26, 2774, 13, 24, 199, 199, 624, 272, 644, 811, 14708, 14880, 3261, 339, 665, 80, 30, 1918, 644, 811, 14708, 14880, 3261, 22741, 1265, 370, 17232, 543, 644, 811, 14708, 8037, 1808, 4465, 14880, 3261, 7249, 14, 2047, 883, 675, 314, 14880, 3261, 370, 6384, 676, 323, 28829, 7934, 5331, 4066, 465, 5847, 1947, 1540, 5274, 9758, 80, 2535, 80, 30, 11423, 1265, 1852, 14880, 3261, 4882, 9682, 314, 644, 811, 14708, 14880, 3261, 3794, 1265, 1471, 1050, 314, 1406, 8441, 11626, 26, 6423, 21462, 1253, 4116, 15337, 4116, 27, 3735, 13, 8803, 6, 3308, 15337, 3308, 3779, 2, 370, 2195, 3101, 4145, 9758, 80, 30, 221, 327, 8151, 26, 662, 8216, 339, 3232, 3735, 3158, 1015, 26, 373, 18, 272, 18684, 26, 682, 5277, 887, 65, 32, 10024, 14708, 14, 957, 272, 17065, 701, 26, 4178, 921, 5031, 14, 957, 15, 29940, 13, 1246, 15, 29940, 13, 600, 2268, 14, 3187, 199, 624, 421, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2882, 199, 199, 646, 12204, 14708, 63, 1246, 63, 1258, 199, 504, 12204, 14708, 63, 1246, 63, 1258, 14, 992, 14, 9078, 63, 4758, 492, 15474, 5688, 221, 327, 8151, 26, 662, 8216, 199, 504, 12204, 14708, 63, 1246, 63, 1258, 14, 3911, 492, 13986, 1726, 421, 199, 533, 1379, 22386, 5688, 8, 2796, 14, 1746, 304, 272, 408, 22386, 5688, 4137, 511, 22312, 624, 339, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 22386, 5688, 8, 277, 304, 267, 408, 774, 15474, 5688, 624, 267, 327, 7600, 26, 6982, 909, 543, 15230, 3004, 543, 2893, 1338, 267, 327, 1402, 275, 12204, 14708, 63, 1246, 63, 1258, 14, 992, 14, 9078, 63, 4758, 14, 22386, 5688, 342, 221, 327, 8151, 26, 662, 8216, 267, 986, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
40223139/39g7test
static/Brython3.1.3-20150514-095342/Lib/fnmatch.py
894
3163
"""Filename matching with shell patterns. fnmatch(FILENAME, PATTERN) matches according to the local convention. fnmatchcase(FILENAME, PATTERN) always takes case in account. The functions operate by translating the pattern into a regular expression. They cache the compiled regular expressions for speed. The function translate(PATTERN) returns a regular expression corresponding to PATTERN. (It does not compile it.) """ import os import posixpath import re import functools __all__ = ["filter", "fnmatch", "fnmatchcase", "translate"] def fnmatch(name, pat): """Test whether FILENAME matches PATTERN. Patterns are Unix shell style: * matches everything ? matches any single character [seq] matches any character in seq [!seq] matches any char not in seq An initial period in FILENAME is not special. Both FILENAME and PATTERN are first case-normalized if the operating system requires it. If you don't want this, use fnmatchcase(FILENAME, PATTERN). """ name = os.path.normcase(name) pat = os.path.normcase(pat) return fnmatchcase(name, pat) @functools.lru_cache(maxsize=256, typed=True) def _compile_pattern(pat): if isinstance(pat, bytes): pat_str = str(pat, 'ISO-8859-1') res_str = translate(pat_str) res = bytes(res_str, 'ISO-8859-1') else: res = translate(pat) return re.compile(res).match def filter(names, pat): """Return the subset of the list NAMES that match PAT.""" result = [] pat = os.path.normcase(pat) match = _compile_pattern(pat) if os.path is posixpath: # normcase on posix is NOP. Optimize it away from the loop. for name in names: if match(name): result.append(name) else: for name in names: if match(os.path.normcase(name)): result.append(name) return result def fnmatchcase(name, pat): """Test whether FILENAME matches PATTERN, including case. This is a version of fnmatch() which doesn't case-normalize its arguments. """ match = _compile_pattern(pat) return match(name) is not None def translate(pat): """Translate a shell PATTERN to a regular expression. There is no way to quote meta-characters. """ i, n = 0, len(pat) res = '' while i < n: c = pat[i] i = i+1 if c == '*': res = res + '.*' elif c == '?': res = res + '.' elif c == '[': j = i if j < n and pat[j] == '!': j = j+1 if j < n and pat[j] == ']': j = j+1 while j < n and pat[j] != ']': j = j+1 if j >= n: res = res + '\\[' else: stuff = pat[i:j].replace('\\','\\\\') i = j+1 if stuff[0] == '!': stuff = '^' + stuff[1:] elif stuff[0] == '^': stuff = '\\' + stuff res = '%s[%s]' % (res, stuff) else: res = res + re.escape(c) return res + '\Z(?ms)'
gpl-3.0
[ 624, 8117, 4877, 543, 5218, 7970, 14, 199, 199, 15359, 8, 15440, 12, 31467, 7689, 9, 4450, 7182, 370, 314, 2257, 16129, 14, 199, 15359, 2546, 8, 15440, 12, 31467, 7689, 9, 3544, 6181, 1930, 315, 2933, 14, 199, 199, 1918, 3423, 19218, 701, 1752, 24615, 314, 3851, 1901, 282, 5578, 199, 5599, 14, 221, 9322, 2581, 314, 10311, 5578, 8455, 367, 8112, 14, 199, 199, 1918, 805, 9028, 8, 10764, 9, 2529, 282, 5578, 3965, 199, 989, 31137, 370, 31467, 7689, 14, 221, 334, 7940, 1630, 440, 6555, 652, 4959, 199, 624, 199, 646, 747, 199, 646, 15454, 199, 646, 295, 199, 646, 9143, 199, 199, 363, 452, 363, 275, 2097, 1541, 401, 298, 15359, 401, 298, 15359, 2546, 401, 298, 5275, 937, 199, 199, 318, 15951, 8, 354, 12, 12713, 304, 272, 408, 774, 3775, 16444, 11536, 4450, 31467, 7689, 14, 339, 510, 4823, 787, 13074, 5218, 3449, 26, 339, 627, 755, 4450, 8137, 272, 5805, 755, 4450, 1263, 2849, 4528, 272, 359, 3610, 61, 257, 4450, 1263, 4528, 315, 5412, 272, 359, 1, 3610, 61, 221, 4450, 1263, 1495, 440, 315, 5412, 339, 1626, 2536, 6247, 315, 16444, 11536, 365, 440, 4539, 14, 272, 17650, 16444, 11536, 436, 31467, 7689, 787, 1642, 1930, 13, 12916, 272, 340, 314, 17406, 2656, 5074, 652, 14, 272, 982, 1265, 2793, 1133, 2934, 642, 12, 675, 15951, 2546, 8, 15440, 12, 31467, 7689, 680, 272, 408, 272, 536, 275, 747, 14, 515, 14, 21288, 8, 354, 9, 272, 12713, 275, 747, 14, 515, 14, 21288, 8, 10853, 9, 272, 372, 15951, 2546, 8, 354, 12, 12713, 9, 199, 199, 32, 17869, 14, 25003, 63, 1637, 8, 13634, 29, 3912, 12, 20041, 29, 549, 9, 199, 318, 485, 2014, 63, 3401, 8, 10853, 304, 272, 340, 1228, 8, 10853, 12, 2783, 304, 267, 12713, 63, 495, 275, 620, 8, 10853, 12, 283, 7336, 13, 4830, 13, 17, 358, 267, 522, 63, 495, 275, 9028, 8, 10853, 63, 495, 9, 267, 522, 275, 2783, 8, 470, 63, 495, 12, 283, 7336, 13, 4830, 13, 17, 358, 272, 587, 26, 267, 522, 275, 9028, 8, 10853, 9, 272, 372, 295, 14, 2014, 8, 470, 680, 1431, 199, 199, 318, 2457, 8, 1247, 12, 12713, 304, 272, 408, 1767, 314, 10026, 402, 314, 769, 26149, 654, 626, 1336, 31467, 1041, 272, 754, 275, 942, 272, 12713, 275, 747, 14, 515, 14, 21288, 8, 10853, 9, 272, 1336, 275, 485, 2014, 63, 3401, 8, 10853, 9, 272, 340, 747, 14, 515, 365, 15454, 26, 267, 327, 6316, 2546, 641, 10694, 365, 653, 1938, 14, 19246, 794, 652, 13437, 687, 314, 4438, 14, 267, 367, 536, 315, 1561, 26, 288, 340, 1336, 8, 354, 304, 355, 754, 14, 740, 8, 354, 9, 272, 587, 26, 267, 367, 536, 315, 1561, 26, 288, 340, 1336, 8, 736, 14, 515, 14, 21288, 8, 354, 2298, 355, 754, 14, 740, 8, 354, 9, 272, 372, 754, 199, 199, 318, 15951, 2546, 8, 354, 12, 12713, 304, 272, 408, 774, 3775, 16444, 11536, 4450, 31467, 7689, 12, 5893, 1930, 14, 339, 961, 365, 282, 1015, 402, 15951, 342, 1314, 3181, 1133, 1930, 13, 7721, 272, 2399, 2368, 14, 272, 408, 272, 1336, 275, 485, 2014, 63, 3401, 8, 10853, 9, 272, 372, 1336, 8, 354, 9, 365, 440, 488, 421, 199, 318, 9028, 8, 10853, 304, 272, 408, 18355, 282, 5218, 31467, 7689, 370, 282, 5578, 3965, 14, 339, 6006, 365, 949, 4340, 370, 6313, 3404, 13, 16516, 14, 272, 408, 339, 284, 12, 302, 275, 378, 12, 822, 8, 10853, 9, 272, 522, 275, 2125, 272, 1830, 284, 665, 302, 26, 267, 286, 275, 12713, 59, 73, 61, 267, 284, 275, 284, 11, 17, 267, 340, 286, 508, 22969, 288, 522, 275, 522, 435, 1987, 10223, 267, 916, 286, 508, 8720, 356, 288, 522, 275, 522, 435, 7815, 267, 916, 286, 508, 6730, 356, 288, 1335, 275, 284, 288, 340, 1335, 665, 302, 436, 12713, 59, 74, 61, 508, 14597, 356, 355, 1335, 275, 1335, 11, 17, 288, 340, 1335, 665, 302, 436, 12713, 59, 74, 61, 508, 24710, 356, 355, 1335, 275, 1335, 11, 17, 288, 1830, 1335, 665, 302, 436, 12713, 59, 74, 61, 1137, 24710, 356, 355, 1335, 275, 1335, 11, 17, 288, 340, 1335, 2356, 302, 26, 355, 522, 275, 522, 435, 6468, 459, 288, 587, 26, 355, 8292, 275, 12713, 59, 73, 26, 74, 1055, 1814, 11671, 1673, 8712, 358, 355, 284, 275, 1335, 11, 17, 355, 340, 8292, 59, 16, 61, 508, 14597, 356, 490, 8292, 275, 14452, 7, 435, 8292, 59, 17, 2938, 355, 916, 8292, 59, 16, 61, 508, 14452, 356, 490, 8292, 275, 22548, 435, 8292, 355, 522, 275, 1543, 83, 9722, 83, 6616, 450, 334, 470, 12, 8292, 9, 267, 587, 26, 288, 522, 275, 522, 435, 295, 14, 3765, 8, 67, 9, 272, 372, 522, 435, 1557, 58, 2229, 706, 3171, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8117, 4877, 543, 5218, 7970, 14, 199, 199, 15359, 8, 15440, 12, 31467, 7689, 9, 4450, 7182, 370, 314, 2257, 16129, 14, 199, 15359, 2546, 8, 15440, 12, 31467, 7689, 9, 3544, 6181, 1930, 315, 2933, 14, 199, 199, 1918, 3423, 19218, 701, 1752, 24615, 314, 3851, 1901, 282, 5578, 199, 5599, 14, 221, 9322, 2581, 314, 10311, 5578, 8455, 367, 8112, 14, 199, 199, 1918, 805, 9028, 8, 10764, 9, 2529, 282, 5578, 3965, 199, 989, 31137, 370, 31467, 7689, 14, 221, 334, 7940, 1630, 440, 6555, 652, 4959, 199, 624, 199, 646, 747, 199, 646, 15454, 199, 646, 295, 199, 646, 9143, 199, 199, 363, 452, 363, 275, 2097, 1541, 401, 298, 15359, 401, 298, 15359, 2546, 401, 298, 5275, 937, 199, 199, 318, 15951, 8, 354, 12, 12713, 304, 272, 408, 774, 3775, 16444, 11536, 4450, 31467, 7689, 14, 339, 510, 4823, 787, 13074, 5218, 3449, 26, 339, 627, 755, 4450, 8137, 272, 5805, 755, 4450, 1263, 2849, 4528, 272, 359, 3610, 61, 257, 4450, 1263, 4528, 315, 5412, 272, 359, 1, 3610, 61, 221, 4450, 1263, 1495, 440, 315, 5412, 339, 1626, 2536, 6247, 315, 16444, 11536, 365, 440, 4539, 14, 272, 17650, 16444, 11536, 436, 31467, 7689, 787, 1642, 1930, 13, 12916, 272, 340, 314, 17406, 2656, 5074, 652, 14, 272, 982, 1265, 2793, 1133, 2934, 642, 12, 675, 15951, 2546, 8, 15440, 12, 31467, 7689, 680, 272, 408, 272, 536, 275, 747, 14, 515, 14, 21288, 8, 354, 9, 272, 12713, 275, 747, 14, 515, 14, 21288, 8, 10853, 9, 272, 372, 15951, 2546, 8, 354, 12, 12713, 9, 199, 199, 32, 17869, 14, 25003, 63, 1637, 8, 13634, 29, 3912, 12, 20041, 29, 549, 9, 199, 318, 485, 2014, 63, 3401, 8, 10853, 304, 272, 340, 1228, 8, 10853, 12, 2783, 304, 267, 12713, 63, 495, 275, 620, 8, 10853, 12, 283, 7336, 13, 4830, 13, 17, 358, 267, 522, 63, 495, 275, 9028, 8, 10853, 63, 495, 9, 267, 522, 275, 2783, 8, 470, 63, 495, 12, 283, 7336, 13, 4830, 13, 17, 358, 272, 587, 26, 267, 522, 275, 9028, 8, 10853, 9, 272, 372, 295, 14, 2014, 8, 470, 680, 1431, 199, 199, 318, 2457, 8, 1247, 12, 12713, 304, 272, 408, 1767, 314, 10026, 402, 314, 769, 26149, 654, 626, 1336, 31467, 1041, 272, 754, 275, 942, 272, 12713, 275, 747, 14, 515, 14, 21288, 8, 10853, 9, 272, 1336, 275, 485, 2014, 63, 3401, 8, 10853, 9, 272, 340, 747, 14, 515, 365, 15454, 26, 267, 327, 6316, 2546, 641, 10694, 365, 653, 1938, 14, 19246, 794, 652, 13437, 687, 314, 4438, 14, 267, 367, 536, 315, 1561, 26, 288, 340, 1336, 8, 354, 304, 355, 754, 14, 740, 8, 354, 9, 272, 587, 26, 267, 367, 536, 315, 1561, 26, 288, 340, 1336, 8, 736, 14, 515, 14, 21288, 8, 354, 2298, 355, 754, 14, 740, 8, 354, 9, 272, 372, 754, 199, 199, 318, 15951, 2546, 8, 354, 12, 12713, 304, 272, 408, 774, 3775, 16444, 11536, 4450, 31467, 7689, 12, 5893, 1930, 14, 339, 961, 365, 282, 1015, 402, 15951, 342, 1314, 3181, 1133, 1930, 13, 7721, 272, 2399, 2368, 14, 272, 408, 272, 1336, 275, 485, 2014, 63, 3401, 8, 10853, 9, 272, 372, 1336, 8, 354, 9, 365, 440, 488, 421, 199, 318, 9028, 8, 10853, 304, 272, 408, 18355, 282, 5218, 31467, 7689, 370, 282, 5578, 3965, 14, 339, 6006, 365, 949, 4340, 370, 6313, 3404, 13, 16516, 14, 272, 408, 339, 284, 12, 302, 275, 378, 12, 822, 8, 10853, 9, 272, 522, 275, 2125, 272, 1830, 284, 665, 302, 26, 267, 286, 275, 12713, 59, 73, 61, 267, 284, 275, 284, 11, 17, 267, 340, 286, 508, 22969, 288, 522, 275, 522, 435, 1987, 10223, 267, 916, 286, 508, 8720, 356, 288, 522, 275, 522, 435, 7815, 267, 916, 286, 508, 6730, 356, 288, 1335, 275, 284, 288, 340, 1335, 665, 302, 436, 12713, 59, 74, 61, 508, 14597, 356, 355, 1335, 275, 1335, 11, 17, 288, 340, 1335, 665, 302, 436, 12713, 59, 74, 61, 508, 24710, 356, 355, 1335, 275, 1335, 11, 17, 288, 1830, 1335, 665, 302, 436, 12713, 59, 74, 61, 1137, 24710, 356, 355, 1335, 275, 1335, 11, 17, 288, 340, 1335, 2356, 302, 26, 355, 522, 275, 522, 435, 6468, 459, 288, 587, 26, 355, 8292, 275, 12713, 59, 73, 26, 74, 1055, 1814, 11671, 1673, 8712, 358, 355, 284, 275, 1335, 11, 17, 355, 340, 8292, 59, 16, 61, 508, 14597, 356, 490, 8292, 275, 14452, 7, 435, 8292, 59, 17, 2938, 355, 916, 8292, 59, 16, 61, 508, 14452, 356, 490, 8292, 275, 22548, 435, 8292, 355, 522, 275, 1543, 83, 9722, 83, 6616, 450, 334, 470, 12, 8292, 9, 267, 587, 26, 288, 522, 275, 522, 435, 295, 14, 3765, 8, 67, 9, 272, 372, 522, 435, 1557, 58, 2229, 706, 3171, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rbian/avocado-vt
virttest/virsh.py
2
130509
""" Utility classes and functions to handle connection to a libvirt host system The entire contents of callables in this module (minus the names defined in NOCLOSE below), will become methods of the Virsh and VirshPersistent classes. A Closure class is used to wrap the module functions, lambda does not properly store instance state in this implementation. Because none of the methods have a 'self' parameter defined, the classes are defined to be dict-like, and get passed in to the methods as a the special ``**dargs`` parameter. All virsh module functions _MUST_ include a special ``**dargs`` (variable keyword arguments) to accept non-default keyword arguments. The standard set of keyword arguments to all functions/modules is declared in the VirshBase class. Only the 'virsh_exec' key is guaranteed to always be present, the remainder may or may not be provided. Therefor, virsh functions/methods should use the dict.get() method to retrieve with a default for non-existant keys. :copyright: 2012 Red Hat Inc. """ import signal import logging import urlparse import re import weakref import time import select from avocado.utils import path from avocado.utils import process import aexpect from . import propcan from . import remote from . import utils_misc # list of symbol names NOT to wrap as Virsh class methods # Everything else from globals() will become a method of Virsh class NOCLOSE = globals().keys() + [ 'NOCLOSE', 'SCREENSHOT_ERROR_COUNT', 'VIRSH_COMMAND_CACHE', 'VIRSH_EXEC', 'VirshBase', 'VirshClosure', 'VirshSession', 'Virsh', 'VirshPersistent', 'VirshConnectBack', 'VIRSH_COMMAND_GROUP_CACHE', 'VIRSH_COMMAND_GROUP_CACHE_NO_DETAIL', ] # Needs to be in-scope for Virsh* class screenshot method and module function SCREENSHOT_ERROR_COUNT = 0 # Cache of virsh commands, used by help_command_group() and help_command_only() # TODO: Make the cache into a class attribute on VirshBase class. VIRSH_COMMAND_CACHE = None VIRSH_COMMAND_GROUP_CACHE = None VIRSH_COMMAND_GROUP_CACHE_NO_DETAIL = False # This is used both inside and outside classes try: VIRSH_EXEC = path.find_command("virsh") except ValueError: logging.warning("Virsh executable not set or found on path, " "virsh module will not function normally") VIRSH_EXEC = '/bin/true' class VirshBase(propcan.PropCanBase): """ Base Class storing libvirt Connection & state to a host """ __slots__ = ('uri', 'ignore_status', 'debug', 'virsh_exec', 'readonly') def __init__(self, *args, **dargs): """ Initialize instance with virsh_exec always set to something """ init_dict = dict(*args, **dargs) init_dict['virsh_exec'] = init_dict.get('virsh_exec', VIRSH_EXEC) init_dict['uri'] = init_dict.get('uri', None) init_dict['debug'] = init_dict.get('debug', False) init_dict['ignore_status'] = init_dict.get('ignore_status', False) init_dict['readonly'] = init_dict.get('readonly', False) super(VirshBase, self).__init__(init_dict) def get_uri(self): """ Accessor method for 'uri' property that must exist """ # self.get() would call get_uri() recursivly try: return self.__dict_get__('uri') except KeyError: return None class VirshSession(aexpect.ShellSession): """ A virsh shell session, used with Virsh instances. """ # No way to get virsh sub-command "exit" status # Check output against list of known error-status strings ERROR_REGEX_LIST = ['error:\s*.+$', '.*failed.*'] def __init__(self, virsh_exec=None, uri=None, a_id=None, prompt=r"virsh\s*[\#\>]\s*", remote_ip=None, remote_user=None, remote_pwd=None, ssh_remote_auth=False, readonly=False, unprivileged_user=None, auto_close=False): """ Initialize virsh session server, or client if id set. :param virsh_exec: path to virsh executable :param uri: uri of libvirt instance to connect to :param id: ID of an already running server, if accessing a running server, or None if starting a new one. :param prompt: Regular expression describing the shell's prompt line. :param remote_ip: Hostname/IP of remote system to ssh into (if any) :param remote_user: Username to ssh in as (if any) :param remote_pwd: Password to use, or None for host/pubkey :param auto_close: Param to init ShellSession. :param ssh_remote_auth: ssh to remote first.(VirshConnectBack). Then execute virsh commands. Because the VirshSession is designed for class VirshPersistent, so the default value of auto_close is False, and we manage the reference to VirshSession in VirshPersistent manually with counter_increase and counter_decrease. If you really want to use it directly over VirshPe- rsistent, please init it with auto_close=True, then the session will be closed in __del__. * session = VirshSession(virsh.VIRSH_EXEC, auto_close=True) """ self.uri = uri self.remote_ip = remote_ip self.remote_user = remote_user self.remote_pwd = remote_pwd # Special handling if setting up a remote session if ssh_remote_auth: # remote to remote if remote_pwd: pref_auth = "-o PreferredAuthentications=password" else: pref_auth = "-o PreferredAuthentications=hostbased,publickey" # ssh_cmd is not None flags this as remote session ssh_cmd = ("ssh -o UserKnownHostsFile=/dev/null %s -p %s %s@%s" % (pref_auth, 22, self.remote_user, self.remote_ip)) self.virsh_exec = ("%s \"%s -c '%s'\"" % (ssh_cmd, virsh_exec, self.uri)) else: # setting up a local session or re-using a session self.virsh_exec = virsh_exec if self.uri: self.virsh_exec += " -c '%s'" % self.uri ssh_cmd = None # flags not-remote session if readonly: self.virsh_exec += " -r" if unprivileged_user: self.virsh_exec = "su - %s -c '%s'" % (unprivileged_user, self.virsh_exec) # aexpect tries to auto close session because no clients connected yet aexpect.ShellSession.__init__(self, self.virsh_exec, a_id, prompt=prompt, auto_close=auto_close) # Handle remote session prompts: # 1.remote to remote with ssh # 2.local to remote with "virsh -c uri" if ssh_remote_auth or self.uri: # Handle ssh / password prompts remote.handle_prompts(self, self.remote_user, self.remote_pwd, prompt, debug=True) # fail if libvirtd is not running if self.cmd_status('list', timeout=60) != 0: logging.debug("Persistent virsh session is not responding, " "libvirtd may be dead.") self.auto_close = True raise aexpect.ShellStatusError(virsh_exec, 'list') def cmd_status_output(self, cmd, timeout=60, internal_timeout=None, print_func=None): """ Send a virsh command and return its exit status and output. :param cmd: virsh command to send (must not contain newline characters) :param timeout: The duration (in seconds) to wait for the prompt to return :param internal_timeout: The timeout to pass to read_nonblocking :param print_func: A function to be used to print the data being read (should take a string parameter) :return: A tuple (status, output) where status is the exit status and output is the output of cmd :raise ShellTimeoutError: Raised if timeout expires :raise ShellProcessTerminatedError: Raised if the shell process terminates while waiting for output :raise ShellStatusError: Raised if the exit status cannot be obtained :raise ShellError: Raised if an unknown error occurs """ out = self.cmd_output(cmd, timeout, internal_timeout, print_func) for line in out.splitlines(): if self.match_patterns(line, self.ERROR_REGEX_LIST) is not None: return 1, out return 0, out def cmd_result(self, cmd, ignore_status=False, debug=False, timeout=60): """Mimic process.run()""" exit_status, stdout = self.cmd_status_output(cmd, timeout=timeout) stderr = '' # no way to retrieve this separately result = process.CmdResult(cmd, stdout, stderr, exit_status) if not ignore_status and exit_status: raise process.CmdError(cmd, result, "Virsh Command returned non-zero exit status") if debug: logging.debug(result) return result def read_until_output_matches(self, patterns, filter_func=lambda x: x, timeout=60, internal_timeout=None, print_func=None, match_func=None): """ Read from child using read_nonblocking until a pattern matches. Read using read_nonblocking until a match is found using match_patterns, or until timeout expires. Before attempting to search for a match, the data is filtered using the filter_func function provided. :param patterns: List of strings (regular expression patterns) :param filter_func: Function to apply to the data read from the child before attempting to match it against the patterns (should take and return a string) :param timeout: The duration (in seconds) to wait until a match is found :param internal_timeout: The timeout to pass to read_nonblocking :param print_func: A function to be used to print the data being read (should take a string parameter) :param match_func: Function to compare the output and patterns. :return: Tuple containing the match index and the data read so far :raise ExpectTimeoutError: Raised if timeout expires :raise ExpectProcessTerminatedError: Raised if the child process terminates while waiting for output :raise ExpectError: Raised if an unknown error occurs """ if not match_func: match_func = self.match_patterns fd = self._get_fd("expect") o = "" end_time = time.time() + timeout while True: try: r, w, x = select.select([fd], [], [], max(0, end_time - time.time())) except (select.error, TypeError): break if not r: raise aexpect.ExpectTimeoutError(patterns, o) # Read data from child data = self.read_nonblocking(internal_timeout, end_time - time.time()) if not data: break # Print it if necessary if print_func: for line in data.splitlines(): print_func(line) # Look for patterns o += data out = '' match = match_func(filter_func(o), patterns) if match is not None: output = o.splitlines() # Find the second match in output reverse list, only return # the content between the last match and the second last match. # read_nonblocking might include output of last command or help # info when session initiated, # e.g. # When use VirshPersistent initiate a virsh session, an list # command is send in to test libvirtd status, and the first # command output will be like: # Welcome to virsh, the virtualization interactive terminal. # # Type: 'help' for help with commands # 'quit' to quit # # virsh # Id Name State #---------------------------------------------------- # # virsh # # the session help info is included, and the exact output # should be the content start after first virsh # prompt. # The list command did no harm here with help info included, # but sometime other commands get list command output included, # e.g. # Running virsh command: net-list --all # Sending command: net-list --all # Id Name State # ---------------------------------------------------- # # virsh # Name State Autostart Persistent # ---------------------------------------------------------- # default active yes yes # # virsh # # The list command output is mixed in the net-list command # output, this will fail to extract network name if use set # number 2 in list of output splitlines like in function # virsh.net_state_dict. for i in reversed(range(len(output) - 1)): if match_func(output[i].strip(), patterns) is not None: if re.split(patterns[match], output[i])[-1]: output[i] = re.split(patterns[match], output[i])[-1] output_slice = output[i:] else: output_slice = output[i + 1:] for j in range(len(output_slice) - 1): output_slice[j] = output_slice[j] + '\n' for k in range(len(output_slice)): out += output_slice[k] return match, out return match, o # Check if the child has terminated if utils_misc.wait_for(lambda: not self.is_alive(), 5, 0, 0.1): raise aexpect.ExpectProcessTerminatedError(patterns, self.get_status(), o) else: # This shouldn't happen raise aexpect.ExpectError(patterns, o) # Work around for inconsistent builtin closure local reference problem # across different versions of python class VirshClosure(object): """ Callable with weak ref. to override ``**dargs`` when calling reference_function """ def __init__(self, reference_function, dict_like_instance): """ Callable reference_function with weak ref dict_like_instance """ if not issubclass(dict_like_instance.__class__, dict): raise ValueError("dict_like_instance %s must be dict or subclass" % dict_like_instance.__class__.__name__) self.reference_function = reference_function self.dict_like_weakref = weakref.ref(dict_like_instance) def __call__(self, *args, **dargs): """ Call reference_function with dict_like_instance augmented by **dargs :param args: Passthrough to reference_function :param dargs: Updates dict_like_instance copy before call """ new_dargs = self.dict_like_weakref() if new_dargs is None: new_dargs = {} for key in new_dargs.keys(): if key not in dargs.keys(): dargs[key] = new_dargs[key] return self.reference_function(*args, **dargs) class Virsh(VirshBase): """ Execute libvirt operations, using a new virsh shell each time. """ __slots__ = [] def __init__(self, *args, **dargs): """ Initialize Virsh instance with persistent options :param args: Initial property keys/values :param dargs: Initial property keys/values """ super(Virsh, self).__init__(*args, **dargs) # Define the instance callables from the contents of this module # to avoid using class methods and hand-written aliases for sym, ref in globals().items(): if sym not in NOCLOSE and callable(ref): # Adding methods, not properties, so avoid special __slots__ # handling. __getattribute__ will still find these. self.__super_set__(sym, VirshClosure(ref, self)) class VirshPersistent(Virsh): """ Execute libvirt operations using persistent virsh session. """ __slots__ = ('session_id', 'remote_pwd', 'remote_user', 'uri', 'remote_ip', 'ssh_remote_auth', 'unprivileged_user', 'readonly') # B/c the auto_close of VirshSession is False, we # need to manage the ref-count of it manually. COUNTERS = {} def __init__(self, *args, **dargs): super(VirshPersistent, self).__init__(*args, **dargs) if self.get('session_id') is None: # set_uri does not call when INITIALIZED = False # and no session_id passed to super __init__ self.new_session() # increase the counter of session_id in COUNTERS. self.counter_increase() def __del__(self): """ Clean up any leftover sessions """ self.close_session() def counter_increase(self): """ Method to increase the counter to self.a_id in COUNTERS. """ session_id = self.__dict_get__("session_id") try: counter = self.__class__.COUNTERS[session_id] except KeyError, e: VirshPersistent.COUNTERS[session_id] = 1 return # increase the counter of session_id. VirshPersistent.COUNTERS[session_id] += 1 def counter_decrease(self): """ Method to decrease the counter to self.a_id in COUNTERS. If the counter is less than 1, it means there is no more VirshSession instance referring to the session. So close this session, and return True. Else, decrease the counter in COUNTERS and return False. """ session_id = self.__dict_get__("session_id") self.__class__.COUNTERS[session_id] -= 1 counter = self.__class__.COUNTERS[session_id] if counter <= 0: # The last reference to this session. Closing it. session = VirshSession(a_id=session_id) # try nicely first session.close() if session.is_alive(): # Be mean, incase it's hung session.close(sig=signal.SIGTERM) del self.__class__.COUNTERS[session_id] return True else: return False def close_session(self): """ If a persistent session exists, close it down. """ try: session_id = self.__dict_get__('session_id') if session_id: try: existing = VirshSession(a_id=session_id) if existing.is_alive(): self.counter_decrease() except (aexpect.ShellStatusError, aexpect.ShellProcessTerminatedError): # session was already closed pass # don't check is_alive or update counter self.__dict_del__("session_id") except KeyError: # Allow other exceptions to be raised pass # session was closed already def new_session(self): """ Open new session, closing any existing """ # Accessors may call this method, avoid recursion # Must exist, can't be None virsh_exec = self.__dict_get__('virsh_exec') uri = self.__dict_get__('uri') # Must exist, can be None readonly = self.__dict_get__('readonly') try: remote_user = self.__dict_get__('remote_user') except KeyError: remote_user = "root" try: remote_pwd = self.__dict_get__('remote_pwd') except KeyError: remote_pwd = None try: remote_ip = self.__dict_get__('remote_ip') except KeyError: remote_ip = None try: ssh_remote_auth = self.__dict_get__('ssh_remote_auth') except KeyError: ssh_remote_auth = False try: unprivileged_user = self.__dict_get__('unprivileged_user') except KeyError: unprivileged_user = None self.close_session() # Always create new session new_session = VirshSession(virsh_exec, uri, a_id=None, remote_ip=remote_ip, remote_user=remote_user, remote_pwd=remote_pwd, ssh_remote_auth=ssh_remote_auth, unprivileged_user=unprivileged_user, readonly=readonly) session_id = new_session.get_id() self.__dict_set__('session_id', session_id) def set_uri(self, uri): """ Accessor method for 'uri' property, create new session on change """ if not self.INITIALIZED: # Allow __init__ to call new_session self.__dict_set__('uri', uri) else: # If the uri is changing if self.__dict_get__('uri') != uri: self.__dict_set__('uri', uri) self.new_session() # otherwise do nothing class VirshConnectBack(VirshPersistent): """ Persistent virsh session connected back from a remote host """ __slots__ = ('remote_ip', ) def new_session(self): """ Open new remote session, closing any existing """ # Accessors may call this method, avoid recursion # Must exist, can't be None virsh_exec = self.__dict_get__('virsh_exec') uri = self.__dict_get__('uri') # Must exist, can be None remote_ip = self.__dict_get__('remote_ip') try: remote_user = self.__dict_get__('remote_user') except KeyError: remote_user = 'root' try: remote_pwd = self.__dict_get__('remote_pwd') except KeyError: remote_pwd = None super(VirshConnectBack, self).close_session() new_session = VirshSession(virsh_exec, uri, a_id=None, remote_ip=remote_ip, remote_user=remote_user, remote_pwd=remote_pwd, ssh_remote_auth=True) session_id = new_session.get_id() self.__dict_set__('session_id', session_id) @staticmethod def kosher_args(remote_ip, uri): """ Convenience static method to help validate argument sanity before use :param remote_ip: ip/hostname of remote libvirt helper-system :param uri: fully qualified libvirt uri of local system, from remote. :return: True/False if checks pass or not """ if remote_ip is None or uri is None: return False all_false = [ # remote_ip checks bool(remote_ip.count("EXAMPLE.COM")), bool(remote_ip.count("localhost")), bool(remote_ip.count("127.")), # uri checks uri is None, uri is "", bool(uri.count("default")), bool(uri.count(':///')), bool(uri.count("localhost")), bool(uri.count("127.")) ] return True not in all_false # virsh module functions follow (See module docstring for API) ##### def command(cmd, **dargs): """ Interface to cmd function as 'cmd' symbol is polluted. :param cmd: Command line to append to virsh command :param dargs: standardized virsh function API keywords :return: CmdResult object :raise: CmdError if non-zero exit status and ignore_status=False """ virsh_exec = dargs.get('virsh_exec', VIRSH_EXEC) uri = dargs.get('uri', None) debug = dargs.get('debug', False) # Caller deals with errors ignore_status = dargs.get('ignore_status', True) session_id = dargs.get('session_id', None) readonly = dargs.get('readonly', False) unprivileged_user = dargs.get('unprivileged_user', None) timeout = dargs.get('timeout', None) # Check if this is a VirshPersistent method call if session_id: # Retrieve existing session session = VirshSession(a_id=session_id) else: session = None if debug: logging.debug("Running virsh command: %s", cmd) if timeout: try: timeout = int(timeout) except ValueError: logging.error("Ignore the invalid timeout value: %s", timeout) timeout = None if session: # Utilize persistent virsh session, not suit for readonly mode if readonly: logging.debug("Ignore readonly flag for this virsh session") if timeout is None: timeout = 60 ret = session.cmd_result(cmd, ignore_status=ignore_status, debug=debug, timeout=timeout) # Mark return value with session it came from ret.from_session_id = session_id else: # Normal call to run virsh command # Readonly mode if readonly: cmd = " -r " + cmd if uri: # uri argument IS being used uri_arg = " -c '%s' " % uri else: uri_arg = " " # No uri argument being used cmd = "%s%s%s" % (virsh_exec, uri_arg, cmd) if unprivileged_user: # Run cmd as unprivileged user cmd = "su - %s -c '%s'" % (unprivileged_user, cmd) # Raise exception if ignore_status is False ret = process.run(cmd, timeout=timeout, verbose=debug, ignore_status=ignore_status, shell=True) # Mark return as not coming from persistent virsh session ret.from_session_id = None # Always log debug info, if persistent session or not if debug: logging.debug("status: %s", ret.exit_status) logging.debug("stdout: %s", ret.stdout.strip()) logging.debug("stderr: %s", ret.stderr.strip()) # Return CmdResult instance when ignore_status is True return ret def domname(dom_id_or_uuid, **dargs): """ Convert a domain id or UUID to domain name :param dom_id_or_uuid: a domain id or UUID. :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("domname --domain %s" % dom_id_or_uuid, **dargs) def qemu_monitor_command(name, cmd, options="", **dargs): """ This helps to execute the qemu monitor command through virsh command. :param name: Name of monitor domain :param cmd: monitor command to execute :param options: extra options :param dargs: standardized virsh function API keywords """ cmd_str = "qemu-monitor-command %s %s --cmd \'%s\'" % (name, options, cmd) return command(cmd_str, **dargs) def qemu_agent_command(name, cmd, options="", **dargs): """ This helps to execute the qemu agent command through virsh command. :param name: Name of monitor domain :param cmd: agent command to execute :param options: extra options :param dargs: standardized virsh function API keywords """ cmd_str = "qemu-agent-command %s %s --cmd \'%s\'" % (name, options, cmd) return command(cmd_str, **dargs) def qemu_attach(pid, extra="", **dargs): """ This helps to execute the qemu-attach command through virsh command. :param pid: pid of qemu process :param extra: extra options :param dargs: standardized virsh function API keywords """ cmd_str = "qemu-attach --pid %s %s" % (pid, extra) return command(cmd_str, **dargs) def setvcpus(name, count, extra="", **dargs): """ Change the number of virtual CPUs in the guest domain. :param name: name of vm to affect :param count: value for vcpu parameter :param options: any extra command options. :param dargs: standardized virsh function API keywords :return: CmdResult object from command """ cmd = "setvcpus %s %s %s" % (name, count, extra) return command(cmd, **dargs) def vcpupin(name, vcpu="", cpu_list="", options="", **dargs): """ Changes the cpu affinity for respective vcpu. :param name: name of domain :param vcpu: virtual CPU to modify :param cpu_list: physical CPU specification (string) :param dargs: standardized virsh function API keywords :param options: --live, --current or --config. :return: CmdResult object. """ cmd_vcpupin = "vcpupin %s %s %s %s" % (name, vcpu, cpu_list, options) return command(cmd_vcpupin, **dargs) def vcpuinfo(name, **dargs): """ :param name: name of domain :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("vcpuinfo %s" % name, **dargs) def freecell(cellno=None, options="", **dargs): """ Prints the available amount of memory on the machine or within a NUMA cell. :param cellno: number of cell to show. :param options: extra argument string to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "freecell " if cellno: cmd = "%s --cellno %s " % (cmd, cellno) cmd = "%s %s" % (cmd, options) return command(cmd, **dargs) def nodeinfo(extra="", **dargs): """ Returns basic information about the node,like number and type of CPU, and size of the physical memory. :param extra: extra argument string to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd_nodeinfo = "nodeinfo %s" % extra return command(cmd_nodeinfo, **dargs) def nodecpumap(extra="", **dargs): """ Displays the node's total number of CPUs, the number of online CPUs and the list of online CPUs. :param extra: extra argument string to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "nodecpumap %s" % extra return command(cmd, **dargs) def nodesuspend(target, duration, extra='', **dargs): """ Suspend the host node for a given time duration. :param target: Suspend target mem/disk/hybrid. mem(Suspend-to-RAM) disk(Suspend-to-Disk) hybrid(Hybrid-Suspend) :param duration: Suspend duration in seconds, at least 60. :param extra: extra argument string to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "nodesuspend %s %s" % (target, duration) if extra: cmd += " %s" % extra return command(cmd, **dargs) def canonical_uri(option='', **dargs): """ Return the hypervisor canonical URI. :param option: additional option string to pass :param dargs: standardized virsh function API keywords :return: standard output from command """ return command("uri %s" % option, **dargs).stdout.strip() def hostname(option='', **dargs): """ Return the hypervisor hostname. :param option: additional option string to pass :param dargs: standardized virsh function API keywords :return: standard output from command """ return command("hostname %s" % option, **dargs).stdout.strip() def version(option='', **dargs): """ Return the major version info about what this built from. :param option: additional option string to pass :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("version %s" % option, **dargs) def maxvcpus(option='', **dargs): """ Return the connection vcpu maximum number. :param: option: additional option string to pass :param: dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "maxvcpus %s" % option return command(cmd, **dargs) def dom_list(options="", **dargs): """ Return the list of domains. :param options: options to pass to list command :return: CmdResult object """ return command("list %s" % options, **dargs) def reboot(name, options="", **dargs): """ Run a reboot command in the target domain. :param name: Name of domain. :param options: options: options to pass to reboot command :return: CmdResult object """ return command("reboot --domain %s %s" % (name, options), **dargs) def managedsave(name, options="", **dargs): """ Managed save of a domain state. :param name: Name of domain to save :param options: options: options to pass to list command :return: CmdResult object """ return command("managedsave --domain %s %s" % (name, options), **dargs) def managedsave_remove(name, **dargs): """ Remove managed save of a domain :param name: name of managed-saved domain to remove :return: CmdResult object """ return command("managedsave-remove --domain %s" % name, **dargs) def driver(**dargs): """ Return the driver by asking libvirt :param dargs: standardized virsh function API keywords :return: VM driver name """ # libvirt schme composed of driver + command # ref: http://libvirt.org/uri.html scheme = urlparse.urlsplit(canonical_uri(**dargs))[0] # extract just the driver, whether or not there is a '+' return scheme.split('+', 2)[0] def domstate(name, extra="", **dargs): """ Return the state about a running domain. :param name: VM name :param extra: command options :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("domstate %s %s" % (name, extra), **dargs) def domid(name_or_uuid, **dargs): """ Return VM's ID. :param name_or_uuid: VM name or uuid :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("domid %s" % (name_or_uuid), **dargs) def dominfo(name, **dargs): """ Return the VM information. :param name: VM's name or id,uuid. :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("dominfo %s" % (name), **dargs) def domuuid(name_or_id, **dargs): """ Return the Converted domain name or id to the domain UUID. :param name_or_id: VM name or id :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("domuuid %s" % name_or_id, **dargs) def screenshot(name, filename, **dargs): """ Capture a screenshot of VM's console and store it in file on host :param name: VM name :param filename: name of host file :param dargs: standardized virsh function API keywords :return: filename """ # Don't take screenshots of shut-off domains if is_dead(name, **dargs): return None global SCREENSHOT_ERROR_COUNT dargs['ignore_status'] = False try: command("screenshot %s %s" % (name, filename), **dargs) except process.CmdError, detail: if SCREENSHOT_ERROR_COUNT < 1: logging.error("Error taking VM %s screenshot. You might have to " "set take_regular_screendumps=no on your " "tests.cfg config file \n%s. This will be the " "only logged error message.", name, detail) SCREENSHOT_ERROR_COUNT += 1 return filename def screenshot_test(name, filename="", options="", **dargs): """ Capture a screenshot of VM's console and store it in file on host :param name: VM name or id :param filename: name of host file :param options: command options :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("screenshot %s %s %s" % (name, filename, options), **dargs) def domblkstat(name, device, option, **dargs): """ Store state of VM into named file. :param name: VM's name. :param device: VM's device. :param option: command domblkstat option. :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("domblkstat %s %s %s" % (name, device, option), **dargs) def dumpxml(name, extra="", to_file="", **dargs): """ Return the domain information as an XML dump. :param name: VM name :param to_file: optional file to write XML output to :param dargs: standardized virsh function API keywords :return: CmdResult object. """ cmd = "dumpxml %s %s" % (name, extra) result = command(cmd, **dargs) if to_file: result_file = open(to_file, 'w') result_file.write(result.stdout.strip()) result_file.close() return result def domifstat(name, interface, **dargs): """ Get network interface stats for a running domain. :param name: Name of domain :param interface: interface device :return: CmdResult object """ return command("domifstat %s %s" % (name, interface), **dargs) def domjobinfo(name, **dargs): """ Get domain job information. :param name: VM name :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("domjobinfo %s" % name, **dargs) def edit(options, **dargs): """ Edit the XML configuration for a domain. :param options: virsh edit options string. :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("edit %s" % options, **dargs) def dompmsuspend(name, target, duration=0, **dargs): """ Suspends a running domain using guest OS's power management. :param name: VM name :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "dompmsuspend %s %s --duration %s" % (name, target, duration) return command(cmd, **dargs) def dompmwakeup(name, **dargs): """ Wakeup a domain that was previously suspended by power management. :param name: VM name :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("dompmwakeup %s" % name, **dargs) def domjobabort(name, **dargs): """ Aborts the currently running domain job. :param name: VM's name, id or uuid. :param dargs: standardized virsh function API keywords :return: result from command """ return command("domjobabort %s" % name, **dargs) def domxml_from_native(info_format, native_file, options=None, **dargs): """ Convert native guest configuration format to domain XML format. :param info_format:The command's options. For exmple:qemu-argv. :param native_file:Native information file. :param options:extra param. :param dargs: standardized virsh function API keywords. :return: result from command """ cmd = "domxml-from-native %s %s %s" % (info_format, native_file, options) return command(cmd, **dargs) def domxml_to_native(info_format, xml_file, options, **dargs): """ Convert domain XML config to a native guest configuration format. :param info_format:The command's options. For exmple:qemu-argv. :param xml_file:XML config file. :param options:extra param. :param dargs: standardized virsh function API keywords :return: result from command """ cmd = "domxml-to-native %s %s %s" % (info_format, xml_file, options) return command(cmd, **dargs) def vncdisplay(name, **dargs): """ Output the IP address and port number for the VNC display. :param name: VM's name or id,uuid. :param dargs: standardized virsh function API keywords. :return: result from command """ return command("vncdisplay %s" % name, **dargs) def is_alive(name, **dargs): """ Return True if the domain is started/alive. :param name: VM name :param dargs: standardized virsh function API keywords :return: True operation was successful """ return not is_dead(name, **dargs) def is_dead(name, **dargs): """ Return True if the domain is undefined or not started/dead. :param name: VM name :param dargs: standardized virsh function API keywords :return: True operation was successful """ dargs['ignore_status'] = False try: state = domstate(name, **dargs).stdout.strip() except process.CmdError: return True if state not in ('running', 'idle', 'paused', 'in shutdown', 'shut off', 'crashed', 'pmsuspended', 'no state'): logging.debug("State '%s' not known", state) if state in ('shut off', 'crashed', 'no state'): return True return False def suspend(name, **dargs): """ True on successful suspend of VM - kept in memory and not scheduled. :param name: VM name :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("suspend %s" % (name), **dargs) def resume(name, **dargs): """ True on successful moving domain out of suspend :param name: VM name :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("resume %s" % (name), **dargs) def dommemstat(name, extra="", **dargs): """ Store state of VM into named file. :param name: VM name :param extra: extra options to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("dommemstat %s %s" % (name, extra), **dargs) def dump(name, path, option="", **dargs): """ Dump the core of a domain to a file for analysis. :param name: VM name :param path: absolute path to state file :param option: command's option. :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("dump %s %s %s" % (name, path, option), **dargs) def save(name, path, options="", **dargs): """ Store state of VM into named file. :param name: VM'name, id or uuid. :param path: absolute path to state file :param options: command's options. :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("save %s %s %s" % (name, path, options), **dargs) def restore(path, options="", **dargs): """ Load state of VM from named file and remove file. :param path: absolute path to state file. :param options: options for virsh restore. :param dargs: standardized virsh function API keywords """ return command("restore %s %s" % (path, options), **dargs) def start(name, options="", **dargs): """ True on successful start of (previously defined) inactive domain. :param name: VM name :param dargs: standardized virsh function API keywords :return: CmdResult object. """ return command("start %s %s" % (name, options), **dargs) def shutdown(name, options="", **dargs): """ True on successful domain shutdown. :param name: VM name :param options: options for virsh shutdown. :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("shutdown %s %s" % (name, options), **dargs) def destroy(name, options="", **dargs): """ True on successful domain destruction :param name: VM name :param options: options for virsh destroy :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("destroy %s %s" % (name, options), **dargs) def define(xml_path, **dargs): """ Return True on successful domain define. :param xml_path: XML file path :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "define --file %s" % xml_path logging.debug("Define VM from %s", xml_path) return command(cmd, **dargs) def undefine(name, options=None, **dargs): """ Return cmd result of domain undefine (after shutdown/destroy). :param name: VM name :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "undefine %s" % name if options is not None: cmd += " %s" % options logging.debug("Undefine VM %s", name) return command(cmd, **dargs) def remove_domain(name, options=None, **dargs): """ Return True after forcefully removing a domain if it exists. :param name: VM name :param dargs: standardized virsh function API keywords :return: True operation was successful """ if domain_exists(name, **dargs): if is_alive(name, **dargs): destroy(name, **dargs) try: dargs['ignore_status'] = False undefine(name, options, **dargs) except process.CmdError, detail: logging.error("Undefine VM %s failed:\n%s", name, detail) return False return True def domain_exists(name, **dargs): """ Return True if a domain exits. :param name: VM name :param dargs: standardized virsh function API keywords :return: True operation was successful """ dargs['ignore_status'] = False try: command("domstate %s" % name, **dargs) return True except process.CmdError, detail: logging.warning("VM %s does not exist", name) if dargs.get('debug', False): logging.warning(str(detail)) return False def migrate(name="", dest_uri="", option="", extra="", **dargs): """ Migrate a guest to another host. :param name: name of guest on uri. :param dest_uri: libvirt uri to send guest to :param option: Free-form string of options to virsh migrate :param extra: Free-form string of options to follow <domain> <desturi> :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "migrate" if option: cmd += " %s" % option if name: cmd += " --domain %s" % name if dest_uri: cmd += " --desturi %s" % dest_uri if extra: cmd += " %s" % extra return command(cmd, **dargs) def migrate_setspeed(domain, bandwidth, extra=None, **dargs): """ Set the maximum migration bandwidth (in MiB/s) for a domain which is being migrated to another host. :param domain: name/uuid/id of guest :param bandwidth: migration bandwidth limit in MiB/s :param dargs: standardized virsh function API keywords """ cmd = "migrate-setspeed %s %s" % (domain, bandwidth) if extra is not None: cmd += " %s" % extra return command(cmd, **dargs) def migrate_getspeed(domain, **dargs): """ Get the maximum migration bandwidth (in MiB/s) for a domain. :param domain: name/uuid/id of guest :param dargs: standardized virsh function API keywords :return: standard output from command """ cmd = "migrate-getspeed %s" % domain return command(cmd, **dargs) def migrate_setmaxdowntime(domain, downtime, extra=None, **dargs): """ Set maximum tolerable downtime of a domain which is being live-migrated to another host. :param domain: name/uuid/id of guest :param downtime: downtime number of live migration """ cmd = "migrate-setmaxdowntime %s %s" % (domain, downtime) if extra is not None: cmd += " %s" % extra return command(cmd, **dargs) def migrate_compcache(domain, size=None, **dargs): """ Get/set compression cache size for migration. :param domain: name/uuid/id of guest :param size: compression cache size to be set. :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = 'migrate-compcache %s' % domain if size is not None: cmd += ' --size %s' % size return command(cmd, **dargs) def _adu_device(action, domainarg=None, filearg=None, domain_opt=None, file_opt=None, flagstr=None, **dargs): """ Private helper for attach, detach, update device commands """ # N/B: Parameter order is significant: RH BZ 1018369 cmd = action if domain_opt is not None: cmd += " --domain %s" % domain_opt if domainarg is not None: cmd += " %s" % domainarg if file_opt is not None: cmd += " --file %s" % file_opt if filearg is not None: cmd += " %s" % filearg if flagstr is not None: cmd += " %s" % flagstr return command(cmd, **dargs) def attach_device(domainarg=None, filearg=None, domain_opt=None, file_opt=None, flagstr=None, **dargs): """ Attach a device using full parameter/argument set. :param domainarg: Domain name (first pos. parameter) :param filearg: File name (second pos. parameter) :param domain_opt: Option to --domain parameter :param file_opt: Option to --file parameter :param flagstr: string of "--force, --persistent, etc." :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return _adu_device("attach-device", domainarg=domainarg, filearg=filearg, domain_opt=domain_opt, file_opt=file_opt, flagstr=flagstr, **dargs) def detach_device(domainarg=None, filearg=None, domain_opt=None, file_opt=None, flagstr=None, **dargs): """ Attach a device using full parameter/argument set. :param domainarg: Domain name (first pos. parameter) :param filearg: File name (second pos. parameter) :param domain_opt: Option to --domain parameter :param file_opt: Option to --file parameter :param flagstr: string of "--force, --persistent, etc." :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return _adu_device("detach-device", domainarg=domainarg, filearg=filearg, domain_opt=domain_opt, file_opt=file_opt, flagstr=flagstr, **dargs) def update_device(domainarg=None, filearg=None, domain_opt=None, file_opt=None, flagstr="", **dargs): """ Update device from an XML <file>. :param domainarg: Domain name (first pos. parameter) :param filearg: File name (second pos. parameter) :param domain_opt: Option to --domain parameter :param file_opt: Option to --file parameter :param flagstr: string of "--force, --persistent, etc." :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return _adu_device("update-device", domainarg=domainarg, filearg=filearg, domain_opt=domain_opt, file_opt=file_opt, flagstr=flagstr, **dargs) def attach_disk(name, source, target, extra="", **dargs): """ Attach a disk to VM. :param name: name of guest :param source: source of disk device :param target: target of disk device :param extra: additional arguments to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "attach-disk --domain %s --source %s --target %s %s"\ % (name, source, target, extra) return command(cmd, **dargs) def detach_disk(name, target, extra="", **dargs): """ Detach a disk from VM. :param name: name of guest :param target: target of disk device :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "detach-disk --domain %s --target %s %s" % (name, target, extra) return command(cmd, **dargs) def attach_interface(name, option="", **dargs): """ Attach a NIC to VM. :param name: name of guest :param option: options to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "attach-interface " if name: cmd += "--domain %s" % name if option: cmd += " %s" % option return command(cmd, **dargs) def detach_interface(name, option="", **dargs): """ Detach a NIC to VM. :param name: name of guest :param option: options to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "detach-interface " if name: cmd += "--domain %s" % name if option: cmd += " %s" % option return command(cmd, **dargs) def net_dumpxml(name, extra="", to_file="", **dargs): """ Dump XML from network named param name. :param name: Name of a network :param extra: Extra parameters to pass to command :param to_file: Send result to a file :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "net-dumpxml %s %s" % (name, extra) result = command(cmd, **dargs) if to_file: result_file = open(to_file, 'w') result_file.write(result.stdout.strip()) result_file.close() return result def net_create(xml_file, extra="", **dargs): """ Create _transient_ network from a XML file. :param xml_file: xml defining network :param extra: extra parameters to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("net-create %s %s" % (xml_file, extra), **dargs) def net_define(xml_file, extra="", **dargs): """ Define network from a XML file, do not start :param xml_file: xml defining network :param extra: extra parameters to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("net-define %s %s" % (xml_file, extra), **dargs) def net_list(options, extra="", **dargs): """ List networks on host. :param options: options to pass to command :param extra: extra parameters to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("net-list %s %s" % (options, extra), **dargs) def net_state_dict(only_names=False, virsh_instance=None, **dargs): """ Return network name to state/autostart/persistent mapping :param only_names: When true, return network names as keys and None values :param virsh_instance: Call net_list() on this instance instead of module :param dargs: standardized virsh function API keywords :return: dictionary """ # Using multiple virsh commands in different ways dargs['ignore_status'] = False # force problem detection if virsh_instance is not None: net_list_result = virsh_instance.net_list("--all", **dargs) else: net_list_result = net_list("--all", **dargs) # If command failed, exception would be raised here netlist = net_list_result.stdout.strip().splitlines() # First two lines contain table header followed by entries # for each network on the host, such as: # # Name State Autostart Persistent # ---------------------------------------------------------- # default active yes yes # # TODO: Double-check first-two lines really are header netlist = netlist[2:] result = {} for line in netlist: # Split on whitespace, assume 3 columns linesplit = line.split(None, 3) name = linesplit[0] # Several callers in libvirt_xml only require defined names if only_names: result[name] = None continue # Keep search fast & avoid first-letter capital problems active = not bool(linesplit[1].count("nactive")) autostart = bool(linesplit[2].count("es")) if len(linesplit) == 4: persistent = bool(linesplit[3].count("es")) else: # There is no representation of persistent status in output # in older libvirt. When libvirt older than 0.10.2 no longer # supported, this block can be safely removed. try: # Rely on net_autostart will raise() if not persistent state if autostart: # Enabled, try enabling again # dargs['ignore_status'] already False if virsh_instance is not None: virsh_instance.net_autostart(name, **dargs) else: net_autostart(name, **dargs) else: # Disabled, try disabling again if virsh_instance is not None: virsh_instance.net_autostart( name, "--disable", **dargs) else: net_autostart(name, "--disable", **dargs) # no exception raised, must be persistent persistent = True except process.CmdError, detail: # Exception thrown, could be transient or real problem if bool(str(detail.result_obj).count("ransient")): persistent = False else: # A unexpected problem happened, re-raise it. raise # Warning: These key names are used by libvirt_xml and test modules! result[name] = {'active': active, 'autostart': autostart, 'persistent': persistent} return result def net_start(network, extra="", **dargs): """ Start network on host. :param network: name/parameter for network option/argument :param extra: extra parameters to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("net-start %s %s" % (network, extra), **dargs) def net_destroy(network, extra="", **dargs): """ Destroy (stop) an activated network on host. :param network: name/parameter for network option/argument :param extra: extra string to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("net-destroy %s %s" % (network, extra), **dargs) def net_undefine(network, extra="", **dargs): """ Undefine a defined network on host. :param network: name/parameter for network option/argument :param extra: extra string to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("net-undefine %s %s" % (network, extra), **dargs) def net_name(uuid, extra="", **dargs): """ Get network name on host. :param uuid: network UUID. :param extra: extra parameters to pass to command. :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("net-name %s %s" % (uuid, extra), **dargs) def net_uuid(network, extra="", **dargs): """ Get network UUID on host. :param network: name/parameter for network option/argument :param extra: extra parameters to pass to command. :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("net-uuid %s %s" % (network, extra), **dargs) def net_autostart(network, extra="", **dargs): """ Set/unset a network to autostart on host boot :param network: name/parameter for network option/argument :param extra: extra parameters to pass to command (e.g. --disable) :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("net-autostart %s %s" % (network, extra), **dargs) def net_info(network, extra="", **dargs): """ Get network information :param network: name/parameter for network option/argument :param extra: extra parameters to pass to command. :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("net-info %s %s" % (network, extra), **dargs) def net_update(network, update_cmd, section, xml, extra="", **dargs): """ Update parts of an existing network's configuration :param network: network name or uuid :param update_cmd: type of update (add-first, add-last, delete, or modify) :param section: which section of network configuration to update :param xml: name of file containing xml :param extra: extra parameters to pass to command. :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "net-update %s %s %s %s %s" \ % (network, update_cmd, section, xml, extra) return command(cmd, **dargs) def _pool_type_check(pool_type): """ check if the pool_type is supported or not :param pool_type: pool type :return: valid pool type or None """ valid_types = ['dir', 'fs', 'netfs', 'disk', 'iscsi', 'logical', 'gluster'] if pool_type and pool_type not in valid_types: logging.error("Specified pool type '%s' not in '%s'", pool_type, valid_types) pool_type = None elif not pool_type: # take the first element as default pool_type pool_type = valid_types[0] return pool_type def pool_info(name, **dargs): """ Returns basic information about the storage pool. :param name: name of pool :param dargs: standardized virsh function API keywords """ cmd = "pool-info %s" % name return command(cmd, **dargs) def pool_destroy(name, **dargs): """ Forcefully stop a given pool. :param name: name of pool :param dargs: standardized virsh function API keywords """ cmd = "pool-destroy %s" % name dargs['ignore_status'] = False try: command(cmd, **dargs) return True except process.CmdError, detail: logging.error("Failed to destroy pool: %s.", detail) return False def pool_create(xml_file, extra="", **dargs): """ Create a pool from an xml file. :param xml_file: file containing an XML pool description :param extra: extra parameters to pass to command :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("pool-create %s %s" % (extra, xml_file), **dargs) def pool_create_as(name, pool_type, target, extra="", **dargs): """ Create a pool from a set of args. :param name: name of pool :param pool_type: storage pool type such as 'dir' :param target: libvirt uri to send guest to :param extra: Free-form string of options :param dargs: standardized virsh function API keywords :return: True if pool creation command was successful """ if not name: logging.error("Please give a pool name") pool_type = _pool_type_check(pool_type) if pool_type is None: return False logging.info("Create %s type pool %s", pool_type, name) cmd = "pool-create-as --name %s --type %s --target %s %s" \ % (name, pool_type, target, extra) dargs['ignore_status'] = False try: command(cmd, **dargs) return True except process.CmdError, detail: logging.error("Failed to create pool: %s.", detail) return False def pool_list(option="", extra="", **dargs): """ Prints the pool information of Host. :param option: options given to command all gives all pool details, including inactive inactive gives only inactive pool details details Gives the complete details about the pools :param extra: to provide extra options(to enter invalid options) """ return command("pool-list %s %s" % (option, extra), **dargs) def pool_uuid(name, **dargs): """ Convert a pool name to pool UUID :param name: Name of the pool :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("pool-uuid %s" % name, **dargs) def pool_name(uuid, **dargs): """ Convert a pool UUID to pool name :param name: UUID of the pool :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("pool-name %s" % uuid, **dargs) def pool_refresh(name, **dargs): """ Refresh a pool :param name: Name of the pool :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("pool-refresh %s" % name, **dargs) def pool_delete(name, **dargs): """ Destroy the resources used by a given pool object :param name: Name of the pool :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("pool-delete %s" % name, **dargs) def pool_state_dict(only_names=False, **dargs): """ Return pool name to state/autostart mapping :param only_names: When true, return pool names as keys and None values :param dargs: standardized virsh function API keywords :return: dictionary """ # Using multiple virsh commands in different ways dargs['ignore_status'] = False # force problem detection pool_list_result = pool_list("--all", **dargs) # If command failed, exception would be raised here poollist = pool_list_result.stdout.strip().splitlines() # First two lines contain table header followed by entries # for each pool on the host, such as: # # Name State Autostart # ------------------------------------------- # default active yes # iscsi-net-pool active yes # # TODO: Double-check first-two lines really are header poollist = poollist[2:] result = {} for line in poollist: # Split on whitespace, assume 3 columns linesplit = line.split(None, 3) name = linesplit[0] # Several callers in libvirt_xml only require defined names # TODO: Copied from net_state_dict where this is true, but # as of writing only caller is virsh_pool_create test # which doesn't use this 'feature'. if only_names: result[name] = None continue # Keep search fast & avoid first-letter capital problems active = not bool(linesplit[1].count("nactive")) autostart = bool(linesplit[2].count("es")) # Warning: These key names are used by libvirt_xml and test modules! result[name] = {'active': active, 'autostart': autostart} return result def pool_define_as(name, pool_type, target, extra="", **dargs): """ Define the pool from the arguments :param name: Name of the pool to be defined :param typ: Type of the pool to be defined dir file system directory disk Physical Disk Device fs Pre-formatted Block Device netfs Network Exported Directory iscsi iSCSI Target logical LVM Volume Group mpath Multipath Device Enumerater scsi SCSI Host Adapter :param target: libvirt uri to send guest to :param extra: Free-form string of options :param dargs: standardized virsh function API keywords :return: True if pool define command was successful """ pool_type = _pool_type_check(pool_type) if pool_type is None: return False logging.debug("Try to define %s type pool %s", pool_type, name) cmd = "pool-define-as --name %s --type %s --target %s %s" \ % (name, pool_type, target, extra) return command(cmd, **dargs) def pool_start(name, extra="", **dargs): """ Start the defined pool :param name: Name of the pool to be started :param extra: Free-form string of options :param dargs: standardized virsh function API keywords :return: True if pool start command was successful """ return command("pool-start %s %s" % (name, extra), **dargs) def pool_autostart(name, extra="", **dargs): """ Mark for autostart of a pool :param name: Name of the pool to be mark for autostart :param extra: Free-form string of options :param dargs: standardized virsh function API keywords :return: True if pool autostart command was successful """ return command("pool-autostart %s %s" % (name, extra), **dargs) def pool_edit(name, **dargs): """ Edit XML configuration for a storage pool. :param name: pool name or uuid :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "pool-edit %s" % name return command(cmd, **dargs) def pool_undefine(name, extra="", **dargs): """ Undefine the given pool :param name: Name of the pool to be undefined :param extra: Free-form string of options :param dargs: standardized virsh function API keywords :return: True if pool undefine command was successful """ return command("pool-undefine %s %s" % (name, extra), **dargs) def pool_build(name, options="", **dargs): """ Build pool. :param name: Name of the pool to be built :param options: options for pool-build """ return command("pool-build %s %s" % (name, options), **dargs) def find_storage_pool_sources_as(source_type, options="", **dargs): """ Find potential storage pool sources :param source_type: type of storage pool sources to find :param options: cmd options :param dargs: standardized virsh function API keywords :return: returns the output of the command """ return command("find-storage-pool-sources-as %s %s" % (source_type, options), **dargs) def find_storage_pool_sources(source_type, srcSpec, **dargs): """ Find potential storage pool sources :param source_type: type of storage pool sources to find :param srcSpec: file of source xml to qurey for pools :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("find-storage-pool-sources %s %s" % (source_type, srcSpec), **dargs) def pool_dumpxml(name, extra="", to_file="", **dargs): """ Return the pool information as an XML dump. :param name: pool_name name :param to_file: optional file to write XML output to :param dargs: standardized virsh function API keywords :return: standard output from command """ dargs['ignore_status'] = True cmd = "pool-dumpxml %s %s" % (name, extra) result = command(cmd, **dargs) if to_file: result_file = open(to_file, 'w') result_file.write(result.stdout.strip()) result_file.close() if result.exit_status: raise process.CmdError(cmd, result, "Virsh dumpxml returned non-zero exit status") return result.stdout.strip() def pool_define(xml_path, **dargs): """ Return True on successful pool define. :param xml_path: XML file path :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "pool-define --file %s" % xml_path return command(cmd, **dargs) def vol_create(pool_name, xml_file, extra="", **dargs): """ To create the volumes from xml file. :param pool_name: Name of the pool to be used :param xml_file: file containing an XML vol description :param extra: string of extra options :return: CmdResult object """ cmd = "vol-create --pool %s --file %s %s" % (pool_name, xml_file, extra) return command(cmd, **dargs) def vol_create_as(volume_name, pool_name, capacity, allocation, frmt, extra="", **dargs): """ To create the volumes on different available pool :param name: Name of the volume to be created :param pool_name: Name of the pool to be used :param capacity: Size of the volume :param allocaltion: Size of the volume to be pre-allocated :param frmt: volume formats(e.g. raw, qed, qcow2) :param extra: Free-form string of options :param dargs: standardized virsh function API keywords :return: True if pool undefine command was successful """ cmd = "vol-create-as --pool %s" % pool_name cmd += " %s --capacity %s" % (volume_name, capacity) if allocation: cmd += " --allocation %s" % (allocation) if frmt: cmd += " --format %s" % (frmt) if extra: cmd += " %s" % (extra) return command(cmd, **dargs) def vol_create_from(pool_name, vol_file, input_vol, input_pool, extra="", **dargs): """ Create a vol, using another volume as input :param: pool_name: Name of the pool to create the volume in :param: vol_file: XML <file> with the volume definition :param: input_vol: Name of the source volume :param: input_pool: Name of the pool the source volume is in :param: extra: Free-form string of options :return: True if volume create successfully """ cmd = ("vol-create-from --pool %s --file %s --vol %s --inputpool %s" % (pool_name, vol_file, input_vol, input_pool)) if extra: cmd += " %s" % (extra) return command(cmd, **dargs) def vol_list(pool_name, extra="", **dargs): """ List the volumes for a given pool :param pool_name: Name of the pool :param extra: Free-form string options :param dargs: standardized virsh function API keywords :return: returns the output of the command """ return command("vol-list %s %s" % (pool_name, extra), **dargs) def vol_delete(volume_name, pool_name, extra="", **dargs): """ Delete a given volume :param volume_name: Name of the volume :param pool_name: Name of the pool :param extra: Free-form string options :param dargs: standardized virsh function API keywords :return: returns the output of the command """ return command("vol-delete %s %s %s" % (volume_name, pool_name, extra), **dargs) def vol_key(volume_name, pool_name, extra="", **drags): """ Prints the key of the given volume name :param volume_name: Name of the volume :param extra: Free-form string options :param dargs: standardized virsh function API keywords :return: returns the output of the command """ return command("vol-key --vol %s --pool %s %s" % (volume_name, pool_name, extra), **drags) def vol_info(volume_name, pool_name, extra="", **drags): """ Prints the given volume info :param volume_name: Name of the volume :param extra: Free-form string options :param dargs: standardized virsh function API keywords :return: returns the output of the command """ cmd = "vol-info --vol %s" % volume_name if pool_name: cmd += " --pool %s" % pool_name if extra: cmd += " %s" % extra return command(cmd, **drags) def vol_name(volume_key, extra="", **drags): """ Prints the given volume name :param volume_name: Name of the volume :param extra: Free-form string options :param dargs: standardized virsh function API keywords :return: returns the output of the command """ return command("vol-name --vol %s %s" % (volume_key, extra), **drags) def vol_path(volume_name, pool_name, extra="", **dargs): """ Prints the give volume path :param volume_name: Name of the volume :param pool_name: Name of the pool :param extra: Free-form string options :param dargs: standardized virsh function API keywords :return: returns the output of the command """ return command("vol-path --vol %s --pool %s %s" % (volume_name, pool_name, extra), **dargs) def vol_dumpxml(volume_name, pool_name, to_file=None, options="", **dargs): """ Dumps volume details in xml :param volume_name: Name of the volume :param pool_name: Name of the pool :param to_file: path of the file to store the output :param options: Free-form string options :param dargs: standardized virsh function API keywords :return: returns the output of the command """ cmd = ('vol-dumpxml --vol %s --pool %s %s' % (volume_name, pool_name, options)) result = command(cmd, **dargs) if to_file is not None: result_file = open(to_file, 'w') result_file.write(result.stdout.strip()) result_file.close() return result def vol_pool(volume_name, extra="", **dargs): """ Returns pool name for a given vol-key :param volume_name: Name of the volume :param extra: Free-form string options :param dargs: standardized virsh function API keywords :return: returns the output of the command """ return command("vol-pool %s %s" % (volume_name, extra), **dargs) def vol_clone(volume_name, new_name, pool_name="", extra="", **dargs): """ Clone an existing volume. :param volume_name: Name of the original volume :param new_name: Clone name :param pool_name: Name of the pool :param extra: Free-form string options :param dargs: Standardized virsh function API keywords :return: Returns the output of the command """ cmd = "vol-clone --vol %s --newname %s %s" % (volume_name, new_name, extra) if pool_name: cmd += " --pool %s" % pool_name return command(cmd, **dargs) def vol_wipe(volume_name, pool_name="", alg="", **dargs): """ Ensure data previously on a volume is not accessible to future reads. :param volume_name: Name of the volume :param pool_name: Name of the pool :param alg: Perform selected wiping algorithm :param dargs: Standardized virsh function API keywords :return: Returns the output of the command """ cmd = "vol-wipe --vol %s" % volume_name if pool_name: cmd += " --pool %s" % pool_name if alg: cmd += " --algorithm %s" % alg return command(cmd, **dargs) def vol_resize(volume_name, capacity, pool_name="", extra="", **dargs): """ Resizes a storage volume. :param volume_name: Name of the volume :param capacity: New capacity for the volume (default bytes) :param pool_name: Name of the pool :param extra: Free-form string options :param dargs: Standardized virsh function API keywords :return: Returns the output of the command """ cmd = "vol-resize --vol %s --capacity %s " % (volume_name, capacity) if pool_name: cmd += " --pool %s " % pool_name if extra: cmd += extra return command(cmd, **dargs) def capabilities(option='', to_file=None, **dargs): """ Return output from virsh capabilities command :param option: additional options (takes none) :param dargs: standardized virsh function API keywords """ cmd_result = command('capabilities %s' % option, **dargs) if to_file is not None: result_file = open(to_file, 'w') result_file.write(cmd_result.stdout.strip()) result_file.close() return cmd_result.stdout.strip() def nodecpustats(option='', **dargs): """ Returns basic information about the node CPU statistics :param option: additional options (takes none) :param dargs: standardized virsh function API keywords """ cmd_nodecpustat = "nodecpustats %s" % option return command(cmd_nodecpustat, **dargs) def nodememstats(option='', **dargs): """ Returns basic information about the node Memory statistics :param option: additional options (takes none) :param dargs: standardized virsh function API keywords """ return command('nodememstats %s' % option, **dargs) def memtune_set(name, options, **dargs): """ Set the memory controller parameters :param domname: VM Name :param options: contains the values limit, state and value """ return command("memtune %s %s" % (name, options), **dargs) def memtune_list(name, **dargs): """ List the memory controller value of a given domain :param domname: VM Name """ return command("memtune %s" % (name), **dargs) def memtune_get(name, key): """ Get the specific memory controller value :param domname: VM Name :param key: memory controller limit for which the value needed :return: the memory value of a key in Kbs """ memtune_output = memtune_list(name) memtune_value = re.findall(r"%s\s*:\s+(\S+)" % key, str(memtune_output)) if memtune_value: return int(memtune_value[0]) else: return -1 def help_command(options='', cache=False, **dargs): """ Return list of commands and groups in help command output :param options: additional options to pass to help command :param cache: Return cached result if True, or refreshed cache if False :param dargs: standardized virsh function API keywords :return: List of command and group names """ # Combine virsh command list and virsh group list. virsh_command_list = help_command_only(options, cache, **dargs) virsh_group_list = help_command_group(options, cache, **dargs) virsh_command_group = None virsh_command_group = virsh_command_list + virsh_group_list return virsh_command_group def help_command_only(options='', cache=False, **dargs): """ Return list of commands in help command output :param options: additional options to pass to help command :param cache: Return cached result if True, or refreshed cache if False :param dargs: standardized virsh function API keywords :return: List of command names """ # global needed to support this function's use in Virsh method closure global VIRSH_COMMAND_CACHE if not VIRSH_COMMAND_CACHE or cache is False: VIRSH_COMMAND_CACHE = [] regx_command_word = re.compile(r"\s+([a-z0-9-]+)\s+") for line in help(options, **dargs).stdout.strip().splitlines(): # Get rid of 'keyword' line if line.find("keyword") != -1: continue mobj_command_word = regx_command_word.search(line) if mobj_command_word: VIRSH_COMMAND_CACHE.append(mobj_command_word.group(1)) # Prevent accidental modification of cache itself return list(VIRSH_COMMAND_CACHE) def help_command_group(options='', cache=False, **dargs): """ Return list of groups in help command output :param options: additional options to pass to help command :param cache: Return cached result if True, or refreshed cache if False :param dargs: standardized virsh function API keywords :return: List of group names """ # global needed to support this function's use in Virsh method closure global VIRSH_COMMAND_GROUP_CACHE, VIRSH_COMMAND_GROUP_CACHE_NO_DETAIL if VIRSH_COMMAND_GROUP_CACHE_NO_DETAIL: return [] if not VIRSH_COMMAND_GROUP_CACHE or cache is False: VIRSH_COMMAND_GROUP_CACHE = [] regx_group_word = re.compile(r"[\']([a-zA-Z0-9]+)[\']") for line in help(options, **dargs).stdout.strip().splitlines(): # 'keyword' only exists in group line. if line.find("keyword") != -1: mojb_group_word = regx_group_word.search(line) if mojb_group_word: VIRSH_COMMAND_GROUP_CACHE.append(mojb_group_word.group(1)) if len(list(VIRSH_COMMAND_GROUP_CACHE)) == 0: VIRSH_COMMAND_GROUP_CACHE_NO_DETAIL = True # Prevent accidental modification of cache itself return list(VIRSH_COMMAND_GROUP_CACHE) def has_help_command(virsh_cmd, options='', **dargs): """ String match on virsh command in help output command list :param virsh_cmd: Name of virsh command or group to look for :param options: Additional options to send to help command :param dargs: standardized virsh function API keywords :return: True/False """ return bool(help_command_only(options, cache=True, **dargs).count(virsh_cmd)) def has_command_help_match(virsh_cmd, regex, **dargs): """ Regex search on subcommand help output :param virsh_cmd: Name of virsh command or group to match help output :param regex: regular expression string to match :param dargs: standardized virsh function API keywords :return: re match object """ command_help_output = help(virsh_cmd, **dargs).stdout.strip() return re.search(regex, command_help_output) def help(virsh_cmd='', **dargs): """ Prints global help, command specific help, or help for a group of related commands :param virsh_cmd: Name of virsh command or group :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("help %s" % virsh_cmd, **dargs) def schedinfo(domain, options="", **dargs): """ Show/Set scheduler parameters. :param domain: vm's name id or uuid. :param options: additional options. :param dargs: standardized virsh function API keywords """ cmd = "schedinfo %s %s" % (domain, options) return command(cmd, **dargs) def setmem(domainarg=None, sizearg=None, domain=None, size=None, use_kilobytes=False, flagstr="", **dargs): """ Change the current memory allocation in the guest domain. :param domainarg: Domain name (first pos. parameter) :param sizearg: Memory size in KiB (second. pos. parameter) :param domain: Option to --domain parameter :param size: Option to --size or --kilobytes parameter :param use_kilobytes: True for --kilobytes, False for --size :param dargs: standardized virsh function API keywords :param flagstr: string of "--config, --live, --current, etc." :return: CmdResult instance :raise: process.CmdError: if libvirtd is not running """ cmd = "setmem" if domainarg is not None: # Allow testing of "" cmd += " %s" % domainarg if domain is not None: # Allow testing of --domain "" cmd += " --domain %s" % domain if sizearg is not None: # Allow testing of 0 and "" cmd += " %s" % sizearg if size is not None: # Allow testing of --size "" or --size 0 if use_kilobytes: cmd += " --kilobytes %s" % size else: cmd += " --size %s" % size if len(flagstr) > 0: cmd += " %s" % flagstr return command(cmd, **dargs) def setmaxmem(domainarg=None, sizearg=None, domain=None, size=None, use_kilobytes=False, flagstr="", **dargs): """ Change the maximum memory allocation for the guest domain. :param domainarg: Domain name (first pos. parameter) :param sizearg: Memory size in KiB (second. pos. parameter) :param domain: Option to --domain parameter :param size: Option to --size or --kilobytes parameter :param use_kilobytes: True for --kilobytes, False for --size :param flagstr: string of "--config, --live, --current, etc." :return: CmdResult instance :raise: process.CmdError: if libvirtd is not running. """ cmd = "setmaxmem" if domainarg is not None: # Allow testing of "" cmd += " %s" % domainarg if sizearg is not None: # Allow testing of 0 and "" cmd += " %s" % sizearg if domain is not None: # Allow testing of --domain "" cmd += " --domain %s" % domain if size is not None: # Allow testing of --size "" or --size 0 if use_kilobytes: cmd += " --kilobytes %s" % size else: cmd += " --size %s" % size if len(flagstr) > 0: cmd += " %s" % flagstr return command(cmd, **dargs) def snapshot_create(name, options="", **dargs): """ Create snapshot of domain. :param name: name of domain :param dargs: standardized virsh function API keywords :return: name of snapshot """ cmd = "snapshot-create %s %s" % (name, options) return command(cmd, **dargs) def snapshot_edit(name, options="", **dargs): """ Edit snapshot xml :param name: name of domain :param options: options of snapshot-edit command :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "snapshot-edit %s %s" % (name, options) return command(cmd, **dargs) def snapshot_create_as(name, options="", **dargs): """ Create snapshot of domain with options. :param name: name of domain :param options: options of snapshot-create-as :param dargs: standardized virsh function API keywords :return: name of snapshot """ # CmdResult is handled here, force ignore_status cmd = "snapshot-create-as %s" % name if options is not None: cmd += " %s" % options return command(cmd, **dargs) def snapshot_parent(name, options, **dargs): """ Get name of snapshot parent :param name: name of domain :param options: options of snapshot-parent :param dargs: standardized virsh function API keywords :return: name of snapshot """ cmd = "snapshot-parent %s %s" % (name, options) return command(cmd, **dargs) def snapshot_current(name, options="--name", **dargs): """ Get name or xml of current snapshot. :param name: name of domain :param options: options of snapshot-current, default is --name :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "snapshot-current %s" % name if options is not None: cmd += " %s" % options return command(cmd, **dargs) def snapshot_list(name, options=None, **dargs): """ Get list of snapshots of domain. :param name: name of domain :param options: options of snapshot_list :param dargs: standardized virsh function API keywords :return: list of snapshot names """ # CmdResult is handled here, force ignore_status dargs['ignore_status'] = True ret = [] cmd = "snapshot-list %s" % name if options is not None: cmd += " %s" % options sc_output = command(cmd, **dargs) if sc_output.exit_status != 0: raise process.CmdError( cmd, sc_output, "Failed to get list of snapshots") data = re.findall("\S* *\d*-\d*-\d* \d*:\d*:\d* [+-]\d* \w*", sc_output.stdout) for rec in data: if not rec: continue ret.append(re.match("\S*", rec).group()) return ret def snapshot_dumpxml(name, snapshot, options=None, to_file=None, **dargs): """ Get dumpxml of snapshot :param name: name of domain :param snapshot: name of snapshot :param options: options of snapshot_list :param to_file: optional file to write XML output to :param dargs: standardized virsh function API keywords :return: standard output from command """ cmd = "snapshot-dumpxml %s %s" % (name, snapshot) if options is not None: cmd += " %s" % options result = command(cmd, **dargs) if to_file is not None: result_file = open(to_file, 'w') result_file.write(result.stdout.strip()) result_file.close() return result def snapshot_info(name, snapshot, **dargs): """ Check snapshot information. :param name: name of domain :param snapshot: name os snapshot to verify :param dargs: standardized virsh function API keywords :return: snapshot information dictionary """ # CmdResult is handled here, force ignore_status dargs['ignore_status'] = True ret = {} values = ["Name", "Domain", "Current", "State", "Parent", "Children", "Descendants", "Metadata"] cmd = "snapshot-info %s %s" % (name, snapshot) sc_output = command(cmd, **dargs) if sc_output.exit_status != 0: raise process.CmdError(cmd, sc_output, "Failed to get snapshot info") for val in values: data = re.search("(?<=%s:) *\w*" % val, sc_output.stdout) if data is None: continue ret[val] = data.group(0).strip() if ret["Parent"] == "-": ret["Parent"] = None return ret def snapshot_revert(name, snapshot, options="", **dargs): """ Revert domain state to saved snapshot. :param name: name of domain :param dargs: standardized virsh function API keywords :param snapshot: snapshot to revert to :return: CmdResult instance """ cmd = "snapshot-revert %s %s %s" % (name, snapshot, options) return command(cmd, **dargs) def snapshot_delete(name, snapshot, options='', **dargs): """ Remove domain snapshot :param name: name of domain :param dargs: standardized virsh function API keywords :param snapshot: snapshot to delete :return: CmdResult instance """ cmd = "snapshot-delete %s %s %s" % (name, snapshot, options) return command(cmd, **dargs) def blockcommit(name, path, options="", **dargs): """ Start a block commit operation. :param name: name of domain :param options: options of blockcommit :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "blockcommit %s %s" % (name, path) if options is not None: cmd += " %s" % options return command(cmd, **dargs) def blockpull(name, path, options="", **dargs): """ Start a block pull operation. :param name: name of domain :param options: options of blockpull :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "blockpull %s %s" % (name, path) if options is not None: cmd += " %s" % options return command(cmd, **dargs) def blockresize(name, path, size, **dargs): """ Resize block device of domain. :param name: name of domain :param path: path of block device :size: new size of the block device :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("blockresize %s %s %s" % (name, path, size), **dargs) def domblkinfo(name, device, **dargs): """ Get block device size info for a domain. :param name: VM's name or id,uuid. :param device: device of VM. :param dargs: standardized virsh function API keywords. :return: CmdResult object. """ return command("domblkinfo %s %s" % (name, device), **dargs) def domblklist(name, options=None, **dargs): """ Get domain devices. :param name: name of domain :param options: options of domblklist. :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "domblklist %s" % name if options: cmd += " %s" % options return command(cmd, **dargs) def domiflist(name, options='', extra='', **dargs): """ Get the domain network devices :param name: name of domain :param options: options of domiflist :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command('domiflist %s %s %s' % (name, options, extra), **dargs) def cpu_stats(name, options, **dargs): """ Display per-CPU and total statistics about domain's CPUs :param name: name of domain :param options: options of cpu_stats :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "cpu-stats %s" % name if options: cmd += " %s" % options return command(cmd, **dargs) def change_media(name, device, options, **dargs): """ Change media of CD or floppy drive. :param name: VM's name. :param path: Fully-qualified path or target of disk device :param options: command change_media options. :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "change-media %s %s " % (name, device) if options: cmd += " %s " % options return command(cmd, **dargs) def cpu_compare(xml_file, **dargs): """ Compare host CPU with a CPU described by an XML file :param xml_file: file containing an XML CPU description. :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("cpu-compare %s" % xml_file, **dargs) def cpu_baseline(xml_file, **dargs): """ Compute baseline CPU for a set of given CPUs. :param xml_file: file containing an XML CPU description. :param dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("cpu-baseline %s" % xml_file, **dargs) def numatune(name, mode=None, nodeset=None, options=None, **dargs): """ Set or get a domain's numa parameters :param name: name of domain :param options: options may be live, config and current :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "numatune %s" % name if options: cmd += " --%s" % options if mode: cmd += " --mode %s" % mode if nodeset: cmd += " --nodeset %s" % nodeset return command(cmd, **dargs) def nodedev_reset(name, options="", **dargs): """ Trigger a device reset for device node. :param name: device node name to be reset. :param options: additional options passed to virsh command :param dargs: standardized virsh function API keywords :return: cmdresult object. """ cmd = ("nodedev-reset --device %s %s" % (name, options)) return command(cmd, **dargs) def ttyconsole(name, **dargs): """ Print tty console device. :param name: name, uuid or id of domain :return: CmdResult instance """ return command("ttyconsole %s" % name, **dargs) def nodedev_dumpxml(name, options="", to_file=None, **dargs): """ Do dumpxml for node device. :param name: the name of device. :param options: extra options to nodedev-dumpxml cmd. :param to_file: optional file to write XML output to. :return: Cmdobject of virsh nodedev-dumpxml. """ cmd = ('nodedev-dumpxml %s %s' % (name, options)) result = command(cmd, **dargs) if to_file is not None: result_file = open(to_file, 'w') result_file.write(result.stdout.strip()) result_file.close() return result def connect(connect_uri="", options="", **dargs): """ Run a connect command to the uri. :param connect_uri: target uri connect to. :param options: options to pass to connect command :return: CmdResult object. """ return command("connect %s %s" % (connect_uri, options), **dargs) def domif_setlink(name, interface, state, options=None, **dargs): """ Set network interface stats for a running domain. :param name: Name of domain :param interface: interface device :param state: new state of the device up or down :param options: command options. :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "domif-setlink %s %s %s " % (name, interface, state) if options: cmd += " %s" % options return command(cmd, **dargs) def domif_getlink(name, interface, options=None, **dargs): """ Get network interface stats for a running domain. :param name: Name of domain :param interface: interface device :param options: command options. :param dargs: standardized virsh function API keywords :return: domif state """ cmd = "domif-getlink %s %s " % (name, interface) if options: cmd += " %s" % options return command(cmd, **dargs) def nodedev_list(tree=False, cap="", options="", **dargs): """ List the node devices. :param tree: list devices in a tree :param cap: capability names, separated by comma :param options: extra command options. :param dargs: standardized virsh function API keywords :return: CmdResult object. """ cmd = "nodedev-list" if tree: cmd += " --tree" if cap: cmd += " --cap %s" % cap if options: cmd += " %s" % options return command(cmd, **dargs) def nodedev_detach(name, options="", **dargs): """ Detach node device from host. :return: cmdresult object. """ cmd = ("nodedev-detach --device %s %s" % (name, options)) return command(cmd, **dargs) def nodedev_dettach(name, options="", **dargs): """ Detach node device from host. :return: nodedev_detach(name). """ return nodedev_detach(name, options, **dargs) def nodedev_reattach(name, options="", **dargs): """ If node device is detached, this action will reattach it to its device driver. :return: cmdresult object. """ cmd = ("nodedev-reattach --device %s %s" % (name, options)) return command(cmd, **dargs) def vcpucount(name, options="", **dargs): """ Get the vcpu count of guest. :param name: name of domain. :param options: options for vcpucoutn command. :return: CmdResult object. """ cmd = "vcpucount %s %s" % (name, options) return command(cmd, **dargs) def blockcopy(name, path, dest, options="", **dargs): """ Start a block copy operation. :param name: name of domain. :param path: fully-qualified path or target of disk. :param dest: path of the copy to create. :param options: options of blockcopy. :param dargs: standardized virsh function API keywords. :return: CmdResult instance. """ cmd = "blockcopy %s %s %s %s" % (name, path, dest, options) return command(cmd, **dargs) def blockjob(name, path, options="", **dargs): """ Manage active block operations. :param name: name of domain. :param path: fully-qualified path or target of disk. :param options: options of blockjob. :param dargs: standardized virsh function API keywords. :return: CmdResult instance. """ cmd = "blockjob %s %s %s" % (name, path, options) return command(cmd, **dargs) def domiftune(name, interface, options=None, inbound=None, outbound=None, **dargs): """ Set/get parameters of a virtual interface. :param name: name of domain. :param interface: interface device (MAC Address). :param inbound: control domain's incoming traffics. :param outbound: control domain's outgoing traffics. :param options: options may be live, config and current. :param dargs: standardized virsh function API keywords. :return: CmdResult instance. """ cmd = "domiftune %s %s" % (name, interface) if inbound: cmd += " --inbound %s" % inbound if outbound: cmd += " --outbound %s" % outbound if options: cmd += " --%s" % options return command(cmd, **dargs) def desc(name, options, desc_str, **dargs): """ Show or modify description or title of a domain. :param name: name of domain. :param options: options for desc command. :param desc_str: new desc message. :param dargs: standardized virsh function API keywords. :return: CmdResult object. """ if desc_str: options = options + " \"%s\"" % desc_str cmd = "desc %s %s" % (name, options) return command(cmd, **dargs) def autostart(name, options, **dargs): """ Autostart a domain :return: cmdresult object. """ cmd = ("autostart %s %s" % (name, options)) return command(cmd, **dargs) def node_memtune(shm_pages_to_scan=None, shm_sleep_millisecs=None, shm_merge_across_nodes=None, options=None, **dargs): """ Get or set node memory parameters. :param options: Extra options to virsh. :param shm-pages-to-scan: Pages to scan. :param shm-sleep-millisecs: Sleep time (ms). :param shm-merge-across-nodes: Merge across nodes. :param dargs: Standardized virsh function API keywords. :return: CmdResult instance """ cmd = "node-memory-tune" if shm_pages_to_scan: cmd += " --shm-pages-to-scan %s" % shm_pages_to_scan if shm_sleep_millisecs: cmd += " --shm-sleep-millisecs %s" % shm_sleep_millisecs if shm_merge_across_nodes: cmd += " --shm-merge-across-nodes %s" % shm_merge_across_nodes if options: cmd += " --%s" % options return command(cmd, **dargs) def iface_list(extra="", **dargs): """ List physical host interfaces. :param extra: Free-form string of options :param dargs: Standardized virsh functiont API keywords :return: CmdResult object """ return command("iface-list %s" % extra, **dargs) def iface_define(xml_path, **dargs): """ Define (but don't start) a physical host interface from an XML file. :param xml_path: XML file path :param dargs: Standardized virsh function API keywords :return: CmdResult object """ return command("iface-define --file %s" % xml_path, **dargs) def iface_start(iface, **dargs): """ Start a physical host interface. :param iface: Interface name or MAC address :param dargs: Standardized virsh function API keywords :return: CmdResult object """ return command("iface-start %s" % iface, **dargs) def iface_destroy(iface, **dargs): """ Destroy a physical host interface. :param iface: Interface name or MAC address :param dargs: Standardized virsh function API keywords :return: CmdResult object """ return command("iface-destroy %s" % iface, **dargs) def iface_undefine(iface, **dargs): """ Undefine a physical host interface (remove it from configuration). :param iface: Interface name or MAC address :param dargs: Standardized virsh function API keywords :return: CmdResult object """ return command("iface-undefine %s" % iface, **dargs) def iface_dumpxml(iface, extra="", to_file="", **dargs): """ Interface information in XML. :param iface: Interface name or MAC address :param extra: Free-form string of options :param to_file: Optional file to write xml :param dargs: standardized virsh function API keywords :return: standard output from command """ dargs['ignore_status'] = True cmd = "iface-dumpxml %s %s" % (iface, extra) result = command(cmd, **dargs) if to_file: result_file = open(to_file, 'w') result_file.write(result.stdout.strip()) result_file.close() if result.exit_status: raise process.CmdError(cmd, result, "Dumpxml returned non-zero exit status") return result.stdout.strip() def iface_name(mac, **dargs): """ Convert an interface MAC address to interface name. :param mac: Interface MAC address :param dargs: Standardized virsh function API keywords :return: CmdResult object """ return command("iface-name %s" % mac, **dargs) def iface_mac(name, **dargs): """ Convert an interface name to interface MAC address. :param name: Interface name :param dargs: Standardized virsh function API keywords :return: CmdResult object """ return command("iface-mac %s" % name, **dargs) def iface_edit(iface, **dargs): """ Edit XML configuration for a physical host interface. :param iface: Interface name or MAC address :param dargs: standardized virsh function API keywords :return: CmdResult object """ return command("iface-edit %s" % iface, **dargs) def iface_bridge(iface, bridge, extra="", **dargs): """ Create a bridge device and attach an existing network device to it. :param iface: Interface name or MAC address :param bridge: New bridge device name :param extra: Free-form string of options :param dargs: Standardized virsh functiont API keywords :return: CmdResult object """ return command("iface-bridge %s %s %s" % (iface, bridge, extra), **dargs) def iface_unbridge(bridge, extra="", **dargs): """ Undefine a bridge device after detaching its slave device. :param bridge: Current bridge device name :param extra: Free-form string of options :param dargs: Standardized virsh functiont API keywords :return: CmdResult object """ return command("iface-unbridge %s %s" % (bridge, extra), **dargs) def iface_begin(**dargs): """ Create a snapshot of current interfaces settings :param: dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("iface-begin", **dargs) def iface_commit(**dargs): """ Commit changes made since iface-begin and free restore point :param: dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("iface-commit", **dargs) def iface_rollback(**dargs): """ Rollback to previous saved configuration created via iface-begin :param: dargs: standardized virsh function API keywords :return: CmdResult instance """ return command("iface-rollback", **dargs) def emulatorpin(name, cpulist=None, options=None, **dargs): """ Control or query domain emulator affinity :param name: name of domain :param cpulist: a list of physical CPU numbers :param options: options may be live, config and current :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "emulatorpin %s" % name if options: cmd += " --%s" % options if cpulist: cmd += " --cpulist %s" % cpulist return command(cmd, **dargs) def secret_list(options="", **dargs): """ Get list of secret. :param options: the option may be '--ephemeral' :param dargs: standardized virsh function API keywords :return: list of secret """ # CmdResult is handled here, force ignore_status cmd = "secret-list %s" % options return command(cmd, **dargs) def secret_define(xml_file, options=None, **dargs): """ Return True on successful secret define. :param xml_file: secret XML file :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "secret-define --file %s" % xml_file if options is not None: cmd += " %s" % options logging.debug("Define secret from %s", xml_file) return command(cmd, **dargs) def secret_undefine(uuid, options=None, **dargs): """ Return cmd result of secret undefine. :param uuid: secret UUID :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "secret-undefine %s" % uuid if options is not None: cmd += " %s" % options logging.debug("Undefine secret %s", uuid) return command(cmd, **dargs) def secret_dumpxml(uuid, to_file="", options=None, **dargs): """ Return the secret information as an XML dump. :param uuid: secret UUID :param to_file: optional file to write XML output to :param dargs: standardized virsh function API keywords :return: standard output from command """ dargs['ignore_status'] = True cmd = "secret-dumpxml %s" % uuid if options is not None: cmd += " %s" % options result = command(cmd, **dargs) if to_file: result_file = open(to_file, 'w') result_file.write(result.stdout.strip()) result_file.close() if result.exit_status: raise process.CmdError(cmd, result, "Virsh secret-dumpxml returned \ non-zero exit status") return result def secret_get_value(uuid, options=None, **dargs): """ Get a secret value :param uuid: secret UUID :return: CmdResult object. """ cmd = "secret-get-value --secret %s" % uuid if options: cmd += " --%s" % options return command(cmd, **dargs) def secret_set_value(uuid, base64, options=None, **dargs): """ Set a secret value :param uuid: secret UUID :param base64: base64-encoded secret value :return: CmdResult object. """ cmd = "secret-set-value --secret %s" % uuid if base64: cmd += " --base64 %s" % base64 if options: cmd += " --%s" % options return command(cmd, **dargs) def nodedev_create(xml_file, options=None, **dargs): """ Return cmd result of the device to be created by an XML file :param xml_file: device XML file :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "nodedev-create %s" % xml_file if options is not None: cmd += " %s" % options logging.debug("Create the device from %s", xml_file) return command(cmd, **dargs) def nodedev_destroy(dev_name, options=None, **dargs): """ Return cmd result of the device to be destroyed :param dev_name: name of the device :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "nodedev-destroy %s" % dev_name if options is not None: cmd += " %s" % options logging.debug("Destroy the device %s on the node", dev_name) return command(cmd, **dargs) def domfstrim(name, minimum=None, mountpoint=None, options="", **dargs): """ Do fstrim on domain's mounted filesystems :param name: name of domain :param options: options maybe --minimum <number>, --mountpoint <string> :return: CmdResult object """ cmd = "domfstrim %s" % name if minimum is not None: cmd += " --minimum %s" % minimum if mountpoint is not None: cmd += " --mountpoint %s" % mountpoint cmd += " %s" % options return command(cmd, **dargs) def domfsfreeze(name, mountpoint=None, options="", **dargs): """ Freeze domain's mounted filesystems :param name: name of domain :param mountpoint: specific mountpoints to be frozen :param options: extra options to domfsfreeze cmd. :return: CmdResult object """ cmd = "domfsfreeze %s" % name if mountpoint is not None: cmd += " --mountpoint %s" % mountpoint cmd += " %s" % options return command(cmd, **dargs) def domfsthaw(name, mountpoint=None, options="", **dargs): """ Thaw domain's mounted filesystems :param name: name of domain :param mountpoint: specific mountpoints to be thawed :param options: extra options to domfsfreeze cmd. :return: CmdResult object """ cmd = "domfsthaw %s" % name if mountpoint is not None: cmd += " --mountpoint %s" % mountpoint cmd += " %s" % options return command(cmd, **dargs) def domtime(name, now=False, pretty=False, sync=False, time=None, options="", **dargs): """ Get/Set domain's time :param name: name of domain :param now: set to the time of the host running virsh :param pretty: print domain's time in human readable form :param sync: instead of setting given time, synchronize from domain's RTC :param time: integer time to set :return: CmdResult object """ cmd = "domtime %s" % name if now: cmd += " --now" if pretty: cmd += " --pretty" if sync: cmd += " --sync" if time is not None: cmd += " --time %s" % time cmd += " %s" % options return command(cmd, **dargs) def nwfilter_dumpxml(name, options="", to_file=None, **dargs): """ Do dumpxml for network filter. :param name: the name or uuid of filter. :param options: extra options to nwfilter-dumpxml cmd. :param to_file: optional file to write XML output to. :param dargs: standardized virsh function API keywords :return: Cmdobject of virsh nwfilter-dumpxml. """ cmd = ('nwfilter-dumpxml %s %s' % (name, options)) result = command(cmd, **dargs) if to_file is not None: result_file = open(to_file, 'w') result_file.write(result.stdout.strip()) result_file.close() return result def nwfilter_define(xml_file, options="", **dargs): """ Return True on successful network filter define. :param xml_file: network filter XML file :param options: extra options to nwfilter-define cmd. :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "nwfilter-define --file %s %s" % (xml_file, options) return command(cmd, **dargs) def nwfilter_undefine(name, options="", **dargs): """ Return cmd result of network filter undefine. :param name: network filter name or uuid :param options: extra options to nwfilter-undefine cmd. :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "nwfilter-undefine %s %s" % (name, options) return command(cmd, **dargs) def nwfilter_list(options="", **dargs): """ Get list of network filters. :param options: extra options :param dargs: standardized virsh function API keywords :return: list of network filters """ cmd = "nwfilter-list %s" % options return command(cmd, **dargs) def nwfilter_edit(name, options="", **dargs): """ Edit the XML configuration for a network filter. :param name: network filter name or uuid. :param options: extra options to nwfilter-edit cmd. :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "nwfilter-edit %s %s" % (name, options) return command(cmd, **dargs) def cd(dir_path, options="", **dargs): """ Run cd command in virsh interactive session. :param dir_path: dir path string :param options: extra options :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "cd --dir %s %s" % (dir_path, options) return command(cmd, **dargs) def pwd(options="", **dargs): """ Run pwd command in virsh session. :param options: extra options :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "pwd %s" % options return command(cmd, **dargs) def echo(echo_str, options="", **dargs): """ Run echo command in virsh session. :param echo_str: the echo string :param options: extra options :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "echo %s %s" % (echo_str, options) return command(cmd, **dargs) def exit(**dargs): """ Run exit command in virsh session. :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "exit" return command(cmd, **dargs) def quit(**dargs): """ Run quit command in virsh session. :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "quit" return command(cmd, **dargs) def sendkey(name, options="", **dargs): """ Send keycodes to the guest :param name: name of domain :param codeset: the codeset of keycodes :param keycode: the key code :return: CmdResult object """ cmd = "send-key %s %s" % (name, options) return command(cmd, **dargs) def create(xmlfile, options="", **dargs): """ Create guest from xml :param xmlfile: domain xml file :param options: --paused :return: CmdResult object """ cmd = "create %s %s" % (xmlfile, options) return command(cmd, **dargs) def sysinfo(options="", **dargs): """ Return the hypervisor sysinfo xml. :param options: extra options :return: CmdResult object """ cmd = "sysinfo %s" % options return command(cmd, **dargs) def reset(name, **dargs): """ Reset a domain :param name: name of domain :return: CmdResult object """ cmd = "reset %s" % name return command(cmd, **dargs) def domdisplay(name, options="", **dargs): """ Get domain display connection URI :param name: name of domain :param options: options of domdisplay :return: CmdResult object """ cmd = "domdisplay %s %s" % (name, options) return command(cmd, **dargs) def domblkerror(name, **dargs): """ Show errors on block devices :param name: name of domain :return: CmdResult object """ return command("domblkerror %s" % name, **dargs) def domcontrol(name, options="", **dargs): """ Return domain control interface state. :param name: name of domain :param options: extra options :return: CmdResult object """ cmd = "domcontrol %s %s" % (name, options) return command(cmd, **dargs) def save_image_dumpxml(state_file, options="", to_file="", **dargs): """ Dump xml from saved state file :param state_file: saved state file to read :param options: extra options :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "save-image-dumpxml %s %s" % (state_file, options) result = command(cmd, **dargs) if to_file: result_file = open(to_file, 'w') result_file.write(result.stdout.strip()) result_file.close() return result def save_image_define(state_file, xmlfile, options="", **dargs): """ Redefine the XML for a domain's saved state file :param state_file: saved state file to modify :param xmlfile: filename containing updated XML for the target :param options: extra options :param dargs: standardized virsh function API keywords :return: CmdResult object """ cmd = "save-image-define %s %s %s" % (state_file, xmlfile, options) return command(cmd, **dargs) def inject_nmi(name, options="", **dargs): """ Inject NMI to the guest :param name: domain name :param options: extra options """ cmd = "inject-nmi %s %s" % (name, options) return command(cmd, **dargs) def vol_download(name, dfile, options="", **dargs): """ Download volume contents to a file :param name: name of volume :param dfile: file path that will download to :param options: pool name, offset and length :return: CmdResult object """ cmd = "vol-download %s %s %s" % (name, dfile, options) return command(cmd, **dargs) def vol_upload(name, dfile, options="", **dargs): """ Upload file contents to a volume :param name: name of volume :param dfile: file path that will upload from :param options: pool name, offset and length :return: CmdResult object """ cmd = "vol-upload %s %s %s" % (name, dfile, options) return command(cmd, **dargs) def blkiotune(name, weight=None, device_weights=None, options=None, **dargs): """ Set or get a domain's blkio parameters :param name: name of domain :param options: options may be live, config and current :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "blkiotune %s" % name if options: cmd += " --%s" % options if weight: cmd += " --weight %s" % weight if device_weights: cmd += " --device-weights %s" % device_weights return command(cmd, **dargs) def blkdeviotune(name, device=None, options=None, total_bytes_sec=None, read_bytes_sec=None, write_bytes_sec=None, total_iops_sec=None, read_iops_sec=None, write_iops_sec=None, **dargs): """ Set or get a domain's blkio parameters :param name: name of domain :param options: options may be live, config and current :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "blkdeviotune %s" % name if options: cmd += " %s" % options if device: cmd += " --device %s" % device if total_bytes_sec: cmd += " --total-bytes-sec %s" % total_bytes_sec if read_bytes_sec: cmd += " --read-bytes-sec %s" % read_bytes_sec if write_bytes_sec: cmd += " --write-bytes-sec %s" % write_bytes_sec if total_iops_sec: cmd += " --total-iops-sec %s" % total_iops_sec if read_iops_sec: cmd += " --read-iops-sec %s" % read_iops_sec if write_iops_sec: cmd += " --write-iops-sec %s" % write_iops_sec return command(cmd, **dargs) def domstats(domains="", options="", **dargs): """ Get statistics about one or multiple domains :param domains: List of domains :param options: Extra options :param dargs: Standardized virsh function API keywords :return: CmdResult instance """ cmd = "domstats %s %s" % (domains, options) return command(cmd, **dargs) def freepages(cellno=None, pagesize=None, options="", **dargs): """ Display available free pages for the NUMA cell :param cellno: NUMA cell number :param pagesize: Page size (in kibibytes) :param options: Extra options :param dargs: Standardized virsh function API keywords :return: CmdResult instance """ cmd = "freepages %s" % options if cellno is not None: cmd += " --cellno %s" % cellno if pagesize is not None: cmd += " --pagesize %s" % pagesize return command(cmd, **dargs) def domcapabilities(virttype=None, emulatorbin=None, arch=None, machine=None, options="", **dargs): """ Capabilities of emulator with respect to host and libvirt :param virttype: Virtualization type (/domain/@type) :param emulatorbin: Path to emulator binary (/domain/devices/emulator) :param arch: Domain architecture (/domain/os/type/@arch) :param machine: machine type (/domain/os/type/@machine) :param options: Extra options :param dargs: Standardized virsh function API keywords :return: CmdResult instance """ cmd = "domcapabilities %s" % options if virttype: cmd += " --virttype %s" % virttype if emulatorbin: cmd += " --emulatorbin %s" % emulatorbin if arch: cmd += " --arch %s" % arch if machine: cmd += " --machine %s" % machine return command(cmd, **dargs) def metadata(name, uri, options="", key=None, new_metadata=None, **dargs): """ Show or set domain's custom XML Metadata :param name: Domain name, id or uuid :param uri: URI of the namespace :param options: options may be live, config and current :param key: Key to be used as a namespace identifier :param new_metadata: new metadata to set :param dargs: standardized virsh function API keywords :return: CmdResult instance """ cmd = "metadata --domain %s --uri %s %s" % (name, uri, options) if key: cmd += " --key %s" % key if new_metadata: cmd += " --set '%s'" % new_metadata.replace("\'", "\"") return command(cmd, **dargs) def cpu_models(arch, options="", **dargs): """ Get the CPU models for an arch. :param arch: Architecture :param options: Extra options :param dargs: Standardized virsh function API keywords :return: CmdResult instance """ cmd = "cpu-models %s %s" % (arch, options) return command(cmd, **dargs) def net_dhcp_leases(network, mac=None, options="", **dargs): """ Print lease info for a given network :param network: Network name or uuid :param mac: Mac address :param options: Extra options :param dargs: Standardized virsh function API keywords :return: CmdResult instance """ cmd = "net-dhcp-leases %s %s" % (network, options) if mac: cmd += " --mac %s" % mac return command(cmd, **dargs) def qemu_monitor_event(domain=None, event=None, event_timeout=None, options="", **dargs): """ Listen for QEMU Monitor Events :param domain: Domain name, id or UUID :param event: Event type name :param event_timeout: Timeout seconds :param options: Extra options :param dargs: Standardized virsh function API keywords :return: CmdResult instance """ cmd = "qemu-monitor-event %s" % options if domain: cmd += " --domain %s" % domain if event: cmd += " --event %s" % event if event_timeout: cmd += " --timeout %s" % event return command(cmd, **dargs) def net_event(network=None, event=None, event_timeout=None, options="", **dargs): """ List event types, or wait for network events to occur :param network: Network name or uuid :param event: Event type to wait for :param event_timeout: Timeout seconds :param options: Extra options :param dargs: Standardized virsh function API keywords :return: CmdResult instance """ cmd = "net-event %s" % options if network: cmd += " --network %s" % network if event: cmd += " --event %s" % event if event_timeout: cmd += " --timeout %s" % event_timeout return command(cmd, **dargs) def event(domain=None, event=None, event_timeout=None, options="", **dargs): """ List event types, or wait for domain events to occur :param domain: Domain name, id or UUID :param event: Event type name :param event_timeout: Timeout seconds :param options: Extra options :param dargs: Standardized virsh function API keywords :return: CmdResult instance """ cmd = "event %s" % options if domain: cmd += " --domain %s" % domain if event: cmd += " --event %s" % event if event_timeout: cmd += " --timeout %s" % event return command(cmd, **dargs)
gpl-2.0
[ 624, 199, 17505, 3992, 436, 3423, 370, 2429, 1950, 370, 282, 13108, 1591, 2656, 199, 199, 1918, 8039, 4072, 402, 28041, 315, 642, 859, 334, 13084, 314, 1561, 3247, 315, 199, 2826, 18219, 5084, 395, 911, 8649, 3102, 402, 314, 812, 723, 609, 436, 812, 723, 609, 31966, 3992, 14, 199, 33, 5980, 3253, 1021, 365, 1202, 370, 4816, 314, 859, 3423, 12, 2400, 1630, 440, 199, 28314, 590, 3877, 1256, 1174, 315, 642, 4514, 14, 199, 199, 3655, 2651, 7179, 402, 314, 3102, 1172, 282, 283, 277, 7, 2725, 3247, 12, 314, 3992, 199, 1530, 3247, 370, 506, 1211, 13, 2930, 12, 436, 664, 3032, 315, 370, 314, 3102, 465, 282, 314, 199, 6664, 1124, 538, 31895, 1040, 2725, 14, 221, 2900, 28248, 859, 3423, 485, 45, 7698, 63, 2387, 282, 199, 6664, 1124, 538, 31895, 1040, 334, 1975, 4252, 2368, 9, 370, 4729, 2222, 13, 885, 199, 6691, 2368, 14, 199, 199, 1918, 4465, 663, 402, 4252, 2368, 370, 1006, 3423, 15, 3112, 365, 14290, 199, 262, 314, 812, 723, 609, 1563, 1021, 14, 221, 5972, 314, 283, 1042, 609, 63, 1628, 7, 790, 365, 17334, 370, 3544, 199, 1235, 3451, 12, 314, 15748, 1443, 503, 1443, 440, 506, 2741, 14, 221, 6006, 509, 12, 28248, 199, 5777, 15, 2474, 1077, 675, 314, 1211, 14, 362, 342, 1083, 370, 8044, 543, 282, 849, 199, 509, 2222, 13, 4494, 867, 2883, 14, 199, 199, 26, 7307, 26, 6029, 9572, 13002, 3277, 14, 199, 624, 199, 199, 646, 4673, 199, 646, 2050, 199, 646, 7097, 199, 646, 295, 199, 646, 13852, 199, 646, 900, 199, 646, 3504, 199, 199, 504, 2289, 679, 5129, 14, 1208, 492, 931, 199, 504, 2289, 679, 5129, 14, 1208, 492, 2112, 199, 199, 646, 282, 4921, 199, 199, 504, 1275, 492, 557, 2352, 290, 199, 504, 1275, 492, 3982, 199, 504, 1275, 492, 3778, 63, 9923, 199, 199, 3, 769, 402, 5272, 1561, 2845, 370, 4816, 465, 812, 723, 609, 1021, 3102, 199, 3, 18414, 2127, 587, 687, 7992, 342, 911, 8649, 282, 1083, 402, 812, 723, 609, 1021, 199, 2826, 18219, 275, 7992, 1252, 1612, 342, 435, 359, 272, 283, 2826, 18219, 297, 283, 25070, 25041, 63, 3170, 63, 8760, 297, 283, 13679, 3234, 63, 10761, 63, 8677, 297, 272, 283, 13679, 3234, 63, 10276, 297, 283, 54, 723, 609, 1563, 297, 283, 54, 723, 609, 3337, 3253, 297, 283, 54, 723, 609, 4434, 297, 283, 54, 723, 609, 297, 272, 283, 54, 723, 609, 31966, 297, 283, 54, 723, 609, 8631, 4540, 297, 283, 13679, 3234, 63, 10761, 63, 7823, 63, 8677, 297, 272, 283, 13679, 3234, 63, 10761, 63, 7823, 63, 8677, 63, 2826, 63, 25081, 297, 199, 61, 199, 199, 3, 29613, 370, 506, 315, 13, 2645, 367, 812, 723, 609, 10, 1021, 27981, 1083, 436, 859, 805, 199, 25070, 25041, 63, 3170, 63, 8760, 275, 378, 199, 199, 3, 11977, 402, 28248, 3718, 12, 1202, 701, 1720, 63, 1531, 63, 923, 342, 436, 1720, 63, 1531, 63, 2118, 342, 199, 3, 3254, 26, 4155, 314, 2581, 1901, 282, 1021, 2225, 641, 812, 723, 609, 1563, 1021, 14, 199, 13679, 3234, 63, 10761, 63, 8677, 275, 488, 199, 13679, 3234, 63, 10761, 63, 7823, 63, 8677, 275, 488, 199, 13679, 3234, 63, 10761, 63, 7823, 63, 8677, 63, 2826, 63, 25081, 275, 756, 199, 199, 3, 961, 365, 1202, 3865, 6272, 436, 9682, 3992, 199, 893, 26, 272, 812, 3927, 3234, 63, 10276, 275, 931, 14, 1623, 63, 1531, 480, 1042, 609, 531, 199, 2590, 1722, 26, 272, 2050, 14, 3764, 480, 54, 723, 609, 7286, 440, 663, 503, 1911, 641, 931, 12, 298, 490, 298, 1042, 609, 859, 911, 440, 805, 12252, 531, 272, 812, 3927, 3234, 63, 10276, 275, 1994, 1393, 15, 2052, 7, 421, 199, 533, 812, 723, 609, 1563, 8, 496, 2352, 290, 14, 9955, 6049, 1563, 304, 339, 408, 272, 3523, 8089, 16915, 13108, 8113, 1253, 1174, 370, 282, 1591, 272, 408, 339, 636, 7257, 363, 275, 661, 2302, 297, 283, 4247, 63, 1205, 297, 283, 1757, 297, 283, 1042, 609, 63, 1628, 297, 283, 6753, 358, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 31895, 304, 267, 408, 267, 11578, 1256, 543, 28248, 63, 1628, 3544, 663, 370, 6020, 267, 408, 267, 4205, 63, 807, 275, 1211, 2031, 589, 12, 1011, 31895, 9, 267, 4205, 63, 807, 459, 1042, 609, 63, 1628, 418, 275, 4205, 63, 807, 14, 362, 360, 1042, 609, 63, 1628, 297, 812, 3927, 3234, 63, 10276, 9, 267, 4205, 63, 807, 459, 2302, 418, 275, 4205, 63, 807, 14, 362, 360, 2302, 297, 488, 9, 267, 4205, 63, 807, 459, 1757, 418, 275, 4205, 63, 807, 14, 362, 360, 1757, 297, 756, 9, 267, 4205, 63, 807, 459, 4247, 63, 1205, 418, 275, 4205, 63, 807, 14, 362, 360, 4247, 63, 1205, 297, 756, 9, 267, 4205, 63, 807, 459, 6753, 418, 275, 4205, 63, 807, 14, 362, 360, 6753, 297, 756, 9, 267, 1613, 8, 54, 723, 609, 1563, 12, 291, 2843, 826, 721, 826, 63, 807, 9, 339, 347, 664, 63, 2302, 8, 277, 304, 267, 408, 267, 11003, 269, 1083, 367, 283, 2302, 7, 3324, 626, 1471, 2187, 267, 408, 267, 327, 291, 14, 362, 342, 3955, 1240, 664, 63, 2302, 342, 5344, 338, 86, 590, 267, 862, 26, 288, 372, 291, 855, 807, 63, 362, 19734, 2302, 358, 267, 871, 4067, 26, 288, 372, 488, 421, 199, 533, 812, 723, 609, 4434, 8, 65, 4921, 14, 8529, 4434, 304, 339, 408, 272, 437, 28248, 5218, 2351, 12, 1202, 543, 812, 723, 609, 4454, 14, 272, 408, 339, 327, 3091, 4340, 370, 664, 28248, 1007, 13, 1531, 298, 2224, 2, 2004, 272, 327, 2670, 1072, 6169, 769, 402, 6040, 1125, 13, 1205, 3326, 272, 12539, 63, 10710, 63, 4924, 275, 788, 705, 3427, 83, 4856, 11, 4268, 1987, 10, 4892, 2795, 418, 339, 347, 636, 826, 721, 277, 12, 28248, 63, 1628, 29, 403, 12, 5108, 29, 403, 12, 282, 63, 344, 29, 403, 12, 326, 8457, 29, 82, 2, 1042, 609, 60, 83, 10, 7023, 20262, 30, 7272, 83, 14421, 3982, 63, 711, 29, 403, 12, 326, 3982 ]
[ 199, 17505, 3992, 436, 3423, 370, 2429, 1950, 370, 282, 13108, 1591, 2656, 199, 199, 1918, 8039, 4072, 402, 28041, 315, 642, 859, 334, 13084, 314, 1561, 3247, 315, 199, 2826, 18219, 5084, 395, 911, 8649, 3102, 402, 314, 812, 723, 609, 436, 812, 723, 609, 31966, 3992, 14, 199, 33, 5980, 3253, 1021, 365, 1202, 370, 4816, 314, 859, 3423, 12, 2400, 1630, 440, 199, 28314, 590, 3877, 1256, 1174, 315, 642, 4514, 14, 199, 199, 3655, 2651, 7179, 402, 314, 3102, 1172, 282, 283, 277, 7, 2725, 3247, 12, 314, 3992, 199, 1530, 3247, 370, 506, 1211, 13, 2930, 12, 436, 664, 3032, 315, 370, 314, 3102, 465, 282, 314, 199, 6664, 1124, 538, 31895, 1040, 2725, 14, 221, 2900, 28248, 859, 3423, 485, 45, 7698, 63, 2387, 282, 199, 6664, 1124, 538, 31895, 1040, 334, 1975, 4252, 2368, 9, 370, 4729, 2222, 13, 885, 199, 6691, 2368, 14, 199, 199, 1918, 4465, 663, 402, 4252, 2368, 370, 1006, 3423, 15, 3112, 365, 14290, 199, 262, 314, 812, 723, 609, 1563, 1021, 14, 221, 5972, 314, 283, 1042, 609, 63, 1628, 7, 790, 365, 17334, 370, 3544, 199, 1235, 3451, 12, 314, 15748, 1443, 503, 1443, 440, 506, 2741, 14, 221, 6006, 509, 12, 28248, 199, 5777, 15, 2474, 1077, 675, 314, 1211, 14, 362, 342, 1083, 370, 8044, 543, 282, 849, 199, 509, 2222, 13, 4494, 867, 2883, 14, 199, 199, 26, 7307, 26, 6029, 9572, 13002, 3277, 14, 199, 624, 199, 199, 646, 4673, 199, 646, 2050, 199, 646, 7097, 199, 646, 295, 199, 646, 13852, 199, 646, 900, 199, 646, 3504, 199, 199, 504, 2289, 679, 5129, 14, 1208, 492, 931, 199, 504, 2289, 679, 5129, 14, 1208, 492, 2112, 199, 199, 646, 282, 4921, 199, 199, 504, 1275, 492, 557, 2352, 290, 199, 504, 1275, 492, 3982, 199, 504, 1275, 492, 3778, 63, 9923, 199, 199, 3, 769, 402, 5272, 1561, 2845, 370, 4816, 465, 812, 723, 609, 1021, 3102, 199, 3, 18414, 2127, 587, 687, 7992, 342, 911, 8649, 282, 1083, 402, 812, 723, 609, 1021, 199, 2826, 18219, 275, 7992, 1252, 1612, 342, 435, 359, 272, 283, 2826, 18219, 297, 283, 25070, 25041, 63, 3170, 63, 8760, 297, 283, 13679, 3234, 63, 10761, 63, 8677, 297, 272, 283, 13679, 3234, 63, 10276, 297, 283, 54, 723, 609, 1563, 297, 283, 54, 723, 609, 3337, 3253, 297, 283, 54, 723, 609, 4434, 297, 283, 54, 723, 609, 297, 272, 283, 54, 723, 609, 31966, 297, 283, 54, 723, 609, 8631, 4540, 297, 283, 13679, 3234, 63, 10761, 63, 7823, 63, 8677, 297, 272, 283, 13679, 3234, 63, 10761, 63, 7823, 63, 8677, 63, 2826, 63, 25081, 297, 199, 61, 199, 199, 3, 29613, 370, 506, 315, 13, 2645, 367, 812, 723, 609, 10, 1021, 27981, 1083, 436, 859, 805, 199, 25070, 25041, 63, 3170, 63, 8760, 275, 378, 199, 199, 3, 11977, 402, 28248, 3718, 12, 1202, 701, 1720, 63, 1531, 63, 923, 342, 436, 1720, 63, 1531, 63, 2118, 342, 199, 3, 3254, 26, 4155, 314, 2581, 1901, 282, 1021, 2225, 641, 812, 723, 609, 1563, 1021, 14, 199, 13679, 3234, 63, 10761, 63, 8677, 275, 488, 199, 13679, 3234, 63, 10761, 63, 7823, 63, 8677, 275, 488, 199, 13679, 3234, 63, 10761, 63, 7823, 63, 8677, 63, 2826, 63, 25081, 275, 756, 199, 199, 3, 961, 365, 1202, 3865, 6272, 436, 9682, 3992, 199, 893, 26, 272, 812, 3927, 3234, 63, 10276, 275, 931, 14, 1623, 63, 1531, 480, 1042, 609, 531, 199, 2590, 1722, 26, 272, 2050, 14, 3764, 480, 54, 723, 609, 7286, 440, 663, 503, 1911, 641, 931, 12, 298, 490, 298, 1042, 609, 859, 911, 440, 805, 12252, 531, 272, 812, 3927, 3234, 63, 10276, 275, 1994, 1393, 15, 2052, 7, 421, 199, 533, 812, 723, 609, 1563, 8, 496, 2352, 290, 14, 9955, 6049, 1563, 304, 339, 408, 272, 3523, 8089, 16915, 13108, 8113, 1253, 1174, 370, 282, 1591, 272, 408, 339, 636, 7257, 363, 275, 661, 2302, 297, 283, 4247, 63, 1205, 297, 283, 1757, 297, 283, 1042, 609, 63, 1628, 297, 283, 6753, 358, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 31895, 304, 267, 408, 267, 11578, 1256, 543, 28248, 63, 1628, 3544, 663, 370, 6020, 267, 408, 267, 4205, 63, 807, 275, 1211, 2031, 589, 12, 1011, 31895, 9, 267, 4205, 63, 807, 459, 1042, 609, 63, 1628, 418, 275, 4205, 63, 807, 14, 362, 360, 1042, 609, 63, 1628, 297, 812, 3927, 3234, 63, 10276, 9, 267, 4205, 63, 807, 459, 2302, 418, 275, 4205, 63, 807, 14, 362, 360, 2302, 297, 488, 9, 267, 4205, 63, 807, 459, 1757, 418, 275, 4205, 63, 807, 14, 362, 360, 1757, 297, 756, 9, 267, 4205, 63, 807, 459, 4247, 63, 1205, 418, 275, 4205, 63, 807, 14, 362, 360, 4247, 63, 1205, 297, 756, 9, 267, 4205, 63, 807, 459, 6753, 418, 275, 4205, 63, 807, 14, 362, 360, 6753, 297, 756, 9, 267, 1613, 8, 54, 723, 609, 1563, 12, 291, 2843, 826, 721, 826, 63, 807, 9, 339, 347, 664, 63, 2302, 8, 277, 304, 267, 408, 267, 11003, 269, 1083, 367, 283, 2302, 7, 3324, 626, 1471, 2187, 267, 408, 267, 327, 291, 14, 362, 342, 3955, 1240, 664, 63, 2302, 342, 5344, 338, 86, 590, 267, 862, 26, 288, 372, 291, 855, 807, 63, 362, 19734, 2302, 358, 267, 871, 4067, 26, 288, 372, 488, 421, 199, 533, 812, 723, 609, 4434, 8, 65, 4921, 14, 8529, 4434, 304, 339, 408, 272, 437, 28248, 5218, 2351, 12, 1202, 543, 812, 723, 609, 4454, 14, 272, 408, 339, 327, 3091, 4340, 370, 664, 28248, 1007, 13, 1531, 298, 2224, 2, 2004, 272, 327, 2670, 1072, 6169, 769, 402, 6040, 1125, 13, 1205, 3326, 272, 12539, 63, 10710, 63, 4924, 275, 788, 705, 3427, 83, 4856, 11, 4268, 1987, 10, 4892, 2795, 418, 339, 347, 636, 826, 721, 277, 12, 28248, 63, 1628, 29, 403, 12, 5108, 29, 403, 12, 282, 63, 344, 29, 403, 12, 326, 8457, 29, 82, 2, 1042, 609, 60, 83, 10, 7023, 20262, 30, 7272, 83, 14421, 3982, 63, 711, 29, 403, 12, 326, 3982, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Dolphman/pynationstates
tests/test_call.py
1
12322
import unittest import nationstates as ns from random import choice import datetime USERAGENT = "Automated Testing Builds by Circle CI for the nationstates API wrapper by The United Island Tribes. dolphdevgithub@gmail.com" import os test_nation = 'Python Nationstates API wrapper' test_nation_r = 'pynationstates_telegram_recipient' PASSWORD = os.environ.get('password') tgid = os.environ.get('telegram_tgid') key = os.environ.get('telegram_key') client_key = os.environ.get('telegram_clientkey') del os sep_api = ns.Nationstates(USERAGENT) joint_api = ns.Nationstates(USERAGENT) test_nation_nonauth = joint_api.nation(test_nation) test_auth_nation = joint_api.nation(test_nation, password=PASSWORD) test_nation_r = joint_api.nation(test_nation_r) issue_nation_1 = joint_api.nation('Pynationstates Issue Farm 1', password=PASSWORD) issue_nation_2 = joint_api.nation('Pynationstates Issue Farm 2', password=PASSWORD) issue_nation_3 = joint_api.nation('Pynationstates Issue Farm 3', password=PASSWORD) issue_nation_zero = joint_api.nation('pynationstates_0_issues_test_nation', password=PASSWORD) api_threads = ns.Nationstates(USERAGENT, threading_mode=True) def grab_id(newfactbookresponse_text): part1 = newfactbookresponse_text.split('id=') return part1[1].split('">')[0] class SetupCallTest(unittest.TestCase): def test_create_ns(self): try: api = ns.Nationstates(USERAGENT) except Exception as Err: self.fail(Err) class SeperateCallTest(unittest.TestCase): def test_nation_call(self): try: api = sep_api mycall = api.nation("testlandia") mycall.get_shards(choice(mycall.auto_shards)) mycall.get_shards(choice(mycall.auto_shards), full_response=True) except Exception as Err: self.fail(Err) def test_region_call(self): try: api = sep_api mycall = api.region("Balder") mycall.get_shards(choice(mycall.auto_shards)) mycall.get_shards(choice(mycall.auto_shards), full_response=True) except Exception as Err: self.fail(Err) def test_world_call(self): try: api = sep_api mycall = api.world() mycall.get_shards(choice(mycall.auto_shards)) mycall.get_shards(choice(mycall.auto_shards), full_response=True) except Exception as Err: self.fail(Err) def test_wa_call(self): try: api = sep_api mycall = api.wa("1") mycall.get_shards(choice(mycall.auto_shards)) mycall.get_shards(choice(mycall.auto_shards), full_response=True) except Exception as Err: self.fail(Err) def test_cards_indv_call(self): try: api = sep_api mycall = api.cards() mycall.individual_cards(1, 1) mycall.individual_cards(1, 1, full_response=True) mycall.individual_cards(1, 1, 'trades') mycall.individual_cards(1, 1, ns.Shard('trades')) mycall.individual_cards(1, 1, (ns.Shard('trades'),)) # mycall.get_shards(choice(mycall.auto_shards)) # mycall.get_shards(choice(mycall.auto_shards), full_response=True) except Exception as Err: raise Err self.fail(Err) def test_cards_decks_call(self): try: api = sep_api mycall = api.cards() mycall.decks(nation_name='testlandia') mycall.decks(nation_name='testlandia', full_response=True) mycall.decks(nation_id=1) # mycall.get_shards(choice(mycall.auto_shards)) # mycall.get_shards(choice(mycall.auto_shards), full_response=True) except Exception as Err: self.fail(Err) def test_cards_decksinfo_call(self): try: api = sep_api mycall = api.cards() mycall.deck_owner_info(nation_name='testlandia') mycall.deck_owner_info(nation_name='testlandia', full_response=True) mycall.deck_owner_info(nation_id=1) # mycall.get_shards(choice(mycall.auto_shards)) # mycall.get_shards(choice(mycall.auto_shards), full_response=True) except Exception as Err: self.fail(Err) def test_cards_asks_and_bids_call(self): try: api = sep_api mycall = api.cards() mycall.asks_and_bids(nation_name='testlandia') mycall.asks_and_bids(nation_name='testlandia', full_response=True) mycall.asks_and_bids(nation_id=1) # mycall.get_shards(choice(mycall.auto_shards)) # mycall.get_shards(choice(mycall.auto_shards), full_response=True) except Exception as Err: self.fail(Err) def test_cards_collections_call(self): try: api = sep_api mycall = api.cards() mycall.collections(nation_name='testlandia') mycall.collections(nation_name='testlandia', full_response=True) mycall.collections(nation_id=1) # mycall.get_shards(choice(mycall.auto_shards)) # mycall.get_shards(choice(mycall.auto_shards), full_response=True) except Exception as Err: self.fail(Err) def test_cards_auctions_call(self): try: api = sep_api mycall = api.cards() mycall.auctions() mycall.auctions(full_response=True) # mycall.get_shards(choice(mycall.auto_shards)) # mycall.get_shards(choice(mycall.auto_shards), full_response=True) except Exception as Err: self.fail(Err) def test_cards_trades_call(self): try: api = sep_api mycall = api.cards() mycall.trades() mycall.trades(full_response=True) mycall.collections(nation_id=1) # mycall.get_shards(choice(mycall.auto_shards)) # mycall.get_shards(choice(mycall.auto_shards), full_response=True) except Exception as Err: self.fail(Err) def test_auto_shard_static_n(self): try: api = sep_api mycall = api.nation("testlandia") mycall.fullname except Exception as Err: self.fail(Err) def test_auto_shard_static_r(self): try: api = sep_api mycall = api.region("balder") mycall.numnations except Exception as Err: self.fail(Err) def test_auto_shard_static_w(self): try: api = sep_api mycall = api.world() mycall.numnations except Exception as Err: self.fail(Err) def test_auto_shard_static_wa(self): try: api = sep_api mycall = api.wa("1") mycall.numnations except Exception as Err: self.fail(Err) class ApiJoinTest(unittest.TestCase): def test_private_nation(self): try: test_auth_nation.get_shards('ping') except Exception as Err: self.fail(Err) def test_create_dispatch(self): from datetime import datetime now = datetime.now try: resp = test_auth_nation.create_dispatch(title='AUTOMATED ADD DISPATCH TEST', text=str(now()), category=1, subcategory=105, full_response=True) dispatch_id = grab_id(resp['data']['nation']['success']) resp = test_auth_nation.remove_dispatch(dispatch_id=dispatch_id, full_response=True) resp = test_auth_nation.create_dispatch(title='AUTOMATED ADD DISPATCH TEST', text=str(now()), category=1, subcategory=105, full_response=False) dispatch_id = grab_id(resp.success) resp = test_auth_nation.remove_dispatch(dispatch_id=dispatch_id, full_response=True) except Exception as Err: self.fail(Err) def test_edit_dispatch(self): from datetime import datetime now = datetime.now try: resp = test_auth_nation.create_dispatch(title='AUTOMATED ADD DISPATCH EDIT TEST', text=str(now()), category=1, subcategory=105, full_response=False) dispatch_id = grab_id(resp.success) resp = test_auth_nation.edit_dispatch(dispatch_id=dispatch_id, title='EDIT TEST', text="THIS POST WAS LAST EDITED AT:" + str(now()), category=1, subcategory=111, full_response=False) resp = test_auth_nation.remove_dispatch(dispatch_id=dispatch_id, full_response=True) resp = test_auth_nation.create_dispatch(title='AUTOMATED ADD DISPATCH EDIT TEST', text=str(now()), category=1, subcategory=105, full_response=False) dispatch_id = grab_id(resp.success) resp = test_auth_nation.edit_dispatch(dispatch_id=dispatch_id, title='EDIT TEST', text="THIS POST WAS LAST EDITED AT:" + str(now()), category=1, subcategory=111, full_response=True) resp = test_auth_nation.remove_dispatch(dispatch_id=dispatch_id, full_response=True) except Exception as Err: self.fail(Err) def test_remove_dispatch(self): from datetime import datetime now = datetime.now try: resp = test_auth_nation.create_dispatch(title='AUTOMATED ADD DISPATCH REMOVE TEST', text=str(now()), category=1, subcategory=105, full_response=False) dispatch_id = grab_id(resp.success) resp = test_auth_nation.remove_dispatch(dispatch_id=dispatch_id) resp = test_auth_nation.create_dispatch(title='AUTOMATED ADD DISPATCH REMOVE TEST', text=str(now()), category=1, subcategory=105, full_response=False) dispatch_id = grab_id(resp.success) resp = test_auth_nation.remove_dispatch(dispatch_id=dispatch_id, full_response=True) except Exception as Err: self.fail(Err) def test_telegram_send(self): from datetime import datetime import time now = datetime.now try: telegram = joint_api.telegram(tgid=tgid, key=key, client_key=client_key) test_nation_r.send_telegram(telegram) try: test_nation_r.send_telegram(telegram) self.fail('API was suppose to block this') except ns.nsapiwrapper.exceptions.APIRateLimitBan: pass try: telegram.send_telegram(test_nation_r.name) except ns.nsapiwrapper.exceptions.APIRateLimitBan: # Just testing code path works - to much wasted time to wait 30 seconds pass except Exception as Err: raise (Err) def test_pick_issue_always_fail(self): resp = issue_nation_zero.get_shards('issues') if resp.issues is None: pass else: self.fail('Nation should have no issues') def test_pick_issue(self): import random def pick_random_nation(*apis): for api in apis: resp = api.get_shards('issues') if resp.issues is None: continue random_issue = random.choice(resp.issues.issue) random_issue_id = random_issue.id random_option_choice = random.choice(random_issue.option).id (api.pick_issue(random_issue_id, random_option_choice)) break nations = [issue_nation_1, issue_nation_2, issue_nation_3] random.shuffle(nations) pick_random_nation(*nations) def test_threads(self): import threading import time nation = api_threads.nation('testlandia') def HelloWorld(): """User defined Thread function""" nation.flag return def Main(): threads = [] # Threads list needed when we use a bulk of threads for i in range(5): mythread = threading.Thread(target=HelloWorld) threads.append(mythread) mythread.start() for row in threads: row.join() assert (nation.api_mother.api.__activerequests__) == 0 Main()
mit
[ 646, 2882, 199, 646, 302, 425, 4981, 465, 700, 199, 504, 2196, 492, 7141, 199, 646, 2197, 199, 3791, 14565, 275, 298, 23570, 23513, 11940, 6516, 83, 701, 445, 12571, 445, 41, 367, 314, 302, 425, 4981, 3261, 4975, 701, 710, 1910, 5703, 473, 2482, 460, 12480, 11562, 14, 366, 393, 838, 2374, 5031, 32, 6799, 14, 957, 2, 199, 199, 646, 747, 199, 396, 63, 78, 425, 275, 283, 4718, 653, 425, 4981, 3261, 4975, 7, 199, 396, 63, 78, 425, 63, 82, 275, 283, 647, 78, 425, 4981, 63, 15253, 1679, 63, 10043, 7, 199, 9032, 275, 747, 14, 2314, 14, 362, 360, 2060, 358, 199, 84, 8787, 275, 747, 14, 2314, 14, 362, 360, 15253, 1679, 63, 84, 8787, 358, 199, 498, 275, 747, 14, 2314, 14, 362, 360, 15253, 1679, 63, 498, 358, 199, 1258, 63, 498, 275, 747, 14, 2314, 14, 362, 360, 15253, 1679, 63, 1258, 498, 358, 199, 2264, 747, 199, 199, 4127, 63, 1246, 275, 221, 700, 14, 46, 425, 4981, 8, 3791, 14565, 9, 199, 199, 10153, 63, 1246, 275, 700, 14, 46, 425, 4981, 8, 3791, 14565, 9, 199, 396, 63, 78, 425, 63, 2865, 1178, 275, 22211, 63, 1246, 14, 78, 425, 8, 396, 63, 78, 425, 9, 199, 396, 63, 1178, 63, 78, 425, 275, 22211, 63, 1246, 14, 78, 425, 8, 396, 63, 78, 425, 12, 2505, 29, 9032, 9, 199, 396, 63, 78, 425, 63, 82, 275, 22211, 63, 1246, 14, 78, 425, 8, 396, 63, 78, 425, 63, 82, 9, 199, 5237, 63, 78, 425, 63, 17, 275, 22211, 63, 1246, 14, 78, 425, 360, 48, 1236, 425, 4981, 13383, 481, 5362, 413, 297, 2505, 29, 9032, 9, 199, 5237, 63, 78, 425, 63, 18, 275, 22211, 63, 1246, 14, 78, 425, 360, 48, 1236, 425, 4981, 13383, 481, 5362, 499, 297, 2505, 29, 9032, 9, 199, 5237, 63, 78, 425, 63, 19, 275, 22211, 63, 1246, 14, 78, 425, 360, 48, 1236, 425, 4981, 13383, 481, 5362, 650, 297, 2505, 29, 9032, 9, 199, 5237, 63, 78, 425, 63, 4262, 275, 22211, 63, 1246, 14, 78, 425, 360, 647, 78, 425, 4981, 63, 16, 63, 10115, 63, 396, 63, 78, 425, 297, 2505, 29, 9032, 9, 199, 1246, 63, 6962, 275, 700, 14, 46, 425, 4981, 8, 3791, 14565, 12, 5796, 63, 632, 29, 549, 9, 421, 199, 318, 18200, 63, 344, 8, 1222, 7783, 2706, 1310, 63, 505, 304, 272, 1777, 17, 275, 892, 7783, 2706, 1310, 63, 505, 14, 1294, 360, 344, 14619, 272, 372, 1777, 17, 59, 17, 1055, 1294, 360, 1743, 5832, 16, 61, 421, 199, 533, 12439, 2176, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 981, 63, 561, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 700, 14, 46, 425, 4981, 8, 3791, 14565, 9, 267, 871, 2186, 465, 221, 5432, 26, 288, 291, 14, 1633, 8, 5432, 9, 199, 199, 533, 3240, 529, 323, 2176, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 78, 425, 63, 1250, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 7375, 63, 1246, 288, 3002, 1250, 275, 2986, 14, 78, 425, 480, 396, 1502, 2391, 531, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 430, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 395, 2615, 63, 1310, 29, 549, 9, 398, 871, 2186, 465, 221, 5432, 26, 288, 291, 14, 1633, 8, 5432, 9, 339, 347, 511, 63, 4551, 63, 1250, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 7375, 63, 1246, 953, 3002, 1250, 275, 2986, 14, 4551, 480, 13129, 424, 531, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 430, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 395, 2615, 63, 1310, 29, 549, 9, 398, 871, 2186, 465, 221, 5432, 26, 288, 291, 14, 1633, 8, 5432, 9, 339, 347, 511, 63, 7617, 63, 1250, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 7375, 63, 1246, 953, 3002, 1250, 275, 2986, 14, 7617, 342, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 430, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 395, 2615, 63, 1310, 29, 549, 9, 267, 871, 2186, 465, 221, 5432, 26, 288, 291, 14, 1633, 8, 5432, 9, 2378, 347, 511, 63, 758, 63, 1250, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 7375, 63, 1246, 953, 3002, 1250, 275, 2986, 14, 758, 480, 17, 531, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 430, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 395, 2615, 63, 1310, 29, 549, 9, 267, 871, 2186, 465, 221, 5432, 26, 288, 291, 14, 1633, 8, 5432, 9, 339, 347, 511, 63, 13761, 63, 688, 86, 63, 1250, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 7375, 63, 1246, 953, 3002, 1250, 275, 2986, 14, 13761, 342, 288, 3002, 1250, 14, 23001, 63, 13761, 8, 17, 12, 413, 9, 288, 3002, 1250, 14, 23001, 63, 13761, 8, 17, 12, 413, 12, 2615, 63, 1310, 29, 549, 9, 288, 3002, 1250, 14, 23001, 63, 13761, 8, 17, 12, 413, 12, 283, 1239, 3424, 358, 288, 3002, 1250, 14, 23001, 63, 13761, 8, 17, 12, 413, 12, 700, 14, 20019, 360, 1239, 3424, 1333, 288, 3002, 1250, 14, 23001, 63, 13761, 8, 17, 12, 413, 12, 334, 561, 14, 20019, 360, 1239, 3424, 659, 430, 953, 327, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 430, 288, 327, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 395, 2615, 63, 1310, 29, 549, 9, 267, 871, 2186, 465, 221, 5432, 26, 288, 746, 221, 5432, 288, 291, 14, 1633, 8, 5432, 9, 339, 347, 511, 63, 13761, 63, 271, 5618, 63, 1250, 8, 277, 304, 267, 862, 26 ]
[ 2882, 199, 646, 302, 425, 4981, 465, 700, 199, 504, 2196, 492, 7141, 199, 646, 2197, 199, 3791, 14565, 275, 298, 23570, 23513, 11940, 6516, 83, 701, 445, 12571, 445, 41, 367, 314, 302, 425, 4981, 3261, 4975, 701, 710, 1910, 5703, 473, 2482, 460, 12480, 11562, 14, 366, 393, 838, 2374, 5031, 32, 6799, 14, 957, 2, 199, 199, 646, 747, 199, 396, 63, 78, 425, 275, 283, 4718, 653, 425, 4981, 3261, 4975, 7, 199, 396, 63, 78, 425, 63, 82, 275, 283, 647, 78, 425, 4981, 63, 15253, 1679, 63, 10043, 7, 199, 9032, 275, 747, 14, 2314, 14, 362, 360, 2060, 358, 199, 84, 8787, 275, 747, 14, 2314, 14, 362, 360, 15253, 1679, 63, 84, 8787, 358, 199, 498, 275, 747, 14, 2314, 14, 362, 360, 15253, 1679, 63, 498, 358, 199, 1258, 63, 498, 275, 747, 14, 2314, 14, 362, 360, 15253, 1679, 63, 1258, 498, 358, 199, 2264, 747, 199, 199, 4127, 63, 1246, 275, 221, 700, 14, 46, 425, 4981, 8, 3791, 14565, 9, 199, 199, 10153, 63, 1246, 275, 700, 14, 46, 425, 4981, 8, 3791, 14565, 9, 199, 396, 63, 78, 425, 63, 2865, 1178, 275, 22211, 63, 1246, 14, 78, 425, 8, 396, 63, 78, 425, 9, 199, 396, 63, 1178, 63, 78, 425, 275, 22211, 63, 1246, 14, 78, 425, 8, 396, 63, 78, 425, 12, 2505, 29, 9032, 9, 199, 396, 63, 78, 425, 63, 82, 275, 22211, 63, 1246, 14, 78, 425, 8, 396, 63, 78, 425, 63, 82, 9, 199, 5237, 63, 78, 425, 63, 17, 275, 22211, 63, 1246, 14, 78, 425, 360, 48, 1236, 425, 4981, 13383, 481, 5362, 413, 297, 2505, 29, 9032, 9, 199, 5237, 63, 78, 425, 63, 18, 275, 22211, 63, 1246, 14, 78, 425, 360, 48, 1236, 425, 4981, 13383, 481, 5362, 499, 297, 2505, 29, 9032, 9, 199, 5237, 63, 78, 425, 63, 19, 275, 22211, 63, 1246, 14, 78, 425, 360, 48, 1236, 425, 4981, 13383, 481, 5362, 650, 297, 2505, 29, 9032, 9, 199, 5237, 63, 78, 425, 63, 4262, 275, 22211, 63, 1246, 14, 78, 425, 360, 647, 78, 425, 4981, 63, 16, 63, 10115, 63, 396, 63, 78, 425, 297, 2505, 29, 9032, 9, 199, 1246, 63, 6962, 275, 700, 14, 46, 425, 4981, 8, 3791, 14565, 12, 5796, 63, 632, 29, 549, 9, 421, 199, 318, 18200, 63, 344, 8, 1222, 7783, 2706, 1310, 63, 505, 304, 272, 1777, 17, 275, 892, 7783, 2706, 1310, 63, 505, 14, 1294, 360, 344, 14619, 272, 372, 1777, 17, 59, 17, 1055, 1294, 360, 1743, 5832, 16, 61, 421, 199, 533, 12439, 2176, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 981, 63, 561, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 700, 14, 46, 425, 4981, 8, 3791, 14565, 9, 267, 871, 2186, 465, 221, 5432, 26, 288, 291, 14, 1633, 8, 5432, 9, 199, 199, 533, 3240, 529, 323, 2176, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 78, 425, 63, 1250, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 7375, 63, 1246, 288, 3002, 1250, 275, 2986, 14, 78, 425, 480, 396, 1502, 2391, 531, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 430, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 395, 2615, 63, 1310, 29, 549, 9, 398, 871, 2186, 465, 221, 5432, 26, 288, 291, 14, 1633, 8, 5432, 9, 339, 347, 511, 63, 4551, 63, 1250, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 7375, 63, 1246, 953, 3002, 1250, 275, 2986, 14, 4551, 480, 13129, 424, 531, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 430, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 395, 2615, 63, 1310, 29, 549, 9, 398, 871, 2186, 465, 221, 5432, 26, 288, 291, 14, 1633, 8, 5432, 9, 339, 347, 511, 63, 7617, 63, 1250, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 7375, 63, 1246, 953, 3002, 1250, 275, 2986, 14, 7617, 342, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 430, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 395, 2615, 63, 1310, 29, 549, 9, 267, 871, 2186, 465, 221, 5432, 26, 288, 291, 14, 1633, 8, 5432, 9, 2378, 347, 511, 63, 758, 63, 1250, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 7375, 63, 1246, 953, 3002, 1250, 275, 2986, 14, 758, 480, 17, 531, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 430, 288, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 395, 2615, 63, 1310, 29, 549, 9, 267, 871, 2186, 465, 221, 5432, 26, 288, 291, 14, 1633, 8, 5432, 9, 339, 347, 511, 63, 13761, 63, 688, 86, 63, 1250, 8, 277, 304, 267, 862, 26, 288, 2986, 275, 7375, 63, 1246, 953, 3002, 1250, 275, 2986, 14, 13761, 342, 288, 3002, 1250, 14, 23001, 63, 13761, 8, 17, 12, 413, 9, 288, 3002, 1250, 14, 23001, 63, 13761, 8, 17, 12, 413, 12, 2615, 63, 1310, 29, 549, 9, 288, 3002, 1250, 14, 23001, 63, 13761, 8, 17, 12, 413, 12, 283, 1239, 3424, 358, 288, 3002, 1250, 14, 23001, 63, 13761, 8, 17, 12, 413, 12, 700, 14, 20019, 360, 1239, 3424, 1333, 288, 3002, 1250, 14, 23001, 63, 13761, 8, 17, 12, 413, 12, 334, 561, 14, 20019, 360, 1239, 3424, 659, 430, 953, 327, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 430, 288, 327, 3002, 1250, 14, 362, 63, 15570, 8, 5095, 8, 1662, 1250, 14, 2495, 63, 15570, 395, 2615, 63, 1310, 29, 549, 9, 267, 871, 2186, 465, 221, 5432, 26, 288, 746, 221, 5432, 288, 291, 14, 1633, 8, 5432, 9, 339, 347, 511, 63, 13761, 63, 271, 5618, 63, 1250, 8, 277, 304, 267, 862, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
PsychoGame/android_kernel_samsung_royss_old
arch/ia64/scripts/unwcheck.py
13143
1714
#!/usr/bin/python # # Usage: unwcheck.py FILE # # This script checks the unwind info of each function in file FILE # and verifies that the sum of the region-lengths matches the total # length of the function. # # Based on a shell/awk script originally written by Harish Patil, # which was converted to Perl by Matthew Chapman, which was converted # to Python by David Mosberger. # import os import re import sys if len(sys.argv) != 2: print "Usage: %s FILE" % sys.argv[0] sys.exit(2) readelf = os.getenv("READELF", "readelf") start_pattern = re.compile("<([^>]*)>: \[0x([0-9a-f]+)-0x([0-9a-f]+)\]") rlen_pattern = re.compile(".*rlen=([0-9]+)") def check_func (func, slots, rlen_sum): if slots != rlen_sum: global num_errors num_errors += 1 if not func: func = "[%#x-%#x]" % (start, end) print "ERROR: %s: %lu slots, total region length = %lu" % (func, slots, rlen_sum) return num_funcs = 0 num_errors = 0 func = False slots = 0 rlen_sum = 0 for line in os.popen("%s -u %s" % (readelf, sys.argv[1])): m = start_pattern.match(line) if m: check_func(func, slots, rlen_sum) func = m.group(1) start = long(m.group(2), 16) end = long(m.group(3), 16) slots = 3 * (end - start) / 16 rlen_sum = 0L num_funcs += 1 else: m = rlen_pattern.match(line) if m: rlen_sum += long(m.group(1)) check_func(func, slots, rlen_sum) if num_errors == 0: print "No errors detected in %u functions." % num_funcs else: if num_errors > 1: err="errors" else: err="error" print "%u %s detected in %u functions." % (num_errors, err, num_funcs) sys.exit(1)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 11028, 26, 625, 87, 1074, 14, 647, 13024, 199, 3, 199, 3, 961, 2884, 5920, 314, 625, 11530, 2256, 402, 1924, 805, 315, 570, 13024, 199, 3, 436, 22694, 626, 314, 3089, 402, 314, 4897, 13, 14563, 4450, 314, 3141, 199, 3, 2582, 402, 314, 805, 14, 199, 3, 199, 3, 21311, 641, 282, 5218, 15, 10084, 75, 2884, 20657, 5313, 701, 25378, 2453, 510, 2159, 76, 12, 199, 3, 1314, 1990, 6702, 370, 3492, 76, 701, 18619, 29640, 2799, 439, 1237, 12, 1314, 1990, 6702, 199, 3, 370, 2018, 701, 20232, 603, 736, 605, 836, 14, 199, 3, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 272, 870, 298, 7692, 26, 450, 83, 13024, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 984, 14, 2224, 8, 18, 9, 199, 199, 8273, 271, 276, 275, 747, 14, 12959, 480, 24345, 4424, 38, 401, 298, 8273, 271, 276, 531, 199, 199, 928, 63, 3401, 275, 295, 14, 2014, 6757, 7059, 30, 3672, 13032, 26, 30257, 16, 88, 779, 16, 13, 25, 65, 13, 70, 2807, 7216, 16, 88, 779, 16, 13, 25, 65, 13, 70, 18096, 12523, 199, 82, 552, 63, 3401, 221, 275, 295, 14, 2014, 480, 2795, 82, 552, 30982, 16, 13, 25, 2807, 6320, 199, 199, 318, 1104, 63, 1532, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 304, 272, 340, 14319, 1137, 24746, 63, 1838, 26, 267, 2288, 1967, 63, 2550, 267, 1967, 63, 2550, 847, 413, 267, 340, 440, 2562, 26, 2562, 275, 26503, 3, 88, 3295, 3, 88, 8480, 450, 334, 928, 12, 1284, 9, 267, 870, 298, 3170, 26, 450, 83, 26, 450, 10836, 14319, 12, 3141, 4897, 2582, 275, 450, 10836, 2, 450, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 272, 372, 199, 199, 1507, 63, 9204, 275, 378, 199, 1507, 63, 2550, 275, 378, 199, 1532, 275, 756, 199, 7257, 275, 378, 199, 82, 552, 63, 1838, 275, 378, 199, 509, 1004, 315, 747, 14, 12207, 3647, 83, 446, 85, 450, 83, 2, 450, 334, 8273, 271, 276, 12, 984, 14, 3020, 59, 17, 18710, 272, 333, 275, 1343, 63, 3401, 14, 1431, 8, 604, 9, 272, 340, 333, 26, 267, 1104, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 398, 2562, 221, 275, 333, 14, 923, 8, 17, 9, 267, 1343, 275, 1846, 8, 77, 14, 923, 8, 18, 395, 3193, 9, 267, 1284, 257, 275, 1846, 8, 77, 14, 923, 8, 19, 395, 3193, 9, 267, 14319, 275, 650, 627, 334, 500, 446, 1343, 9, 1182, 3193, 267, 24746, 63, 1838, 275, 378, 44, 267, 1967, 63, 9204, 847, 413, 272, 587, 26, 267, 333, 275, 24746, 63, 3401, 14, 1431, 8, 604, 9, 267, 340, 333, 26, 288, 24746, 63, 1838, 847, 1846, 8, 77, 14, 923, 8, 17, 430, 199, 1074, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 199, 199, 692, 1967, 63, 2550, 508, 378, 26, 272, 870, 298, 1944, 2552, 10501, 315, 450, 85, 3423, 2122, 450, 1967, 63, 9204, 199, 2836, 26, 272, 340, 1967, 63, 2550, 690, 413, 26, 267, 2329, 628, 2550, 2, 272, 587, 26, 267, 2329, 628, 705, 2, 272, 870, 2071, 85, 450, 83, 10501, 315, 450, 85, 3423, 2122, 450, 334, 1507, 63, 2550, 12, 2329, 12, 1967, 63, 9204, 9, 272, 984, 14, 2224, 8, 17, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 11028, 26, 625, 87, 1074, 14, 647, 13024, 199, 3, 199, 3, 961, 2884, 5920, 314, 625, 11530, 2256, 402, 1924, 805, 315, 570, 13024, 199, 3, 436, 22694, 626, 314, 3089, 402, 314, 4897, 13, 14563, 4450, 314, 3141, 199, 3, 2582, 402, 314, 805, 14, 199, 3, 199, 3, 21311, 641, 282, 5218, 15, 10084, 75, 2884, 20657, 5313, 701, 25378, 2453, 510, 2159, 76, 12, 199, 3, 1314, 1990, 6702, 370, 3492, 76, 701, 18619, 29640, 2799, 439, 1237, 12, 1314, 1990, 6702, 199, 3, 370, 2018, 701, 20232, 603, 736, 605, 836, 14, 199, 3, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 1137, 499, 26, 272, 870, 298, 7692, 26, 450, 83, 13024, 2, 450, 984, 14, 3020, 59, 16, 61, 272, 984, 14, 2224, 8, 18, 9, 199, 199, 8273, 271, 276, 275, 747, 14, 12959, 480, 24345, 4424, 38, 401, 298, 8273, 271, 276, 531, 199, 199, 928, 63, 3401, 275, 295, 14, 2014, 6757, 7059, 30, 3672, 13032, 26, 30257, 16, 88, 779, 16, 13, 25, 65, 13, 70, 2807, 7216, 16, 88, 779, 16, 13, 25, 65, 13, 70, 18096, 12523, 199, 82, 552, 63, 3401, 221, 275, 295, 14, 2014, 480, 2795, 82, 552, 30982, 16, 13, 25, 2807, 6320, 199, 199, 318, 1104, 63, 1532, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 304, 272, 340, 14319, 1137, 24746, 63, 1838, 26, 267, 2288, 1967, 63, 2550, 267, 1967, 63, 2550, 847, 413, 267, 340, 440, 2562, 26, 2562, 275, 26503, 3, 88, 3295, 3, 88, 8480, 450, 334, 928, 12, 1284, 9, 267, 870, 298, 3170, 26, 450, 83, 26, 450, 10836, 14319, 12, 3141, 4897, 2582, 275, 450, 10836, 2, 450, 334, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 272, 372, 199, 199, 1507, 63, 9204, 275, 378, 199, 1507, 63, 2550, 275, 378, 199, 1532, 275, 756, 199, 7257, 275, 378, 199, 82, 552, 63, 1838, 275, 378, 199, 509, 1004, 315, 747, 14, 12207, 3647, 83, 446, 85, 450, 83, 2, 450, 334, 8273, 271, 276, 12, 984, 14, 3020, 59, 17, 18710, 272, 333, 275, 1343, 63, 3401, 14, 1431, 8, 604, 9, 272, 340, 333, 26, 267, 1104, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 398, 2562, 221, 275, 333, 14, 923, 8, 17, 9, 267, 1343, 275, 1846, 8, 77, 14, 923, 8, 18, 395, 3193, 9, 267, 1284, 257, 275, 1846, 8, 77, 14, 923, 8, 19, 395, 3193, 9, 267, 14319, 275, 650, 627, 334, 500, 446, 1343, 9, 1182, 3193, 267, 24746, 63, 1838, 275, 378, 44, 267, 1967, 63, 9204, 847, 413, 272, 587, 26, 267, 333, 275, 24746, 63, 3401, 14, 1431, 8, 604, 9, 267, 340, 333, 26, 288, 24746, 63, 1838, 847, 1846, 8, 77, 14, 923, 8, 17, 430, 199, 1074, 63, 1532, 8, 1532, 12, 14319, 12, 24746, 63, 1838, 9, 199, 199, 692, 1967, 63, 2550, 508, 378, 26, 272, 870, 298, 1944, 2552, 10501, 315, 450, 85, 3423, 2122, 450, 1967, 63, 9204, 199, 2836, 26, 272, 340, 1967, 63, 2550, 690, 413, 26, 267, 2329, 628, 2550, 2, 272, 587, 26, 267, 2329, 628, 705, 2, 272, 870, 2071, 85, 450, 83, 10501, 315, 450, 85, 3423, 2122, 450, 334, 1507, 63, 2550, 12, 2329, 12, 1967, 63, 9204, 9, 272, 984, 14, 2224, 8, 17, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
retornaz/aseba
examples/clients/python-dbus/aseba.py
1
7674
#!/usr/bin/python # -*- coding: utf-8 -*- """ A Python binding for Aseba that relies on DBus for IPC. Supports event sending/receiving as well as setting/getting an Aseba variable. Typical usage: def my_callback(evt): pass with Aseba as aseba: aseba.on_event("evt_name", my_callback) aseba.send_event("evt_name or evt_id", [arg1, arg2, ...]) aseba.set("node_name", "var_name", value) value = aseba.get("node_name", "var_name") Aseba.event_freq is a dictionary that store the frequency at which each (subscribed) event is received. For events that are emitted at fixed period, it may be a convenient way to make sure the connection is in good shape. """ __author__ = "Séverin Lemaignan, Stéphane Magnenat" import dbus import time from dbus.mainloop.glib import DBusGMainLoop import gobject # required to prevent the glib main loop to interfere with Python threads gobject.threads_init() class AsebaException(Exception): def __init__(self, value): self.value = value def __str__(self): return repr(self.value) class Aseba(object): NB_EVTS_FREQ = 10 # nb of events to be received before computing frequency def __init__(self, system_bus = False, dummy = False): self.dummy = dummy self.callbacks = {} self._events_last_evt = {} self._events_periods = {} self.events_freq = {} if not dummy: DBusGMainLoop(set_as_default=True) # init if system_bus: self.bus = dbus.SystemBus() else: self.bus = dbus.SessionBus() try: self.network = dbus.Interface( self.bus.get_object('ch.epfl.mobots.Aseba', '/'), dbus_interface='ch.epfl.mobots.AsebaNetwork') except dbus.exceptions.DBusException: raise AsebaException("Can not connect to Aseba DBus services! " "Is asebamedulla running?") # Configure event management self.clear_events() eventfilter = self.network.CreateEventFilter() self.events = dbus.Interface( self.bus.get_object('ch.epfl.mobots.Aseba', eventfilter), dbus_interface='ch.epfl.mobots.EventFilter') self.dispatch_handler = self.events.connect_to_signal('Event', self._dispatch_events) def clear_events(self): """ Use DBus introspection to get the list of event filters, and remove them. """ try: introspect = dbus.Interface( self.bus.get_object('ch.epfl.mobots.Aseba', "/events_filters"), dbus_interface=dbus.INTROSPECTABLE_IFACE) interface = introspect.Introspect() except dbus.exceptions.DBusException: # /events_filters not yet created -> no events to delete return import xml.etree.ElementTree as ET root = ET.fromstring(interface) for n in root.iter("node"): if 'name' in n.attrib: evtfilter = dbus.Interface( self.bus.get_object('ch.epfl.mobots.Aseba', "/events_filters/%s" % n.attrib['name']), dbus_interface='ch.epfl.mobots.EventFilter') evtfilter.Free() def __enter__(self): self.run() return self def __exit__(self, type, value, traceback): self.close() def run(self): # run event loop self.loop = gobject.MainLoop() self.loop.run() def close(self): self.loop.quit() if not self.dummy: self.dispatch_handler.remove() self.events.Free() def dbus_reply(self): # correct replay on D-Bus, ignore pass def dbus_error(self, e): assert(not dummy) # there was an error on D-Bus, stop loop self.close() raise Exception('dbus error: %s' % str(e)) def get_nodes_list(self): if self.dummy: return [] dbus_array = self.network.GetNodesList() size = len(dbus_array) return [str(dbus_array[x]) for x in range(0,size)] def set(self, node, var, value): if self.dummy: return self.network.SetVariable(node, var, value) def get(self, node, var): if self.dummy: return [0] * 10 dbus_array = self.network.GetVariable(node, var) size = len(dbus_array) if (size == 1): return int(dbus_array[0]) else: return [int(dbus_array[x]) for x in range(0,size)] def send_event(self, event_id, event_args): if isinstance(event_id, basestring): return self.send_event_name(event_id, event_args) if self.dummy: return # events are sent asynchronously self.network.SendEvent(event_id, event_args, reply_handler=self.dbus_reply, error_handler=self.dbus_error) def send_event_name(self, event_name, event_args): if self.dummy: return # events are sent asynchronously self.network.SendEventName(event_name, event_args, reply_handler=self.dbus_reply, error_handler=self.dbus_error) def load_scripts(self, path): if self.dummy: return self.network.LoadScripts(path) def _dispatch_events(self, *args): id, name, vals = args #if id in self.callbacks: # self.callbacks[id](vals) if name in self.callbacks: self.callbacks[name](vals) # update frequency for this event now = time.time() self._events_periods[name].append(now - self._events_last_evt[name]) self._events_last_evt[name] = now if len(self._events_periods[name]) == Aseba.NB_EVTS_FREQ: self.events_freq[name] = 1. / (sum(self._events_periods[name]) / float(Aseba.NB_EVTS_FREQ)) self._events_periods[name] = [] def on_event(self, event_id, cb): if self.dummy: return if not isinstance(event_id, basestring): # supporting events by ID would be easy to add. Actually, it only requires more code in _dispatch_events raise Exception("Only setting event by name is currently supported") self.callbacks[event_id] = cb self._events_last_evt[event_id] = time.time() self._events_periods[event_id] = [] self.events_freq[event_id] = 0. if isinstance(event_id, basestring): self.events.ListenEventName(event_id) else: self.events.ListenEvent(event_id) # *** TEST *** if __name__ == '__main__': from optparse import OptionParser parser = OptionParser() parser.add_option("-s", "--system", action="store_true", dest="system", default=False, help="use the system bus instead of the session bus") (options, args) = parser.parse_args() def my_callback(evt): print(evt) with Aseba(options.system) as aseba: # 'timer0' is the name of the Aseba event you want to subscribe to. aseba.on_event("timer0", my_callback) print "List of nodes: ", aseba.get_nodes_list() aseba.set("thymio-II", "event.source", [1]) aseba.send_event(0, []) print "Get variable temperature: ", aseba.get("thymio-II", "temperature") print "Get array acc: ", aseba.get("thymio-II", "acc")
lgpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 33, 2018, 11696, 367, 437, 261, 2470, 626, 25749, 641, 6249, 527, 367, 3531, 35, 14, 199, 199, 31373, 1566, 10209, 15, 24890, 316, 465, 5521, 465, 4260, 15, 362, 1337, 376, 437, 261, 2470, 1750, 14, 199, 199, 26876, 4503, 26, 339, 347, 3002, 63, 3058, 8, 19296, 304, 267, 986, 339, 543, 437, 261, 2470, 465, 282, 261, 2470, 26, 267, 282, 261, 2470, 14, 265, 63, 1430, 480, 19296, 63, 354, 401, 3002, 63, 3058, 9, 267, 282, 261, 2470, 14, 2254, 63, 1430, 480, 19296, 63, 354, 503, 16330, 63, 344, 401, 359, 1273, 17, 12, 1680, 18, 12, 2263, 566, 398, 282, 261, 2470, 14, 409, 480, 932, 63, 354, 401, 298, 1391, 63, 354, 401, 574, 9, 267, 574, 275, 282, 261, 2470, 14, 362, 480, 932, 63, 354, 401, 298, 1391, 63, 354, 531, 421, 199, 33, 261, 2470, 14, 1430, 63, 5646, 365, 282, 2600, 626, 3877, 314, 9857, 737, 1314, 1924, 199, 8, 23178, 9, 1566, 365, 3086, 14, 2104, 4474, 626, 787, 19515, 737, 6317, 6247, 12, 652, 199, 7551, 506, 282, 22700, 4340, 370, 1852, 3238, 314, 1950, 365, 315, 6954, 2215, 14, 199, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 51, 5741, 422, 262, 7005, 391, 1030, 290, 12, 1933, 5741, 838, 5865, 603, 643, 78, 287, 292, 2, 199, 199, 646, 21140, 199, 646, 900, 199, 199, 504, 21140, 14, 22644, 14, 30816, 492, 6249, 527, 39, 6756, 7382, 199, 646, 25595, 199, 3, 1415, 370, 7981, 314, 486, 773, 2446, 4438, 370, 1640, 771, 264, 543, 2018, 7183, 199, 71, 785, 14, 6962, 63, 826, 342, 421, 199, 533, 437, 261, 2470, 1726, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 574, 304, 267, 291, 14, 585, 275, 574, 272, 347, 636, 495, 721, 277, 304, 267, 372, 4700, 8, 277, 14, 585, 9, 199, 199, 533, 437, 261, 2470, 8, 785, 304, 339, 25377, 63, 12093, 51, 63, 38, 14583, 275, 1616, 327, 8526, 402, 4474, 370, 506, 3086, 2544, 17226, 9857, 339, 347, 636, 826, 721, 277, 12, 2656, 63, 5610, 275, 756, 12, 7283, 275, 756, 304, 267, 291, 14, 5869, 275, 7283, 398, 291, 14, 11948, 275, 1052, 267, 291, 423, 4368, 63, 2019, 63, 19296, 275, 1052, 267, 291, 423, 4368, 63, 20441, 275, 1052, 267, 291, 14, 4368, 63, 5646, 275, 1052, 398, 340, 440, 7283, 26, 288, 6249, 527, 39, 6756, 7382, 8, 409, 63, 305, 63, 885, 29, 549, 9, 288, 327, 4205, 7205, 340, 2656, 63, 5610, 26, 355, 291, 14, 5610, 275, 21140, 14, 3989, 12106, 342, 288, 587, 26, 355, 291, 14, 5610, 275, 21140, 14, 4434, 12106, 342, 953, 862, 26, 355, 291, 14, 1200, 275, 21140, 14, 4267, 8, 717, 291, 14, 5610, 14, 362, 63, 785, 360, 335, 14, 1545, 2327, 14, 573, 28143, 14, 33, 261, 2470, 297, 1994, 659, 12723, 21140, 63, 3266, 534, 335, 14, 1545, 2327, 14, 573, 28143, 14, 33, 261, 2470, 4491, 358, 288, 871, 21140, 14, 3924, 14, 2846, 527, 1726, 26, 355, 746, 437, 261, 2470, 1726, 480, 6049, 440, 4907, 370, 437, 261, 2470, 6249, 527, 8500, 1, 298, 3660, 298, 1831, 282, 261, 66, 313, 68, 348, 416, 3879, 18582, 22919, 327, 15453, 1566, 10041, 288, 291, 14, 3584, 63, 4368, 342, 288, 1566, 1541, 275, 291, 14, 1200, 14, 2499, 2390, 4131, 342, 288, 291, 14, 4368, 275, 21140, 14, 4267, 8, 717, 291, 14, 5610, 14, 362, 63, 785, 360, 335, 14, 1545, 2327, 14, 573, 28143, 14, 33, 261, 2470, 297, 1566, 1541, 395, 12723, 21140, 63, 3266, 534, 335, 14, 1545, 2327, 14, 573, 28143, 14, 2390, 4131, 358, 288, 291, 14, 6052, 63, 2232, 275, 291, 14, 4368, 14, 2242, 63, 475, 63, 4653, 360, 2390, 297, 291, 423, 6052, 63, 4368, 9, 339, 347, 5436, 63, 4368, 8, 277, 304, 267, 408, 3645, 6249, 527, 1109, 14254, 370, 664, 314, 769, 402, 1566, 4766, 12, 436, 2813, 3062, 14, 267, 408, 267, 862, 26, 288, 1109, 21302, 275, 21140, 14, 4267, 8, 717, 291, 14, 5610, 14, 362, 63, 785, 360, 335, 14, 1545, 2327, 14, 573, 28143, 14, 33, 261, 2470, 297, 3286, 4368, 63, 4273, 1288, 12723, 21140, 63, 3266, 29, 17066, 14, 2919, 1092, 51, 11401, 2617, 63, 4656, 4121, 9, 288, 3217, 275, 1109, 21302, 14, 3241, 21302, 342, 267, 871, 21140, 14, 3924, 14, 2846, 527, 1726, 26, 288, 327, 1182, 4368, 63, 4273, 440, 5966, 2737, 1035, 949, 4474, 370, 3145, 288, 372, 398, 492, 2748, 14, 9464, 14, 15325, 465, 12265, 267, 1738, 275, 12265, 14, 13521, 8, 3266, 9, 267, 367, 302, 315, 1738, 14, 1661, 480, 932, 2349, 288, 340, 283, 354, 7, 315, 302, 14, 6640, 26, 355, 16330, 1541, 275, 21140, 14, 4267, 8, 717, 291, 14, 5610, 14, 362, 63, 785, 360, 335, 14, 1545, 2327, 14, 573, 28143, 14, 33, 261, 2470, 297, 3286, 4368, 63, 4273, 3149, 83, 2, 450, 302, 14, 6640, 459, 354, 3815, 12723, 21140, 63, 3266, 534, 335, 14, 1545, 2327, 14, 573, 28143, 14, 2390, 4131, 358, 355, 16330, 1541, 14, 10146, 342, 339, 347, 636, 4200, 721, 277, 304, 267, 291, 14, 1065, 342, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 730, 12, 574, 12, 5190, 304, 267, 291, 14, 1600, 342, 339, 347, 1255, 8, 277, 304, 267, 327, 1255, 1566, 4438, 267, 291, 14, 3813, 275, 25595, 14, 6756, 7382, 342, 267, 291, 14, 3813, 14, 1065, 342, 339, 347, 4002, 8, 277, 304, 267, 291, 14, 3813, 14, 10589, 342, 267, 340, 440, 291, 14, 5869, 26, 288, 291, 14, 6052, 63, 2232, 14, 2168, 342, 288, 291, 14, 4368, 14, 10146, 342, 339, 347, 21140, 63, 8102, 8, 277, 304, 267, 327, 3211, 24331, 641, 577, 13, 12106, 12, 3686, 267, 986, 339, 347, 21140, 63, 705, 8, 277, 12, 325, 304, 267, 702, 8, 1397, 7283, 9, 398, 327, 2337, 1990, 376, 1125, 641, 577, 13, 12106, 12, 3631 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 33, 2018, 11696, 367, 437, 261, 2470, 626, 25749, 641, 6249, 527, 367, 3531, 35, 14, 199, 199, 31373, 1566, 10209, 15, 24890, 316, 465, 5521, 465, 4260, 15, 362, 1337, 376, 437, 261, 2470, 1750, 14, 199, 199, 26876, 4503, 26, 339, 347, 3002, 63, 3058, 8, 19296, 304, 267, 986, 339, 543, 437, 261, 2470, 465, 282, 261, 2470, 26, 267, 282, 261, 2470, 14, 265, 63, 1430, 480, 19296, 63, 354, 401, 3002, 63, 3058, 9, 267, 282, 261, 2470, 14, 2254, 63, 1430, 480, 19296, 63, 354, 503, 16330, 63, 344, 401, 359, 1273, 17, 12, 1680, 18, 12, 2263, 566, 398, 282, 261, 2470, 14, 409, 480, 932, 63, 354, 401, 298, 1391, 63, 354, 401, 574, 9, 267, 574, 275, 282, 261, 2470, 14, 362, 480, 932, 63, 354, 401, 298, 1391, 63, 354, 531, 421, 199, 33, 261, 2470, 14, 1430, 63, 5646, 365, 282, 2600, 626, 3877, 314, 9857, 737, 1314, 1924, 199, 8, 23178, 9, 1566, 365, 3086, 14, 2104, 4474, 626, 787, 19515, 737, 6317, 6247, 12, 652, 199, 7551, 506, 282, 22700, 4340, 370, 1852, 3238, 314, 1950, 365, 315, 6954, 2215, 14, 199, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 51, 5741, 422, 262, 7005, 391, 1030, 290, 12, 1933, 5741, 838, 5865, 603, 643, 78, 287, 292, 2, 199, 199, 646, 21140, 199, 646, 900, 199, 199, 504, 21140, 14, 22644, 14, 30816, 492, 6249, 527, 39, 6756, 7382, 199, 646, 25595, 199, 3, 1415, 370, 7981, 314, 486, 773, 2446, 4438, 370, 1640, 771, 264, 543, 2018, 7183, 199, 71, 785, 14, 6962, 63, 826, 342, 421, 199, 533, 437, 261, 2470, 1726, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 574, 304, 267, 291, 14, 585, 275, 574, 272, 347, 636, 495, 721, 277, 304, 267, 372, 4700, 8, 277, 14, 585, 9, 199, 199, 533, 437, 261, 2470, 8, 785, 304, 339, 25377, 63, 12093, 51, 63, 38, 14583, 275, 1616, 327, 8526, 402, 4474, 370, 506, 3086, 2544, 17226, 9857, 339, 347, 636, 826, 721, 277, 12, 2656, 63, 5610, 275, 756, 12, 7283, 275, 756, 304, 267, 291, 14, 5869, 275, 7283, 398, 291, 14, 11948, 275, 1052, 267, 291, 423, 4368, 63, 2019, 63, 19296, 275, 1052, 267, 291, 423, 4368, 63, 20441, 275, 1052, 267, 291, 14, 4368, 63, 5646, 275, 1052, 398, 340, 440, 7283, 26, 288, 6249, 527, 39, 6756, 7382, 8, 409, 63, 305, 63, 885, 29, 549, 9, 288, 327, 4205, 7205, 340, 2656, 63, 5610, 26, 355, 291, 14, 5610, 275, 21140, 14, 3989, 12106, 342, 288, 587, 26, 355, 291, 14, 5610, 275, 21140, 14, 4434, 12106, 342, 953, 862, 26, 355, 291, 14, 1200, 275, 21140, 14, 4267, 8, 717, 291, 14, 5610, 14, 362, 63, 785, 360, 335, 14, 1545, 2327, 14, 573, 28143, 14, 33, 261, 2470, 297, 1994, 659, 12723, 21140, 63, 3266, 534, 335, 14, 1545, 2327, 14, 573, 28143, 14, 33, 261, 2470, 4491, 358, 288, 871, 21140, 14, 3924, 14, 2846, 527, 1726, 26, 355, 746, 437, 261, 2470, 1726, 480, 6049, 440, 4907, 370, 437, 261, 2470, 6249, 527, 8500, 1, 298, 3660, 298, 1831, 282, 261, 66, 313, 68, 348, 416, 3879, 18582, 22919, 327, 15453, 1566, 10041, 288, 291, 14, 3584, 63, 4368, 342, 288, 1566, 1541, 275, 291, 14, 1200, 14, 2499, 2390, 4131, 342, 288, 291, 14, 4368, 275, 21140, 14, 4267, 8, 717, 291, 14, 5610, 14, 362, 63, 785, 360, 335, 14, 1545, 2327, 14, 573, 28143, 14, 33, 261, 2470, 297, 1566, 1541, 395, 12723, 21140, 63, 3266, 534, 335, 14, 1545, 2327, 14, 573, 28143, 14, 2390, 4131, 358, 288, 291, 14, 6052, 63, 2232, 275, 291, 14, 4368, 14, 2242, 63, 475, 63, 4653, 360, 2390, 297, 291, 423, 6052, 63, 4368, 9, 339, 347, 5436, 63, 4368, 8, 277, 304, 267, 408, 3645, 6249, 527, 1109, 14254, 370, 664, 314, 769, 402, 1566, 4766, 12, 436, 2813, 3062, 14, 267, 408, 267, 862, 26, 288, 1109, 21302, 275, 21140, 14, 4267, 8, 717, 291, 14, 5610, 14, 362, 63, 785, 360, 335, 14, 1545, 2327, 14, 573, 28143, 14, 33, 261, 2470, 297, 3286, 4368, 63, 4273, 1288, 12723, 21140, 63, 3266, 29, 17066, 14, 2919, 1092, 51, 11401, 2617, 63, 4656, 4121, 9, 288, 3217, 275, 1109, 21302, 14, 3241, 21302, 342, 267, 871, 21140, 14, 3924, 14, 2846, 527, 1726, 26, 288, 327, 1182, 4368, 63, 4273, 440, 5966, 2737, 1035, 949, 4474, 370, 3145, 288, 372, 398, 492, 2748, 14, 9464, 14, 15325, 465, 12265, 267, 1738, 275, 12265, 14, 13521, 8, 3266, 9, 267, 367, 302, 315, 1738, 14, 1661, 480, 932, 2349, 288, 340, 283, 354, 7, 315, 302, 14, 6640, 26, 355, 16330, 1541, 275, 21140, 14, 4267, 8, 717, 291, 14, 5610, 14, 362, 63, 785, 360, 335, 14, 1545, 2327, 14, 573, 28143, 14, 33, 261, 2470, 297, 3286, 4368, 63, 4273, 3149, 83, 2, 450, 302, 14, 6640, 459, 354, 3815, 12723, 21140, 63, 3266, 534, 335, 14, 1545, 2327, 14, 573, 28143, 14, 2390, 4131, 358, 355, 16330, 1541, 14, 10146, 342, 339, 347, 636, 4200, 721, 277, 304, 267, 291, 14, 1065, 342, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 730, 12, 574, 12, 5190, 304, 267, 291, 14, 1600, 342, 339, 347, 1255, 8, 277, 304, 267, 327, 1255, 1566, 4438, 267, 291, 14, 3813, 275, 25595, 14, 6756, 7382, 342, 267, 291, 14, 3813, 14, 1065, 342, 339, 347, 4002, 8, 277, 304, 267, 291, 14, 3813, 14, 10589, 342, 267, 340, 440, 291, 14, 5869, 26, 288, 291, 14, 6052, 63, 2232, 14, 2168, 342, 288, 291, 14, 4368, 14, 10146, 342, 339, 347, 21140, 63, 8102, 8, 277, 304, 267, 327, 3211, 24331, 641, 577, 13, 12106, 12, 3686, 267, 986, 339, 347, 21140, 63, 705, 8, 277, 12, 325, 304, 267, 702, 8, 1397, 7283, 9, 398, 327, 2337, 1990, 376, 1125, 641, 577, 13, 12106, 12, 3631, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
titeuf87/evennia
evennia/contrib/rplanguage.py
6
19614
""" Language and whisper obfuscation system Evennia contrib - Griatch 2015 This module is intented to be used with an emoting system (such as contrib/rpsystem.py). It offers the ability to obfuscate spoken words in the game in various ways: - Language: The language functionality defines a pseudo-language map to any number of languages. The string will be obfuscated depending on a scaling that (most likely) will be input as a weighted average of the language skill of the speaker and listener. - Whisper: The whisper functionality will gradually "fade out" a whisper along as scale 0-1, where the fading is based on gradually removing sections of the whisper that is (supposedly) easier to overhear (for example "s" sounds tend to be audible even when no other meaning can be determined). Usage: ```python from evennia.contrib import rplanguages # need to be done once, here we create the "default" lang rplanguages.add_language() say = "This is me talking." whisper = "This is me whispering. print rplanguages.obfuscate_language(say, level=0.0) <<< "This is me talking." print rplanguages.obfuscate_language(say, level=0.5) <<< "This is me byngyry." print rplanguages.obfuscate_language(say, level=1.0) <<< "Daly ly sy byngyry." result = rplanguages.obfuscate_whisper(whisper, level=0.0) <<< "This is me whispering" result = rplanguages.obfuscate_whisper(whisper, level=0.2) <<< "This is m- whisp-ring" result = rplanguages.obfuscate_whisper(whisper, level=0.5) <<< "---s -s -- ---s------" result = rplanguages.obfuscate_whisper(whisper, level=0.7) <<< "---- -- -- ----------" result = rplanguages.obfuscate_whisper(whisper, level=1.0) <<< "..." ``` To set up new languages, import and use the `add_language()` helper method in this module. This allows you to customize the "feel" of the semi-random language you are creating. Especially the `word_length_variance` helps vary the length of translated words compared to the original and can help change the "feel" for the language you are creating. You can also add your own dictionary and "fix" random words for a list of input words. Below is an example of "elvish", using "rounder" vowels and sounds: ```python phonemes = "oi oh ee ae aa eh ah ao aw ay er ey ow ia ih iy " \ "oy ua uh uw y p b t d f v t dh s z sh zh ch jh k " \ "ng g m n l r w", vowels = "eaoiuy" grammar = "v vv vvc vcc vvcc cvvc vccv vvccv vcvccv vcvcvcc vvccvvcc " \ "vcvvccvvc cvcvvcvvcc vcvcvvccvcvv", word_length_variance = 1 noun_postfix = "'la" manual_translations = {"the":"y'e", "we":"uyi", "she":"semi", "he":"emi", "you": "do", 'me':'mi','i':'me', 'be':"hy'e", 'and':'y'} rplanguages.add_language(key="elvish", phonemes=phonemes, grammar=grammar, word_length_variance=word_length_variance, noun_postfix=noun_postfix, vowels=vowels, manual_translations=manual_translations auto_translations="my_word_file.txt") ``` This will produce a decicively more "rounded" and "soft" language than the default one. The few manual_translations also make sure to make it at least look superficially "reasonable". The `auto_translations` keyword is useful, this accepts either a list or a path to a file of words (one per line) to automatically create fixed translations for according to the grammatical rules. This allows to quickly build a large corpus of translated words that never change (if this is desired). """ from builtins import range import re from random import choice, randint from collections import defaultdict from evennia import DefaultScript #------------------------------------------------------------ # # Obfuscate language # #------------------------------------------------------------ # default language grammar _PHONEMES = "ea oh ae aa eh ah ao aw ai er ey ow ia ih iy oy ua uh uw a e i u y p b t d f v t dh s z sh zh ch jh k ng g m n l r w" _VOWELS = "eaoiuy" # these must be able to be constructed from phonemes (so for example, # if you have v here, there must exixt at least one single-character # vowel phoneme defined above) _GRAMMAR = "v cv vc cvv vcc vcv cvcc vccv cvccv cvcvcc cvccvcv vccvccvc cvcvccvv cvcvcvcvv" _RE_FLAGS = re.MULTILINE + re.IGNORECASE + re.UNICODE _RE_GRAMMAR = re.compile(r"vv|cc|v|c", _RE_FLAGS) _RE_WORD = re.compile(r'\w+', _RE_FLAGS) class LanguageExistsError(Exception): message = "Language is already created. Re-adding it will re-build" \ " its dictionary map. Use 'force=True' keyword if you are sure." class LanguageHandler(DefaultScript): """ This is a storage class that should usually not be created on its own. It's automatically created by a call to `obfuscate_language` or `add_language` below. Languages are implemented as a "logical" pseudo- consistent language algorith here. The idea is that a language is built up from phonemes. These are joined together according to a "grammar" of possible phoneme- combinations and allowed characters. It may sound simplistic, but this allows to easily make "similar-sounding" languages. One can also custom-define a dictionary of some common words to give further consistency. Optionally, the system also allows an input list of common words to be loaded and given random translations. These will be stored to disk and will thus not change. This gives a decent "stability" of the language but if the goal is to obfuscate, this may allow players to eventually learn to understand the gist of a sentence even if their characters can not. Any number of languages can be created this way. This nonsense language will partially replace the actual spoken language when so desired (usually because the speaker/listener don't know the language well enough). """ def at_script_creation(self): "Called when script is first started" self.key = "language_handler" self.persistent = True self.db.language_storage = {} def add(self, key="default", phonemes=_PHONEMES, grammar=_GRAMMAR, word_length_variance=0, noun_prefix="", noun_postfix="", vowels=_VOWELS, manual_translations=None, auto_translations=None, force=False): """ Add a new language. Note that you generally only need to do this once per language and that adding an existing language will re-initialize all the random components to new permanent values. Args: key (str, optional): The name of the language. This will be used as an identifier for the language so it should be short and unique. phonemes (str, optional): Space-separated string of all allowed phonemes in this language. grammar (str): All allowed consonant (c) and vowel (v) combinations allowed to build up words. For example cvv would be a consonant followed by two vowels (would allow for a word like 'die'). word_length_variance (real): The variation of length of words. 0 means a minimal variance, higher variance may mean words have wildly varying length; this strongly affects how the language "looks". noun_prefix (str, optional): A prefix to go before every noun in this language (if any). noun_postfix (str, optuonal): A postfix to go after every noun in this language (if any, usually best to avoid combining with `noun_prefix` or language becomes very wordy). vowels (str, optional): Every vowel allowed in this language. manual_translations (dict, optional): This allows for custom-setting certain words in the language to mean the same thing. It is on the form `{real_word: fictional_word}`, for example `{"the", "y'e"}` . auto_translations (str or list, optional): These are lists words that should be auto-translated with a random, but fixed, translation. If a path to a file, this file should contain a list of words to produce translations for, one word per line. If a list, the list's elements should be the words to translate. The `manual_translations` will always override overlapping translations created automatically. force (bool, optional): Unless true, will not allow the addition of a language that is already created. Raises: LanguageExistsError: Raised if trying to adding a language with a key that already exists, without `force` being set. Notes: The `word_file` is for example a word-frequency list for the N most common words in the host language. The translations will be random, but will be stored persistently to always be the same. This allows for building a quick, decently-sounding fictive language that tend to produce the same "translation" (mostly) with the same input sentence. """ if key in self.db.language_storage and not force: raise LanguageExistsError # allowed grammar are grouped by length gramdict = defaultdict(list) for gram in grammar.split(): gramdict[len(gram)].append(gram) grammar = dict(gramdict) # create grammar_component->phoneme mapping # {"vv": ["ea", "oh", ...], ...} grammar2phonemes = defaultdict(list) for phoneme in phonemes.split(): gram = "".join(["v" if char in vowels else "c" for char in phoneme]) grammar2phonemes[gram].append(phoneme) # create automatic translation translation = {} if auto_translations: if isinstance(auto_translations, basestring): # path to a file rather than a list with open(auto_translations, 'r') as f: auto_translations = f.readlines() for word in auto_translations: word = word.strip() lword = len(word) new_word = "" wlen = max(0, lword + sum(randint(-1,1) for i in range(word_length_variance))) if wlen not in grammar: # always create a translation, use random length structure = choice(grammar[choice(list(grammar))]) else: # use the corresponding length structure = choice(grammar[wlen]) for match in _RE_GRAMMAR.finditer(structure): new_word += choice(grammar2phonemes[match.group()]) translation[word.lower()] = new_word.lower() if manual_translations: # update with manual translations translation.update(dict((key.lower(), value.lower()) for key, value in manual_translations.items())) # store data storage = {"translation" : translation, "grammar": grammar, "grammar2phonemes": dict(grammar2phonemes), "word_length_variance": word_length_variance, "noun_prefix": noun_prefix, "noun_postfix": noun_postfix} self.db.language_storage[key] = storage def _translate_sub(self, match): """ Replacer method called by re.sub when traversing the language string. Args: match (re.matchobj): Match object from regex. Returns: converted word. Notes: Assumes self.lastword and self.level is available on the object. """ word = match.group() lword = len(word) if len(word) <= self.level: # below level. Don't translate new_word = word else: # translate the word new_word = self.language["translation"].get(word.lower(), "") if not new_word: if word.istitle(): # capitalized word we don't have a translation for - # treat as a name (don't translate) new_word = "%s%s%s" % (self.language["noun_prefix"], word, self.language["noun_postfix"]) else: # make up translation on the fly. Length can # vary from un-translated word. wlen = max(0, lword + sum(randint(-1,1) for i in range(self.language["word_length_variance"]))) grammar = self.language["grammar"] if wlen not in grammar: # this word has no direct translation! return "" structure = choice(grammar[wlen]) grammar2phonemes = self.language["grammar2phonemes"] for match in _RE_GRAMMAR.finditer(structure): # there are only four combinations: vv,cc,c,v new_word += choice(grammar2phonemes[match.group()]) if word.istitle(): # capitalize words the same way new_word = new_word.capitalize() if len(word) > 1 and word.isupper(): # keep LOUD words loud also when translated new_word = new_word.upper() return new_word def translate(self, text, level=0.0, language="default"): """ Translate the text according to the given level. Args: text (str): The text to translate level (real): Value between 0.0 and 1.0, where 0.0 means no obfuscation (text returned unchanged) and 1.0 means full conversion of every word. The closer to 1, the shorter words will be translated. language (str): The language key identifier. Returns: text (str): A translated string. """ if level == 0.0: # no translation return text language = self.db.language_storage.get(language, None) if not language: return text self.language = language # configuring the translation self.level = int(10 * (1.0 - max(0, min(level, 1.0)))) return _RE_WORD.sub(self._translate_sub, text) # Language access functions _LANGUAGE_HANDLER = None def obfuscate_language(text, level=0.0, language="default"): """ Main access method for the language parser. Args: text (str): Text to obfuscate. level (real, optional): A value from 0.0-1.0 determining the level of obfuscation where 0 means no jobfuscation (string returned unchanged) and 1.0 means the entire string is obfuscated. language (str, optional): The identifier of a language the system understands. Returns: translated (str): The translated text. """ # initialize the language handler and cache it global _LANGUAGE_HANDLER if not _LANGUAGE_HANDLER: try: _LANGUAGE_HANDLER = LanguageHandler.objects.get(db_key="language_handler") except LanguageHandler.DoesNotExist: if not _LANGUAGE_HANDLER: from evennia import create_script _LANGUAGE_HANDLER = create_script(LanguageHandler) return _LANGUAGE_HANDLER.translate(text, level=level, language=language) def add_language(**kwargs): """ Access function to creating a new language. See the docstring of `LanguageHandler.add` for list of keyword arguments. """ global _LANGUAGE_HANDLER if not _LANGUAGE_HANDLER: try: _LANGUAGE_HANDLER = LanguageHandler.objects.get(db_key="language_handler") except LanguageHandler.DoesNotExist: if not _LANGUAGE_HANDLER: from evennia import create_script _LANGUAGE_HANDLER = create_script(LanguageHandler) _LANGUAGE_HANDLER.add(**kwargs) def available_languages(): """ Returns all available language keys. Returns: languages (list): List of key strings of all available languages. """ global _LANGUAGE_HANDLER if not _LANGUAGE_HANDLER: try: _LANGUAGE_HANDLER = LanguageHandler.objects.get(db_key="language_handler") except LanguageHandler.DoesNotExist: if not _LANGUAGE_HANDLER: from evennia import create_script _LANGUAGE_HANDLER = create_script(LanguageHandler) return list(_LANGUAGE_HANDLER.attributes.get("language_storage", {})) #------------------------------------------------------------ # # Whisper obscuration # # This obsucration table is designed by obscuring certain # vowels first, following by consonants that tend to be # more audible over long distances, like s. Finally it # does non-auditory replacements, like exclamation marks # and capitalized letters (assumed to be spoken louder) that may still # give a user some idea of the sentence structure. Then the word # lengths are also obfuscated and finally the whisper # length itself. # #------------------------------------------------------------ _RE_WHISPER_OBSCURE = [ re.compile(r"^$", _RE_FLAGS), # This is a Test! #0 full whisper re.compile(r"[ae]", _RE_FLAGS), # This -s - Test! #1 add uy re.compile(r"[aeuy]", _RE_FLAGS), # This -s - Test! #2 add oue re.compile(r"[aeiouy]", _RE_FLAGS), # Th-s -s - T-st! #3 add all consonants re.compile(r"[aeiouybdhjlmnpqrv]", _RE_FLAGS), # T--s -s - T-st! #4 add hard consonants re.compile(r"[a-eg-rt-z]", _RE_FLAGS), # T--s -s - T-s-! #5 add all capitals re.compile(r"[A-EG-RT-Za-eg-rt-z]", _RE_FLAGS), # ---s -s - --s-! #6 add f re.compile(r"[A-EG-RT-Za-rt-z]", _RE_FLAGS), # ---s -s - --s-! #7 add s re.compile(r"[A-EG-RT-Za-z]", _RE_FLAGS), # ---- -- - ----! #8 add capital F re.compile(r"[A-RT-Za-z]", _RE_FLAGS), # ---- -- - ----! #9 add capital S re.compile(r"[\w]", _RE_FLAGS), # ---- -- - ----! #10 non-alphanumerals re.compile(r"[\S]", _RE_FLAGS), # ---- -- - ---- #11 words re.compile(r"[\w\W]", _RE_FLAGS), # -------------- #12 whisper length re.compile(r".*", _RE_FLAGS)] # ... #13 (always same length) def obfuscate_whisper(whisper, level=0.0): """ Obfuscate whisper depending on a pre-calculated level (that may depend on distance, listening skill etc) Args: whisper (str): The whisper string to obscure. The entire string will be considered in the obscuration. level (real, optional): This is a value 0-1, where 0 means not obscured (whisper returned unchanged) and 1 means fully obscured. """ level = min(max(0.0, level), 1.0) olevel = int(13.0 * level) return _RE_WHISPER_OBSCURE[olevel].sub('...' if olevel == 13.0 else '-', whisper)
bsd-3-clause
[ 624, 199, 8493, 436, 704, 374, 529, 2607, 31958, 1063, 2656, 199, 199, 29704, 22042, 5914, 446, 598, 322, 693, 6900, 421, 199, 2765, 859, 365, 315, 724, 471, 370, 506, 1202, 543, 376, 18564, 15866, 2656, 334, 10180, 465, 199, 2828, 15, 82, 1190, 3045, 14, 647, 680, 2779, 32563, 314, 21255, 370, 2607, 31958, 1411, 25664, 917, 5932, 199, 262, 314, 9219, 315, 7750, 15217, 26, 199, 199, 13, 8466, 26, 710, 2637, 9330, 7890, 282, 15984, 13, 3671, 2341, 272, 370, 1263, 1329, 402, 10815, 14, 221, 710, 1059, 911, 506, 2607, 31958, 3153, 10298, 272, 641, 282, 13690, 626, 334, 2786, 12060, 9, 911, 506, 1324, 465, 282, 14609, 8095, 402, 272, 314, 2637, 2386, 778, 402, 314, 308, 19838, 436, 11647, 14, 199, 13, 644, 866, 529, 26, 710, 704, 374, 529, 9330, 911, 1999, 2033, 1183, 298, 667, 271, 734, 2, 282, 272, 704, 374, 529, 3180, 465, 4666, 378, 13, 17, 12, 2382, 314, 289, 5384, 365, 4079, 641, 1999, 2033, 1183, 272, 12881, 10189, 402, 314, 704, 374, 529, 626, 365, 334, 1961, 5824, 590, 9, 14905, 370, 272, 1806, 426, 285, 334, 509, 2893, 298, 83, 2, 20453, 83, 221, 7169, 370, 506, 10576, 328, 830, 2755, 1380, 949, 1163, 272, 11150, 883, 506, 12037, 680, 199, 199, 7692, 26, 339, 10841, 1548, 272, 687, 2755, 22042, 14, 2828, 492, 519, 1168, 1731, 83, 339, 327, 1929, 370, 506, 4224, 5403, 12, 2348, 781, 1218, 314, 298, 885, 2, 6339, 272, 519, 1168, 1731, 83, 14, 525, 63, 3671, 342, 339, 14722, 275, 298, 2765, 365, 562, 22811, 316, 2122, 272, 704, 374, 529, 275, 298, 2765, 365, 562, 704, 374, 529, 316, 14, 339, 870, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 3671, 8, 19787, 12, 2166, 29, 16, 14, 16, 9, 272, 5213, 28, 298, 2765, 365, 562, 22811, 316, 2122, 272, 870, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 3671, 8, 19787, 12, 2166, 29, 16, 14, 21, 9, 272, 5213, 28, 298, 2765, 365, 562, 701, 2753, 89, 651, 2122, 272, 870, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 3671, 8, 19787, 12, 2166, 29, 17, 14, 16, 9, 272, 5213, 28, 298, 36, 2618, 21559, 1847, 701, 2753, 89, 651, 2122, 339, 754, 275, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 87, 866, 529, 8, 87, 866, 529, 12, 2166, 29, 16, 14, 16, 9, 272, 5213, 28, 298, 2765, 365, 562, 704, 374, 529, 316, 2, 272, 754, 275, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 87, 866, 529, 8, 87, 866, 529, 12, 2166, 29, 16, 14, 18, 9, 272, 5213, 28, 298, 2765, 365, 333, 13, 704, 27474, 13, 5985, 2, 272, 754, 275, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 87, 866, 529, 8, 87, 866, 529, 12, 2166, 29, 16, 14, 21, 9, 272, 5213, 28, 298, 2595, 83, 446, 83, 1553, 10894, 83, 8648, 2, 272, 754, 275, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 87, 866, 529, 8, 87, 866, 529, 12, 2166, 29, 16, 14, 23, 9, 272, 5213, 28, 298, 375, 1553, 1553, 4143, 2, 272, 754, 275, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 87, 866, 529, 8, 87, 866, 529, 12, 2166, 29, 17, 14, 16, 9, 272, 5213, 28, 298, 11500, 339, 10841, 339, 4005, 663, 1536, 892, 10815, 12, 492, 436, 675, 314, 658, 525, 63, 3671, 11995, 272, 5922, 1083, 315, 642, 859, 14, 961, 6127, 1265, 370, 17551, 314, 272, 298, 771, 352, 2, 402, 314, 18734, 13, 2355, 2637, 1265, 787, 6425, 14, 662, 22568, 272, 314, 658, 1027, 63, 1267, 63, 6221, 64, 22577, 17083, 314, 2582, 402, 14598, 272, 5932, 13524, 370, 314, 3379, 436, 883, 1720, 1570, 314, 298, 771, 352, 2, 367, 272, 314, 2637, 1265, 787, 6425, 14, 2047, 883, 2597, 1050, 2195, 5705, 272, 2600, 436, 298, 970, 2, 2196, 5932, 367, 282, 769, 402, 1324, 5932, 14, 339, 6423, 674, 365, 376, 2893, 402, 298, 352, 86, 2453, 401, 1808, 298, 293, 7138, 2, 373, 11797, 83, 436, 20453, 83, 26, 339, 10841, 1548, 272, 14617, 6415, 275, 298, 16142, 312, 72, 325, 69, 16951, 18319, 325, 72, 282, 72, 282, 79, 26936, 282, 89, 9266, 325, 89, 22182, 284, 65, 284, 72, 284, 89, 298, 971, 2049, 298, 79, 89, 18500, 399, 72, 399, 87, 612, 299, 330, 307, 366, 289, 373, 307, 31387, 308, 1315, 1033, 1315, 72, 682, 1335, 72, 1022, 298, 971, 2049, 298, 2753, 486, 333, 302, 634, 519, 336, 401, 272, 373, 11797, 83, 275, 298, 4489, 16142, 29514, 2, 272, 12528, 275, 298, 86, 373, 86, 373, 6737, 373, 2055, 373, 86, 2055, 6277, 6737, 373, 2055, 86, 373, 86, 2055, 86, 373, 5107, 2055, 86, 373, 5107, 5107, 2055, 373, 86, 2055, 8958, 2055, 298, 971, 1598, 298, 86, 5107, 86, 2055, 86, 6737, 6277, 5107, 86, 5107, 86, 2055, 373, 5107, 5107, 86, 2055, 86, 5107, 86, 401, 272, 4349, 63, 1267, 63, 6221, 275, 413, 272, 949, 324, 63, 24791, 275, 3546, 416, 2, 272, 8722, 63, 13982, 275, 2420, 1589, 5122, 89, 7, 69, 401, 298, 1129, 5122, 85, 21643, 401, 298, 19195, 5122, 19290, 401, 298, 426, 5122, 69, 2664, 401, 2079, 298, 13297, 582, 298, 1117, 401, 283, 278, 5242, 2664, 1673, 73, 5242, 278, 297, 283, 1235, 27182, 3577, 7, 69, 401, 283, 460, 5242, 89, 936, 339, 519, 1168, 1731, 83, 14, 525, 63, 3671, 8, 498, 628, 352, 86, 2453, 401, 14617, 6415, 29, 9339, 6415, 12, 12528, 29, 15239, 12, 2490, 4349, 63, 1267, 63, 6221, 29, 1027, 63, 1267, 63, 6221, 12, 2490, 949, 324, 63, 24791, 29, 889, 324, 63, 24791, 12, 373, 11797, 83, 29, 28597, 83, 12, 2490, 8722, 63, 13982, 29, 9285, 63, 13982, 2490, 2599, 63, 13982, 628, 1662, 63, 1027, 63, 493, 14, 2424, 531, 339, 10841, 339, 961, 911, 7389, 282, 9700, 530, 1003, 7742, 1655, 298, 25677, 2, 436, 298, 4617, 2, 2637, 272, 2419, 314, 849, 1373, 14, 710, 9284, 8722, 63, 13982, 2597 ]
[ 199, 8493, 436, 704, 374, 529, 2607, 31958, 1063, 2656, 199, 199, 29704, 22042, 5914, 446, 598, 322, 693, 6900, 421, 199, 2765, 859, 365, 315, 724, 471, 370, 506, 1202, 543, 376, 18564, 15866, 2656, 334, 10180, 465, 199, 2828, 15, 82, 1190, 3045, 14, 647, 680, 2779, 32563, 314, 21255, 370, 2607, 31958, 1411, 25664, 917, 5932, 199, 262, 314, 9219, 315, 7750, 15217, 26, 199, 199, 13, 8466, 26, 710, 2637, 9330, 7890, 282, 15984, 13, 3671, 2341, 272, 370, 1263, 1329, 402, 10815, 14, 221, 710, 1059, 911, 506, 2607, 31958, 3153, 10298, 272, 641, 282, 13690, 626, 334, 2786, 12060, 9, 911, 506, 1324, 465, 282, 14609, 8095, 402, 272, 314, 2637, 2386, 778, 402, 314, 308, 19838, 436, 11647, 14, 199, 13, 644, 866, 529, 26, 710, 704, 374, 529, 9330, 911, 1999, 2033, 1183, 298, 667, 271, 734, 2, 282, 272, 704, 374, 529, 3180, 465, 4666, 378, 13, 17, 12, 2382, 314, 289, 5384, 365, 4079, 641, 1999, 2033, 1183, 272, 12881, 10189, 402, 314, 704, 374, 529, 626, 365, 334, 1961, 5824, 590, 9, 14905, 370, 272, 1806, 426, 285, 334, 509, 2893, 298, 83, 2, 20453, 83, 221, 7169, 370, 506, 10576, 328, 830, 2755, 1380, 949, 1163, 272, 11150, 883, 506, 12037, 680, 199, 199, 7692, 26, 339, 10841, 1548, 272, 687, 2755, 22042, 14, 2828, 492, 519, 1168, 1731, 83, 339, 327, 1929, 370, 506, 4224, 5403, 12, 2348, 781, 1218, 314, 298, 885, 2, 6339, 272, 519, 1168, 1731, 83, 14, 525, 63, 3671, 342, 339, 14722, 275, 298, 2765, 365, 562, 22811, 316, 2122, 272, 704, 374, 529, 275, 298, 2765, 365, 562, 704, 374, 529, 316, 14, 339, 870, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 3671, 8, 19787, 12, 2166, 29, 16, 14, 16, 9, 272, 5213, 28, 298, 2765, 365, 562, 22811, 316, 2122, 272, 870, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 3671, 8, 19787, 12, 2166, 29, 16, 14, 21, 9, 272, 5213, 28, 298, 2765, 365, 562, 701, 2753, 89, 651, 2122, 272, 870, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 3671, 8, 19787, 12, 2166, 29, 17, 14, 16, 9, 272, 5213, 28, 298, 36, 2618, 21559, 1847, 701, 2753, 89, 651, 2122, 339, 754, 275, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 87, 866, 529, 8, 87, 866, 529, 12, 2166, 29, 16, 14, 16, 9, 272, 5213, 28, 298, 2765, 365, 562, 704, 374, 529, 316, 2, 272, 754, 275, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 87, 866, 529, 8, 87, 866, 529, 12, 2166, 29, 16, 14, 18, 9, 272, 5213, 28, 298, 2765, 365, 333, 13, 704, 27474, 13, 5985, 2, 272, 754, 275, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 87, 866, 529, 8, 87, 866, 529, 12, 2166, 29, 16, 14, 21, 9, 272, 5213, 28, 298, 2595, 83, 446, 83, 1553, 10894, 83, 8648, 2, 272, 754, 275, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 87, 866, 529, 8, 87, 866, 529, 12, 2166, 29, 16, 14, 23, 9, 272, 5213, 28, 298, 375, 1553, 1553, 4143, 2, 272, 754, 275, 519, 1168, 1731, 83, 14, 2873, 31958, 1411, 63, 87, 866, 529, 8, 87, 866, 529, 12, 2166, 29, 17, 14, 16, 9, 272, 5213, 28, 298, 11500, 339, 10841, 339, 4005, 663, 1536, 892, 10815, 12, 492, 436, 675, 314, 658, 525, 63, 3671, 11995, 272, 5922, 1083, 315, 642, 859, 14, 961, 6127, 1265, 370, 17551, 314, 272, 298, 771, 352, 2, 402, 314, 18734, 13, 2355, 2637, 1265, 787, 6425, 14, 662, 22568, 272, 314, 658, 1027, 63, 1267, 63, 6221, 64, 22577, 17083, 314, 2582, 402, 14598, 272, 5932, 13524, 370, 314, 3379, 436, 883, 1720, 1570, 314, 298, 771, 352, 2, 367, 272, 314, 2637, 1265, 787, 6425, 14, 2047, 883, 2597, 1050, 2195, 5705, 272, 2600, 436, 298, 970, 2, 2196, 5932, 367, 282, 769, 402, 1324, 5932, 14, 339, 6423, 674, 365, 376, 2893, 402, 298, 352, 86, 2453, 401, 1808, 298, 293, 7138, 2, 373, 11797, 83, 436, 20453, 83, 26, 339, 10841, 1548, 272, 14617, 6415, 275, 298, 16142, 312, 72, 325, 69, 16951, 18319, 325, 72, 282, 72, 282, 79, 26936, 282, 89, 9266, 325, 89, 22182, 284, 65, 284, 72, 284, 89, 298, 971, 2049, 298, 79, 89, 18500, 399, 72, 399, 87, 612, 299, 330, 307, 366, 289, 373, 307, 31387, 308, 1315, 1033, 1315, 72, 682, 1335, 72, 1022, 298, 971, 2049, 298, 2753, 486, 333, 302, 634, 519, 336, 401, 272, 373, 11797, 83, 275, 298, 4489, 16142, 29514, 2, 272, 12528, 275, 298, 86, 373, 86, 373, 6737, 373, 2055, 373, 86, 2055, 6277, 6737, 373, 2055, 86, 373, 86, 2055, 86, 373, 5107, 2055, 86, 373, 5107, 5107, 2055, 373, 86, 2055, 8958, 2055, 298, 971, 1598, 298, 86, 5107, 86, 2055, 86, 6737, 6277, 5107, 86, 5107, 86, 2055, 373, 5107, 5107, 86, 2055, 86, 5107, 86, 401, 272, 4349, 63, 1267, 63, 6221, 275, 413, 272, 949, 324, 63, 24791, 275, 3546, 416, 2, 272, 8722, 63, 13982, 275, 2420, 1589, 5122, 89, 7, 69, 401, 298, 1129, 5122, 85, 21643, 401, 298, 19195, 5122, 19290, 401, 298, 426, 5122, 69, 2664, 401, 2079, 298, 13297, 582, 298, 1117, 401, 283, 278, 5242, 2664, 1673, 73, 5242, 278, 297, 283, 1235, 27182, 3577, 7, 69, 401, 283, 460, 5242, 89, 936, 339, 519, 1168, 1731, 83, 14, 525, 63, 3671, 8, 498, 628, 352, 86, 2453, 401, 14617, 6415, 29, 9339, 6415, 12, 12528, 29, 15239, 12, 2490, 4349, 63, 1267, 63, 6221, 29, 1027, 63, 1267, 63, 6221, 12, 2490, 949, 324, 63, 24791, 29, 889, 324, 63, 24791, 12, 373, 11797, 83, 29, 28597, 83, 12, 2490, 8722, 63, 13982, 29, 9285, 63, 13982, 2490, 2599, 63, 13982, 628, 1662, 63, 1027, 63, 493, 14, 2424, 531, 339, 10841, 339, 961, 911, 7389, 282, 9700, 530, 1003, 7742, 1655, 298, 25677, 2, 436, 298, 4617, 2, 2637, 272, 2419, 314, 849, 1373, 14, 710, 9284, 8722, 63, 13982, 2597, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MyAOSP/external_chromium_org
third_party/pymock/mock.py
424
75527
# mock.py # Test tools for mocking and patching. # Copyright (C) 2007-2012 Michael Foord & the mock team # E-mail: fuzzyman AT voidspace DOT org DOT uk # mock 1.0 # http://www.voidspace.org.uk/python/mock/ # Released subject to the BSD License # Please see http://www.voidspace.org.uk/python/license.shtml # Scripts maintained at http://www.voidspace.org.uk/python/index.shtml # Comments, suggestions and bug reports welcome. __all__ = ( 'Mock', 'MagicMock', 'patch', 'sentinel', 'DEFAULT', 'ANY', 'call', 'create_autospec', 'FILTER_DIR', 'NonCallableMock', 'NonCallableMagicMock', 'mock_open', 'PropertyMock', ) __version__ = '1.0.1' import pprint import sys try: import inspect except ImportError: # for alternative platforms that # may not have inspect inspect = None try: from functools import wraps as original_wraps except ImportError: # Python 2.4 compatibility def wraps(original): def inner(f): f.__name__ = original.__name__ f.__doc__ = original.__doc__ f.__module__ = original.__module__ f.__wrapped__ = original return f return inner else: if sys.version_info[:2] >= (3, 3): wraps = original_wraps else: def wraps(func): def inner(f): f = original_wraps(func)(f) f.__wrapped__ = func return f return inner try: unicode except NameError: # Python 3 basestring = unicode = str try: long except NameError: # Python 3 long = int try: BaseException except NameError: # Python 2.4 compatibility BaseException = Exception try: next except NameError: def next(obj): return obj.next() BaseExceptions = (BaseException,) if 'java' in sys.platform: # jython import java BaseExceptions = (BaseException, java.lang.Throwable) try: _isidentifier = str.isidentifier except AttributeError: # Python 2.X import keyword import re regex = re.compile(r'^[a-z_][a-z0-9_]*$', re.I) def _isidentifier(string): if string in keyword.kwlist: return False return regex.match(string) inPy3k = sys.version_info[0] == 3 # Needed to work around Python 3 bug where use of "super" interferes with # defining __class__ as a descriptor _super = super self = 'im_self' builtin = '__builtin__' if inPy3k: self = '__self__' builtin = 'builtins' FILTER_DIR = True def _is_instance_mock(obj): # can't use isinstance on Mock objects because they override __class__ # The base class for all mocks is NonCallableMock return issubclass(type(obj), NonCallableMock) def _is_exception(obj): return ( isinstance(obj, BaseExceptions) or isinstance(obj, ClassTypes) and issubclass(obj, BaseExceptions) ) class _slotted(object): __slots__ = ['a'] DescriptorTypes = ( type(_slotted.a), property, ) def _getsignature(func, skipfirst, instance=False): if inspect is None: raise ImportError('inspect module not available') if isinstance(func, ClassTypes) and not instance: try: func = func.__init__ except AttributeError: return skipfirst = True elif not isinstance(func, FunctionTypes): # for classes where instance is True we end up here too try: func = func.__call__ except AttributeError: return if inPy3k: try: argspec = inspect.getfullargspec(func) except TypeError: # C function / method, possibly inherited object().__init__ return regargs, varargs, varkw, defaults, kwonly, kwonlydef, ann = argspec else: try: regargs, varargs, varkwargs, defaults = inspect.getargspec(func) except TypeError: # C function / method, possibly inherited object().__init__ return # instance methods and classmethods need to lose the self argument if getattr(func, self, None) is not None: regargs = regargs[1:] if skipfirst: # this condition and the above one are never both True - why? regargs = regargs[1:] if inPy3k: signature = inspect.formatargspec( regargs, varargs, varkw, defaults, kwonly, kwonlydef, ann, formatvalue=lambda value: "") else: signature = inspect.formatargspec( regargs, varargs, varkwargs, defaults, formatvalue=lambda value: "") return signature[1:-1], func def _check_signature(func, mock, skipfirst, instance=False): if not _callable(func): return result = _getsignature(func, skipfirst, instance) if result is None: return signature, func = result # can't use self because "self" is common as an argument name # unfortunately even not in the first place src = "lambda _mock_self, %s: None" % signature checksig = eval(src, {}) _copy_func_details(func, checksig) type(mock)._mock_check_sig = checksig def _copy_func_details(func, funcopy): funcopy.__name__ = func.__name__ funcopy.__doc__ = func.__doc__ #funcopy.__dict__.update(func.__dict__) funcopy.__module__ = func.__module__ if not inPy3k: funcopy.func_defaults = func.func_defaults return funcopy.__defaults__ = func.__defaults__ funcopy.__kwdefaults__ = func.__kwdefaults__ def _callable(obj): if isinstance(obj, ClassTypes): return True if getattr(obj, '__call__', None) is not None: return True return False def _is_list(obj): # checks for list or tuples # XXXX badly named! return type(obj) in (list, tuple) def _instance_callable(obj): """Given an object, return True if the object is callable. For classes, return True if instances would be callable.""" if not isinstance(obj, ClassTypes): # already an instance return getattr(obj, '__call__', None) is not None klass = obj # uses __bases__ instead of __mro__ so that we work with old style classes if klass.__dict__.get('__call__') is not None: return True for base in klass.__bases__: if _instance_callable(base): return True return False def _set_signature(mock, original, instance=False): # creates a function with signature (*args, **kwargs) that delegates to a # mock. It still does signature checking by calling a lambda with the same # signature as the original. if not _callable(original): return skipfirst = isinstance(original, ClassTypes) result = _getsignature(original, skipfirst, instance) if result is None: # was a C function (e.g. object().__init__ ) that can't be mocked return signature, func = result src = "lambda %s: None" % signature checksig = eval(src, {}) _copy_func_details(func, checksig) name = original.__name__ if not _isidentifier(name): name = 'funcopy' context = {'_checksig_': checksig, 'mock': mock} src = """def %s(*args, **kwargs): _checksig_(*args, **kwargs) return mock(*args, **kwargs)""" % name exec (src, context) funcopy = context[name] _setup_func(funcopy, mock) return funcopy def _setup_func(funcopy, mock): funcopy.mock = mock # can't use isinstance with mocks if not _is_instance_mock(mock): return def assert_called_with(*args, **kwargs): return mock.assert_called_with(*args, **kwargs) def assert_called_once_with(*args, **kwargs): return mock.assert_called_once_with(*args, **kwargs) def assert_has_calls(*args, **kwargs): return mock.assert_has_calls(*args, **kwargs) def assert_any_call(*args, **kwargs): return mock.assert_any_call(*args, **kwargs) def reset_mock(): funcopy.method_calls = _CallList() funcopy.mock_calls = _CallList() mock.reset_mock() ret = funcopy.return_value if _is_instance_mock(ret) and not ret is mock: ret.reset_mock() funcopy.called = False funcopy.call_count = 0 funcopy.call_args = None funcopy.call_args_list = _CallList() funcopy.method_calls = _CallList() funcopy.mock_calls = _CallList() funcopy.return_value = mock.return_value funcopy.side_effect = mock.side_effect funcopy._mock_children = mock._mock_children funcopy.assert_called_with = assert_called_with funcopy.assert_called_once_with = assert_called_once_with funcopy.assert_has_calls = assert_has_calls funcopy.assert_any_call = assert_any_call funcopy.reset_mock = reset_mock mock._mock_delegate = funcopy def _is_magic(name): return '__%s__' % name[2:-2] == name class _SentinelObject(object): "A unique, named, sentinel object." def __init__(self, name): self.name = name def __repr__(self): return 'sentinel.%s' % self.name class _Sentinel(object): """Access attributes to return a named object, usable as a sentinel.""" def __init__(self): self._sentinels = {} def __getattr__(self, name): if name == '__bases__': # Without this help(mock) raises an exception raise AttributeError return self._sentinels.setdefault(name, _SentinelObject(name)) sentinel = _Sentinel() DEFAULT = sentinel.DEFAULT _missing = sentinel.MISSING _deleted = sentinel.DELETED class OldStyleClass: pass ClassType = type(OldStyleClass) def _copy(value): if type(value) in (dict, list, tuple, set): return type(value)(value) return value ClassTypes = (type,) if not inPy3k: ClassTypes = (type, ClassType) _allowed_names = set( [ 'return_value', '_mock_return_value', 'side_effect', '_mock_side_effect', '_mock_parent', '_mock_new_parent', '_mock_name', '_mock_new_name' ] ) def _delegating_property(name): _allowed_names.add(name) _the_name = '_mock_' + name def _get(self, name=name, _the_name=_the_name): sig = self._mock_delegate if sig is None: return getattr(self, _the_name) return getattr(sig, name) def _set(self, value, name=name, _the_name=_the_name): sig = self._mock_delegate if sig is None: self.__dict__[_the_name] = value else: setattr(sig, name, value) return property(_get, _set) class _CallList(list): def __contains__(self, value): if not isinstance(value, list): return list.__contains__(self, value) len_value = len(value) len_self = len(self) if len_value > len_self: return False for i in range(0, len_self - len_value + 1): sub_list = self[i:i+len_value] if sub_list == value: return True return False def __repr__(self): return pprint.pformat(list(self)) def _check_and_set_parent(parent, value, name, new_name): if not _is_instance_mock(value): return False if ((value._mock_name or value._mock_new_name) or (value._mock_parent is not None) or (value._mock_new_parent is not None)): return False _parent = parent while _parent is not None: # setting a mock (value) as a child or return value of itself # should not modify the mock if _parent is value: return False _parent = _parent._mock_new_parent if new_name: value._mock_new_parent = parent value._mock_new_name = new_name if name: value._mock_parent = parent value._mock_name = name return True class Base(object): _mock_return_value = DEFAULT _mock_side_effect = None def __init__(self, *args, **kwargs): pass class NonCallableMock(Base): """A non-callable version of `Mock`""" def __new__(cls, *args, **kw): # every instance has its own class # so we can create magic methods on the # class without stomping on other mocks new = type(cls.__name__, (cls,), {'__doc__': cls.__doc__}) instance = object.__new__(new) return instance def __init__( self, spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, **kwargs ): if _new_parent is None: _new_parent = parent __dict__ = self.__dict__ __dict__['_mock_parent'] = parent __dict__['_mock_name'] = name __dict__['_mock_new_name'] = _new_name __dict__['_mock_new_parent'] = _new_parent if spec_set is not None: spec = spec_set spec_set = True self._mock_add_spec(spec, spec_set) __dict__['_mock_children'] = {} __dict__['_mock_wraps'] = wraps __dict__['_mock_delegate'] = None __dict__['_mock_called'] = False __dict__['_mock_call_args'] = None __dict__['_mock_call_count'] = 0 __dict__['_mock_call_args_list'] = _CallList() __dict__['_mock_mock_calls'] = _CallList() __dict__['method_calls'] = _CallList() if kwargs: self.configure_mock(**kwargs) _super(NonCallableMock, self).__init__( spec, wraps, name, spec_set, parent, _spec_state ) def attach_mock(self, mock, attribute): """ Attach a mock as an attribute of this one, replacing its name and parent. Calls to the attached mock will be recorded in the `method_calls` and `mock_calls` attributes of this one.""" mock._mock_parent = None mock._mock_new_parent = None mock._mock_name = '' mock._mock_new_name = None setattr(self, attribute, mock) def mock_add_spec(self, spec, spec_set=False): """Add a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.""" self._mock_add_spec(spec, spec_set) def _mock_add_spec(self, spec, spec_set): _spec_class = None if spec is not None and not _is_list(spec): if isinstance(spec, ClassTypes): _spec_class = spec else: _spec_class = _get_class(spec) spec = dir(spec) __dict__ = self.__dict__ __dict__['_spec_class'] = _spec_class __dict__['_spec_set'] = spec_set __dict__['_mock_methods'] = spec def __get_return_value(self): ret = self._mock_return_value if self._mock_delegate is not None: ret = self._mock_delegate.return_value if ret is DEFAULT: ret = self._get_child_mock( _new_parent=self, _new_name='()' ) self.return_value = ret return ret def __set_return_value(self, value): if self._mock_delegate is not None: self._mock_delegate.return_value = value else: self._mock_return_value = value _check_and_set_parent(self, value, None, '()') __return_value_doc = "The value to be returned when the mock is called." return_value = property(__get_return_value, __set_return_value, __return_value_doc) @property def __class__(self): if self._spec_class is None: return type(self) return self._spec_class called = _delegating_property('called') call_count = _delegating_property('call_count') call_args = _delegating_property('call_args') call_args_list = _delegating_property('call_args_list') mock_calls = _delegating_property('mock_calls') def __get_side_effect(self): sig = self._mock_delegate if sig is None: return self._mock_side_effect return sig.side_effect def __set_side_effect(self, value): value = _try_iter(value) sig = self._mock_delegate if sig is None: self._mock_side_effect = value else: sig.side_effect = value side_effect = property(__get_side_effect, __set_side_effect) def reset_mock(self): "Restore the mock object to its initial state." self.called = False self.call_args = None self.call_count = 0 self.mock_calls = _CallList() self.call_args_list = _CallList() self.method_calls = _CallList() for child in self._mock_children.values(): if isinstance(child, _SpecState): continue child.reset_mock() ret = self._mock_return_value if _is_instance_mock(ret) and ret is not self: ret.reset_mock() def configure_mock(self, **kwargs): """Set attributes on the mock through keyword arguments. Attributes plus return values and side effects can be set on child mocks using standard dot notation and unpacking a dictionary in the method call: >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError} >>> mock.configure_mock(**attrs)""" for arg, val in sorted(kwargs.items(), # we sort on the number of dots so that # attributes are set before we set attributes on # attributes key=lambda entry: entry[0].count('.')): args = arg.split('.') final = args.pop() obj = self for entry in args: obj = getattr(obj, entry) setattr(obj, final, val) def __getattr__(self, name): if name == '_mock_methods': raise AttributeError(name) elif self._mock_methods is not None: if name not in self._mock_methods or name in _all_magics: raise AttributeError("Mock object has no attribute %r" % name) elif _is_magic(name): raise AttributeError(name) result = self._mock_children.get(name) if result is _deleted: raise AttributeError(name) elif result is None: wraps = None if self._mock_wraps is not None: # XXXX should we get the attribute without triggering code # execution? wraps = getattr(self._mock_wraps, name) result = self._get_child_mock( parent=self, name=name, wraps=wraps, _new_name=name, _new_parent=self ) self._mock_children[name] = result elif isinstance(result, _SpecState): result = create_autospec( result.spec, result.spec_set, result.instance, result.parent, result.name ) self._mock_children[name] = result return result def __repr__(self): _name_list = [self._mock_new_name] _parent = self._mock_new_parent last = self dot = '.' if _name_list == ['()']: dot = '' seen = set() while _parent is not None: last = _parent _name_list.append(_parent._mock_new_name + dot) dot = '.' if _parent._mock_new_name == '()': dot = '' _parent = _parent._mock_new_parent # use ids here so as not to call __hash__ on the mocks if id(_parent) in seen: break seen.add(id(_parent)) _name_list = list(reversed(_name_list)) _first = last._mock_name or 'mock' if len(_name_list) > 1: if _name_list[1] not in ('()', '().'): _first += '.' _name_list[0] = _first name = ''.join(_name_list) name_string = '' if name not in ('mock', 'mock.'): name_string = ' name=%r' % name spec_string = '' if self._spec_class is not None: spec_string = ' spec=%r' if self._spec_set: spec_string = ' spec_set=%r' spec_string = spec_string % self._spec_class.__name__ return "<%s%s%s id='%s'>" % ( type(self).__name__, name_string, spec_string, id(self) ) def __dir__(self): """Filter the output of `dir(mock)` to only useful members. XXXX """ extras = self._mock_methods or [] from_type = dir(type(self)) from_dict = list(self.__dict__) if FILTER_DIR: from_type = [e for e in from_type if not e.startswith('_')] from_dict = [e for e in from_dict if not e.startswith('_') or _is_magic(e)] return sorted(set(extras + from_type + from_dict + list(self._mock_children))) def __setattr__(self, name, value): if name in _allowed_names: # property setters go through here return object.__setattr__(self, name, value) elif (self._spec_set and self._mock_methods is not None and name not in self._mock_methods and name not in self.__dict__): raise AttributeError("Mock object has no attribute '%s'" % name) elif name in _unsupported_magics: msg = 'Attempting to set unsupported magic method %r.' % name raise AttributeError(msg) elif name in _all_magics: if self._mock_methods is not None and name not in self._mock_methods: raise AttributeError("Mock object has no attribute '%s'" % name) if not _is_instance_mock(value): setattr(type(self), name, _get_method(name, value)) original = value value = lambda *args, **kw: original(self, *args, **kw) else: # only set _new_name and not name so that mock_calls is tracked # but not method calls _check_and_set_parent(self, value, None, name) setattr(type(self), name, value) self._mock_children[name] = value elif name == '__class__': self._spec_class = value return else: if _check_and_set_parent(self, value, name, name): self._mock_children[name] = value return object.__setattr__(self, name, value) def __delattr__(self, name): if name in _all_magics and name in type(self).__dict__: delattr(type(self), name) if name not in self.__dict__: # for magic methods that are still MagicProxy objects and # not set on the instance itself return if name in self.__dict__: object.__delattr__(self, name) obj = self._mock_children.get(name, _missing) if obj is _deleted: raise AttributeError(name) if obj is not _missing: del self._mock_children[name] self._mock_children[name] = _deleted def _format_mock_call_signature(self, args, kwargs): name = self._mock_name or 'mock' return _format_call_signature(name, args, kwargs) def _format_mock_failure_message(self, args, kwargs): message = 'Expected call: %s\nActual call: %s' expected_string = self._format_mock_call_signature(args, kwargs) call_args = self.call_args if len(call_args) == 3: call_args = call_args[1:] actual_string = self._format_mock_call_signature(*call_args) return message % (expected_string, actual_string) def assert_called_with(_mock_self, *args, **kwargs): """assert that the mock was called with the specified arguments. Raises an AssertionError if the args and keyword args passed in are different to the last call to the mock.""" self = _mock_self if self.call_args is None: expected = self._format_mock_call_signature(args, kwargs) raise AssertionError('Expected call: %s\nNot called' % (expected,)) if self.call_args != (args, kwargs): msg = self._format_mock_failure_message(args, kwargs) raise AssertionError(msg) def assert_called_once_with(_mock_self, *args, **kwargs): """assert that the mock was called exactly once and with the specified arguments.""" self = _mock_self if not self.call_count == 1: msg = ("Expected to be called once. Called %s times." % self.call_count) raise AssertionError(msg) return self.assert_called_with(*args, **kwargs) def assert_has_calls(self, calls, any_order=False): """assert the mock has been called with the specified calls. The `mock_calls` list is checked for the calls. If `any_order` is False (the default) then the calls must be sequential. There can be extra calls before or after the specified calls. If `any_order` is True then the calls can be in any order, but they must all appear in `mock_calls`.""" if not any_order: if calls not in self.mock_calls: raise AssertionError( 'Calls not found.\nExpected: %r\n' 'Actual: %r' % (calls, self.mock_calls) ) return all_calls = list(self.mock_calls) not_found = [] for kall in calls: try: all_calls.remove(kall) except ValueError: not_found.append(kall) if not_found: raise AssertionError( '%r not all found in call list' % (tuple(not_found),) ) def assert_any_call(self, *args, **kwargs): """assert the mock has been called with the specified arguments. The assert passes if the mock has *ever* been called, unlike `assert_called_with` and `assert_called_once_with` that only pass if the call is the most recent one.""" kall = call(*args, **kwargs) if kall not in self.call_args_list: expected_string = self._format_mock_call_signature(args, kwargs) raise AssertionError( '%s call not found' % expected_string ) def _get_child_mock(self, **kw): """Create the child mocks for attributes and return value. By default child mocks will be the same type as the parent. Subclasses of Mock may want to override this to customize the way child mocks are made. For non-callable mocks the callable variant will be used (rather than any custom subclass).""" _type = type(self) if not issubclass(_type, CallableMixin): if issubclass(_type, NonCallableMagicMock): klass = MagicMock elif issubclass(_type, NonCallableMock) : klass = Mock else: klass = _type.__mro__[1] return klass(**kw) def _try_iter(obj): if obj is None: return obj if _is_exception(obj): return obj if _callable(obj): return obj try: return iter(obj) except TypeError: # XXXX backwards compatibility # but this will blow up on first call - so maybe we should fail early? return obj class CallableMixin(Base): def __init__(self, spec=None, side_effect=None, return_value=DEFAULT, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, **kwargs): self.__dict__['_mock_return_value'] = return_value _super(CallableMixin, self).__init__( spec, wraps, name, spec_set, parent, _spec_state, _new_name, _new_parent, **kwargs ) self.side_effect = side_effect def _mock_check_sig(self, *args, **kwargs): # stub method that can be replaced with one with a specific signature pass def __call__(_mock_self, *args, **kwargs): # can't use self in-case a function / method we are mocking uses self # in the signature _mock_self._mock_check_sig(*args, **kwargs) return _mock_self._mock_call(*args, **kwargs) def _mock_call(_mock_self, *args, **kwargs): self = _mock_self self.called = True self.call_count += 1 self.call_args = _Call((args, kwargs), two=True) self.call_args_list.append(_Call((args, kwargs), two=True)) _new_name = self._mock_new_name _new_parent = self._mock_new_parent self.mock_calls.append(_Call(('', args, kwargs))) seen = set() skip_next_dot = _new_name == '()' do_method_calls = self._mock_parent is not None name = self._mock_name while _new_parent is not None: this_mock_call = _Call((_new_name, args, kwargs)) if _new_parent._mock_new_name: dot = '.' if skip_next_dot: dot = '' skip_next_dot = False if _new_parent._mock_new_name == '()': skip_next_dot = True _new_name = _new_parent._mock_new_name + dot + _new_name if do_method_calls: if _new_name == name: this_method_call = this_mock_call else: this_method_call = _Call((name, args, kwargs)) _new_parent.method_calls.append(this_method_call) do_method_calls = _new_parent._mock_parent is not None if do_method_calls: name = _new_parent._mock_name + '.' + name _new_parent.mock_calls.append(this_mock_call) _new_parent = _new_parent._mock_new_parent # use ids here so as not to call __hash__ on the mocks _new_parent_id = id(_new_parent) if _new_parent_id in seen: break seen.add(_new_parent_id) ret_val = DEFAULT effect = self.side_effect if effect is not None: if _is_exception(effect): raise effect if not _callable(effect): result = next(effect) if _is_exception(result): raise result return result ret_val = effect(*args, **kwargs) if ret_val is DEFAULT: ret_val = self.return_value if (self._mock_wraps is not None and self._mock_return_value is DEFAULT): return self._mock_wraps(*args, **kwargs) if ret_val is DEFAULT: ret_val = self.return_value return ret_val class Mock(CallableMixin, NonCallableMock): """ Create a new `Mock` object. `Mock` takes several optional arguments that specify the behaviour of the Mock object: * `spec`: This can be either a list of strings or an existing object (a class or instance) that acts as the specification for the mock object. If you pass in an object then a list of strings is formed by calling dir on the object (excluding unsupported magic attributes and methods). Accessing any attribute not in this list will raise an `AttributeError`. If `spec` is an object (rather than a list of strings) then `mock.__class__` returns the class of the spec object. This allows mocks to pass `isinstance` tests. * `spec_set`: A stricter variant of `spec`. If used, attempting to *set* or get an attribute on the mock that isn't on the object passed as `spec_set` will raise an `AttributeError`. * `side_effect`: A function to be called whenever the Mock is called. See the `side_effect` attribute. Useful for raising exceptions or dynamically changing return values. The function is called with the same arguments as the mock, and unless it returns `DEFAULT`, the return value of this function is used as the return value. Alternatively `side_effect` can be an exception class or instance. In this case the exception will be raised when the mock is called. If `side_effect` is an iterable then each call to the mock will return the next value from the iterable. If any of the members of the iterable are exceptions they will be raised instead of returned. * `return_value`: The value returned when the mock is called. By default this is a new Mock (created on first access). See the `return_value` attribute. * `wraps`: Item for the mock object to wrap. If `wraps` is not None then calling the Mock will pass the call through to the wrapped object (returning the real result). Attribute access on the mock will return a Mock object that wraps the corresponding attribute of the wrapped object (so attempting to access an attribute that doesn't exist will raise an `AttributeError`). If the mock has an explicit `return_value` set then calls are not passed to the wrapped object and the `return_value` is returned instead. * `name`: If the mock has a name then it will be used in the repr of the mock. This can be useful for debugging. The name is propagated to child mocks. Mocks can also be called with arbitrary keyword arguments. These will be used to set attributes on the mock after it is created. """ def _dot_lookup(thing, comp, import_path): try: return getattr(thing, comp) except AttributeError: __import__(import_path) return getattr(thing, comp) def _importer(target): components = target.split('.') import_path = components.pop(0) thing = __import__(import_path) for comp in components: import_path += ".%s" % comp thing = _dot_lookup(thing, comp, import_path) return thing def _is_started(patcher): # XXXX horrible return hasattr(patcher, 'is_local') class _patch(object): attribute_name = None _active_patches = set() def __init__( self, getter, attribute, new, spec, create, spec_set, autospec, new_callable, kwargs ): if new_callable is not None: if new is not DEFAULT: raise ValueError( "Cannot use 'new' and 'new_callable' together" ) if autospec is not None: raise ValueError( "Cannot use 'autospec' and 'new_callable' together" ) self.getter = getter self.attribute = attribute self.new = new self.new_callable = new_callable self.spec = spec self.create = create self.has_local = False self.spec_set = spec_set self.autospec = autospec self.kwargs = kwargs self.additional_patchers = [] def copy(self): patcher = _patch( self.getter, self.attribute, self.new, self.spec, self.create, self.spec_set, self.autospec, self.new_callable, self.kwargs ) patcher.attribute_name = self.attribute_name patcher.additional_patchers = [ p.copy() for p in self.additional_patchers ] return patcher def __call__(self, func): if isinstance(func, ClassTypes): return self.decorate_class(func) return self.decorate_callable(func) def decorate_class(self, klass): for attr in dir(klass): if not attr.startswith(patch.TEST_PREFIX): continue attr_value = getattr(klass, attr) if not hasattr(attr_value, "__call__"): continue patcher = self.copy() setattr(klass, attr, patcher(attr_value)) return klass def decorate_callable(self, func): if hasattr(func, 'patchings'): func.patchings.append(self) return func @wraps(func) def patched(*args, **keywargs): # don't use a with here (backwards compatability with Python 2.4) extra_args = [] entered_patchers = [] # can't use try...except...finally because of Python 2.4 # compatibility exc_info = tuple() try: try: for patching in patched.patchings: arg = patching.__enter__() entered_patchers.append(patching) if patching.attribute_name is not None: keywargs.update(arg) elif patching.new is DEFAULT: extra_args.append(arg) args += tuple(extra_args) return func(*args, **keywargs) except: if (patching not in entered_patchers and _is_started(patching)): # the patcher may have been started, but an exception # raised whilst entering one of its additional_patchers entered_patchers.append(patching) # Pass the exception to __exit__ exc_info = sys.exc_info() # re-raise the exception raise finally: for patching in reversed(entered_patchers): patching.__exit__(*exc_info) patched.patchings = [self] if hasattr(func, 'func_code'): # not in Python 3 patched.compat_co_firstlineno = getattr( func, "compat_co_firstlineno", func.func_code.co_firstlineno ) return patched def get_original(self): target = self.getter() name = self.attribute original = DEFAULT local = False try: original = target.__dict__[name] except (AttributeError, KeyError): original = getattr(target, name, DEFAULT) else: local = True if not self.create and original is DEFAULT: raise AttributeError( "%s does not have the attribute %r" % (target, name) ) return original, local def __enter__(self): """Perform the patch.""" new, spec, spec_set = self.new, self.spec, self.spec_set autospec, kwargs = self.autospec, self.kwargs new_callable = self.new_callable self.target = self.getter() # normalise False to None if spec is False: spec = None if spec_set is False: spec_set = None if autospec is False: autospec = None if spec is not None and autospec is not None: raise TypeError("Can't specify spec and autospec") if ((spec is not None or autospec is not None) and spec_set not in (True, None)): raise TypeError("Can't provide explicit spec_set *and* spec or autospec") original, local = self.get_original() if new is DEFAULT and autospec is None: inherit = False if spec is True: # set spec to the object we are replacing spec = original if spec_set is True: spec_set = original spec = None elif spec is not None: if spec_set is True: spec_set = spec spec = None elif spec_set is True: spec_set = original if spec is not None or spec_set is not None: if original is DEFAULT: raise TypeError("Can't use 'spec' with create=True") if isinstance(original, ClassTypes): # If we're patching out a class and there is a spec inherit = True Klass = MagicMock _kwargs = {} if new_callable is not None: Klass = new_callable elif spec is not None or spec_set is not None: this_spec = spec if spec_set is not None: this_spec = spec_set if _is_list(this_spec): not_callable = '__call__' not in this_spec else: not_callable = not _callable(this_spec) if not_callable: Klass = NonCallableMagicMock if spec is not None: _kwargs['spec'] = spec if spec_set is not None: _kwargs['spec_set'] = spec_set # add a name to mocks if (isinstance(Klass, type) and issubclass(Klass, NonCallableMock) and self.attribute): _kwargs['name'] = self.attribute _kwargs.update(kwargs) new = Klass(**_kwargs) if inherit and _is_instance_mock(new): # we can only tell if the instance should be callable if the # spec is not a list this_spec = spec if spec_set is not None: this_spec = spec_set if (not _is_list(this_spec) and not _instance_callable(this_spec)): Klass = NonCallableMagicMock _kwargs.pop('name') new.return_value = Klass(_new_parent=new, _new_name='()', **_kwargs) elif autospec is not None: # spec is ignored, new *must* be default, spec_set is treated # as a boolean. Should we check spec is not None and that spec_set # is a bool? if new is not DEFAULT: raise TypeError( "autospec creates the mock for you. Can't specify " "autospec and new." ) if original is DEFAULT: raise TypeError("Can't use 'autospec' with create=True") spec_set = bool(spec_set) if autospec is True: autospec = original new = create_autospec(autospec, spec_set=spec_set, _name=self.attribute, **kwargs) elif kwargs: # can't set keyword args when we aren't creating the mock # XXXX If new is a Mock we could call new.configure_mock(**kwargs) raise TypeError("Can't pass kwargs to a mock we aren't creating") new_attr = new self.temp_original = original self.is_local = local setattr(self.target, self.attribute, new_attr) if self.attribute_name is not None: extra_args = {} if self.new is DEFAULT: extra_args[self.attribute_name] = new for patching in self.additional_patchers: arg = patching.__enter__() if patching.new is DEFAULT: extra_args.update(arg) return extra_args return new def __exit__(self, *exc_info): """Undo the patch.""" if not _is_started(self): raise RuntimeError('stop called on unstarted patcher') if self.is_local and self.temp_original is not DEFAULT: setattr(self.target, self.attribute, self.temp_original) else: delattr(self.target, self.attribute) if not self.create and not hasattr(self.target, self.attribute): # needed for proxy objects like django settings setattr(self.target, self.attribute, self.temp_original) del self.temp_original del self.is_local del self.target for patcher in reversed(self.additional_patchers): if _is_started(patcher): patcher.__exit__(*exc_info) def start(self): """Activate a patch, returning any created mock.""" result = self.__enter__() self._active_patches.add(self) return result def stop(self): """Stop an active patch.""" self._active_patches.discard(self) return self.__exit__() def _get_target(target): try: target, attribute = target.rsplit('.', 1) except (TypeError, ValueError): raise TypeError("Need a valid target to patch. You supplied: %r" % (target,)) getter = lambda: _importer(target) return getter, attribute def _patch_object( target, attribute, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs ): """ patch.object(target, attribute, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs) patch the named member (`attribute`) on an object (`target`) with a mock object. `patch.object` can be used as a decorator, class decorator or a context manager. Arguments `new`, `spec`, `create`, `spec_set`, `autospec` and `new_callable` have the same meaning as for `patch`. Like `patch`, `patch.object` takes arbitrary keyword arguments for configuring the mock object it creates. When used as a class decorator `patch.object` honours `patch.TEST_PREFIX` for choosing which methods to wrap. """ getter = lambda: target return _patch( getter, attribute, new, spec, create, spec_set, autospec, new_callable, kwargs ) def _patch_multiple(target, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs): """Perform multiple patches in a single call. It takes the object to be patched (either as an object or a string to fetch the object by importing) and keyword arguments for the patches:: with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'): ... Use `DEFAULT` as the value if you want `patch.multiple` to create mocks for you. In this case the created mocks are passed into a decorated function by keyword, and a dictionary is returned when `patch.multiple` is used as a context manager. `patch.multiple` can be used as a decorator, class decorator or a context manager. The arguments `spec`, `spec_set`, `create`, `autospec` and `new_callable` have the same meaning as for `patch`. These arguments will be applied to *all* patches done by `patch.multiple`. When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX` for choosing which methods to wrap. """ if type(target) in (unicode, str): getter = lambda: _importer(target) else: getter = lambda: target if not kwargs: raise ValueError( 'Must supply at least one keyword argument with patch.multiple' ) # need to wrap in a list for python 3, where items is a view items = list(kwargs.items()) attribute, new = items[0] patcher = _patch( getter, attribute, new, spec, create, spec_set, autospec, new_callable, {} ) patcher.attribute_name = attribute for attribute, new in items[1:]: this_patcher = _patch( getter, attribute, new, spec, create, spec_set, autospec, new_callable, {} ) this_patcher.attribute_name = attribute patcher.additional_patchers.append(this_patcher) return patcher def patch( target, new=DEFAULT, spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs ): """ `patch` acts as a function decorator, class decorator or a context manager. Inside the body of the function or with statement, the `target` is patched with a `new` object. When the function/with statement exits the patch is undone. If `new` is omitted, then the target is replaced with a `MagicMock`. If `patch` is used as a decorator and `new` is omitted, the created mock is passed in as an extra argument to the decorated function. If `patch` is used as a context manager the created mock is returned by the context manager. `target` should be a string in the form `'package.module.ClassName'`. The `target` is imported and the specified object replaced with the `new` object, so the `target` must be importable from the environment you are calling `patch` from. The target is imported when the decorated function is executed, not at decoration time. The `spec` and `spec_set` keyword arguments are passed to the `MagicMock` if patch is creating one for you. In addition you can pass `spec=True` or `spec_set=True`, which causes patch to pass in the object being mocked as the spec/spec_set object. `new_callable` allows you to specify a different class, or callable object, that will be called to create the `new` object. By default `MagicMock` is used. A more powerful form of `spec` is `autospec`. If you set `autospec=True` then the mock with be created with a spec from the object being replaced. All attributes of the mock will also have the spec of the corresponding attribute of the object being replaced. Methods and functions being mocked will have their arguments checked and will raise a `TypeError` if they are called with the wrong signature. For mocks replacing a class, their return value (the 'instance') will have the same spec as the class. Instead of `autospec=True` you can pass `autospec=some_object` to use an arbitrary object as the spec instead of the one being replaced. By default `patch` will fail to replace attributes that don't exist. If you pass in `create=True`, and the attribute doesn't exist, patch will create the attribute for you when the patched function is called, and delete it again afterwards. This is useful for writing tests against attributes that your production code creates at runtime. It is off by by default because it can be dangerous. With it switched on you can write passing tests against APIs that don't actually exist! Patch can be used as a `TestCase` class decorator. It works by decorating each test method in the class. This reduces the boilerplate code when your test methods share a common patchings set. `patch` finds tests by looking for method names that start with `patch.TEST_PREFIX`. By default this is `test`, which matches the way `unittest` finds tests. You can specify an alternative prefix by setting `patch.TEST_PREFIX`. Patch can be used as a context manager, with the with statement. Here the patching applies to the indented block after the with statement. If you use "as" then the patched object will be bound to the name after the "as"; very useful if `patch` is creating a mock object for you. `patch` takes arbitrary keyword arguments. These will be passed to the `Mock` (or `new_callable`) on construction. `patch.dict(...)`, `patch.multiple(...)` and `patch.object(...)` are available for alternate use-cases. """ getter, attribute = _get_target(target) return _patch( getter, attribute, new, spec, create, spec_set, autospec, new_callable, kwargs ) class _patch_dict(object): """ Patch a dictionary, or dictionary like object, and restore the dictionary to its original state after the test. `in_dict` can be a dictionary or a mapping like container. If it is a mapping then it must at least support getting, setting and deleting items plus iterating over keys. `in_dict` can also be a string specifying the name of the dictionary, which will then be fetched by importing it. `values` can be a dictionary of values to set in the dictionary. `values` can also be an iterable of `(key, value)` pairs. If `clear` is True then the dictionary will be cleared before the new values are set. `patch.dict` can also be called with arbitrary keyword arguments to set values in the dictionary:: with patch.dict('sys.modules', mymodule=Mock(), other_module=Mock()): ... `patch.dict` can be used as a context manager, decorator or class decorator. When used as a class decorator `patch.dict` honours `patch.TEST_PREFIX` for choosing which methods to wrap. """ def __init__(self, in_dict, values=(), clear=False, **kwargs): if isinstance(in_dict, basestring): in_dict = _importer(in_dict) self.in_dict = in_dict # support any argument supported by dict(...) constructor self.values = dict(values) self.values.update(kwargs) self.clear = clear self._original = None def __call__(self, f): if isinstance(f, ClassTypes): return self.decorate_class(f) @wraps(f) def _inner(*args, **kw): self._patch_dict() try: return f(*args, **kw) finally: self._unpatch_dict() return _inner def decorate_class(self, klass): for attr in dir(klass): attr_value = getattr(klass, attr) if (attr.startswith(patch.TEST_PREFIX) and hasattr(attr_value, "__call__")): decorator = _patch_dict(self.in_dict, self.values, self.clear) decorated = decorator(attr_value) setattr(klass, attr, decorated) return klass def __enter__(self): """Patch the dict.""" self._patch_dict() def _patch_dict(self): values = self.values in_dict = self.in_dict clear = self.clear try: original = in_dict.copy() except AttributeError: # dict like object with no copy method # must support iteration over keys original = {} for key in in_dict: original[key] = in_dict[key] self._original = original if clear: _clear_dict(in_dict) try: in_dict.update(values) except AttributeError: # dict like object with no update method for key in values: in_dict[key] = values[key] def _unpatch_dict(self): in_dict = self.in_dict original = self._original _clear_dict(in_dict) try: in_dict.update(original) except AttributeError: for key in original: in_dict[key] = original[key] def __exit__(self, *args): """Unpatch the dict.""" self._unpatch_dict() return False start = __enter__ stop = __exit__ def _clear_dict(in_dict): try: in_dict.clear() except AttributeError: keys = list(in_dict) for key in keys: del in_dict[key] def _patch_stopall(): """Stop all active patches.""" for patch in list(_patch._active_patches): patch.stop() patch.object = _patch_object patch.dict = _patch_dict patch.multiple = _patch_multiple patch.stopall = _patch_stopall patch.TEST_PREFIX = 'test' magic_methods = ( "lt le gt ge eq ne " "getitem setitem delitem " "len contains iter " "hash str sizeof " "enter exit " "divmod neg pos abs invert " "complex int float index " "trunc floor ceil " ) numerics = "add sub mul div floordiv mod lshift rshift and xor or pow " inplace = ' '.join('i%s' % n for n in numerics.split()) right = ' '.join('r%s' % n for n in numerics.split()) extra = '' if inPy3k: extra = 'bool next ' else: extra = 'unicode long nonzero oct hex truediv rtruediv ' # not including __prepare__, __instancecheck__, __subclasscheck__ # (as they are metaclass methods) # __del__ is not supported at all as it causes problems if it exists _non_defaults = set('__%s__' % method for method in [ 'cmp', 'getslice', 'setslice', 'coerce', 'subclasses', 'format', 'get', 'set', 'delete', 'reversed', 'missing', 'reduce', 'reduce_ex', 'getinitargs', 'getnewargs', 'getstate', 'setstate', 'getformat', 'setformat', 'repr', 'dir' ]) def _get_method(name, func): "Turns a callable object (like a mock) into a real function" def method(self, *args, **kw): return func(self, *args, **kw) method.__name__ = name return method _magics = set( '__%s__' % method for method in ' '.join([magic_methods, numerics, inplace, right, extra]).split() ) _all_magics = _magics | _non_defaults _unsupported_magics = set([ '__getattr__', '__setattr__', '__init__', '__new__', '__prepare__' '__instancecheck__', '__subclasscheck__', '__del__' ]) _calculate_return_value = { '__hash__': lambda self: object.__hash__(self), '__str__': lambda self: object.__str__(self), '__sizeof__': lambda self: object.__sizeof__(self), '__unicode__': lambda self: unicode(object.__str__(self)), } _return_values = { '__lt__': NotImplemented, '__gt__': NotImplemented, '__le__': NotImplemented, '__ge__': NotImplemented, '__int__': 1, '__contains__': False, '__len__': 0, '__exit__': False, '__complex__': 1j, '__float__': 1.0, '__bool__': True, '__nonzero__': True, '__oct__': '1', '__hex__': '0x1', '__long__': long(1), '__index__': 1, } def _get_eq(self): def __eq__(other): ret_val = self.__eq__._mock_return_value if ret_val is not DEFAULT: return ret_val return self is other return __eq__ def _get_ne(self): def __ne__(other): if self.__ne__._mock_return_value is not DEFAULT: return DEFAULT return self is not other return __ne__ def _get_iter(self): def __iter__(): ret_val = self.__iter__._mock_return_value if ret_val is DEFAULT: return iter([]) # if ret_val was already an iterator, then calling iter on it should # return the iterator unchanged return iter(ret_val) return __iter__ _side_effect_methods = { '__eq__': _get_eq, '__ne__': _get_ne, '__iter__': _get_iter, } def _set_return_value(mock, method, name): fixed = _return_values.get(name, DEFAULT) if fixed is not DEFAULT: method.return_value = fixed return return_calulator = _calculate_return_value.get(name) if return_calulator is not None: try: return_value = return_calulator(mock) except AttributeError: # XXXX why do we return AttributeError here? # set it as a side_effect instead? return_value = AttributeError(name) method.return_value = return_value return side_effector = _side_effect_methods.get(name) if side_effector is not None: method.side_effect = side_effector(mock) class MagicMixin(object): def __init__(self, *args, **kw): _super(MagicMixin, self).__init__(*args, **kw) self._mock_set_magics() def _mock_set_magics(self): these_magics = _magics if self._mock_methods is not None: these_magics = _magics.intersection(self._mock_methods) remove_magics = set() remove_magics = _magics - these_magics for entry in remove_magics: if entry in type(self).__dict__: # remove unneeded magic methods delattr(self, entry) # don't overwrite existing attributes if called a second time these_magics = these_magics - set(type(self).__dict__) _type = type(self) for entry in these_magics: setattr(_type, entry, MagicProxy(entry, self)) class NonCallableMagicMock(MagicMixin, NonCallableMock): """A version of `MagicMock` that isn't callable.""" def mock_add_spec(self, spec, spec_set=False): """Add a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.""" self._mock_add_spec(spec, spec_set) self._mock_set_magics() class MagicMock(MagicMixin, Mock): """ MagicMock is a subclass of Mock with default implementations of most of the magic methods. You can use MagicMock without having to configure the magic methods yourself. If you use the `spec` or `spec_set` arguments then *only* magic methods that exist in the spec will be created. Attributes and the return value of a `MagicMock` will also be `MagicMocks`. """ def mock_add_spec(self, spec, spec_set=False): """Add a spec to a mock. `spec` can either be an object or a list of strings. Only attributes on the `spec` can be fetched as attributes from the mock. If `spec_set` is True then only attributes on the spec can be set.""" self._mock_add_spec(spec, spec_set) self._mock_set_magics() class MagicProxy(object): def __init__(self, name, parent): self.name = name self.parent = parent def __call__(self, *args, **kwargs): m = self.create_mock() return m(*args, **kwargs) def create_mock(self): entry = self.name parent = self.parent m = parent._get_child_mock(name=entry, _new_name=entry, _new_parent=parent) setattr(parent, entry, m) _set_return_value(parent, m, entry) return m def __get__(self, obj, _type=None): return self.create_mock() class _ANY(object): "A helper object that compares equal to everything." def __eq__(self, other): return True def __ne__(self, other): return False def __repr__(self): return '<ANY>' ANY = _ANY() def _format_call_signature(name, args, kwargs): message = '%s(%%s)' % name formatted_args = '' args_string = ', '.join([repr(arg) for arg in args]) kwargs_string = ', '.join([ '%s=%r' % (key, value) for key, value in kwargs.items() ]) if args_string: formatted_args = args_string if kwargs_string: if formatted_args: formatted_args += ', ' formatted_args += kwargs_string return message % formatted_args class _Call(tuple): """ A tuple for holding the results of a call to a mock, either in the form `(args, kwargs)` or `(name, args, kwargs)`. If args or kwargs are empty then a call tuple will compare equal to a tuple without those values. This makes comparisons less verbose:: _Call(('name', (), {})) == ('name',) _Call(('name', (1,), {})) == ('name', (1,)) _Call(((), {'a': 'b'})) == ({'a': 'b'},) The `_Call` object provides a useful shortcut for comparing with call:: _Call(((1, 2), {'a': 3})) == call(1, 2, a=3) _Call(('foo', (1, 2), {'a': 3})) == call.foo(1, 2, a=3) If the _Call has no name then it will match any name. """ def __new__(cls, value=(), name=None, parent=None, two=False, from_kall=True): name = '' args = () kwargs = {} _len = len(value) if _len == 3: name, args, kwargs = value elif _len == 2: first, second = value if isinstance(first, basestring): name = first if isinstance(second, tuple): args = second else: kwargs = second else: args, kwargs = first, second elif _len == 1: value, = value if isinstance(value, basestring): name = value elif isinstance(value, tuple): args = value else: kwargs = value if two: return tuple.__new__(cls, (args, kwargs)) return tuple.__new__(cls, (name, args, kwargs)) def __init__(self, value=(), name=None, parent=None, two=False, from_kall=True): self.name = name self.parent = parent self.from_kall = from_kall def __eq__(self, other): if other is ANY: return True try: len_other = len(other) except TypeError: return False self_name = '' if len(self) == 2: self_args, self_kwargs = self else: self_name, self_args, self_kwargs = self other_name = '' if len_other == 0: other_args, other_kwargs = (), {} elif len_other == 3: other_name, other_args, other_kwargs = other elif len_other == 1: value, = other if isinstance(value, tuple): other_args = value other_kwargs = {} elif isinstance(value, basestring): other_name = value other_args, other_kwargs = (), {} else: other_args = () other_kwargs = value else: # len 2 # could be (name, args) or (name, kwargs) or (args, kwargs) first, second = other if isinstance(first, basestring): other_name = first if isinstance(second, tuple): other_args, other_kwargs = second, {} else: other_args, other_kwargs = (), second else: other_args, other_kwargs = first, second if self_name and other_name != self_name: return False # this order is important for ANY to work! return (other_args, other_kwargs) == (self_args, self_kwargs) def __ne__(self, other): return not self.__eq__(other) def __call__(self, *args, **kwargs): if self.name is None: return _Call(('', args, kwargs), name='()') name = self.name + '()' return _Call((self.name, args, kwargs), name=name, parent=self) def __getattr__(self, attr): if self.name is None: return _Call(name=attr, from_kall=False) name = '%s.%s' % (self.name, attr) return _Call(name=name, parent=self, from_kall=False) def __repr__(self): if not self.from_kall: name = self.name or 'call' if name.startswith('()'): name = 'call%s' % name return name if len(self) == 2: name = 'call' args, kwargs = self else: name, args, kwargs = self if not name: name = 'call' elif not name.startswith('()'): name = 'call.%s' % name else: name = 'call%s' % name return _format_call_signature(name, args, kwargs) def call_list(self): """For a call object that represents multiple calls, `call_list` returns a list of all the intermediate calls as well as the final call.""" vals = [] thing = self while thing is not None: if thing.from_kall: vals.append(thing) thing = thing.parent return _CallList(reversed(vals)) call = _Call(from_kall=False) def create_autospec(spec, spec_set=False, instance=False, _parent=None, _name=None, **kwargs): """Create a mock object using another object as a spec. Attributes on the mock will use the corresponding attribute on the `spec` object as their spec. Functions or methods being mocked will have their arguments checked to check that they are called with the correct signature. If `spec_set` is True then attempting to set attributes that don't exist on the spec object will raise an `AttributeError`. If a class is used as a spec then the return value of the mock (the instance of the class) will have the same spec. You can use a class as the spec for an instance object by passing `instance=True`. The returned mock will only be callable if instances of the mock are callable. `create_autospec` also takes arbitrary keyword arguments that are passed to the constructor of the created mock.""" if _is_list(spec): # can't pass a list instance to the mock constructor as it will be # interpreted as a list of strings spec = type(spec) is_type = isinstance(spec, ClassTypes) _kwargs = {'spec': spec} if spec_set: _kwargs = {'spec_set': spec} elif spec is None: # None we mock with a normal mock without a spec _kwargs = {} _kwargs.update(kwargs) Klass = MagicMock if type(spec) in DescriptorTypes: # descriptors don't have a spec # because we don't know what type they return _kwargs = {} elif not _callable(spec): Klass = NonCallableMagicMock elif is_type and instance and not _instance_callable(spec): Klass = NonCallableMagicMock _new_name = _name if _parent is None: # for a top level object no _new_name should be set _new_name = '' mock = Klass(parent=_parent, _new_parent=_parent, _new_name=_new_name, name=_name, **_kwargs) if isinstance(spec, FunctionTypes): # should only happen at the top level because we don't # recurse for functions mock = _set_signature(mock, spec) else: _check_signature(spec, mock, is_type, instance) if _parent is not None and not instance: _parent._mock_children[_name] = mock if is_type and not instance and 'return_value' not in kwargs: mock.return_value = create_autospec(spec, spec_set, instance=True, _name='()', _parent=mock) for entry in dir(spec): if _is_magic(entry): # MagicMock already does the useful magic methods for us continue if isinstance(spec, FunctionTypes) and entry in FunctionAttributes: # allow a mock to actually be a function continue # XXXX do we need a better way of getting attributes without # triggering code execution (?) Probably not - we need the actual # object to mock it so we would rather trigger a property than mock # the property descriptor. Likewise we want to mock out dynamically # provided attributes. # XXXX what about attributes that raise exceptions other than # AttributeError on being fetched? # we could be resilient against it, or catch and propagate the # exception when the attribute is fetched from the mock try: original = getattr(spec, entry) except AttributeError: continue kwargs = {'spec': original} if spec_set: kwargs = {'spec_set': original} if not isinstance(original, FunctionTypes): new = _SpecState(original, spec_set, mock, entry, instance) mock._mock_children[entry] = new else: parent = mock if isinstance(spec, FunctionTypes): parent = mock.mock new = MagicMock(parent=parent, name=entry, _new_name=entry, _new_parent=parent, **kwargs) mock._mock_children[entry] = new skipfirst = _must_skip(spec, entry, is_type) _check_signature(original, new, skipfirst=skipfirst) # so functions created with _set_signature become instance attributes, # *plus* their underlying mock exists in _mock_children of the parent # mock. Adding to _mock_children may be unnecessary where we are also # setting as an instance attribute? if isinstance(new, FunctionTypes): setattr(mock, entry, new) return mock def _must_skip(spec, entry, is_type): if not isinstance(spec, ClassTypes): if entry in getattr(spec, '__dict__', {}): # instance attribute - shouldn't skip return False spec = spec.__class__ if not hasattr(spec, '__mro__'): # old style class: can't have descriptors anyway return is_type for klass in spec.__mro__: result = klass.__dict__.get(entry, DEFAULT) if result is DEFAULT: continue if isinstance(result, (staticmethod, classmethod)): return False return is_type # shouldn't get here unless function is a dynamically provided attribute # XXXX untested behaviour return is_type def _get_class(obj): try: return obj.__class__ except AttributeError: # in Python 2, _sre.SRE_Pattern objects have no __class__ return type(obj) class _SpecState(object): def __init__(self, spec, spec_set=False, parent=None, name=None, ids=None, instance=False): self.spec = spec self.ids = ids self.spec_set = spec_set self.parent = parent self.instance = instance self.name = name FunctionTypes = ( # python function type(create_autospec), # instance method type(ANY.__eq__), # unbound method type(_ANY.__eq__), ) FunctionAttributes = set([ 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name', ]) file_spec = None def mock_open(mock=None, read_data=''): """ A helper function to create a mock to replace the use of `open`. It works for `open` called directly or used as a context manager. The `mock` argument is the mock object to configure. If `None` (the default) then a `MagicMock` will be created for you, with the API limited to methods or attributes available on standard file handles. `read_data` is a string for the `read` method of the file handle to return. This is an empty string by default. """ global file_spec if file_spec is None: # set on first use if inPy3k: import _io file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))) else: file_spec = file if mock is None: mock = MagicMock(name='open', spec=open) handle = MagicMock(spec=file_spec) handle.write.return_value = None handle.__enter__.return_value = handle handle.read.return_value = read_data mock.return_value = handle return mock class PropertyMock(Mock): """ A mock intended to be used as a property, or other descriptor, on a class. `PropertyMock` provides `__get__` and `__set__` methods so you can specify a return value when it is fetched. Fetching a `PropertyMock` instance from an object calls the mock, with no args. Setting it calls the mock with the value being set. """ def _get_child_mock(self, **kwargs): return MagicMock(**kwargs) def __get__(self, obj, obj_type): return self() def __set__(self, obj, val): self(val)
bsd-3-clause
[ 3, 1683, 14, 647, 199, 3, 1379, 7249, 367, 1683, 316, 436, 3371, 316, 14, 199, 3, 1898, 334, 35, 9, 10219, 13, 7409, 16922, 481, 79, 2181, 1253, 314, 1683, 8099, 199, 3, 662, 13, 1198, 26, 24101, 1237, 15059, 2309, 2638, 15854, 5981, 15854, 399, 75, 199, 199, 3, 1683, 413, 14, 16, 199, 3, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1805, 15, 199, 199, 3, 17646, 68, 5420, 370, 314, 6289, 844, 199, 3, 7754, 1937, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1682, 14, 83, 1360, 199, 199, 3, 14914, 83, 26391, 737, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1080, 14, 83, 1360, 199, 3, 5429, 1470, 12, 18453, 15293, 436, 6519, 13924, 336, 14628, 14, 421, 199, 363, 452, 363, 275, 334, 272, 283, 3346, 297, 272, 283, 11988, 297, 272, 283, 2068, 297, 272, 283, 13400, 297, 272, 283, 3472, 297, 272, 283, 8974, 297, 272, 283, 1250, 297, 272, 283, 981, 63, 22303, 297, 272, 283, 9905, 63, 3022, 297, 272, 283, 6932, 16410, 3346, 297, 272, 283, 6932, 16410, 11988, 297, 272, 283, 1805, 63, 1490, 297, 272, 283, 3697, 3346, 297, 199, 9, 421, 199, 363, 1023, 363, 275, 283, 17, 14, 16, 14, 17, 7, 421, 199, 646, 10933, 199, 646, 984, 199, 199, 893, 26, 272, 492, 6485, 199, 2590, 3545, 26, 272, 327, 367, 13943, 10677, 626, 272, 327, 1443, 440, 1172, 6485, 272, 6485, 275, 488, 199, 199, 893, 26, 272, 687, 9143, 492, 14018, 465, 3379, 63, 13582, 199, 2590, 3545, 26, 272, 327, 2018, 499, 14, 20, 7163, 272, 347, 14018, 8, 5043, 304, 267, 347, 6506, 8, 70, 304, 288, 289, 855, 354, 363, 275, 3379, 855, 354, 363, 288, 289, 855, 1301, 363, 275, 3379, 855, 1301, 363, 288, 289, 855, 578, 363, 275, 3379, 855, 578, 363, 288, 289, 855, 9130, 363, 275, 3379, 288, 372, 289, 267, 372, 6506, 199, 2836, 26, 272, 340, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 650, 304, 267, 14018, 275, 3379, 63, 13582, 272, 587, 26, 267, 347, 14018, 8, 1532, 304, 288, 347, 6506, 8, 70, 304, 355, 289, 275, 3379, 63, 13582, 8, 1532, 5130, 70, 9, 355, 289, 855, 9130, 363, 275, 2562, 355, 372, 289, 288, 372, 6506, 199, 199, 893, 26, 272, 2649, 199, 2590, 12746, 26, 272, 327, 2018, 650, 272, 7116, 275, 2649, 275, 620, 199, 199, 893, 26, 272, 1846, 199, 2590, 12746, 26, 272, 327, 2018, 650, 272, 1846, 275, 1109, 199, 199, 893, 26, 272, 25416, 199, 2590, 12746, 26, 272, 327, 2018, 499, 14, 20, 7163, 272, 25416, 275, 2186, 199, 199, 893, 26, 272, 2163, 199, 2590, 12746, 26, 272, 347, 2163, 8, 1113, 304, 267, 372, 1559, 14, 2184, 342, 421, 199, 1563, 16836, 275, 334, 29900, 4258, 199, 692, 283, 6138, 7, 315, 984, 14, 3246, 26, 272, 327, 1335, 11361, 272, 492, 12120, 272, 3523, 16836, 275, 334, 29900, 12, 12120, 14, 4159, 14, 2719, 1143, 461, 9, 199, 199, 893, 26, 272, 485, 29022, 2841, 275, 620, 14, 29022, 2841, 199, 2590, 4281, 26, 272, 327, 2018, 499, 14, 56, 272, 492, 4252, 272, 492, 295, 272, 5163, 275, 295, 14, 2014, 8, 82, 23811, 65, 13, 90, 17900, 65, 13, 90, 16, 13, 25, 15555, 4268, 295, 14, 41, 9, 272, 347, 485, 29022, 2841, 8, 875, 304, 267, 340, 1059, 315, 4252, 14, 829, 513, 26, 288, 372, 756, 267, 372, 5163, 14, 1431, 8, 875, 9, 421, 199, 262, 2713, 19, 75, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 199, 199, 3, 28196, 370, 1736, 6818, 2018, 650, 6519, 2382, 675, 402, 298, 4792, 2, 1640, 771, 470, 543, 199, 3, 12669, 636, 533, 363, 465, 282, 5872, 199, 63, 4792, 275, 1613, 199, 199, 277, 275, 283, 1017, 63, 277, 7, 199, 5351, 275, 2560, 5351, 12217, 199, 692, 315, 2713, 19, 75, 26, 272, 291, 275, 2560, 277, 12217, 272, 6762, 275, 283, 10372, 7, 199, 199, 9905, 63, 3022, 275, 715, 421, 199, 318, 485, 374, 63, 842, 63, 1805, 8, 1113, 304, 272, 327, 883, 1133, 675, 1228, 641, 4420, 2251, 2952, 2985, 4278, 636, 533, 363, 272, 327, 710, 1300, 1021, 367, 1006, 26500, 365, 10172, 16410, 3346, 272, 372, 11602, 8, 466, 8, 1113, 395, 10172, 16410, 3346, 9, 421, 199, 318, 485, 374, 63, 1971, 8, 1113, 304, 272, 372, 334, 267, 1228, 8, 1113, 12, 3523, 16836, 9, 503, 267, 1228, 8, 1113, 12, 8089, 4100, 9, 436, 11602, 8, 1113, 12, 3523, 16836, 9, 272, 776, 421, 199, 533, 485, 7998, 471, 8, 785, 304, 272, 636, 7257, 363, 275, 788, 65, 418, 421, 199, 4311, 4100, 275, 334, 272, 730, 1547, 7998, 471, 14, 65, 395, 272, 3324, 12, 199, 9, 421, 199, 318, 485, 362, 5233, 8, 1532, 12, 3372, 2246, 12, 1256, 29, 797, 304, 272, 340, 6485, 365, 488, 26, 267, 746, 3545, 360, 10955, 859, 440, 2808, 358, 339, 340, 1228, 8, 1532, 12, 8089, 4100, 9, 436, 440, 1256, 26, 267, 862, 26, 288, 2562, 275, 2562, 855, 826, 363, 267, 871, 4281, 26, 288, 372, 267, 3372, 2246, 275, 715, 272, 916, 440, 1228, 8, 1532, 12, 6801, 4100, 304, 267, 327, 367, 3992, 2382, 1256, 365, 715, 781, 1284, 1536, 2348, 4634, 267, 862, 26, 288, 2562, 275, 2562, 855, 1250, 363, 267, 871, 4281, 26, 288, 372, 339, 340, 315, 2713, 19, 75, 26, 267, 862, 26, 288, 26632, 275, 6485, 14, 362, 2861, 15644, 8, 1532, 9, 267, 871, 3146, 26, 288, 327, 445, 805, 1182, 1083, 12, 12570, 12623, 909, 11027, 826, 363, 288, 372, 267, 1295, 589, 12, 23377, 12, 27835, 12, 4243, 12, 32635, 12, 32635, 318, 12, 21172, 275, 26632, 272, 587, 26, 267, 862, 26, 288, 1295, 589, 12, 23377, 12, 2729, 958, 12, 4243, 275, 6485, 14, 29836, 8, 1532, 9, 267, 871, 3146, 26, 288, 327, 445, 805, 1182, 1083, 12, 12570, 12623, 909, 11027 ]
[ 1683, 14, 647, 199, 3, 1379, 7249, 367, 1683, 316, 436, 3371, 316, 14, 199, 3, 1898, 334, 35, 9, 10219, 13, 7409, 16922, 481, 79, 2181, 1253, 314, 1683, 8099, 199, 3, 662, 13, 1198, 26, 24101, 1237, 15059, 2309, 2638, 15854, 5981, 15854, 399, 75, 199, 199, 3, 1683, 413, 14, 16, 199, 3, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1805, 15, 199, 199, 3, 17646, 68, 5420, 370, 314, 6289, 844, 199, 3, 7754, 1937, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1682, 14, 83, 1360, 199, 199, 3, 14914, 83, 26391, 737, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1080, 14, 83, 1360, 199, 3, 5429, 1470, 12, 18453, 15293, 436, 6519, 13924, 336, 14628, 14, 421, 199, 363, 452, 363, 275, 334, 272, 283, 3346, 297, 272, 283, 11988, 297, 272, 283, 2068, 297, 272, 283, 13400, 297, 272, 283, 3472, 297, 272, 283, 8974, 297, 272, 283, 1250, 297, 272, 283, 981, 63, 22303, 297, 272, 283, 9905, 63, 3022, 297, 272, 283, 6932, 16410, 3346, 297, 272, 283, 6932, 16410, 11988, 297, 272, 283, 1805, 63, 1490, 297, 272, 283, 3697, 3346, 297, 199, 9, 421, 199, 363, 1023, 363, 275, 283, 17, 14, 16, 14, 17, 7, 421, 199, 646, 10933, 199, 646, 984, 199, 199, 893, 26, 272, 492, 6485, 199, 2590, 3545, 26, 272, 327, 367, 13943, 10677, 626, 272, 327, 1443, 440, 1172, 6485, 272, 6485, 275, 488, 199, 199, 893, 26, 272, 687, 9143, 492, 14018, 465, 3379, 63, 13582, 199, 2590, 3545, 26, 272, 327, 2018, 499, 14, 20, 7163, 272, 347, 14018, 8, 5043, 304, 267, 347, 6506, 8, 70, 304, 288, 289, 855, 354, 363, 275, 3379, 855, 354, 363, 288, 289, 855, 1301, 363, 275, 3379, 855, 1301, 363, 288, 289, 855, 578, 363, 275, 3379, 855, 578, 363, 288, 289, 855, 9130, 363, 275, 3379, 288, 372, 289, 267, 372, 6506, 199, 2836, 26, 272, 340, 984, 14, 1023, 63, 815, 1491, 18, 61, 2356, 334, 19, 12, 650, 304, 267, 14018, 275, 3379, 63, 13582, 272, 587, 26, 267, 347, 14018, 8, 1532, 304, 288, 347, 6506, 8, 70, 304, 355, 289, 275, 3379, 63, 13582, 8, 1532, 5130, 70, 9, 355, 289, 855, 9130, 363, 275, 2562, 355, 372, 289, 288, 372, 6506, 199, 199, 893, 26, 272, 2649, 199, 2590, 12746, 26, 272, 327, 2018, 650, 272, 7116, 275, 2649, 275, 620, 199, 199, 893, 26, 272, 1846, 199, 2590, 12746, 26, 272, 327, 2018, 650, 272, 1846, 275, 1109, 199, 199, 893, 26, 272, 25416, 199, 2590, 12746, 26, 272, 327, 2018, 499, 14, 20, 7163, 272, 25416, 275, 2186, 199, 199, 893, 26, 272, 2163, 199, 2590, 12746, 26, 272, 347, 2163, 8, 1113, 304, 267, 372, 1559, 14, 2184, 342, 421, 199, 1563, 16836, 275, 334, 29900, 4258, 199, 692, 283, 6138, 7, 315, 984, 14, 3246, 26, 272, 327, 1335, 11361, 272, 492, 12120, 272, 3523, 16836, 275, 334, 29900, 12, 12120, 14, 4159, 14, 2719, 1143, 461, 9, 199, 199, 893, 26, 272, 485, 29022, 2841, 275, 620, 14, 29022, 2841, 199, 2590, 4281, 26, 272, 327, 2018, 499, 14, 56, 272, 492, 4252, 272, 492, 295, 272, 5163, 275, 295, 14, 2014, 8, 82, 23811, 65, 13, 90, 17900, 65, 13, 90, 16, 13, 25, 15555, 4268, 295, 14, 41, 9, 272, 347, 485, 29022, 2841, 8, 875, 304, 267, 340, 1059, 315, 4252, 14, 829, 513, 26, 288, 372, 756, 267, 372, 5163, 14, 1431, 8, 875, 9, 421, 199, 262, 2713, 19, 75, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 199, 199, 3, 28196, 370, 1736, 6818, 2018, 650, 6519, 2382, 675, 402, 298, 4792, 2, 1640, 771, 470, 543, 199, 3, 12669, 636, 533, 363, 465, 282, 5872, 199, 63, 4792, 275, 1613, 199, 199, 277, 275, 283, 1017, 63, 277, 7, 199, 5351, 275, 2560, 5351, 12217, 199, 692, 315, 2713, 19, 75, 26, 272, 291, 275, 2560, 277, 12217, 272, 6762, 275, 283, 10372, 7, 199, 199, 9905, 63, 3022, 275, 715, 421, 199, 318, 485, 374, 63, 842, 63, 1805, 8, 1113, 304, 272, 327, 883, 1133, 675, 1228, 641, 4420, 2251, 2952, 2985, 4278, 636, 533, 363, 272, 327, 710, 1300, 1021, 367, 1006, 26500, 365, 10172, 16410, 3346, 272, 372, 11602, 8, 466, 8, 1113, 395, 10172, 16410, 3346, 9, 421, 199, 318, 485, 374, 63, 1971, 8, 1113, 304, 272, 372, 334, 267, 1228, 8, 1113, 12, 3523, 16836, 9, 503, 267, 1228, 8, 1113, 12, 8089, 4100, 9, 436, 11602, 8, 1113, 12, 3523, 16836, 9, 272, 776, 421, 199, 533, 485, 7998, 471, 8, 785, 304, 272, 636, 7257, 363, 275, 788, 65, 418, 421, 199, 4311, 4100, 275, 334, 272, 730, 1547, 7998, 471, 14, 65, 395, 272, 3324, 12, 199, 9, 421, 199, 318, 485, 362, 5233, 8, 1532, 12, 3372, 2246, 12, 1256, 29, 797, 304, 272, 340, 6485, 365, 488, 26, 267, 746, 3545, 360, 10955, 859, 440, 2808, 358, 339, 340, 1228, 8, 1532, 12, 8089, 4100, 9, 436, 440, 1256, 26, 267, 862, 26, 288, 2562, 275, 2562, 855, 826, 363, 267, 871, 4281, 26, 288, 372, 267, 3372, 2246, 275, 715, 272, 916, 440, 1228, 8, 1532, 12, 6801, 4100, 304, 267, 327, 367, 3992, 2382, 1256, 365, 715, 781, 1284, 1536, 2348, 4634, 267, 862, 26, 288, 2562, 275, 2562, 855, 1250, 363, 267, 871, 4281, 26, 288, 372, 339, 340, 315, 2713, 19, 75, 26, 267, 862, 26, 288, 26632, 275, 6485, 14, 362, 2861, 15644, 8, 1532, 9, 267, 871, 3146, 26, 288, 327, 445, 805, 1182, 1083, 12, 12570, 12623, 909, 11027, 826, 363, 288, 372, 267, 1295, 589, 12, 23377, 12, 27835, 12, 4243, 12, 32635, 12, 32635, 318, 12, 21172, 275, 26632, 272, 587, 26, 267, 862, 26, 288, 1295, 589, 12, 23377, 12, 2729, 958, 12, 4243, 275, 6485, 14, 29836, 8,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
koceg/gouda
gouda/engines/datasymbol.py
1
2801
import os import tempfile import cv2 try: from win32com import client as com from win32com.client import constants as c import win32api except ImportError: com = win32api = c = None from gouda.barcode import Barcode from gouda.gouda_error import GoudaError from gouda.util import debug_print, is_clsid_registered class DataSymbolEngine(object): """Decode using the DataSymbol's BarcodeReader SDK BarcodeReader can decode many types of barcodes - currently using it just for Data Matrix and Code 128 + Code 129 """ CLSID = "BarcodeReader.BarcodeDecoder" def __init__(self, datamatrix, n_barcodes=None): if not self.available(): raise GoudaError('Data Symbol unavailable') else: com.pythoncom.CoInitialize() # Tip from stackoverflow about how to access COM constants # http://stackoverflow.com/a/21534997/1773758 self.d = com.gencache.EnsureDispatch(self.CLSID) if datamatrix: self.d.BarcodeTypes = c.DataMatrix else: self.d.BarcodeTypes = c.Code128 | c.Code39 if n_barcodes is None: n_barcodes = 1 if datamatrix else 10 self.d.LinearFindBarcodes = n_barcodes # Map values in EBarcodeTypes to text # This should be a class member but the enumeration is visible only # after the call to EnsureDispatch. self.types = { c.Code128 : 'Code 128', c.Code39 : 'Code 39', c.Interl25 : 'Interleaved 2 of 5', c.EAN13 : 'EAN-13', c.EAN8 : 'EAN-8', c.Codabar : 'Codabar', c.Code11 : 'Code 11', c.UPCA : 'UPC-A', c.UPCE : 'UPC-E', c.DataMatrix : 'Data Matrix', } @classmethod def available(cls): return com is not None and is_clsid_registered(cls.CLSID) def decode_file(self, path): # DecodeStream? self.d.DecodeFile(str(path)) res = [None] * self.d.Barcodes.length for i in range(0, self.d.Barcodes.length): b = self.d.Barcodes.item(i) res[i] = Barcode(self.types.get(b.BarcodeType, 'Unknown'), b.Text) return res def __call__(self, img): # Temporary files on Windows are pain img_temp = tempfile.NamedTemporaryFile(suffix='.png', delete=False) try: debug_print('Writing temp file [{0}] for Data Symbol'.format(img_temp.name)) cv2.imwrite(img_temp.name, img) img_temp.close() return self.decode_file(img_temp.name) finally: os.unlink(img_temp.name)
gpl-2.0
[ 646, 747, 199, 646, 5549, 199, 199, 646, 6277, 18, 199, 199, 893, 26, 272, 687, 4747, 708, 957, 492, 1890, 465, 2414, 272, 687, 4747, 708, 957, 14, 1258, 492, 5262, 465, 286, 272, 492, 4747, 708, 1246, 199, 2590, 3545, 26, 272, 2414, 275, 4747, 708, 1246, 275, 286, 275, 488, 199, 199, 504, 486, 810, 983, 14, 22091, 492, 12377, 600, 199, 504, 486, 810, 983, 14, 71, 810, 983, 63, 705, 492, 598, 810, 983, 547, 199, 504, 486, 810, 983, 14, 1974, 492, 3105, 63, 1361, 12, 365, 63, 429, 4148, 63, 11616, 421, 199, 533, 3918, 8169, 8524, 8, 785, 304, 272, 408, 9400, 1808, 314, 3918, 8169, 1159, 12377, 600, 5929, 15610, 339, 12377, 600, 5929, 883, 4849, 5002, 2943, 402, 4681, 6021, 446, 5544, 1808, 652, 2951, 272, 367, 3918, 8449, 436, 5495, 7960, 435, 5495, 25454, 272, 408, 339, 445, 5296, 998, 275, 298, 5281, 600, 5929, 14, 5281, 600, 8326, 2, 339, 347, 636, 826, 721, 277, 12, 666, 3642, 12, 302, 63, 1700, 6021, 29, 403, 304, 267, 340, 440, 291, 14, 4561, 837, 288, 746, 598, 810, 983, 547, 360, 1451, 10080, 18735, 358, 267, 587, 26, 288, 2414, 14, 1548, 957, 14, 967, 9345, 342, 953, 327, 377, 711, 687, 3464, 14108, 3595, 4212, 370, 2879, 18877, 5262, 288, 327, 1455, 921, 23153, 14, 957, 15, 65, 15, 7842, 1082, 13218, 15, 8881, 1401, 2010, 288, 291, 14, 68, 275, 2414, 14, 2268, 1637, 14, 13913, 20628, 8, 277, 14, 1981, 19514, 9, 953, 340, 666, 3642, 26, 355, 291, 14, 68, 14, 5281, 600, 4100, 275, 286, 14, 1451, 6443, 288, 587, 26, 355, 291, 14, 68, 14, 5281, 600, 4100, 275, 286, 14, 3034, 3933, 1204, 286, 14, 3034, 1355, 953, 340, 302, 63, 1700, 6021, 365, 488, 26, 355, 302, 63, 1700, 6021, 275, 413, 340, 666, 3642, 587, 1616, 288, 291, 14, 68, 14, 10608, 6591, 5281, 6021, 275, 302, 63, 1700, 6021, 398, 327, 9672, 1338, 315, 662, 5281, 600, 4100, 370, 1318, 267, 327, 961, 1077, 506, 282, 1021, 3653, 1325, 314, 28640, 365, 8917, 1454, 267, 327, 2410, 314, 1240, 370, 7523, 20628, 14, 267, 291, 14, 1313, 275, 469, 286, 14, 3034, 3933, 520, 283, 3034, 7960, 297, 2432, 286, 14, 3034, 1355, 520, 283, 3034, 10551, 297, 2432, 286, 14, 2620, 76, 821, 520, 283, 2620, 274, 4292, 499, 402, 959, 297, 2432, 286, 14, 37, 879, 969, 520, 283, 37, 879, 13, 969, 297, 2432, 286, 14, 37, 879, 24, 520, 283, 37, 879, 13, 24, 297, 2432, 286, 14, 35, 364, 371, 285, 520, 283, 35, 364, 371, 285, 297, 2432, 286, 14, 3034, 845, 520, 283, 3034, 4119, 297, 2432, 286, 14, 2160, 3263, 520, 283, 2160, 35, 13, 33, 297, 2432, 286, 14, 2160, 2089, 520, 283, 2160, 35, 13, 37, 297, 2432, 286, 14, 1451, 6443, 520, 283, 1451, 8449, 297, 2151, 789, 339, 768, 3744, 272, 347, 2808, 8, 1886, 304, 267, 372, 2414, 365, 440, 488, 436, 365, 63, 429, 4148, 63, 11616, 8, 1886, 14, 1981, 19514, 9, 339, 347, 4849, 63, 493, 8, 277, 12, 931, 304, 267, 327, 22462, 3296, 31, 267, 291, 14, 68, 14, 9400, 1173, 8, 495, 8, 515, 430, 267, 522, 275, 359, 403, 61, 627, 291, 14, 68, 14, 5281, 6021, 14, 1267, 267, 367, 284, 315, 1425, 8, 16, 12, 291, 14, 68, 14, 5281, 6021, 14, 1267, 304, 288, 330, 275, 291, 14, 68, 14, 5281, 6021, 14, 1053, 8, 73, 9, 288, 522, 59, 73, 61, 275, 12377, 600, 8, 277, 14, 1313, 14, 362, 8, 66, 14, 5281, 600, 804, 12, 283, 5912, 659, 330, 14, 1872, 9, 267, 372, 522, 339, 347, 636, 1250, 721, 277, 12, 6050, 304, 267, 327, 21791, 1584, 641, 5417, 787, 691, 262, 267, 6050, 63, 808, 275, 5549, 14, 19320, 8, 4511, 15637, 4524, 297, 3145, 29, 797, 9, 267, 862, 26, 288, 3105, 63, 1361, 360, 16646, 2388, 570, 8910, 16, 11049, 367, 3918, 10080, 1370, 908, 8, 4060, 63, 808, 14, 354, 430, 288, 6277, 18, 14, 1017, 952, 8, 4060, 63, 808, 14, 354, 12, 6050, 9, 288, 6050, 63, 808, 14, 1600, 342, 288, 372, 291, 14, 2708, 63, 493, 8, 4060, 63, 808, 14, 354, 9, 267, 3753, 26, 288, 747, 14, 7162, 8, 4060, 63, 808, 14, 354, 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 ]
[ 747, 199, 646, 5549, 199, 199, 646, 6277, 18, 199, 199, 893, 26, 272, 687, 4747, 708, 957, 492, 1890, 465, 2414, 272, 687, 4747, 708, 957, 14, 1258, 492, 5262, 465, 286, 272, 492, 4747, 708, 1246, 199, 2590, 3545, 26, 272, 2414, 275, 4747, 708, 1246, 275, 286, 275, 488, 199, 199, 504, 486, 810, 983, 14, 22091, 492, 12377, 600, 199, 504, 486, 810, 983, 14, 71, 810, 983, 63, 705, 492, 598, 810, 983, 547, 199, 504, 486, 810, 983, 14, 1974, 492, 3105, 63, 1361, 12, 365, 63, 429, 4148, 63, 11616, 421, 199, 533, 3918, 8169, 8524, 8, 785, 304, 272, 408, 9400, 1808, 314, 3918, 8169, 1159, 12377, 600, 5929, 15610, 339, 12377, 600, 5929, 883, 4849, 5002, 2943, 402, 4681, 6021, 446, 5544, 1808, 652, 2951, 272, 367, 3918, 8449, 436, 5495, 7960, 435, 5495, 25454, 272, 408, 339, 445, 5296, 998, 275, 298, 5281, 600, 5929, 14, 5281, 600, 8326, 2, 339, 347, 636, 826, 721, 277, 12, 666, 3642, 12, 302, 63, 1700, 6021, 29, 403, 304, 267, 340, 440, 291, 14, 4561, 837, 288, 746, 598, 810, 983, 547, 360, 1451, 10080, 18735, 358, 267, 587, 26, 288, 2414, 14, 1548, 957, 14, 967, 9345, 342, 953, 327, 377, 711, 687, 3464, 14108, 3595, 4212, 370, 2879, 18877, 5262, 288, 327, 1455, 921, 23153, 14, 957, 15, 65, 15, 7842, 1082, 13218, 15, 8881, 1401, 2010, 288, 291, 14, 68, 275, 2414, 14, 2268, 1637, 14, 13913, 20628, 8, 277, 14, 1981, 19514, 9, 953, 340, 666, 3642, 26, 355, 291, 14, 68, 14, 5281, 600, 4100, 275, 286, 14, 1451, 6443, 288, 587, 26, 355, 291, 14, 68, 14, 5281, 600, 4100, 275, 286, 14, 3034, 3933, 1204, 286, 14, 3034, 1355, 953, 340, 302, 63, 1700, 6021, 365, 488, 26, 355, 302, 63, 1700, 6021, 275, 413, 340, 666, 3642, 587, 1616, 288, 291, 14, 68, 14, 10608, 6591, 5281, 6021, 275, 302, 63, 1700, 6021, 398, 327, 9672, 1338, 315, 662, 5281, 600, 4100, 370, 1318, 267, 327, 961, 1077, 506, 282, 1021, 3653, 1325, 314, 28640, 365, 8917, 1454, 267, 327, 2410, 314, 1240, 370, 7523, 20628, 14, 267, 291, 14, 1313, 275, 469, 286, 14, 3034, 3933, 520, 283, 3034, 7960, 297, 2432, 286, 14, 3034, 1355, 520, 283, 3034, 10551, 297, 2432, 286, 14, 2620, 76, 821, 520, 283, 2620, 274, 4292, 499, 402, 959, 297, 2432, 286, 14, 37, 879, 969, 520, 283, 37, 879, 13, 969, 297, 2432, 286, 14, 37, 879, 24, 520, 283, 37, 879, 13, 24, 297, 2432, 286, 14, 35, 364, 371, 285, 520, 283, 35, 364, 371, 285, 297, 2432, 286, 14, 3034, 845, 520, 283, 3034, 4119, 297, 2432, 286, 14, 2160, 3263, 520, 283, 2160, 35, 13, 33, 297, 2432, 286, 14, 2160, 2089, 520, 283, 2160, 35, 13, 37, 297, 2432, 286, 14, 1451, 6443, 520, 283, 1451, 8449, 297, 2151, 789, 339, 768, 3744, 272, 347, 2808, 8, 1886, 304, 267, 372, 2414, 365, 440, 488, 436, 365, 63, 429, 4148, 63, 11616, 8, 1886, 14, 1981, 19514, 9, 339, 347, 4849, 63, 493, 8, 277, 12, 931, 304, 267, 327, 22462, 3296, 31, 267, 291, 14, 68, 14, 9400, 1173, 8, 495, 8, 515, 430, 267, 522, 275, 359, 403, 61, 627, 291, 14, 68, 14, 5281, 6021, 14, 1267, 267, 367, 284, 315, 1425, 8, 16, 12, 291, 14, 68, 14, 5281, 6021, 14, 1267, 304, 288, 330, 275, 291, 14, 68, 14, 5281, 6021, 14, 1053, 8, 73, 9, 288, 522, 59, 73, 61, 275, 12377, 600, 8, 277, 14, 1313, 14, 362, 8, 66, 14, 5281, 600, 804, 12, 283, 5912, 659, 330, 14, 1872, 9, 267, 372, 522, 339, 347, 636, 1250, 721, 277, 12, 6050, 304, 267, 327, 21791, 1584, 641, 5417, 787, 691, 262, 267, 6050, 63, 808, 275, 5549, 14, 19320, 8, 4511, 15637, 4524, 297, 3145, 29, 797, 9, 267, 862, 26, 288, 3105, 63, 1361, 360, 16646, 2388, 570, 8910, 16, 11049, 367, 3918, 10080, 1370, 908, 8, 4060, 63, 808, 14, 354, 430, 288, 6277, 18, 14, 1017, 952, 8, 4060, 63, 808, 14, 354, 12, 6050, 9, 288, 6050, 63, 808, 14, 1600, 342, 288, 372, 291, 14, 2708, 63, 493, 8, 4060, 63, 808, 14, 354, 9, 267, 3753, 26, 288, 747, 14, 7162, 8, 4060, 63, 808, 14, 354, 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, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
reverieinc/RevCode
revcode/rev_code_joiner.py
1
2522
def join_rev_matra(rev_word, rev_vowel): # rev_vowel_list = ["a","A","i","I","u","U","WR","WA","e","E","YE","WO","o","O","YO","x","M","X"] # rev_consonant_list = ["k","K","g","G","Fd","c","C","j","J","Z","T","HT","D","HD","N","t","Ht","d","Hd","n","Q","p","P","b","B","m","y","r","R","l","v","L","Hz","s","S","Hs","h","Fk","FK","Fg","Fj","HR","FP","Fy","z"] if len(rev_word) == 0 : return rev_vowel if rev_word[len(rev_word) - 1].lower() not in "abcdefghijklmnopqrstuvwxyz ": return rev_word if is_last_char_consonant(rev_word) and is_first_char_vowel(rev_vowel): if last_char_to_be_removed(rev_word): rev_word = rev_word[:-1] joined_rev_code = rev_word + rev_vowel return joined_rev_code rev_vowel_list = ["a", "A", "i", "I", "u", "U", "WR", "WA", "e", "E", "YE", "WO", "o", "O", "YO", "x", "M", "X"] rev_consonant_list = ["k", "K", "g", "G", "Fd", "c", "C", "j", "J", "Z", "T", "HT", "D", "HD", "N", "t", "Ht", "d", "Hd", "n", "Q", "p", "P", "b", "B", "m", "y", "r", "R", "l", "v", "L", "Hz", "s", "S", "Hs", "h", "Fk", "FK", "Fg", "Fj", "HR", "FP", "Fy", "z"] def is_last_char_consonant(rev_str): if len(rev_str) > 1: last_ch = rev_str[len(rev_str) - 1] second_last_ch = rev_str[len(rev_str) - 2] last_two_chars = rev_str[-2:] if last_two_chars in rev_consonant_list: return True if last_ch == "a" and (second_last_ch in rev_consonant_list or last_two_chars in rev_consonant_list): return True last_ch = rev_str[-1:] if last_ch in rev_consonant_list: return True return False def is_first_char_vowel(rev_str): first_char = rev_str[:1] if first_char in rev_vowel_list: return True if len(rev_str) > 1: first_two_char = rev_str[:2] if first_two_char in rev_vowel_list: return True return False def is_last_char_matra(rev_str): if len(rev_str)<=1 : return False if len(rev_str) >= 2 : last_char = rev_str[-1:] if last_char == "a" : return False if last_char in rev_vowel_list and is_last_char_consonant(rev_str[:-1]) : return True return False def last_char_to_be_removed(rev_str): if len(rev_str) > 1: last_ch = rev_str[-1:] if last_ch == "a": return True return False # if __name__ == '__main__': # print join_rev_matra("kara", "tE")
gpl-3.0
[ 318, 4263, 63, 4964, 63, 569, 345, 8, 4964, 63, 1027, 12, 6822, 63, 28597, 304, 272, 327, 257, 6822, 63, 28597, 63, 513, 275, 2097, 65, 2266, 33, 2266, 73, 2266, 41, 2266, 85, 2266, 53, 2266, 6524, 2266, 9004, 2266, 69, 2266, 37, 2266, 57, 37, 2266, 11325, 2266, 79, 2266, 47, 2266, 57, 47, 2266, 88, 2266, 45, 2266, 56, 937, 272, 327, 257, 6822, 63, 388, 834, 867, 63, 513, 275, 2097, 75, 2266, 43, 2266, 71, 2266, 39, 2266, 20689, 2266, 67, 2266, 35, 2266, 74, 2266, 42, 2266, 58, 2266, 52, 2266, 2148, 2266, 36, 2266, 14903, 2266, 46, 2266, 84, 2266, 9192, 2266, 68, 2266, 40, 68, 2266, 78, 2266, 49, 2266, 80, 2266, 48, 2266, 66, 2266, 34, 2266, 77, 2266, 89, 2266, 82, 2266, 50, 2266, 76, 2266, 86, 2266, 44, 2266, 13026, 2266, 83, 2266, 51, 2266, 40, 83, 2266, 72, 2266, 38, 75, 2266, 21490, 2266, 38, 71, 2266, 38, 74, 2266, 14784, 2266, 17095, 2266, 30559, 2266, 90, 937, 339, 340, 822, 8, 4964, 63, 1027, 9, 508, 378, 520, 267, 372, 6822, 63, 28597, 272, 340, 6822, 63, 1027, 59, 552, 8, 4964, 63, 1027, 9, 446, 413, 1055, 2325, 342, 440, 315, 298, 23459, 7244, 267, 372, 6822, 63, 1027, 339, 340, 365, 63, 2019, 63, 1560, 63, 388, 834, 867, 8, 4964, 63, 1027, 9, 436, 365, 63, 2246, 63, 1560, 63, 28597, 8, 4964, 63, 28597, 304, 267, 340, 2061, 63, 1560, 63, 475, 63, 1235, 63, 10649, 8, 4964, 63, 1027, 304, 288, 6822, 63, 1027, 275, 6822, 63, 1027, 4439, 17, 61, 339, 16538, 63, 4964, 63, 600, 275, 6822, 63, 1027, 435, 6822, 63, 28597, 339, 372, 16538, 63, 4964, 63, 600, 421, 199, 4964, 63, 28597, 63, 513, 275, 2097, 65, 401, 298, 33, 401, 298, 73, 401, 298, 41, 401, 298, 85, 401, 298, 53, 401, 298, 6524, 401, 298, 9004, 401, 298, 69, 401, 298, 37, 401, 298, 57, 37, 401, 298, 11325, 401, 298, 79, 401, 298, 47, 401, 298, 57, 47, 401, 298, 88, 401, 298, 45, 401, 298, 56, 937, 199, 4964, 63, 388, 834, 867, 63, 513, 275, 2097, 75, 401, 298, 43, 401, 298, 71, 401, 298, 39, 401, 298, 20689, 401, 298, 67, 401, 298, 35, 401, 298, 74, 401, 298, 42, 401, 298, 58, 401, 298, 52, 401, 298, 2148, 401, 298, 36, 401, 298, 14903, 401, 298, 46, 401, 298, 84, 401, 298, 9192, 401, 298, 68, 401, 1993, 298, 40, 68, 401, 298, 78, 401, 298, 49, 401, 298, 80, 401, 298, 48, 401, 298, 66, 401, 298, 34, 401, 298, 77, 401, 298, 89, 401, 298, 82, 401, 298, 50, 401, 298, 76, 401, 298, 86, 401, 298, 44, 401, 298, 13026, 401, 298, 83, 401, 298, 51, 401, 298, 40, 83, 401, 298, 72, 401, 1993, 298, 38, 75, 401, 298, 21490, 401, 298, 38, 71, 401, 298, 38, 74, 401, 298, 14784, 401, 298, 17095, 401, 298, 30559, 401, 298, 90, 937, 421, 199, 318, 365, 63, 2019, 63, 1560, 63, 388, 834, 867, 8, 4964, 63, 495, 304, 272, 340, 822, 8, 4964, 63, 495, 9, 690, 413, 26, 398, 2061, 63, 335, 275, 6822, 63, 495, 59, 552, 8, 4964, 63, 495, 9, 446, 413, 61, 267, 3499, 63, 2019, 63, 335, 275, 6822, 63, 495, 59, 552, 8, 4964, 63, 495, 9, 446, 499, 61, 267, 2061, 63, 5601, 63, 6574, 275, 6822, 63, 495, 1988, 18, 2938, 398, 340, 2061, 63, 5601, 63, 6574, 315, 6822, 63, 388, 834, 867, 63, 513, 26, 288, 372, 715, 398, 340, 2061, 63, 335, 508, 298, 65, 2, 436, 334, 4375, 63, 2019, 63, 335, 315, 6822, 63, 388, 834, 867, 63, 513, 503, 2061, 63, 5601, 63, 6574, 315, 6822, 63, 388, 834, 867, 63, 513, 304, 288, 372, 715, 339, 2061, 63, 335, 275, 6822, 63, 495, 1988, 17, 2938, 272, 340, 2061, 63, 335, 315, 6822, 63, 388, 834, 867, 63, 513, 26, 267, 372, 715, 339, 372, 756, 199, 199, 318, 365, 63, 2246, 63, 1560, 63, 28597, 8, 4964, 63, 495, 304, 272, 1642, 63, 1560, 275, 6822, 63, 495, 1491, 17, 61, 272, 340, 1642, 63, 1560, 315, 6822, 63, 28597, 63, 513, 26, 267, 372, 715, 339, 340, 822, 8, 4964, 63, 495, 9, 690, 413, 26, 267, 1642, 63, 5601, 63, 1560, 275, 6822, 63, 495, 1491, 18, 61, 267, 340, 1642, 63, 5601, 63, 1560, 315, 6822, 63, 28597, 63, 513, 26, 288, 372, 715, 339, 372, 756, 421, 199, 318, 365, 63, 2019, 63, 1560, 63, 569, 345, 8, 4964, 63, 495, 304, 339, 340, 822, 8, 4964, 63, 495, 9, 12932, 17, 520, 267, 372, 756, 272, 340, 822, 8, 4964, 63, 495, 9, 2356, 499, 520, 267, 2061, 63, 1560, 275, 6822, 63, 495, 1988, 17, 2938, 398, 340, 2061, 63, 1560, 508, 298, 65, 2, 520, 288, 372, 756, 267, 340, 2061, 63, 1560, 315, 6822, 63, 28597, 63, 513, 436, 365, 63, 2019, 63, 1560, 63, 388, 834, 867, 8, 4964, 63, 495, 4439, 17, 566, 520, 288, 372, 715, 339, 372, 756, 421, 199, 318, 2061, 63, 1560, 63, 475, 63, 1235, 63, 10649, 8, 4964, 63, 495, 304, 272, 340, 822, 8, 4964, 63, 495, 9, 690, 413, 26, 267, 2061, 63, 335, 275, 6822, 63, 495, 1988, 17, 2938, 267, 340, 2061, 63, 335, 508, 298, 65, 582, 288, 372, 715, 339, 372, 756, 421, 199, 3, 340, 636, 354, 363, 508, 2560, 973, 3706, 199, 3, 258, 870, 4263, 63, 4964, 63, 569, 345, 480, 75, 17956, 401, 298, 84, 37, 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 ]
[ 4263, 63, 4964, 63, 569, 345, 8, 4964, 63, 1027, 12, 6822, 63, 28597, 304, 272, 327, 257, 6822, 63, 28597, 63, 513, 275, 2097, 65, 2266, 33, 2266, 73, 2266, 41, 2266, 85, 2266, 53, 2266, 6524, 2266, 9004, 2266, 69, 2266, 37, 2266, 57, 37, 2266, 11325, 2266, 79, 2266, 47, 2266, 57, 47, 2266, 88, 2266, 45, 2266, 56, 937, 272, 327, 257, 6822, 63, 388, 834, 867, 63, 513, 275, 2097, 75, 2266, 43, 2266, 71, 2266, 39, 2266, 20689, 2266, 67, 2266, 35, 2266, 74, 2266, 42, 2266, 58, 2266, 52, 2266, 2148, 2266, 36, 2266, 14903, 2266, 46, 2266, 84, 2266, 9192, 2266, 68, 2266, 40, 68, 2266, 78, 2266, 49, 2266, 80, 2266, 48, 2266, 66, 2266, 34, 2266, 77, 2266, 89, 2266, 82, 2266, 50, 2266, 76, 2266, 86, 2266, 44, 2266, 13026, 2266, 83, 2266, 51, 2266, 40, 83, 2266, 72, 2266, 38, 75, 2266, 21490, 2266, 38, 71, 2266, 38, 74, 2266, 14784, 2266, 17095, 2266, 30559, 2266, 90, 937, 339, 340, 822, 8, 4964, 63, 1027, 9, 508, 378, 520, 267, 372, 6822, 63, 28597, 272, 340, 6822, 63, 1027, 59, 552, 8, 4964, 63, 1027, 9, 446, 413, 1055, 2325, 342, 440, 315, 298, 23459, 7244, 267, 372, 6822, 63, 1027, 339, 340, 365, 63, 2019, 63, 1560, 63, 388, 834, 867, 8, 4964, 63, 1027, 9, 436, 365, 63, 2246, 63, 1560, 63, 28597, 8, 4964, 63, 28597, 304, 267, 340, 2061, 63, 1560, 63, 475, 63, 1235, 63, 10649, 8, 4964, 63, 1027, 304, 288, 6822, 63, 1027, 275, 6822, 63, 1027, 4439, 17, 61, 339, 16538, 63, 4964, 63, 600, 275, 6822, 63, 1027, 435, 6822, 63, 28597, 339, 372, 16538, 63, 4964, 63, 600, 421, 199, 4964, 63, 28597, 63, 513, 275, 2097, 65, 401, 298, 33, 401, 298, 73, 401, 298, 41, 401, 298, 85, 401, 298, 53, 401, 298, 6524, 401, 298, 9004, 401, 298, 69, 401, 298, 37, 401, 298, 57, 37, 401, 298, 11325, 401, 298, 79, 401, 298, 47, 401, 298, 57, 47, 401, 298, 88, 401, 298, 45, 401, 298, 56, 937, 199, 4964, 63, 388, 834, 867, 63, 513, 275, 2097, 75, 401, 298, 43, 401, 298, 71, 401, 298, 39, 401, 298, 20689, 401, 298, 67, 401, 298, 35, 401, 298, 74, 401, 298, 42, 401, 298, 58, 401, 298, 52, 401, 298, 2148, 401, 298, 36, 401, 298, 14903, 401, 298, 46, 401, 298, 84, 401, 298, 9192, 401, 298, 68, 401, 1993, 298, 40, 68, 401, 298, 78, 401, 298, 49, 401, 298, 80, 401, 298, 48, 401, 298, 66, 401, 298, 34, 401, 298, 77, 401, 298, 89, 401, 298, 82, 401, 298, 50, 401, 298, 76, 401, 298, 86, 401, 298, 44, 401, 298, 13026, 401, 298, 83, 401, 298, 51, 401, 298, 40, 83, 401, 298, 72, 401, 1993, 298, 38, 75, 401, 298, 21490, 401, 298, 38, 71, 401, 298, 38, 74, 401, 298, 14784, 401, 298, 17095, 401, 298, 30559, 401, 298, 90, 937, 421, 199, 318, 365, 63, 2019, 63, 1560, 63, 388, 834, 867, 8, 4964, 63, 495, 304, 272, 340, 822, 8, 4964, 63, 495, 9, 690, 413, 26, 398, 2061, 63, 335, 275, 6822, 63, 495, 59, 552, 8, 4964, 63, 495, 9, 446, 413, 61, 267, 3499, 63, 2019, 63, 335, 275, 6822, 63, 495, 59, 552, 8, 4964, 63, 495, 9, 446, 499, 61, 267, 2061, 63, 5601, 63, 6574, 275, 6822, 63, 495, 1988, 18, 2938, 398, 340, 2061, 63, 5601, 63, 6574, 315, 6822, 63, 388, 834, 867, 63, 513, 26, 288, 372, 715, 398, 340, 2061, 63, 335, 508, 298, 65, 2, 436, 334, 4375, 63, 2019, 63, 335, 315, 6822, 63, 388, 834, 867, 63, 513, 503, 2061, 63, 5601, 63, 6574, 315, 6822, 63, 388, 834, 867, 63, 513, 304, 288, 372, 715, 339, 2061, 63, 335, 275, 6822, 63, 495, 1988, 17, 2938, 272, 340, 2061, 63, 335, 315, 6822, 63, 388, 834, 867, 63, 513, 26, 267, 372, 715, 339, 372, 756, 199, 199, 318, 365, 63, 2246, 63, 1560, 63, 28597, 8, 4964, 63, 495, 304, 272, 1642, 63, 1560, 275, 6822, 63, 495, 1491, 17, 61, 272, 340, 1642, 63, 1560, 315, 6822, 63, 28597, 63, 513, 26, 267, 372, 715, 339, 340, 822, 8, 4964, 63, 495, 9, 690, 413, 26, 267, 1642, 63, 5601, 63, 1560, 275, 6822, 63, 495, 1491, 18, 61, 267, 340, 1642, 63, 5601, 63, 1560, 315, 6822, 63, 28597, 63, 513, 26, 288, 372, 715, 339, 372, 756, 421, 199, 318, 365, 63, 2019, 63, 1560, 63, 569, 345, 8, 4964, 63, 495, 304, 339, 340, 822, 8, 4964, 63, 495, 9, 12932, 17, 520, 267, 372, 756, 272, 340, 822, 8, 4964, 63, 495, 9, 2356, 499, 520, 267, 2061, 63, 1560, 275, 6822, 63, 495, 1988, 17, 2938, 398, 340, 2061, 63, 1560, 508, 298, 65, 2, 520, 288, 372, 756, 267, 340, 2061, 63, 1560, 315, 6822, 63, 28597, 63, 513, 436, 365, 63, 2019, 63, 1560, 63, 388, 834, 867, 8, 4964, 63, 495, 4439, 17, 566, 520, 288, 372, 715, 339, 372, 756, 421, 199, 318, 2061, 63, 1560, 63, 475, 63, 1235, 63, 10649, 8, 4964, 63, 495, 304, 272, 340, 822, 8, 4964, 63, 495, 9, 690, 413, 26, 267, 2061, 63, 335, 275, 6822, 63, 495, 1988, 17, 2938, 267, 340, 2061, 63, 335, 508, 298, 65, 582, 288, 372, 715, 339, 372, 756, 421, 199, 3, 340, 636, 354, 363, 508, 2560, 973, 3706, 199, 3, 258, 870, 4263, 63, 4964, 63, 569, 345, 480, 75, 17956, 401, 298, 84, 37, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
simone/static-erre
ncc4roma/settings.py
1
2976
""" Django settings for ncc4roma project. Generated by 'django-admin startproject' using Django 1.8.4. 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 = 'kjim0aiv*@mu)fd^to&d9-1!f*e47wb=a7ikckup@#lk&04p)h' # SECURITY WARNING: don't run with debug turned on in production! 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', 'sitetree', 'website' ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', '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 = 'ncc4roma.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.template.context_processors.i18n', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'ncc4roma.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'), } } # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'it' from django.utils.translation import ugettext_lazy as _ LANGUAGES = ( ('it', _('Italiano')), ('en', _('Inglese')), ) LOCALE_PATHS = ( os.path.abspath(os.path.join(BASE_DIR, 'locale')), ) TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.8/howto/static-files/ STATIC_URL = '/static/'
mit
[ 624, 199, 9323, 2202, 367, 302, 2055, 20, 293, 391, 2199, 14, 199, 199, 12706, 701, 283, 1176, 13, 2113, 1343, 1715, 7, 1808, 5634, 413, 14, 24, 14, 20, 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, 283, 25775, 1017, 16, 65, 1003, 10, 32, 6553, 9, 2592, 62, 475, 6, 68, 25, 13, 17, 1, 70, 10, 69, 2417, 6603, 29, 65, 23, 3258, 346, 384, 32, 3, 23333, 6, 966, 80, 9, 72, 7, 199, 199, 3, 24143, 32712, 14750, 26, 2793, 1133, 1255, 543, 3105, 19136, 641, 315, 9920, 1, 199, 5287, 275, 715, 199, 199, 17350, 63, 23775, 275, 942, 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, 2124, 2350, 297, 272, 283, 7360, 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, 1176, 14, 5754, 14, 5508, 14, 20342, 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, 78, 2055, 20, 293, 391, 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, 990, 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, 1160, 14, 1100, 63, 10547, 14, 73, 1085, 78, 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, 78, 2055, 20, 293, 391, 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, 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, 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, 390, 7, 199, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 26886, 275, 334, 523, 661, 390, 297, 4018, 7940, 25861, 79, 3855, 523, 661, 287, 297, 4018, 607, 3845, 261, 3855, 199, 9, 199, 199, 20828, 63, 20202, 275, 334, 272, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 5508, 3855, 199, 9, 199, 199, 4961, 63, 15353, 275, 283, 11288, 7, 199, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 4701, 63, 14226, 275, 715, 421, 199, 3, 13599, 1584, 334, 14391, 12, 15250, 12, 32658, 9, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 21232, 15, 1986, 13, 1725, 15, 199, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 302, 2055, 20, 293, 391, 2199, 14, 199, 199, 12706, 701, 283, 1176, 13, 2113, 1343, 1715, 7, 1808, 5634, 413, 14, 24, 14, 20, 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, 283, 25775, 1017, 16, 65, 1003, 10, 32, 6553, 9, 2592, 62, 475, 6, 68, 25, 13, 17, 1, 70, 10, 69, 2417, 6603, 29, 65, 23, 3258, 346, 384, 32, 3, 23333, 6, 966, 80, 9, 72, 7, 199, 199, 3, 24143, 32712, 14750, 26, 2793, 1133, 1255, 543, 3105, 19136, 641, 315, 9920, 1, 199, 5287, 275, 715, 199, 199, 17350, 63, 23775, 275, 942, 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, 2124, 2350, 297, 272, 283, 7360, 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, 1176, 14, 5754, 14, 5508, 14, 20342, 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, 78, 2055, 20, 293, 391, 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, 990, 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, 1160, 14, 1100, 63, 10547, 14, 73, 1085, 78, 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, 78, 2055, 20, 293, 391, 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, 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, 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, 390, 7, 199, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 26886, 275, 334, 523, 661, 390, 297, 4018, 7940, 25861, 79, 3855, 523, 661, 287, 297, 4018, 607, 3845, 261, 3855, 199, 9, 199, 199, 20828, 63, 20202, 275, 334, 272, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 5508, 3855, 199, 9, 199, 199, 4961, 63, 15353, 275, 283, 11288, 7, 199, 199, 4701, 63, 41, 1085, 46, 275, 715, 199, 199, 4701, 63, 44, 709, 46, 275, 715, 199, 199, 4701, 63, 14226, 275, 715, 421, 199, 3, 13599, 1584, 334, 14391, 12, 15250, 12, 32658, 9, 199, 3, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 17, 14, 24, 15, 21232, 15, 1986, 13, 1725, 15, 199, 199, 10449, 63, 2632, 275, 1994, 1986, 4805, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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com> # Licensed under the terms of the GNU GPL License version 2 # # Periodically displays system-wide system call totals, broken down by # syscall. If a [comm] arg is specified, only syscalls called by # [comm] are displayed. If an [interval] arg is specified, the display # will be refreshed every [interval] seconds. The default interval is # 3 seconds. import os, sys, thread, time sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import * usage = "perf script -s sctop.py [comm] [interval]\n"; for_comm = None default_interval = 3 interval = default_interval if len(sys.argv) > 3: sys.exit(usage) if len(sys.argv) > 2: for_comm = sys.argv[1] interval = int(sys.argv[2]) elif len(sys.argv) > 1: try: interval = int(sys.argv[1]) except ValueError: for_comm = sys.argv[1] interval = default_interval syscalls = autodict() def trace_begin(): thread.start_new_thread(print_syscall_totals, (interval,)) pass def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if for_comm is not None: if common_comm != for_comm: return try: syscalls[id] += 1 except TypeError: syscalls[id] = 1 def print_syscall_totals(interval): while 1: clear_term() if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "----------"), for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ reverse = True): try: print "%-40s %10d\n" % (syscall_name(id), val), except TypeError: pass syscalls.clear() time.sleep(interval)
gpl-2.0
[ 3, 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 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 ]
[ 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Denisolt/Tensorflow_Chat_Bot
local/lib/python2.7/site-packages/numpy/core/getlimits.py
100
9714
"""Machine limits for Float32 and Float64 and (long double) if available... """ from __future__ import division, absolute_import, print_function __all__ = ['finfo', 'iinfo'] from .machar import MachAr from . import numeric from . import numerictypes as ntypes from .numeric import array def _frz(a): """fix rank-0 --> rank-1""" if a.ndim == 0: a.shape = (1,) return a _convert_to_float = { ntypes.csingle: ntypes.single, ntypes.complex_: ntypes.float_, ntypes.clongfloat: ntypes.longfloat } class finfo(object): """ finfo(dtype) Machine limits for floating point types. Attributes ---------- eps : float The smallest representable positive number such that ``1.0 + eps != 1.0``. Type of `eps` is an appropriate floating point type. epsneg : floating point number of the appropriate type The smallest representable positive number such that ``1.0 - epsneg != 1.0``. iexp : int The number of bits in the exponent portion of the floating point representation. machar : MachAr The object which calculated these parameters and holds more detailed information. machep : int The exponent that yields `eps`. max : floating point number of the appropriate type The largest representable number. maxexp : int The smallest positive power of the base (2) that causes overflow. min : floating point number of the appropriate type The smallest representable number, typically ``-max``. minexp : int The most negative power of the base (2) consistent with there being no leading 0's in the mantissa. negep : int The exponent that yields `epsneg`. nexp : int The number of bits in the exponent including its sign and bias. nmant : int The number of bits in the mantissa. precision : int The approximate number of decimal digits to which this kind of float is precise. resolution : floating point number of the appropriate type The approximate decimal resolution of this type, i.e., ``10**-precision``. tiny : float The smallest positive usable number. Type of `tiny` is an appropriate floating point type. Parameters ---------- dtype : float, dtype, or instance Kind of floating point data-type about which to get information. See Also -------- MachAr : The implementation of the tests that produce this information. iinfo : The equivalent for integer data types. Notes ----- For developers of NumPy: do not instantiate this at the module level. The initial calculation of these parameters is expensive and negatively impacts import times. These objects are cached, so calling ``finfo()`` repeatedly inside your functions is not a problem. """ _finfo_cache = {} def __new__(cls, dtype): try: dtype = numeric.dtype(dtype) except TypeError: # In case a float instance was given dtype = numeric.dtype(type(dtype)) obj = cls._finfo_cache.get(dtype, None) if obj is not None: return obj dtypes = [dtype] newdtype = numeric.obj2sctype(dtype) if newdtype is not dtype: dtypes.append(newdtype) dtype = newdtype if not issubclass(dtype, numeric.inexact): raise ValueError("data type %r not inexact" % (dtype)) obj = cls._finfo_cache.get(dtype, None) if obj is not None: return obj if not issubclass(dtype, numeric.floating): newdtype = _convert_to_float[dtype] if newdtype is not dtype: dtypes.append(newdtype) dtype = newdtype obj = cls._finfo_cache.get(dtype, None) if obj is not None: return obj obj = object.__new__(cls)._init(dtype) for dt in dtypes: cls._finfo_cache[dt] = obj return obj def _init(self, dtype): self.dtype = numeric.dtype(dtype) if dtype is ntypes.double: itype = ntypes.int64 fmt = '%24.16e' precname = 'double' elif dtype is ntypes.single: itype = ntypes.int32 fmt = '%15.7e' precname = 'single' elif dtype is ntypes.longdouble: itype = ntypes.longlong fmt = '%s' precname = 'long double' elif dtype is ntypes.half: itype = ntypes.int16 fmt = '%12.5e' precname = 'half' else: raise ValueError(repr(dtype)) machar = MachAr(lambda v:array([v], dtype), lambda v:_frz(v.astype(itype))[0], lambda v:array(_frz(v)[0], dtype), lambda v: fmt % array(_frz(v)[0], dtype), 'numpy %s precision floating point number' % precname) for word in ['precision', 'iexp', 'maxexp', 'minexp', 'negep', 'machep']: setattr(self, word, getattr(machar, word)) for word in ['tiny', 'resolution', 'epsneg']: setattr(self, word, getattr(machar, word).flat[0]) self.max = machar.huge.flat[0] self.min = -self.max self.eps = machar.eps.flat[0] self.nexp = machar.iexp self.nmant = machar.it self.machar = machar self._str_tiny = machar._str_xmin.strip() self._str_max = machar._str_xmax.strip() self._str_epsneg = machar._str_epsneg.strip() self._str_eps = machar._str_eps.strip() self._str_resolution = machar._str_resolution.strip() return self def __str__(self): fmt = ( 'Machine parameters for %(dtype)s\n' '---------------------------------------------------------------\n' 'precision=%(precision)3s resolution= %(_str_resolution)s\n' 'machep=%(machep)6s eps= %(_str_eps)s\n' 'negep =%(negep)6s epsneg= %(_str_epsneg)s\n' 'minexp=%(minexp)6s tiny= %(_str_tiny)s\n' 'maxexp=%(maxexp)6s max= %(_str_max)s\n' 'nexp =%(nexp)6s min= -max\n' '---------------------------------------------------------------\n' ) return fmt % self.__dict__ def __repr__(self): c = self.__class__.__name__ d = self.__dict__.copy() d['klass'] = c return (("%(klass)s(resolution=%(resolution)s, min=-%(_str_max)s," " max=%(_str_max)s, dtype=%(dtype)s)") % d) class iinfo(object): """ iinfo(type) Machine limits for integer types. Attributes ---------- min : int The smallest integer expressible by the type. max : int The largest integer expressible by the type. Parameters ---------- int_type : integer type, dtype, or instance The kind of integer data type to get information about. See Also -------- finfo : The equivalent for floating point data types. Examples -------- With types: >>> ii16 = np.iinfo(np.int16) >>> ii16.min -32768 >>> ii16.max 32767 >>> ii32 = np.iinfo(np.int32) >>> ii32.min -2147483648 >>> ii32.max 2147483647 With instances: >>> ii32 = np.iinfo(np.int32(10)) >>> ii32.min -2147483648 >>> ii32.max 2147483647 """ _min_vals = {} _max_vals = {} def __init__(self, int_type): try: self.dtype = numeric.dtype(int_type) except TypeError: self.dtype = numeric.dtype(type(int_type)) self.kind = self.dtype.kind self.bits = self.dtype.itemsize * 8 self.key = "%s%d" % (self.kind, self.bits) if self.kind not in 'iu': raise ValueError("Invalid integer data type.") def min(self): """Minimum value of given dtype.""" if self.kind == 'u': return 0 else: try: val = iinfo._min_vals[self.key] except KeyError: val = int(-(1 << (self.bits-1))) iinfo._min_vals[self.key] = val return val min = property(min) def max(self): """Maximum value of given dtype.""" try: val = iinfo._max_vals[self.key] except KeyError: if self.kind == 'u': val = int((1 << self.bits) - 1) else: val = int((1 << (self.bits-1)) - 1) iinfo._max_vals[self.key] = val return val max = property(max) def __str__(self): """String representation.""" fmt = ( 'Machine parameters for %(dtype)s\n' '---------------------------------------------------------------\n' 'min = %(min)s\n' 'max = %(max)s\n' '---------------------------------------------------------------\n' ) return fmt % {'dtype': self.dtype, 'min': self.min, 'max': self.max} def __repr__(self): return "%s(min=%s, max=%s, dtype=%s)" % (self.__class__.__name__, self.min, self.max, self.dtype) if __name__ == '__main__': f = finfo(ntypes.single) print('single epsilon:', f.eps) print('single tiny:', f.tiny) f = finfo(ntypes.float) print('float epsilon:', f.eps) print('float tiny:', f.tiny) f = finfo(ntypes.longfloat) print('longfloat epsilon:', f.eps) print('longfloat tiny:', f.tiny)
gpl-3.0
[ 624, 8412, 10976, 367, 11140, 708, 436, 11140, 772, 436, 334, 2809, 4270, 9, 340, 2808, 1396, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 363, 452, 363, 275, 788, 23087, 297, 283, 73, 815, 418, 199, 199, 504, 1275, 391, 1560, 492, 30611, 1596, 199, 504, 1275, 492, 8950, 199, 504, 1275, 492, 10330, 322, 9798, 465, 302, 1313, 199, 504, 1275, 6677, 492, 1625, 199, 199, 318, 485, 4391, 90, 8, 65, 304, 272, 408, 970, 6915, 13, 16, 10541, 6915, 13, 17, 624, 272, 340, 282, 14, 8322, 508, 378, 26, 267, 282, 14, 1392, 275, 334, 17, 4258, 272, 372, 282, 199, 199, 63, 3916, 63, 475, 63, 1609, 275, 469, 272, 302, 1313, 14, 67, 4780, 26, 302, 1313, 14, 4780, 12, 272, 302, 1313, 14, 5254, 10388, 302, 1313, 14, 1609, 3131, 272, 302, 1313, 14, 429, 951, 1609, 26, 302, 1313, 14, 2809, 1609, 272, 789, 199, 199, 533, 289, 815, 8, 785, 304, 272, 408, 272, 289, 815, 8, 2271, 9, 339, 18722, 10976, 367, 8402, 2376, 2943, 14, 339, 9382, 272, 4143, 272, 10245, 520, 2069, 267, 710, 18604, 2954, 461, 7317, 1329, 4066, 626, 267, 1124, 17, 14, 16, 435, 10245, 1137, 413, 14, 16, 4345, 221, 2434, 402, 658, 8277, 64, 365, 376, 5827, 8402, 267, 2376, 730, 14, 272, 10245, 8705, 520, 8402, 2376, 1329, 402, 314, 5827, 730, 267, 710, 18604, 2954, 461, 7317, 1329, 4066, 626, 267, 1124, 17, 14, 16, 446, 10245, 8705, 1137, 413, 14, 16, 4345, 272, 284, 1474, 520, 1109, 267, 710, 1329, 402, 5821, 315, 314, 16588, 18046, 402, 314, 8402, 2376, 267, 6025, 14, 272, 610, 1560, 520, 30611, 1596, 267, 710, 909, 1314, 12950, 3520, 2633, 436, 15164, 1655, 267, 16212, 2556, 14, 272, 610, 595, 80, 520, 1109, 267, 710, 16588, 626, 14801, 658, 8277, 2313, 272, 1390, 520, 8402, 2376, 1329, 402, 314, 5827, 730, 267, 710, 17451, 2954, 461, 1329, 14, 272, 1390, 1474, 520, 1109, 267, 710, 18604, 7317, 7074, 402, 314, 1300, 334, 18, 9, 626, 14486, 15784, 14, 272, 1748, 520, 8402, 2376, 1329, 402, 314, 5827, 730, 267, 710, 18604, 2954, 461, 1329, 12, 13609, 27810, 988, 4345, 272, 1748, 1474, 520, 1109, 267, 710, 4750, 6946, 7074, 402, 314, 1300, 334, 18, 9, 12137, 543, 2337, 267, 3769, 949, 9186, 378, 1159, 315, 314, 2169, 280, 28023, 14, 272, 1279, 303, 80, 520, 1109, 267, 710, 16588, 626, 14801, 658, 8277, 8705, 2313, 272, 302, 1474, 520, 1109, 267, 710, 1329, 402, 5821, 315, 314, 16588, 5893, 2399, 2070, 436, 10671, 14, 272, 16751, 867, 520, 1109, 267, 710, 1329, 402, 5821, 315, 314, 2169, 280, 28023, 14, 272, 7151, 520, 1109, 267, 710, 19917, 1329, 402, 6107, 7576, 370, 1314, 642, 4928, 402, 267, 2069, 365, 28334, 14, 272, 12401, 520, 8402, 2376, 1329, 402, 314, 5827, 730, 267, 710, 19917, 6107, 12401, 402, 642, 730, 12, 284, 14, 69, 2020, 267, 1124, 709, 25376, 6833, 4345, 272, 29128, 520, 2069, 267, 710, 18604, 7317, 18025, 1329, 14, 221, 2434, 402, 658, 9864, 64, 365, 376, 267, 5827, 8402, 2376, 730, 14, 339, 3897, 272, 4143, 272, 2152, 520, 2069, 12, 2152, 12, 503, 1256, 267, 1804, 688, 402, 8402, 2376, 666, 13, 466, 3595, 1314, 370, 664, 2556, 14, 339, 1666, 6121, 272, 3001, 272, 30611, 1596, 520, 710, 4514, 402, 314, 2295, 626, 7389, 642, 2556, 14, 272, 284, 815, 520, 710, 7353, 367, 3000, 666, 2943, 14, 339, 8144, 272, 9063, 272, 2104, 19782, 402, 20602, 26, 886, 440, 17321, 642, 737, 314, 859, 2166, 14, 272, 710, 2536, 15232, 402, 3520, 2633, 365, 23133, 436, 14158, 17330, 272, 1742, 22282, 492, 5431, 14, 221, 5723, 2251, 787, 6328, 12, 880, 6358, 1124, 23087, 8497, 272, 27714, 6272, 2195, 3423, 365, 440, 282, 5160, 14, 339, 408, 339, 485, 23087, 63, 1637, 275, 1052, 339, 347, 636, 1222, 721, 1886, 12, 2152, 304, 267, 862, 26, 288, 2152, 275, 8950, 14, 2271, 8, 2271, 9, 267, 871, 3146, 26, 288, 327, 1010, 1930, 282, 2069, 1256, 1990, 1627, 288, 2152, 275, 8950, 14, 2271, 8, 466, 8, 2271, 430, 398, 1559, 275, 843, 423, 23087, 63, 1637, 14, 362, 8, 2271, 12, 488, 9, 267, 340, 1559, 365, 440, 488, 26, 288, 372, 1559, 267, 6674, 275, 359, 2271, 61, 267, 892, 2271, 275, 8950, 14, 1113, 18, 83, 3667, 8, 2271, 9, 267, 340, 892, 2271, 365, 440, 2152, 26, 288, 6674, 14, 740, 8, 1222, 2271, 9, 288, 2152, 275, 892, 2271, 267, 340, 440, 11602, 8, 2271, 12, 8950, 14, 262, 7327, 304, 288, 746, 1722, 480, 576, 730, 450, 82, 440, 315, 7327, 2, 450, 334, 2271, 430, 267, 1559, 275, 843, 423, 23087, 63, 1637, 14, 362, 8, 2271, 12, 488, 9, 267, 340, 1559, 365, 440, 488, 26, 288, 372, 1559, 267, 340, 440, 11602, 8, 2271, 12, 8950, 14, 7774, 304, 288, 892, 2271, 275, 485, 3916, 63, 475, 63, 1609, 59, 2271, 61, 288, 340, 892, 2271, 365, 440, 2152, 26, 355, 6674, 14, 740, 8, 1222, 2271, 9, 355, 2152, 275, 892, 2271, 267, 1559, 275, 843, 423, 23087, 63, 1637, 14, 362, 8, 2271, 12, 488, 9, 267, 340, 1559, 365, 440, 488, 26, 288, 372, 1559, 267, 1559, 275, 909, 855, 1222, 721, 1886, 10445, 826, 8, 2271, 9, 267, 367, 4487, 315, 6674, 26, 288, 843, 423, 23087, 63, 1637, 59, 3583, 61, 275, 1559, 267, 372, 1559, 339, 347, 485, 826, 8, 277, 12, 2152, 304, 267, 291, 14, 2271, 275, 8950, 14, 2271, 8, 2271, 9, 267, 340, 2152, 365, 302, 1313, 14, 3157, 26, 288, 284, 466, 275, 302, 1313, 14, 442, 772, 288, 7104, 275, 1543, 1194, 14, 975, 69, 7, 288, 876, 11690, 275, 283, 3157, 7, 267, 916, 2152, 365, 302, 1313, 14, 4780, 26, 288, 284, 466, 275, 302, 1313, 14, 442, 708, 288, 7104, 275, 1543, 1046, 14, 23, 69, 7, 288, 876, 11690, 275, 283, 4780, 7, 267, 916, 2152, 365, 302, 1313, 14, 2809, 3157, 26, 288 ]
[ 8412, 10976, 367, 11140, 708, 436, 11140, 772, 436, 334, 2809, 4270, 9, 340, 2808, 1396, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 363, 452, 363, 275, 788, 23087, 297, 283, 73, 815, 418, 199, 199, 504, 1275, 391, 1560, 492, 30611, 1596, 199, 504, 1275, 492, 8950, 199, 504, 1275, 492, 10330, 322, 9798, 465, 302, 1313, 199, 504, 1275, 6677, 492, 1625, 199, 199, 318, 485, 4391, 90, 8, 65, 304, 272, 408, 970, 6915, 13, 16, 10541, 6915, 13, 17, 624, 272, 340, 282, 14, 8322, 508, 378, 26, 267, 282, 14, 1392, 275, 334, 17, 4258, 272, 372, 282, 199, 199, 63, 3916, 63, 475, 63, 1609, 275, 469, 272, 302, 1313, 14, 67, 4780, 26, 302, 1313, 14, 4780, 12, 272, 302, 1313, 14, 5254, 10388, 302, 1313, 14, 1609, 3131, 272, 302, 1313, 14, 429, 951, 1609, 26, 302, 1313, 14, 2809, 1609, 272, 789, 199, 199, 533, 289, 815, 8, 785, 304, 272, 408, 272, 289, 815, 8, 2271, 9, 339, 18722, 10976, 367, 8402, 2376, 2943, 14, 339, 9382, 272, 4143, 272, 10245, 520, 2069, 267, 710, 18604, 2954, 461, 7317, 1329, 4066, 626, 267, 1124, 17, 14, 16, 435, 10245, 1137, 413, 14, 16, 4345, 221, 2434, 402, 658, 8277, 64, 365, 376, 5827, 8402, 267, 2376, 730, 14, 272, 10245, 8705, 520, 8402, 2376, 1329, 402, 314, 5827, 730, 267, 710, 18604, 2954, 461, 7317, 1329, 4066, 626, 267, 1124, 17, 14, 16, 446, 10245, 8705, 1137, 413, 14, 16, 4345, 272, 284, 1474, 520, 1109, 267, 710, 1329, 402, 5821, 315, 314, 16588, 18046, 402, 314, 8402, 2376, 267, 6025, 14, 272, 610, 1560, 520, 30611, 1596, 267, 710, 909, 1314, 12950, 3520, 2633, 436, 15164, 1655, 267, 16212, 2556, 14, 272, 610, 595, 80, 520, 1109, 267, 710, 16588, 626, 14801, 658, 8277, 2313, 272, 1390, 520, 8402, 2376, 1329, 402, 314, 5827, 730, 267, 710, 17451, 2954, 461, 1329, 14, 272, 1390, 1474, 520, 1109, 267, 710, 18604, 7317, 7074, 402, 314, 1300, 334, 18, 9, 626, 14486, 15784, 14, 272, 1748, 520, 8402, 2376, 1329, 402, 314, 5827, 730, 267, 710, 18604, 2954, 461, 1329, 12, 13609, 27810, 988, 4345, 272, 1748, 1474, 520, 1109, 267, 710, 4750, 6946, 7074, 402, 314, 1300, 334, 18, 9, 12137, 543, 2337, 267, 3769, 949, 9186, 378, 1159, 315, 314, 2169, 280, 28023, 14, 272, 1279, 303, 80, 520, 1109, 267, 710, 16588, 626, 14801, 658, 8277, 8705, 2313, 272, 302, 1474, 520, 1109, 267, 710, 1329, 402, 5821, 315, 314, 16588, 5893, 2399, 2070, 436, 10671, 14, 272, 16751, 867, 520, 1109, 267, 710, 1329, 402, 5821, 315, 314, 2169, 280, 28023, 14, 272, 7151, 520, 1109, 267, 710, 19917, 1329, 402, 6107, 7576, 370, 1314, 642, 4928, 402, 267, 2069, 365, 28334, 14, 272, 12401, 520, 8402, 2376, 1329, 402, 314, 5827, 730, 267, 710, 19917, 6107, 12401, 402, 642, 730, 12, 284, 14, 69, 2020, 267, 1124, 709, 25376, 6833, 4345, 272, 29128, 520, 2069, 267, 710, 18604, 7317, 18025, 1329, 14, 221, 2434, 402, 658, 9864, 64, 365, 376, 267, 5827, 8402, 2376, 730, 14, 339, 3897, 272, 4143, 272, 2152, 520, 2069, 12, 2152, 12, 503, 1256, 267, 1804, 688, 402, 8402, 2376, 666, 13, 466, 3595, 1314, 370, 664, 2556, 14, 339, 1666, 6121, 272, 3001, 272, 30611, 1596, 520, 710, 4514, 402, 314, 2295, 626, 7389, 642, 2556, 14, 272, 284, 815, 520, 710, 7353, 367, 3000, 666, 2943, 14, 339, 8144, 272, 9063, 272, 2104, 19782, 402, 20602, 26, 886, 440, 17321, 642, 737, 314, 859, 2166, 14, 272, 710, 2536, 15232, 402, 3520, 2633, 365, 23133, 436, 14158, 17330, 272, 1742, 22282, 492, 5431, 14, 221, 5723, 2251, 787, 6328, 12, 880, 6358, 1124, 23087, 8497, 272, 27714, 6272, 2195, 3423, 365, 440, 282, 5160, 14, 339, 408, 339, 485, 23087, 63, 1637, 275, 1052, 339, 347, 636, 1222, 721, 1886, 12, 2152, 304, 267, 862, 26, 288, 2152, 275, 8950, 14, 2271, 8, 2271, 9, 267, 871, 3146, 26, 288, 327, 1010, 1930, 282, 2069, 1256, 1990, 1627, 288, 2152, 275, 8950, 14, 2271, 8, 466, 8, 2271, 430, 398, 1559, 275, 843, 423, 23087, 63, 1637, 14, 362, 8, 2271, 12, 488, 9, 267, 340, 1559, 365, 440, 488, 26, 288, 372, 1559, 267, 6674, 275, 359, 2271, 61, 267, 892, 2271, 275, 8950, 14, 1113, 18, 83, 3667, 8, 2271, 9, 267, 340, 892, 2271, 365, 440, 2152, 26, 288, 6674, 14, 740, 8, 1222, 2271, 9, 288, 2152, 275, 892, 2271, 267, 340, 440, 11602, 8, 2271, 12, 8950, 14, 262, 7327, 304, 288, 746, 1722, 480, 576, 730, 450, 82, 440, 315, 7327, 2, 450, 334, 2271, 430, 267, 1559, 275, 843, 423, 23087, 63, 1637, 14, 362, 8, 2271, 12, 488, 9, 267, 340, 1559, 365, 440, 488, 26, 288, 372, 1559, 267, 340, 440, 11602, 8, 2271, 12, 8950, 14, 7774, 304, 288, 892, 2271, 275, 485, 3916, 63, 475, 63, 1609, 59, 2271, 61, 288, 340, 892, 2271, 365, 440, 2152, 26, 355, 6674, 14, 740, 8, 1222, 2271, 9, 355, 2152, 275, 892, 2271, 267, 1559, 275, 843, 423, 23087, 63, 1637, 14, 362, 8, 2271, 12, 488, 9, 267, 340, 1559, 365, 440, 488, 26, 288, 372, 1559, 267, 1559, 275, 909, 855, 1222, 721, 1886, 10445, 826, 8, 2271, 9, 267, 367, 4487, 315, 6674, 26, 288, 843, 423, 23087, 63, 1637, 59, 3583, 61, 275, 1559, 267, 372, 1559, 339, 347, 485, 826, 8, 277, 12, 2152, 304, 267, 291, 14, 2271, 275, 8950, 14, 2271, 8, 2271, 9, 267, 340, 2152, 365, 302, 1313, 14, 3157, 26, 288, 284, 466, 275, 302, 1313, 14, 442, 772, 288, 7104, 275, 1543, 1194, 14, 975, 69, 7, 288, 876, 11690, 275, 283, 3157, 7, 267, 916, 2152, 365, 302, 1313, 14, 4780, 26, 288, 284, 466, 275, 302, 1313, 14, 442, 708, 288, 7104, 275, 1543, 1046, 14, 23, 69, 7, 288, 876, 11690, 275, 283, 4780, 7, 267, 916, 2152, 365, 302, 1313, 14, 2809, 3157, 26, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
tmxdyf/PJSIP
pjsip-apps/src/confbot/confbot.py
33
16405
# $Id$ # # SIP Conference Bot # # Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # import pjsua as pj import string import sys CFG_FILE = "config" INFO = 1 TRACE = 2 # Call callback. This would just forward the event to the Member class class CallCb(pj.CallCallback): def __init__(self, member, call=None): pj.CallCallback.__init__(self, call) self.member = member def on_state(self): self.member.on_call_state(self.call) def on_media_state(self): self.member.on_call_media_state(self.call) def on_dtmf_digit(self, digits): self.member.on_call_dtmf_digit(self.call, digits) def on_transfer_request(self, dst, code): return self.member.on_call_transfer_request(self.call, dst, code) def on_transfer_status(self, code, reason, final, cont): return self.member.on_call_transfer_status(self.call, code, reason, final, cont) def on_replace_request(self, code, reason): return self.member.on_call_replace_request(self.call, code, reason) def on_replaced(self, new_call): self.member.on_call_replaced(self.call, new_call) def on_typing(self, is_typing): self.member.on_typing(is_typing, call=self.call) def on_pager(self, mime_type, body): self.member.on_pager(mime_type, body, call=self.call) def on_pager_status(self, body, im_id, code, reason): self.member.on_pager_status(body, im_id, code, reason, call=self.call) # Buddy callback. This would just forward the event to Member class class BuddyCb(pj.BuddyCallback): def __init__(self, member, buddy=None): pj.BuddyCallback.__init__(self, buddy) self.member = member def on_pager(self, mime_type, body): self.member.on_pager(mime_type, body, buddy=self.buddy) def on_pager_status(self, body, im_id, code, reason): self.member.on_pager_status(body, im_id, code, reason, buddy=self.buddy) def on_state(self): self.member.on_pres_state(self.buddy) def on_typing(self, is_typing): self.member.on_typing(is_typing, buddy=self.buddy) ############################################################################## # # # This class represents individual room member (either/both chat and voice conf) # # class Member: def __init__(self, bot, uri): self.uri = uri self.bot = bot self.call = None self.buddy = None self.bi = pj.BuddyInfo() self.in_chat = False self.in_voice = False self.im_error = False self.html = False def __str__(self): str = string.ljust(self.uri, 30) + " -- " if self.buddy: bi = self.buddy.info() str = str + bi.online_text else: str = str + "Offline" str = str + " [" if (self.in_voice): str = str + " voice" if (self.in_chat): str = str + " chat" if (self.html): str = str + " html" else: str = str + " plain" if (self.im_error): str = str + " im_error" str = str + "]" return str def join_call(self, call): if self.call: self.call.hangup(603, "You have been disconnected for making another call") self.call = call call.set_callback(CallCb(self, call)) msg = "%(uri)s is attempting to join the voice conference" % \ {'uri': self.uri} self.bot.DEBUG(msg + "\n", INFO) self.bot.broadcast_pager(None, msg) def join_chat(self): if not self.buddy: self.bot.DEBUG(self.uri + " joining chatroom...\n", INFO) self.buddy = self.bot.acc.add_buddy(self.uri) self.buddy.set_callback(BuddyCb(self, self.buddy)) self.buddy.subscribe() else: self.bot.DEBUG(self.uri + " already in chatroom, resubscribing..\n", INFO) self.buddy.subscribe() def send_pager(self, body, mime="text/plain"): self.bot.DEBUG("send_pager() to " + self.uri) if self.in_chat and not self.im_error and self.buddy: if self.html: #This will make us receive html! #mime = "text/html" body = body.replace("<", "&lt;") body = body.replace(">", "&gt;") body = body.replace('"', "&quot;") body = body.replace("\n", "<BR>\n") self.buddy.send_pager(body, content_type=mime) self.bot.DEBUG("..sent\n") else: self.bot.DEBUG("..not sent!\n") def on_call_state(self, call): ci = call.info() if ci.state==pj.CallState.DISCONNECTED: if self.in_voice: msg = "%(uri)s has left the voice conference (%(1)d/%(2)s)" % \ {'uri': self.uri, '1': ci.last_code, '2': ci.last_reason} self.bot.DEBUG(msg + "\n", INFO) self.bot.broadcast_pager(None, msg) self.in_voice = False self.call = None self.bot.on_member_left(self) elif ci.state==pj.CallState.CONFIRMED: msg = "%(uri)s has joined the voice conference" % \ {'uri': self.uri} self.bot.DEBUG(msg + "\n", INFO) self.bot.broadcast_pager(None, msg) def on_call_media_state(self, call): self.bot.DEBUG("Member.on_call_media_state\n") ci = call.info() if ci.conf_slot!=-1: if not self.in_voice: msg = self.uri + " call media is active" self.bot.broadcast_pager(None, msg) self.in_voice = True self.bot.add_to_voice_conf(self) else: if self.in_voice: msg = self.uri + " call media is inactive" self.bot.broadcast_pager(None, msg) self.in_voice = False def on_call_dtmf_digit(self, call, digits): msg = "%(uri)s sent DTMF digits %(dig)s" % \ {'uri': self.uri, 'dig': digits} self.bot.broadcast_pager(None, msg) def on_call_transfer_request(self, call, dst, code): msg = "%(uri)s is transferring the call to %(dst)s" % \ {'uri': self.uri, 'dst': dst} self.bot.broadcast_pager(None, msg) return 202 def on_call_transfer_status(self, call, code, reason, final, cont): msg = "%(uri)s call transfer status is %(code)d/%(res)s" % \ {'uri': self.uri, 'code': code, 'res': reason} self.bot.broadcast_pager(None, msg) return True def on_call_replace_request(self, call, code, reason): msg = "%(uri)s is requesting call replace" % \ {'uri': self.uri} self.bot.broadcast_pager(None, msg) return (code, reason) def on_call_replaced(self, call, new_call): msg = "%(uri)s call is replaced" % \ {'uri': self.uri} self.bot.broadcast_pager(None, msg) def on_pres_state(self, buddy): old_bi = self.bi self.bi = buddy.info() msg = "%(uri)s status is %(st)s" % \ {'uri': self.uri, 'st': self.bi.online_text} self.bot.DEBUG(msg + "\n", INFO) self.bot.broadcast_pager(self, msg) if self.bi.sub_state==pj.SubscriptionState.ACTIVE: if not self.in_chat: self.in_chat = True buddy.send_pager("Welcome to chatroom") self.bot.broadcast_pager(self, self.uri + " has joined the chat room") else: self.in_chat = True elif self.bi.sub_state==pj.SubscriptionState.NULL or \ self.bi.sub_state==pj.SubscriptionState.TERMINATED or \ self.bi.sub_state==pj.SubscriptionState.UNKNOWN: self.buddy.delete() self.buddy = None if self.in_chat: self.in_chat = False self.bot.broadcast_pager(self, self.uri + " has left the chat room") else: self.in_chat = False self.bot.on_member_left(self) def on_typing(self, is_typing, call=None, buddy=None): if is_typing: msg = self.uri + " is typing..." else: msg = self.uri + " has stopped typing" self.bot.broadcast_pager(self, msg) def on_pager(self, mime_type, body, call=None, buddy=None): if not self.bot.handle_cmd(self, None, body): msg = self.uri + ": " + body self.bot.broadcast_pager(self, msg, mime_type) def on_pager_status(self, body, im_id, code, reason, call=None, buddy=None): self.im_error = (code/100 != 2) ############################################################################## # # # The Bot instance (singleton) # # class Bot(pj.AccountCallback): def __init__(self): pj.AccountCallback.__init__(self, None) self.lib = pj.Lib() self.acc = None self.calls = [] self.members = {} self.cfg = None def DEBUG(self, msg, level=TRACE): print msg, def helpstring(self): return """ --h[elp] Display this help screen --j[oin] Join the chat room --html on|off Set to receive HTML or plain text Participant commands: --s[how] Show confbot settings --leave Leave the chatroom --l[ist] List all members Admin commands: --a[dmin] <CMD> Where <CMD> are: list List the admins add <URI> Add URI as admin del <URI> Remove URI as admin rr Reregister account to server call <URI> Make call to the URI and add to voice conf dc <URI> Disconnect call to URI hold <URI> Hold call with that URI update <URI> Send UPDATE to call with that URI reinvite <URI> Send re-INVITE to call with that URI """ def listmembers(self): msg = "" for uri, m in self.members.iteritems(): msg = msg + str(m) + "\n" return msg def showsettings(self): ai = self.acc.info() msg = """ ConfBot status and settings: URI: %(uri)s Status: %(pres)s Reg Status: %(reg_st)d Reg Reason: %(reg_res)s """ % {'uri': ai.uri, 'pres': ai.online_text, \ 'reg_st': ai.reg_status, 'reg_res': ai.reg_reason} return msg def main(self, cfg_file): try: cfg = self.cfg = __import__(cfg_file) self.lib.init(ua_cfg=cfg.ua_cfg, log_cfg=cfg.log_cfg, media_cfg=cfg.media_cfg) self.lib.set_null_snd_dev() transport = None if cfg.udp_cfg: transport = self.lib.create_transport(pj.TransportType.UDP, cfg.udp_cfg) if cfg.tcp_cfg: t = self.lib.create_transport(pj.TransportType.TCP, cfg.tcp_cfg) if not transport: transport = t self.lib.start() if cfg.acc_cfg: self.DEBUG("Creating account %(uri)s..\n" % {'uri': cfg.acc_cfg.id}, INFO) self.acc = self.lib.create_account(cfg.acc_cfg, cb=self) else: self.DEBUG("Creating account for %(t)s..\n" % \ {'t': transport.info().description}, INFO) self.acc = self.lib.create_account_for_transport(transport, cb=self) self.acc.set_basic_status(True) # Wait for ENTER before quitting print "Press q to quit or --help/--h for help" while True: input = sys.stdin.readline().strip(" \t\r\n") if not self.handle_cmd(None, None, input): if input=="q": break self.lib.destroy() self.lib = None except pj.Error, e: print "Exception: " + str(e) if self.lib: self.lib.destroy() self.lib = None def broadcast_pager(self, exclude_member, body, mime_type="text/plain"): self.DEBUG("Broadcast: " + body + "\n") for uri, m in self.members.iteritems(): if m != exclude_member: m.send_pager(body, mime_type) def add_to_voice_conf(self, member): if not member.call: return src_ci = member.call.info() self.DEBUG("bot.add_to_voice_conf\n") for uri, m in self.members.iteritems(): if m==member: continue if not m.call: continue dst_ci = m.call.info() if dst_ci.media_state==pj.MediaState.ACTIVE and dst_ci.conf_slot!=-1: self.lib.conf_connect(src_ci.conf_slot, dst_ci.conf_slot) self.lib.conf_connect(dst_ci.conf_slot, src_ci.conf_slot) def on_member_left(self, member): if not member.call and not member.buddy: del self.members[member.uri] del member def handle_admin_cmd(self, member, body): if member and self.cfg.admins and not member.uri in self.cfg.admins: member.send_pager("You are not admin") return args = body.split() msg = "" if len(args)==1: args.append(" ") if args[1]=="list": if not self.cfg.admins: msg = "Everyone is admin!" else: msg = str(self.cfg.admins) elif args[1]=="add": if len(args)!=3: msg = "Usage: add <URI>" else: self.cfg.admins.append(args[2]) msg = args[2] + " added as admin" elif args[1]=="del": if len(args)!=3: msg = "Usage: del <URI>" elif args[2] not in self.cfg.admins: msg = args[2] + " is not admin" else: self.cfg.admins.remove(args[2]) msg = args[2] + " has been removed from admins" elif args[1]=="rr": msg = "Reregistering.." self.acc.set_registration(True) elif args[1]=="call": if len(args)!=3: msg = "Usage: call <URI>" else: uri = args[2] try: call = self.acc.make_call(uri) except pj.Error, e: msg = "Error: " + str(e) call = None if call: if not uri in self.members: m = Member(self, uri) self.members[m.uri] = m else: m = self.members[uri] msg = "Adding " + m.uri + " to voice conference.." m.join_call(call) elif args[1]=="dc" or args[1]=="hold" or args[1]=="update" or args[1]=="reinvite": if len(args)!=3: msg = "Usage: " + args[1] + " <URI>" else: uri = args[2] if not uri in self.members: msg = "Member not found/URI doesn't match (note: case matters!)" else: m = self.members[uri] if m.call: if args[1]=="dc": msg = "Disconnecting.." m.call.hangup(603, "You're disconnected by admin") elif args[1]=="hold": msg = "Holding the call" m.call.hold() elif args[1]=="update": msg = "Sending UPDATE" m.call.update() elif args[1]=="reinvite": msg = "Sending re-INVITE" m.call.reinvite() else: msg = "He is not in call" else: msg = "Unknown admin command " + body #print "msg is '%(msg)s'" % {'msg': msg} if True: if member: member.send_pager(msg) else: print msg def handle_cmd(self, member, from_uri, body): body = body.strip(" \t\r\n") msg = "" handled = True if body=="--l" or body=="--list": msg = self.listmembers() if msg=="": msg = "Nobody is here" elif body[0:3]=="--s": msg = self.showsettings() elif body[0:6]=="--html" and member: if body[8:11]=="off": member.html = False else: member.html = True elif body=="--h" or body=="--help": msg = self.helpstring() elif body=="--leave": if not member or not member.buddy: msg = "You are not in chatroom" else: member.buddy.unsubscribe() elif body[0:3]=="--j": if not from_uri in self.members: m = Member(self, from_uri) self.members[m.uri] = m self.DEBUG("Adding " + m.uri + " to chatroom\n") m.join_chat() else: m = self.members[from_uri] self.DEBUG("Adding " + m.uri + " to chatroom\n") m.join_chat() elif body[0:3]=="--a": self.handle_admin_cmd(member, body) handled = True else: handled = False if msg: if member: member.send_pager(msg) elif from_uri: self.acc.send_pager(from_uri, msg); else: print msg return handled def on_incoming_call(self, call): self.DEBUG("on_incoming_call from %(uri)s\n" % {'uri': call.info().remote_uri}, INFO) ci = call.info() if not ci.remote_uri in self.members: m = Member(self, ci.remote_uri) self.members[m.uri] = m m.join_call(call) else: m = self.members[ci.remote_uri] m.join_call(call) call.answer(200) def on_incoming_subscribe(self, buddy, from_uri, contact_uri, pres_obj): self.DEBUG("on_incoming_subscribe from %(uri)s\n" % from_uri, INFO) return (200, 'OK') def on_reg_state(self): ai = self.acc.info() self.DEBUG("Registration state: %(code)d/%(reason)s\n" % \ {'code': ai.reg_status, 'reason': ai.reg_reason}, INFO) if ai.reg_status/100==2 and ai.reg_expires > 0: self.acc.set_basic_status(True) def on_pager(self, from_uri, contact, mime_type, body): body = body.strip(" \t\r\n") if not self.handle_cmd(None, from_uri, body): self.acc.send_pager(from_uri, "You have not joined the chat room. Type '--join' to join or '--help' for the help") def on_pager_status(self, to_uri, body, im_id, code, reason): pass def on_typing(self, from_uri, contact, is_typing): pass ############################################################################## # # # main() # # if __name__ == "__main__": bot = Bot() bot.main(CFG_FILE)
gpl-2.0
[ 3, 2672, 1304, 4, 199, 3, 199, 3, 428, 1772, 1448, 1769, 24896, 199, 3, 199, 3, 1898, 334, 35, 9, 9079, 13, 8664, 377, 352, 17031, 3277, 14, 334, 1014, 921, 1544, 14, 266, 10836, 85, 14, 957, 9, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 221, 199, 3, 199, 646, 299, 3596, 1458, 465, 299, 74, 199, 646, 1059, 199, 646, 984, 199, 199, 10118, 63, 3817, 275, 298, 888, 2, 199, 199, 4531, 275, 413, 199, 20112, 275, 499, 507, 199, 3, 6523, 3233, 14, 961, 3955, 2951, 7568, 314, 1566, 370, 314, 14409, 1021, 199, 533, 6523, 24816, 8, 31382, 14, 2176, 2806, 304, 199, 198, 318, 636, 826, 721, 277, 12, 3653, 12, 1240, 29, 403, 304, 507, 198, 31382, 14, 2176, 2806, 855, 826, 721, 277, 12, 1240, 9, 507, 198, 277, 14, 1114, 275, 3653, 8299, 198, 318, 641, 63, 929, 8, 277, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 1250, 63, 929, 8, 277, 14, 1250, 9, 8299, 198, 318, 641, 63, 4603, 63, 929, 8, 277, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 1250, 63, 4603, 63, 929, 8, 277, 14, 1250, 9, 421, 198, 318, 641, 63, 3583, 11821, 63, 8573, 8, 277, 12, 7576, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 1250, 63, 3583, 11821, 63, 8573, 8, 277, 14, 1250, 12, 7576, 9, 421, 198, 318, 641, 63, 9609, 63, 1069, 8, 277, 12, 5042, 12, 1233, 304, 507, 198, 1107, 291, 14, 1114, 14, 265, 63, 1250, 63, 9609, 63, 1069, 8, 277, 14, 1250, 12, 5042, 12, 1233, 9, 8299, 198, 318, 641, 63, 9609, 63, 1205, 8, 277, 12, 1233, 12, 4499, 12, 4242, 12, 13770, 304, 507, 198, 1107, 291, 14, 1114, 14, 265, 63, 1250, 63, 9609, 63, 1205, 8, 277, 14, 1250, 12, 1233, 12, 4499, 12, 4242, 12, 13770, 9, 421, 198, 318, 641, 63, 1814, 63, 1069, 8, 277, 12, 1233, 12, 4499, 304, 507, 198, 1107, 291, 14, 1114, 14, 265, 63, 1250, 63, 1814, 63, 1069, 8, 277, 14, 1250, 12, 1233, 12, 4499, 9, 18118, 198, 318, 641, 63, 31473, 8, 277, 12, 892, 63, 1250, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 1250, 63, 31473, 8, 277, 14, 1250, 12, 892, 63, 1250, 9, 421, 198, 318, 641, 63, 29747, 8, 277, 12, 365, 63, 29747, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 29747, 8, 374, 63, 29747, 12, 1240, 29, 277, 14, 1250, 9, 421, 198, 318, 641, 63, 21219, 8, 277, 12, 6660, 63, 466, 12, 2396, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 21219, 8, 7626, 63, 466, 12, 2396, 12, 1240, 29, 277, 14, 1250, 9, 8299, 198, 318, 641, 63, 21219, 63, 1205, 8, 277, 12, 2396, 12, 3416, 63, 344, 12, 1233, 12, 4499, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 21219, 63, 1205, 8, 2030, 12, 3416, 63, 344, 12, 1233, 12, 4499, 12, 1240, 29, 277, 14, 1250, 9, 199, 199, 3, 4779, 17936, 3233, 14, 961, 3955, 2951, 7568, 314, 1566, 370, 14409, 1021, 199, 533, 4779, 17936, 24816, 8, 31382, 14, 1713, 17936, 2806, 304, 199, 198, 318, 636, 826, 721, 277, 12, 3653, 12, 1032, 17936, 29, 403, 304, 507, 198, 31382, 14, 1713, 17936, 2806, 855, 826, 721, 277, 12, 1032, 17936, 9, 507, 198, 277, 14, 1114, 275, 3653, 8299, 198, 318, 641, 63, 21219, 8, 277, 12, 6660, 63, 466, 12, 2396, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 21219, 8, 7626, 63, 466, 12, 2396, 12, 1032, 17936, 29, 277, 14, 27847, 9, 421, 198, 318, 641, 63, 21219, 63, 1205, 8, 277, 12, 2396, 12, 3416, 63, 344, 12, 1233, 12, 4499, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 21219, 63, 1205, 8, 2030, 12, 3416, 63, 344, 12, 1233, 12, 4499, 12, 1032, 17936, 29, 277, 14, 27847, 9, 421, 198, 318, 641, 63, 929, 8, 277, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 24919, 63, 929, 8, 277, 14, 27847, 9, 421, 198, 318, 641, 63, 29747, 8, 277, 12, 365, 63, 29747, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 29747, 8, 374, 63, 29747, 12, 1032, 17936, 29, 277, 14, 27847, 9, 6905, 199, 4605, 199, 3, 199, 3, 199, 3, 961, 1021, 8469, 8212, 14726, 3653, 334, 22051, 15, 10727, 21472, 436, 26563, 3743, 9, 199, 3, 199, 3, 199, 533, 14409, 26, 199, 198, 318, 636, 826, 721, 277, 12, 5888, 12, 5108, 304, 507, 198, 277, 14, 2302, 275, 5108, 507, 198, 277, 14, 3018, 275, 5888, 507, 198, 277, 14, 1250, 275, 488, 507, 198, 277, 14, 27847, 275, 488, 507, 198, 277, 14, 4492, 275, 299, 74, 14, 1713, 17936, 2354, 342, 507, 198, 277, 14, 262, 63, 10289, 275, 756, 507, 198, 277, 14, 262, 63, 3789, 275, 756, 507, 198, 277, 14, 1017, 63, 705, 275, 756, 507, 198, 277, 14, 1360, 275, 756, 8299, 198, 318, 636, 495, 721, 277, 304, 507, 198, 495, 275, 1059, 14, 19996, 8, 277, 14, 2302, 12, 4233, 9, 435, 298, 1553, 298, 11083, 198, 692, 291 ]
[ 2672, 1304, 4, 199, 3, 199, 3, 428, 1772, 1448, 1769, 24896, 199, 3, 199, 3, 1898, 334, 35, 9, 9079, 13, 8664, 377, 352, 17031, 3277, 14, 334, 1014, 921, 1544, 14, 266, 10836, 85, 14, 957, 9, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 221, 15673, 13, 13421, 221, 8217, 221, 199, 3, 199, 646, 299, 3596, 1458, 465, 299, 74, 199, 646, 1059, 199, 646, 984, 199, 199, 10118, 63, 3817, 275, 298, 888, 2, 199, 199, 4531, 275, 413, 199, 20112, 275, 499, 507, 199, 3, 6523, 3233, 14, 961, 3955, 2951, 7568, 314, 1566, 370, 314, 14409, 1021, 199, 533, 6523, 24816, 8, 31382, 14, 2176, 2806, 304, 199, 198, 318, 636, 826, 721, 277, 12, 3653, 12, 1240, 29, 403, 304, 507, 198, 31382, 14, 2176, 2806, 855, 826, 721, 277, 12, 1240, 9, 507, 198, 277, 14, 1114, 275, 3653, 8299, 198, 318, 641, 63, 929, 8, 277, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 1250, 63, 929, 8, 277, 14, 1250, 9, 8299, 198, 318, 641, 63, 4603, 63, 929, 8, 277, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 1250, 63, 4603, 63, 929, 8, 277, 14, 1250, 9, 421, 198, 318, 641, 63, 3583, 11821, 63, 8573, 8, 277, 12, 7576, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 1250, 63, 3583, 11821, 63, 8573, 8, 277, 14, 1250, 12, 7576, 9, 421, 198, 318, 641, 63, 9609, 63, 1069, 8, 277, 12, 5042, 12, 1233, 304, 507, 198, 1107, 291, 14, 1114, 14, 265, 63, 1250, 63, 9609, 63, 1069, 8, 277, 14, 1250, 12, 5042, 12, 1233, 9, 8299, 198, 318, 641, 63, 9609, 63, 1205, 8, 277, 12, 1233, 12, 4499, 12, 4242, 12, 13770, 304, 507, 198, 1107, 291, 14, 1114, 14, 265, 63, 1250, 63, 9609, 63, 1205, 8, 277, 14, 1250, 12, 1233, 12, 4499, 12, 4242, 12, 13770, 9, 421, 198, 318, 641, 63, 1814, 63, 1069, 8, 277, 12, 1233, 12, 4499, 304, 507, 198, 1107, 291, 14, 1114, 14, 265, 63, 1250, 63, 1814, 63, 1069, 8, 277, 14, 1250, 12, 1233, 12, 4499, 9, 18118, 198, 318, 641, 63, 31473, 8, 277, 12, 892, 63, 1250, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 1250, 63, 31473, 8, 277, 14, 1250, 12, 892, 63, 1250, 9, 421, 198, 318, 641, 63, 29747, 8, 277, 12, 365, 63, 29747, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 29747, 8, 374, 63, 29747, 12, 1240, 29, 277, 14, 1250, 9, 421, 198, 318, 641, 63, 21219, 8, 277, 12, 6660, 63, 466, 12, 2396, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 21219, 8, 7626, 63, 466, 12, 2396, 12, 1240, 29, 277, 14, 1250, 9, 8299, 198, 318, 641, 63, 21219, 63, 1205, 8, 277, 12, 2396, 12, 3416, 63, 344, 12, 1233, 12, 4499, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 21219, 63, 1205, 8, 2030, 12, 3416, 63, 344, 12, 1233, 12, 4499, 12, 1240, 29, 277, 14, 1250, 9, 199, 199, 3, 4779, 17936, 3233, 14, 961, 3955, 2951, 7568, 314, 1566, 370, 14409, 1021, 199, 533, 4779, 17936, 24816, 8, 31382, 14, 1713, 17936, 2806, 304, 199, 198, 318, 636, 826, 721, 277, 12, 3653, 12, 1032, 17936, 29, 403, 304, 507, 198, 31382, 14, 1713, 17936, 2806, 855, 826, 721, 277, 12, 1032, 17936, 9, 507, 198, 277, 14, 1114, 275, 3653, 8299, 198, 318, 641, 63, 21219, 8, 277, 12, 6660, 63, 466, 12, 2396, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 21219, 8, 7626, 63, 466, 12, 2396, 12, 1032, 17936, 29, 277, 14, 27847, 9, 421, 198, 318, 641, 63, 21219, 63, 1205, 8, 277, 12, 2396, 12, 3416, 63, 344, 12, 1233, 12, 4499, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 21219, 63, 1205, 8, 2030, 12, 3416, 63, 344, 12, 1233, 12, 4499, 12, 1032, 17936, 29, 277, 14, 27847, 9, 421, 198, 318, 641, 63, 929, 8, 277, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 24919, 63, 929, 8, 277, 14, 27847, 9, 421, 198, 318, 641, 63, 29747, 8, 277, 12, 365, 63, 29747, 304, 507, 198, 277, 14, 1114, 14, 265, 63, 29747, 8, 374, 63, 29747, 12, 1032, 17936, 29, 277, 14, 27847, 9, 6905, 199, 4605, 199, 3, 199, 3, 199, 3, 961, 1021, 8469, 8212, 14726, 3653, 334, 22051, 15, 10727, 21472, 436, 26563, 3743, 9, 199, 3, 199, 3, 199, 533, 14409, 26, 199, 198, 318, 636, 826, 721, 277, 12, 5888, 12, 5108, 304, 507, 198, 277, 14, 2302, 275, 5108, 507, 198, 277, 14, 3018, 275, 5888, 507, 198, 277, 14, 1250, 275, 488, 507, 198, 277, 14, 27847, 275, 488, 507, 198, 277, 14, 4492, 275, 299, 74, 14, 1713, 17936, 2354, 342, 507, 198, 277, 14, 262, 63, 10289, 275, 756, 507, 198, 277, 14, 262, 63, 3789, 275, 756, 507, 198, 277, 14, 1017, 63, 705, 275, 756, 507, 198, 277, 14, 1360, 275, 756, 8299, 198, 318, 636, 495, 721, 277, 304, 507, 198, 495, 275, 1059, 14, 19996, 8, 277, 14, 2302, 12, 4233, 9, 435, 298, 1553, 298, 11083, 198, 692, 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,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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 ]
uwdata/termite-data-server
server_src/modules/readers/TreeTMReader.py
5
4194
#!/usr/bin/env python # -*- coding: utf-8 -*- import os from LDAReader import LDAReader class TreeTMReader(LDAReader): """ lda_db = a SQLite3 database modelPath = a model folder containing files corpus.voc, model.topic-words, and model.docs """ PROB_THRESHOLD = 0.001 CORPUS_VOCAB_FILENAME = 'corpus.voc' TOPIC_WORDS_FILENAME = 'model.topic-words' DOC_TOPICS_FILENAME = 'model.docs' def __init__(self, lda_db, modelPath): super(TreeTMReader, self).__init__(lda_db) self.modelPath = modelPath self.entryPath = self.GetLatestEntry() self.corpusVocab = '{}/{}'.format( self.modelPath, TreeTMReader.CORPUS_VOCAB_FILENAME ) self.entryTopicWordWeights = '{}/{}'.format( self.entryPath, TreeTMReader.TOPIC_WORDS_FILENAME ) self.entryDocTopicMixtures = '{}/{}'.format( self.entryPath, TreeTMReader.DOC_TOPICS_FILENAME ) def Execute(self): self.logger.info( 'Reading ITM topic model output...' ) self.ReadVocabFile() self.ReadTopicWordWeights() self.ReadDocTopicMixtures() self.logger.info( 'Writing to database...' ) self.SaveToDB() def GetLatestEntry( self ): entries = [] for filename in os.listdir( self.modelPath ): path = '{}/{}'.format( self.modelPath, filename ) # Keep only folders that begin with "entry-". This will prevent # folders like "corpus" to be the last in the list if os.path.isdir( path ) and filename.startswith('entry-'): entries.append(path) # This is so entry-X is listed after entry-Y, X > Y entries.sort() return entries[-1] def ReadVocabFile( self ): self.termList = [] self.logger.debug( ' Loading vocbuary: %s', self.corpusVocab ) with open( self.corpusVocab ) as f: self.termList = [ line.decode('utf-8', 'ignore').rstrip('\n').split('\t')[1] for line in f ] def ReadTopicWordWeights( self ): accumulator = {} self.logger.debug( ' Loading matrix: %s', self.entryTopicWordWeights ) with open( self.entryTopicWordWeights, 'r' ) as f: for line in f: line = line.rstrip('\n').decode('utf-8') topicIndex, term, value = line.split('\t') topicIndex = int(topicIndex) value = float(value) if value > TreeTMReader.PROB_THRESHOLD: if term not in accumulator: accumulator[term] = {} if topicIndex not in accumulator[term]: accumulator[term][topicIndex] = 0.0 accumulator[term][topicIndex] += value self.termTopicMatrix = [] for term in accumulator: for topicIndex in accumulator[term]: value = accumulator[term][topicIndex] self.termTopicMatrix.append({ 'term_index' : term, 'topic_index' : topicIndex, 'value' : value, 'rank' : 0 }) termLookup = { term : termIndex for termIndex, term in enumerate(self.termList) } self.termTopicMatrix.sort( key = lambda d : -d['value'] ) for index, d in enumerate(self.termTopicMatrix): d['term_index'] = termLookup[d['term_index']] d['rank'] = index + 1 def ReadDocTopicMixtures( self ): self.docList = [] self.docTopicMatrix = [] docSet = set() self.logger.debug( ' Loading matrix: %s', self.entryDocTopicMixtures ) with open( self.entryDocTopicMixtures, 'r' ) as f: for index, line in enumerate(f): line = line.rstrip('\n').decode('utf-8') if index == 0: pass # assert line == "#doc source topic proportion ..." else: fields = line.split( ' ' ) docIndex = int(fields[0]) docId = fields[1] topicIndexes = [ int(d) for n, d in enumerate(fields[2:]) if n % 2 == 0 and d != '' ] values = [ float(d) for n, d in enumerate(fields[2:]) if n % 2 == 1 and d != '' ] for n, topicIndex in enumerate(topicIndexes): value = values[n] if value > TreeTMReader.PROB_THRESHOLD: self.docTopicMatrix.append({ 'doc_index' : docId, 'topic_index' : topicIndex, 'value' : value, 'rank' : 0 }) if docId not in docSet: docSet.add(docId) self.docList.append(docId) docLookup = { docId : docIndex for docIndex, docId in enumerate(self.docList) } self.docTopicMatrix.sort( key = lambda d : -d['value'] ) for index, d in enumerate(self.docTopicMatrix): d['doc_index'] = docLookup[d['doc_index']] d['rank'] = index + 1
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 747, 199, 504, 491, 8980, 5929, 492, 491, 8980, 5929, 199, 199, 533, 12178, 20690, 5929, 8, 6533, 33, 5929, 304, 199, 198, 624, 199, 198, 76, 983, 63, 697, 275, 282, 19245, 19, 3050, 199, 198, 1238, 2042, 275, 282, 1402, 4922, 3035, 1584, 16831, 14, 86, 679, 12, 1402, 14, 5746, 13, 3148, 12, 436, 1402, 14, 4757, 199, 198, 624, 8299, 198, 30533, 63, 19307, 275, 378, 14, 4587, 199, 198, 18650, 48, 1668, 63, 10662, 35, 1217, 63, 15440, 275, 283, 16780, 14, 86, 679, 7, 199, 198, 23740, 63, 19984, 63, 15440, 275, 283, 1238, 14, 5746, 13, 3148, 7, 199, 198, 16618, 63, 11422, 21174, 63, 15440, 275, 283, 1238, 14, 4757, 7, 8299, 198, 318, 636, 826, 721, 277, 12, 634, 983, 63, 697, 12, 1402, 2042, 304, 507, 198, 4792, 8, 3987, 20690, 5929, 12, 291, 2843, 826, 721, 76, 983, 63, 697, 9, 507, 198, 277, 14, 1238, 2042, 275, 1402, 2042, 507, 198, 277, 14, 2373, 2042, 275, 291, 14, 1002, 31438, 3900, 342, 507, 198, 277, 14, 16780, 54, 6607, 275, 9005, 30837, 908, 8, 291, 14, 1238, 2042, 12, 12178, 20690, 5929, 14, 18650, 48, 1668, 63, 10662, 35, 1217, 63, 15440, 776, 507, 198, 277, 14, 2373, 12157, 10155, 23885, 275, 9005, 30837, 908, 8, 291, 14, 2373, 2042, 12, 12178, 20690, 5929, 14, 23740, 63, 19984, 63, 15440, 776, 507, 198, 277, 14, 2373, 3768, 12157, 14738, 6969, 275, 9005, 30837, 908, 8, 291, 14, 2373, 2042, 12, 12178, 20690, 5929, 14, 16618, 63, 11422, 21174, 63, 15440, 776, 421, 198, 318, 17009, 8, 277, 304, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 20568, 473, 20690, 7482, 1402, 1072, 13698, 776, 507, 198, 277, 14, 3284, 54, 6607, 1173, 342, 507, 198, 277, 14, 3284, 12157, 10155, 23885, 342, 507, 198, 277, 14, 3284, 3768, 12157, 14738, 6969, 342, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 16646, 370, 3050, 13698, 776, 507, 198, 277, 14, 8229, 1378, 2846, 342, 421, 198, 318, 2372, 31438, 3900, 8, 291, 3461, 507, 198, 3189, 275, 942, 507, 198, 509, 1788, 315, 747, 14, 7374, 8, 291, 14, 1238, 2042, 3461, 686, 198, 515, 275, 9005, 30837, 908, 8, 291, 14, 1238, 2042, 12, 1788, 776, 686, 198, 3, 14797, 1454, 16533, 626, 5386, 543, 298, 2373, 13, 1674, 961, 911, 7981, 686, 198, 3, 16533, 2839, 298, 16780, 2, 370, 506, 314, 2061, 315, 314, 769, 686, 198, 692, 747, 14, 515, 14, 6027, 8, 931, 776, 436, 1788, 14, 2460, 360, 2373, 13, 735, 1585, 198, 3189, 14, 740, 8, 515, 9, 507, 198, 3, 961, 365, 880, 2397, 13, 56, 365, 10532, 2410, 2397, 13, 57, 12, 1323, 690, 1488, 507, 198, 3189, 14, 3191, 342, 507, 198, 1107, 4811, 1988, 17, 61, 421, 198, 318, 5574, 54, 6607, 1173, 8, 291, 3461, 507, 198, 277, 14, 5125, 1296, 275, 942, 507, 198, 277, 14, 2921, 14, 1757, 8, 283, 259, 3835, 5384, 373, 679, 464, 695, 26, 450, 83, 297, 291, 14, 16780, 54, 6607, 776, 507, 198, 1045, 1551, 8, 291, 14, 16780, 54, 6607, 776, 465, 289, 26, 686, 198, 277, 14, 5125, 1296, 275, 359, 1004, 14, 2708, 360, 1624, 13, 24, 297, 283, 4247, 1959, 6735, 2258, 78, 1959, 1294, 2258, 84, 5832, 17, 61, 367, 1004, 315, 289, 1622, 421, 198, 318, 5574, 12157, 10155, 23885, 8, 291, 3461, 507, 198, 21417, 275, 1052, 507, 198, 277, 14, 2921, 14, 1757, 8, 283, 259, 3835, 5384, 3634, 26, 450, 83, 297, 291, 14, 2373, 12157, 10155, 23885, 776, 507, 198, 1045, 1551, 8, 291, 14, 2373, 12157, 10155, 23885, 12, 283, 82, 7, 776, 465, 289, 26, 686, 198, 509, 1004, 315, 289, 26, 1585, 198, 604, 275, 1004, 14, 6735, 2258, 78, 1959, 2708, 360, 1624, 13, 24, 358, 1585, 198, 5746, 2681, 12, 6707, 12, 574, 275, 1004, 14, 1294, 2258, 84, 358, 1585, 198, 5746, 2681, 275, 1109, 8, 5746, 2681, 9, 1585, 198, 585, 275, 2069, 8, 585, 9, 1585, 198, 692, 574, 690, 12178, 20690, 5929, 14, 30533, 63, 19307, 26, 1871, 198, 692, 6707, 440, 315, 23537, 26, 4671, 198, 21417, 59, 5125, 61, 275, 1052, 1871, 198, 692, 7482, 2681, 440, 315, 23537, 59, 5125, 2189, 4671, 198, 21417, 59, 5125, 1527, 5746, 2681, 61, 275, 378, 14, 16, 1871, 198, 21417, 59, 5125, 1527, 5746, 2681, 61, 847, 574, 507, 198, 277, 14, 5125, 12157, 6443, 275, 942, 507, 198, 509, 6707, 315, 23537, 26, 686, 198, 509, 7482, 2681, 315, 23537, 59, 5125, 2189, 1585, 198, 585, 275, 23537, 59, 5125, 1527, 5746, 2681, 61, 1585, 198, 277, 14, 5125, 12157, 6443, 14, 740, 2561, 1871, 198, 1133, 281, 77, 63, 1080, 7, 520, 6707, 12, 1871, 198, 1133, 411, 530, 63, 1080, 7, 520, 7482, 2681, 12, 1871, 198, 7, 585, 7, 520, 574, 12, 1871, 198, 7, 4648, 7, 520, 378, 1585, 198, 1552, 507, 198, 5125, 7521, 275, 469, 6707, 520, 6707, 2681, 367, 6707, 2681, 12, 6707, 315, 3874, 8, 277, 14, 5125, 1296, 9, 789, 507, 198, 277, 14, 5125, 12157, 6443, 14, 3191, 8, 790, 275, 2400, 366, 520, 446, 68, 459, 585, 418, 776, 507, 198, 509, 1478, 12, 366, 315, 3874, 8, 277, 14, 5125, 12157, 6443, 304, 686, 198, 68, 459, 5125, 63, 1080, 418, 275, 6707, 7521, 59, 68, 459, 5125, 63, 1080, 6538, 686, 198, 68, 459, 4648, 418, 275, 1478, 435, 413, 421, 198, 318, 5574, 3768, 12157, 14738, 6969, 8, 291, 3461, 507, 198, 277, 14, 1301, 1296, 275, 942, 507, 198, 277, 14, 1301, 12157, 6443, 275, 942, 507, 198, 1301, 1084, 275, 663, 342, 507, 198, 277, 14, 2921, 14, 1757, 8, 283, 259, 3835, 5384, 3634, 26, 450, 83, 297, 291, 14, 2373, 3768, 12157, 14738, 6969, 776, 507, 198, 1045, 1551, 8, 291, 14, 2373, 3768, 12157, 14738, 6969, 12, 283, 82, 7, 776, 465, 289, 26, 686, 198, 509, 1478, 12, 1004, 315, 3874, 8 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 747, 199, 504, 491, 8980, 5929, 492, 491, 8980, 5929, 199, 199, 533, 12178, 20690, 5929, 8, 6533, 33, 5929, 304, 199, 198, 624, 199, 198, 76, 983, 63, 697, 275, 282, 19245, 19, 3050, 199, 198, 1238, 2042, 275, 282, 1402, 4922, 3035, 1584, 16831, 14, 86, 679, 12, 1402, 14, 5746, 13, 3148, 12, 436, 1402, 14, 4757, 199, 198, 624, 8299, 198, 30533, 63, 19307, 275, 378, 14, 4587, 199, 198, 18650, 48, 1668, 63, 10662, 35, 1217, 63, 15440, 275, 283, 16780, 14, 86, 679, 7, 199, 198, 23740, 63, 19984, 63, 15440, 275, 283, 1238, 14, 5746, 13, 3148, 7, 199, 198, 16618, 63, 11422, 21174, 63, 15440, 275, 283, 1238, 14, 4757, 7, 8299, 198, 318, 636, 826, 721, 277, 12, 634, 983, 63, 697, 12, 1402, 2042, 304, 507, 198, 4792, 8, 3987, 20690, 5929, 12, 291, 2843, 826, 721, 76, 983, 63, 697, 9, 507, 198, 277, 14, 1238, 2042, 275, 1402, 2042, 507, 198, 277, 14, 2373, 2042, 275, 291, 14, 1002, 31438, 3900, 342, 507, 198, 277, 14, 16780, 54, 6607, 275, 9005, 30837, 908, 8, 291, 14, 1238, 2042, 12, 12178, 20690, 5929, 14, 18650, 48, 1668, 63, 10662, 35, 1217, 63, 15440, 776, 507, 198, 277, 14, 2373, 12157, 10155, 23885, 275, 9005, 30837, 908, 8, 291, 14, 2373, 2042, 12, 12178, 20690, 5929, 14, 23740, 63, 19984, 63, 15440, 776, 507, 198, 277, 14, 2373, 3768, 12157, 14738, 6969, 275, 9005, 30837, 908, 8, 291, 14, 2373, 2042, 12, 12178, 20690, 5929, 14, 16618, 63, 11422, 21174, 63, 15440, 776, 421, 198, 318, 17009, 8, 277, 304, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 20568, 473, 20690, 7482, 1402, 1072, 13698, 776, 507, 198, 277, 14, 3284, 54, 6607, 1173, 342, 507, 198, 277, 14, 3284, 12157, 10155, 23885, 342, 507, 198, 277, 14, 3284, 3768, 12157, 14738, 6969, 342, 507, 198, 277, 14, 2921, 14, 815, 8, 283, 16646, 370, 3050, 13698, 776, 507, 198, 277, 14, 8229, 1378, 2846, 342, 421, 198, 318, 2372, 31438, 3900, 8, 291, 3461, 507, 198, 3189, 275, 942, 507, 198, 509, 1788, 315, 747, 14, 7374, 8, 291, 14, 1238, 2042, 3461, 686, 198, 515, 275, 9005, 30837, 908, 8, 291, 14, 1238, 2042, 12, 1788, 776, 686, 198, 3, 14797, 1454, 16533, 626, 5386, 543, 298, 2373, 13, 1674, 961, 911, 7981, 686, 198, 3, 16533, 2839, 298, 16780, 2, 370, 506, 314, 2061, 315, 314, 769, 686, 198, 692, 747, 14, 515, 14, 6027, 8, 931, 776, 436, 1788, 14, 2460, 360, 2373, 13, 735, 1585, 198, 3189, 14, 740, 8, 515, 9, 507, 198, 3, 961, 365, 880, 2397, 13, 56, 365, 10532, 2410, 2397, 13, 57, 12, 1323, 690, 1488, 507, 198, 3189, 14, 3191, 342, 507, 198, 1107, 4811, 1988, 17, 61, 421, 198, 318, 5574, 54, 6607, 1173, 8, 291, 3461, 507, 198, 277, 14, 5125, 1296, 275, 942, 507, 198, 277, 14, 2921, 14, 1757, 8, 283, 259, 3835, 5384, 373, 679, 464, 695, 26, 450, 83, 297, 291, 14, 16780, 54, 6607, 776, 507, 198, 1045, 1551, 8, 291, 14, 16780, 54, 6607, 776, 465, 289, 26, 686, 198, 277, 14, 5125, 1296, 275, 359, 1004, 14, 2708, 360, 1624, 13, 24, 297, 283, 4247, 1959, 6735, 2258, 78, 1959, 1294, 2258, 84, 5832, 17, 61, 367, 1004, 315, 289, 1622, 421, 198, 318, 5574, 12157, 10155, 23885, 8, 291, 3461, 507, 198, 21417, 275, 1052, 507, 198, 277, 14, 2921, 14, 1757, 8, 283, 259, 3835, 5384, 3634, 26, 450, 83, 297, 291, 14, 2373, 12157, 10155, 23885, 776, 507, 198, 1045, 1551, 8, 291, 14, 2373, 12157, 10155, 23885, 12, 283, 82, 7, 776, 465, 289, 26, 686, 198, 509, 1004, 315, 289, 26, 1585, 198, 604, 275, 1004, 14, 6735, 2258, 78, 1959, 2708, 360, 1624, 13, 24, 358, 1585, 198, 5746, 2681, 12, 6707, 12, 574, 275, 1004, 14, 1294, 2258, 84, 358, 1585, 198, 5746, 2681, 275, 1109, 8, 5746, 2681, 9, 1585, 198, 585, 275, 2069, 8, 585, 9, 1585, 198, 692, 574, 690, 12178, 20690, 5929, 14, 30533, 63, 19307, 26, 1871, 198, 692, 6707, 440, 315, 23537, 26, 4671, 198, 21417, 59, 5125, 61, 275, 1052, 1871, 198, 692, 7482, 2681, 440, 315, 23537, 59, 5125, 2189, 4671, 198, 21417, 59, 5125, 1527, 5746, 2681, 61, 275, 378, 14, 16, 1871, 198, 21417, 59, 5125, 1527, 5746, 2681, 61, 847, 574, 507, 198, 277, 14, 5125, 12157, 6443, 275, 942, 507, 198, 509, 6707, 315, 23537, 26, 686, 198, 509, 7482, 2681, 315, 23537, 59, 5125, 2189, 1585, 198, 585, 275, 23537, 59, 5125, 1527, 5746, 2681, 61, 1585, 198, 277, 14, 5125, 12157, 6443, 14, 740, 2561, 1871, 198, 1133, 281, 77, 63, 1080, 7, 520, 6707, 12, 1871, 198, 1133, 411, 530, 63, 1080, 7, 520, 7482, 2681, 12, 1871, 198, 7, 585, 7, 520, 574, 12, 1871, 198, 7, 4648, 7, 520, 378, 1585, 198, 1552, 507, 198, 5125, 7521, 275, 469, 6707, 520, 6707, 2681, 367, 6707, 2681, 12, 6707, 315, 3874, 8, 277, 14, 5125, 1296, 9, 789, 507, 198, 277, 14, 5125, 12157, 6443, 14, 3191, 8, 790, 275, 2400, 366, 520, 446, 68, 459, 585, 418, 776, 507, 198, 509, 1478, 12, 366, 315, 3874, 8, 277, 14, 5125, 12157, 6443, 304, 686, 198, 68, 459, 5125, 63, 1080, 418, 275, 6707, 7521, 59, 68, 459, 5125, 63, 1080, 6538, 686, 198, 68, 459, 4648, 418, 275, 1478, 435, 413, 421, 198, 318, 5574, 3768, 12157, 14738, 6969, 8, 291, 3461, 507, 198, 277, 14, 1301, 1296, 275, 942, 507, 198, 277, 14, 1301, 12157, 6443, 275, 942, 507, 198, 1301, 1084, 275, 663, 342, 507, 198, 277, 14, 2921, 14, 1757, 8, 283, 259, 3835, 5384, 3634, 26, 450, 83, 297, 291, 14, 2373, 3768, 12157, 14738, 6969, 776, 507, 198, 1045, 1551, 8, 291, 14, 2373, 3768, 12157, 14738, 6969, 12, 283, 82, 7, 776, 465, 289, 26, 686, 198, 509, 1478, 12, 1004, 315, 3874, 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, 1, 1, 1, 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 ]
SINGROUP/pycp2k
pycp2k/classes/_each255.py
1
1114
from pycp2k.inputsection import InputSection class _each255(InputSection): def __init__(self): InputSection.__init__(self) self.Just_energy = None self.Powell_opt = None self.Qs_scf = None self.Xas_scf = None self.Md = None self.Pint = None self.Metadynamics = None self.Geo_opt = None self.Rot_opt = None self.Cell_opt = None self.Band = None self.Ep_lin_solver = None self.Spline_find_coeffs = None self.Replica_eval = None self.Bsse = None self.Shell_opt = None self.Tddft_scf = None self._name = "EACH" self._keywords = {'Bsse': 'BSSE', 'Cell_opt': 'CELL_OPT', 'Just_energy': 'JUST_ENERGY', 'Band': 'BAND', 'Xas_scf': 'XAS_SCF', 'Rot_opt': 'ROT_OPT', 'Replica_eval': 'REPLICA_EVAL', 'Tddft_scf': 'TDDFT_SCF', 'Shell_opt': 'SHELL_OPT', 'Md': 'MD', 'Pint': 'PINT', 'Metadynamics': 'METADYNAMICS', 'Geo_opt': 'GEO_OPT', 'Spline_find_coeffs': 'SPLINE_FIND_COEFFS', 'Powell_opt': 'POWELL_OPT', 'Qs_scf': 'QS_SCF', 'Ep_lin_solver': 'EP_LIN_SOLVER'}
lgpl-3.0
[ 504, 1134, 1850, 18, 75, 14, 1210, 2792, 492, 6924, 8660, 421, 199, 533, 485, 10885, 2299, 8, 3205, 8660, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6924, 8660, 855, 826, 721, 277, 9, 267, 291, 14, 22850, 63, 8443, 275, 488, 267, 291, 14, 23432, 1697, 63, 2992, 275, 488, 267, 291, 14, 49, 83, 63, 27441, 275, 488, 267, 291, 14, 56, 305, 63, 27441, 275, 488, 267, 291, 14, 45, 68, 275, 488, 267, 291, 14, 48, 442, 275, 488, 267, 291, 14, 4015, 350, 4019, 2932, 275, 488, 267, 291, 14, 10748, 63, 2992, 275, 488, 267, 291, 14, 14728, 63, 2992, 275, 488, 267, 291, 14, 8108, 63, 2992, 275, 488, 267, 291, 14, 11675, 275, 488, 267, 291, 14, 14057, 63, 472, 63, 11263, 275, 488, 267, 291, 14, 27558, 63, 1623, 63, 15958, 275, 488, 267, 291, 14, 29581, 63, 2579, 275, 488, 267, 291, 14, 26394, 261, 275, 488, 267, 291, 14, 8529, 63, 2992, 275, 488, 267, 291, 14, 52, 617, 856, 63, 27441, 275, 488, 267, 291, 423, 354, 275, 298, 11765, 1244, 2, 267, 291, 423, 7511, 275, 791, 26394, 261, 356, 283, 11087, 899, 297, 283, 8108, 63, 2992, 356, 283, 26474, 63, 5123, 297, 283, 22850, 63, 8443, 356, 283, 42, 7698, 63, 742, 19546, 297, 283, 11675, 356, 283, 23297, 297, 283, 56, 305, 63, 27441, 356, 283, 56, 1179, 63, 5153, 38, 297, 283, 14728, 63, 2992, 356, 283, 31075, 63, 5123, 297, 283, 29581, 63, 2579, 356, 283, 22554, 2507, 33, 63, 28805, 297, 283, 52, 617, 856, 63, 27441, 356, 283, 52, 5745, 2161, 63, 5153, 38, 297, 283, 8529, 63, 2992, 356, 283, 29085, 63, 5123, 297, 283, 45, 68, 356, 283, 5127, 297, 283, 48, 442, 356, 283, 48, 2919, 297, 283, 4015, 350, 4019, 2932, 356, 283, 3940, 1554, 57, 7335, 21174, 297, 283, 10748, 63, 2992, 356, 283, 18120, 63, 5123, 297, 283, 27558, 63, 1623, 63, 15958, 356, 283, 24933, 3565, 63, 27087, 63, 1439, 29512, 51, 297, 283, 23432, 1697, 63, 2992, 356, 283, 1512, 55, 14952, 63, 5123, 297, 283, 49, 83, 63, 27441, 356, 283, 23298, 63, 5153, 38, 297, 283, 14057, 63, 472, 63, 11263, 356, 283, 6102, 63, 6143, 63, 15096, 2111, 936, 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 ]
[ 1134, 1850, 18, 75, 14, 1210, 2792, 492, 6924, 8660, 421, 199, 533, 485, 10885, 2299, 8, 3205, 8660, 304, 272, 347, 636, 826, 721, 277, 304, 267, 6924, 8660, 855, 826, 721, 277, 9, 267, 291, 14, 22850, 63, 8443, 275, 488, 267, 291, 14, 23432, 1697, 63, 2992, 275, 488, 267, 291, 14, 49, 83, 63, 27441, 275, 488, 267, 291, 14, 56, 305, 63, 27441, 275, 488, 267, 291, 14, 45, 68, 275, 488, 267, 291, 14, 48, 442, 275, 488, 267, 291, 14, 4015, 350, 4019, 2932, 275, 488, 267, 291, 14, 10748, 63, 2992, 275, 488, 267, 291, 14, 14728, 63, 2992, 275, 488, 267, 291, 14, 8108, 63, 2992, 275, 488, 267, 291, 14, 11675, 275, 488, 267, 291, 14, 14057, 63, 472, 63, 11263, 275, 488, 267, 291, 14, 27558, 63, 1623, 63, 15958, 275, 488, 267, 291, 14, 29581, 63, 2579, 275, 488, 267, 291, 14, 26394, 261, 275, 488, 267, 291, 14, 8529, 63, 2992, 275, 488, 267, 291, 14, 52, 617, 856, 63, 27441, 275, 488, 267, 291, 423, 354, 275, 298, 11765, 1244, 2, 267, 291, 423, 7511, 275, 791, 26394, 261, 356, 283, 11087, 899, 297, 283, 8108, 63, 2992, 356, 283, 26474, 63, 5123, 297, 283, 22850, 63, 8443, 356, 283, 42, 7698, 63, 742, 19546, 297, 283, 11675, 356, 283, 23297, 297, 283, 56, 305, 63, 27441, 356, 283, 56, 1179, 63, 5153, 38, 297, 283, 14728, 63, 2992, 356, 283, 31075, 63, 5123, 297, 283, 29581, 63, 2579, 356, 283, 22554, 2507, 33, 63, 28805, 297, 283, 52, 617, 856, 63, 27441, 356, 283, 52, 5745, 2161, 63, 5153, 38, 297, 283, 8529, 63, 2992, 356, 283, 29085, 63, 5123, 297, 283, 45, 68, 356, 283, 5127, 297, 283, 48, 442, 356, 283, 48, 2919, 297, 283, 4015, 350, 4019, 2932, 356, 283, 3940, 1554, 57, 7335, 21174, 297, 283, 10748, 63, 2992, 356, 283, 18120, 63, 5123, 297, 283, 27558, 63, 1623, 63, 15958, 356, 283, 24933, 3565, 63, 27087, 63, 1439, 29512, 51, 297, 283, 23432, 1697, 63, 2992, 356, 283, 1512, 55, 14952, 63, 5123, 297, 283, 49, 83, 63, 27441, 356, 283, 23298, 63, 5153, 38, 297, 283, 14057, 63, 472, 63, 11263, 356, 283, 6102, 63, 6143, 63, 15096, 2111, 936, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
PlazaRoute/PlazaRoute-doc
build/upload-to-jira.py
1
1134
#!/bin/python import requests import re import os import sys base_url = "https://jira.robinsuter.ch" api_url = "/rest/api/2/issue/{}/attachments" headers = {"X-Atlassian-Token": "nocheck"} jira_user = os.environ.get("JIRA_USER") jira_pw = os.environ.get("JIRA_PW") jira_prefix = "PZ" branch = os.environ.get("TRAVIS_BRANCH") def get_issue_key(): prefix_re = str.format(r'.*({}-\d+).*', jira_prefix) m = re.match(prefix_re, branch, re.I) if m is None: print(str.format("Issue key of branch {} not found", branch)) exit(1) return m.group(1) def get_file(filename): return open(filename, 'rb') if (len(sys.argv) < 2): print("Must provide filename as argument!") exit(1) issue_key = get_issue_key() request_url = base_url + str.format(api_url, issue_key) filename = sys.argv[1] files = {'file': get_file(filename)} req = requests.post(request_url, auth=(jira_user, jira_pw), files=files, headers=headers) if (req.status_code == 200): print(str.format('upload of {} to issue {} successful', filename, issue_key)) else: print(str.format('Upload to JIRA failed: {}', req.text))
mit
[ 3381, 1393, 15, 1548, 199, 199, 646, 4145, 199, 646, 295, 199, 646, 747, 199, 646, 984, 199, 199, 1095, 63, 633, 275, 298, 2859, 921, 28097, 14, 293, 11329, 2699, 14, 335, 2, 199, 1246, 63, 633, 275, 3286, 3911, 15, 1246, 15, 18, 15, 5237, 19655, 15855, 2, 199, 2139, 275, 2420, 56, 13, 1271, 76, 2608, 290, 13, 3264, 582, 298, 889, 1074, 3570, 199, 28097, 63, 751, 275, 747, 14, 2314, 14, 362, 480, 32126, 2847, 63, 3791, 531, 199, 28097, 63, 8796, 275, 747, 14, 2314, 14, 362, 480, 32126, 2847, 63, 10780, 531, 199, 28097, 63, 1861, 275, 298, 48, 58, 2, 199, 4694, 275, 747, 14, 2314, 14, 362, 480, 1766, 6087, 1311, 63, 24776, 531, 421, 199, 318, 664, 63, 5237, 63, 498, 837, 272, 2403, 63, 264, 275, 620, 14, 908, 8, 82, 1370, 5830, 2440, 2696, 68, 11, 680, 7693, 1335, 20936, 63, 1861, 9, 272, 333, 275, 295, 14, 1431, 8, 1861, 63, 264, 12, 5246, 12, 295, 14, 41, 9, 272, 340, 333, 365, 488, 26, 267, 870, 8, 495, 14, 908, 480, 17106, 790, 402, 5246, 1052, 440, 1911, 401, 5246, 430, 267, 4458, 8, 17, 9, 272, 372, 333, 14, 923, 8, 17, 9, 421, 199, 318, 664, 63, 493, 8, 1501, 304, 272, 372, 1551, 8, 1501, 12, 283, 4848, 358, 421, 199, 692, 334, 552, 8, 1274, 14, 3020, 9, 665, 499, 304, 272, 870, 480, 13757, 5647, 1788, 465, 1423, 9124, 272, 4458, 8, 17, 9, 199, 199, 5237, 63, 498, 275, 664, 63, 5237, 63, 498, 342, 199, 1069, 63, 633, 275, 1300, 63, 633, 435, 620, 14, 908, 8, 1246, 63, 633, 12, 4976, 63, 498, 9, 199, 1501, 275, 984, 14, 3020, 59, 17, 61, 199, 1725, 275, 791, 493, 356, 664, 63, 493, 8, 1501, 6769, 199, 199, 2103, 275, 4145, 14, 1932, 8, 1069, 63, 633, 12, 1790, 2687, 28097, 63, 751, 12, 1335, 20936, 63, 8796, 395, 1584, 29, 1725, 12, 2323, 29, 2139, 9, 199, 199, 692, 334, 2103, 14, 1205, 63, 600, 508, 1926, 304, 272, 870, 8, 495, 14, 908, 360, 5064, 402, 1052, 370, 4976, 1052, 9512, 297, 1788, 12, 4976, 63, 498, 430, 199, 2836, 26, 272, 870, 8, 495, 14, 908, 360, 10301, 370, 1603, 41, 2847, 3405, 26, 1052, 297, 2648, 14, 505, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1393, 15, 1548, 199, 199, 646, 4145, 199, 646, 295, 199, 646, 747, 199, 646, 984, 199, 199, 1095, 63, 633, 275, 298, 2859, 921, 28097, 14, 293, 11329, 2699, 14, 335, 2, 199, 1246, 63, 633, 275, 3286, 3911, 15, 1246, 15, 18, 15, 5237, 19655, 15855, 2, 199, 2139, 275, 2420, 56, 13, 1271, 76, 2608, 290, 13, 3264, 582, 298, 889, 1074, 3570, 199, 28097, 63, 751, 275, 747, 14, 2314, 14, 362, 480, 32126, 2847, 63, 3791, 531, 199, 28097, 63, 8796, 275, 747, 14, 2314, 14, 362, 480, 32126, 2847, 63, 10780, 531, 199, 28097, 63, 1861, 275, 298, 48, 58, 2, 199, 4694, 275, 747, 14, 2314, 14, 362, 480, 1766, 6087, 1311, 63, 24776, 531, 421, 199, 318, 664, 63, 5237, 63, 498, 837, 272, 2403, 63, 264, 275, 620, 14, 908, 8, 82, 1370, 5830, 2440, 2696, 68, 11, 680, 7693, 1335, 20936, 63, 1861, 9, 272, 333, 275, 295, 14, 1431, 8, 1861, 63, 264, 12, 5246, 12, 295, 14, 41, 9, 272, 340, 333, 365, 488, 26, 267, 870, 8, 495, 14, 908, 480, 17106, 790, 402, 5246, 1052, 440, 1911, 401, 5246, 430, 267, 4458, 8, 17, 9, 272, 372, 333, 14, 923, 8, 17, 9, 421, 199, 318, 664, 63, 493, 8, 1501, 304, 272, 372, 1551, 8, 1501, 12, 283, 4848, 358, 421, 199, 692, 334, 552, 8, 1274, 14, 3020, 9, 665, 499, 304, 272, 870, 480, 13757, 5647, 1788, 465, 1423, 9124, 272, 4458, 8, 17, 9, 199, 199, 5237, 63, 498, 275, 664, 63, 5237, 63, 498, 342, 199, 1069, 63, 633, 275, 1300, 63, 633, 435, 620, 14, 908, 8, 1246, 63, 633, 12, 4976, 63, 498, 9, 199, 1501, 275, 984, 14, 3020, 59, 17, 61, 199, 1725, 275, 791, 493, 356, 664, 63, 493, 8, 1501, 6769, 199, 199, 2103, 275, 4145, 14, 1932, 8, 1069, 63, 633, 12, 1790, 2687, 28097, 63, 751, 12, 1335, 20936, 63, 8796, 395, 1584, 29, 1725, 12, 2323, 29, 2139, 9, 199, 199, 692, 334, 2103, 14, 1205, 63, 600, 508, 1926, 304, 272, 870, 8, 495, 14, 908, 360, 5064, 402, 1052, 370, 4976, 1052, 9512, 297, 1788, 12, 4976, 63, 498, 430, 199, 2836, 26, 272, 870, 8, 495, 14, 908, 360, 10301, 370, 1603, 41, 2847, 3405, 26, 1052, 297, 2648, 14, 505, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
benjaminheng/pyivle
pyivle/community.py
2
8715
import api class Community(): # Community.Communities def communities(self, duration=0, auth=True): params = {'Duration': duration} return api.call('Communities', params, auth) # Community.CommunitySearch def community_search(self, searchType, keyword, activeOnly=False, titleOnly=False, auth=True): params = {'SearchType': searchType, 'Keyword': keyword, 'ActiveOnly': activeOnly, 'TitleOnly': titleOnly} return api.call('CommunitySearch', params, auth) # Community.CommunityCategories def community_categories(self, activeOnly=False, auth=True): params = {'ActiveOnly': activeOnly} return api.call('CommunityCategories', params, auth) # Community.CommunityTags def community_tags(self, activeOnly=False, auth=True): params = {'ActiveOnly': activeOnly} return api.call('CommunityTags', params, auth) # Community.Community def community(self, comId, duration=0, auth=True): params = {'ComID': comId, 'Duration': duration} return api.call('Community', params, auth) # Community.CommunityMembers def community_members(self, comId, auth=True): params = {'ComID': comId} return api.call('CommunityMembers', params, auth) # Community.CommunityAnnouncements def community_announcements(self, comId, duration=0, auth=True): params = {'ComID': comId, 'Duration': duration} return api.call('CommunityAnnouncements', params, auth) # Community.CommunityWorkbinFolders def community_workbin_folders(self, comId, includingFiles=True, duration=0, auth=True): params = {'ComID': comId, 'IncludingFiles': includingFiles, 'Duration': duration} return api.call('CommunityWorkbinFolders', params, auth) # Community.CommunityWorkbinFiles def community_workbin_files(self, comId, folderId, duration=0, auth=True): params = {'ComID': comId, 'FolderID': folderId, 'Duration': duration} return api.call('CommunityWorkbinFiles', params, auth) # Community.CommunityForumHeadings def community_forum_headings(self, comId, includingPosts=True, duration=0, auth=True): params = {'ComID': comId, 'IncludingPosts': includingPosts, 'Duration': duration} return api.call('CommunityForumHeadings', params, auth) # Community.CommunityForumPosts def community_forum_posts(self, headingId, duration=0, auth=True): params = {'HeadingId': headingId, 'Duration': duration} return api.call('CommunityForumPosts', params, auth) # Community.CommunityForum_AddLogByPost_JSON def community_forum_add_log_by_post(self, postId, auth=True): params = {'PostID': postId} return api.call('CommunityForum_AddLogByPost_JSON', params, auth, 'post') # Community.CommunityForum_NewTopic_JSON def community_forum_new_topic(self, headingId, title, message, auth=True): params = {'HeadingID': headingId, 'Title': title, 'Message': message} return api.call('CommunityForum_NewTopic_JSON', params, auth, 'post') # Community.CommunityForum_ReplyPost_JSON def community_forum_reply_post(self, postId, title, message, auth=True): params = {'PostID': postId, 'Title': title, 'Message': message} return api.call('CommunityForum_ReplyPost_JSON', params, auth, 'post') # Community.CommunityWeblinks def community_weblinks(self, comId, auth=True): params = {'ComID': comId} return api.call('CommunityWeblinks', params, auth) # Community.Community_Join_JSON def community_join(self, comId, auth=True): params = {'ComID': comId} return api.call('Community_Join_JSON', params, auth, 'post') # Community.Community_Quit_JSON def community_quit(self, comId, auth=True): params = {'ComID': comId} return api.call('Community_Quit_JSON', params, auth, 'post') # Community.Community_AddMember_JSON def community_add_member(self, comId, memberId, memberType, auth=True): params = {'ComID': comId, 'MemberID': memberId, 'MemberType': memberType} return api.call('Community_AddMember_JSON', params, auth, 'post') # Community.Community_DeleteMember_JSON def community_delete_member(self, comId, memberId, auth=True): params = {'ComID': comId, 'MemberID': memberId} return api.call('Community_DeleteMember_JSON', params, auth, 'post') # Community.Community_UpdateMember_JSON def community_update_member(self, comId, memberId, memberType, auth=True): params = {'ComID': comId, 'MemberID': memberId, 'MemberType': memberType} return api.call('Community_UpdateMember_JSON', params, auth, 'post') # Community.Community_Create_JSON def community_create(self, title, description, accessType, defaultForum, defaultWorkbin, categoryId, tags, auth=True): params = {'Title': title, 'Description': description, 'AccessType': accessType, 'DefaultForm': defaultForum, 'DefaultWorkbin': defaultWorkbin, 'CategoryID': categoryId, 'Tags': tags} return api.call('Community_Create_JSON', params, auth, 'post') # Community.Community_Update_JSON def community_update(self, title, description, accessType, defaultForum, defaultWorkbin, categoryId, tags, displayMembersTo, openingDate, expiryDate, auth=True): params = {'Title': title, 'Description': description, 'AccessType': accessType, 'DefaultForm': defaultForum, 'DefaultWorkbin': defaultWorkbin, 'CategoryID': categoryId, 'Tags': tags, 'DisplayMembersTo': displayMembersTo, 'OpeningDate': openingDate, 'ExpiryDate': expiryDate} return api.call('Community_Update_JSON', params, auth, 'post') # Community.Community_GetTask def community_get_task(self, taskId, auth=True): params = {'TaskID': taskId} return api.call('Community_GetTask', params, auth) # Community.Community_GetAllTasks def community_get_all_tasks(self, comId, auth=True): params = {'ComID': comId} return api.call('Community_GetAllTasks', params, auth) # Community.Community_GetSubTask def community_get_sub_task(self, taskId, auth=True): params = {'TaskID': taskId} return api.call('Community_GetSubTask', params, auth) # Community.Community_CreateTask_JSON def community_create_task(self, taskId, taskName, taskDescription, parentTaskId, taskStatus, taskPriority, taskDueDate, auth=True): params = {'TaskID': taskId, 'TaskName': taskName, 'TaskDescription': taskDescription, 'ParentTaskID': parentTaskId, 'TaskStatus': taskStatus, 'TaskPriority': taskPriority, 'TaskDueDate': taskDueDate} return api.call('Community_CreateTask_JSON', params, auth, 'post') # Community.Community_UpdateTask_JSON def community_update_task(self, taskId, taskName, taskDescription, parentTaskId, taskStatus, taskPriority, taskDueDate, auth=True): params = {'TaskID': taskId, 'TaskName': taskName, 'TaskDescription': taskDescription, 'ParentTaskID': parentTaskId, 'TaskStatus': taskStatus, 'TaskPriority': taskPriority, 'TaskDueDate': taskDueDate} return api.call('Community_UpdateTask_JSON', params, auth, 'post') # Community.Community_DeleteTask_JSON def community_delete_task(self, taskId, auth=True): params = {'TaskID': taskId} return api.call('Community_DeleteTask_JSON', params, auth, 'post') # Community.Community_CreateComment_JSON def community_create_comment(self, taskId, comment, auth=True): params = {'TaskID': taskId, 'Comment': comment} return api.call('Community_CreateComment_JSON', params, auth, 'post') # Community.Community_UpdateComment_JSON def community_update_comment(self, commentId, comment, auth=True): params = {'CommentID': commentId, 'Comment': comment} return api.call('Community_UpdateComment_JSON', params, auth, 'post') # Community.Community_DeleteComment_JSON def community_delete_comment(self, commentId, auth=True): params = {'CommentID': commentId} return api.call('Community_DeleteComment_JSON', params, auth, 'post') # Community.Community_GetComment def community_get_comment(self, commentId, auth=True): params = {'CommentID': commentId} return api.call('Community_GetComment', params, auth) # Community.Community_GetAllComments def community_get_all_comments(self, taskId, auth=True): params = {'TaskID': taskId} return api.call('Community_GetAllComments', params, auth) # Non-standard API method, replacement for Community.DownloadFile def community_download_file(id, auth=True): return api.download_file(id, 'community', auth)
mit
[ 646, 2986, 199, 199, 533, 7046, 6639, 837, 272, 327, 7046, 6639, 14, 5150, 22047, 272, 347, 1923, 22047, 8, 277, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 5150, 22047, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 5278, 272, 347, 23633, 63, 1733, 8, 277, 12, 2754, 804, 12, 4252, 12, 4702, 5903, 29, 797, 12, 2538, 5903, 29, 797, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 5278, 804, 356, 2754, 804, 12, 283, 10650, 356, 4252, 12, 283, 7472, 5903, 356, 4702, 5903, 12, 283, 6888, 5903, 356, 2538, 5903, 93, 267, 372, 2986, 14, 1250, 360, 29799, 5278, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 28731, 272, 347, 23633, 63, 8906, 8, 277, 12, 4702, 5903, 29, 797, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 7472, 5903, 356, 4702, 5903, 93, 267, 372, 2986, 14, 1250, 360, 29799, 28731, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 9440, 272, 347, 23633, 63, 2969, 8, 277, 12, 4702, 5903, 29, 797, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 7472, 5903, 356, 4702, 5903, 93, 267, 372, 2986, 14, 1250, 360, 29799, 9440, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 272, 347, 23633, 8, 277, 12, 2414, 1304, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 23056, 272, 347, 23633, 63, 6334, 8, 277, 12, 2414, 1304, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 93, 267, 372, 2986, 14, 1250, 360, 29799, 23056, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 2493, 13348, 1470, 272, 347, 23633, 63, 17803, 1470, 8, 277, 12, 2414, 1304, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 2493, 13348, 1470, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 6517, 1393, 7850, 83, 272, 347, 23633, 63, 800, 1393, 63, 15171, 8, 277, 12, 2414, 1304, 12, 5893, 5535, 29, 549, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 12, 283, 607, 4923, 5535, 356, 5893, 5535, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 6517, 1393, 7850, 83, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 6517, 1393, 5535, 272, 347, 23633, 63, 800, 1393, 63, 1725, 8, 277, 12, 2414, 1304, 12, 4922, 1304, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 12, 283, 7850, 998, 356, 4922, 1304, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 6517, 1393, 5535, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 1858, 453, 11664, 780, 272, 347, 23633, 63, 10044, 63, 2993, 780, 8, 277, 12, 2414, 1304, 12, 5893, 6564, 83, 29, 549, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 12, 283, 607, 4923, 6564, 83, 356, 5893, 6564, 83, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 1858, 453, 11664, 780, 297, 1862, 12, 1790, 9, 2286, 327, 7046, 6639, 14, 29799, 1858, 453, 6564, 83, 272, 347, 23633, 63, 10044, 63, 18084, 8, 277, 12, 16631, 1304, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 23818, 1304, 356, 16631, 1304, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 1858, 453, 6564, 83, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 1858, 453, 63, 1123, 2445, 2175, 6564, 63, 6243, 272, 347, 23633, 63, 10044, 63, 525, 63, 793, 63, 991, 63, 1932, 8, 277, 12, 2963, 1304, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 6564, 998, 356, 2963, 1304, 93, 267, 372, 2986, 14, 1250, 360, 29799, 1858, 453, 63, 1123, 2445, 2175, 6564, 63, 6243, 297, 1862, 12, 1790, 12, 283, 1932, 358, 339, 327, 7046, 6639, 14, 29799, 1858, 453, 63, 4665, 12157, 63, 6243, 272, 347, 23633, 63, 10044, 63, 1222, 63, 5746, 8, 277, 12, 16631, 1304, 12, 2538, 12, 1245, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 23818, 998, 356, 16631, 1304, 12, 283, 6888, 356, 2538, 12, 283, 2209, 356, 1245, 93, 267, 372, 2986, 14, 1250, 360, 29799, 1858, 453, 63, 4665, 12157, 63, 6243, 297, 1862, 12, 1790, 12, 283, 1932, 358, 339, 327, 7046, 6639, 14, 29799, 1858, 453, 63, 14166, 6564, 63, 6243, 272, 347, 23633, 63, 10044, 63, 8102, 63, 1932, 8, 277, 12, 2963, 1304, 12, 2538, 12, 1245, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 6564, 998, 356, 2963, 1304, 12, 283, 6888, 356, 2538, 12, 283, 2209, 356, 1245, 93, 267, 372, 2986, 14, 1250, 360, 29799, 1858, 453, 63, 14166, 6564, 63, 6243, 297, 1862, 12, 1790, 12, 283, 1932, 358, 339, 327, 7046, 6639, 14, 29799, 5926, 4614, 272, 347, 23633, 63, 2520, 4614, 8, 277, 12, 2414, 1304, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 93, 267, 372, 2986, 14, 1250, 360, 29799, 5926, 4614, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 63, 13005, 63, 6243, 272, 347, 23633, 63, 904, 8, 277, 12, 2414, 1304, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 93, 267, 372, 2986, 14, 1250, 360, 29799, 63, 13005, 63, 6243, 297, 1862, 12, 1790, 12, 283, 1932, 358, 339, 327, 7046, 6639, 14, 29799, 63, 24145, 63, 6243, 272, 347, 23633, 63, 10589, 8, 277, 12, 2414, 1304, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998 ]
[ 2986, 199, 199, 533, 7046, 6639, 837, 272, 327, 7046, 6639, 14, 5150, 22047, 272, 347, 1923, 22047, 8, 277, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 5150, 22047, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 5278, 272, 347, 23633, 63, 1733, 8, 277, 12, 2754, 804, 12, 4252, 12, 4702, 5903, 29, 797, 12, 2538, 5903, 29, 797, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 5278, 804, 356, 2754, 804, 12, 283, 10650, 356, 4252, 12, 283, 7472, 5903, 356, 4702, 5903, 12, 283, 6888, 5903, 356, 2538, 5903, 93, 267, 372, 2986, 14, 1250, 360, 29799, 5278, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 28731, 272, 347, 23633, 63, 8906, 8, 277, 12, 4702, 5903, 29, 797, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 7472, 5903, 356, 4702, 5903, 93, 267, 372, 2986, 14, 1250, 360, 29799, 28731, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 9440, 272, 347, 23633, 63, 2969, 8, 277, 12, 4702, 5903, 29, 797, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 7472, 5903, 356, 4702, 5903, 93, 267, 372, 2986, 14, 1250, 360, 29799, 9440, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 272, 347, 23633, 8, 277, 12, 2414, 1304, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 23056, 272, 347, 23633, 63, 6334, 8, 277, 12, 2414, 1304, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 93, 267, 372, 2986, 14, 1250, 360, 29799, 23056, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 2493, 13348, 1470, 272, 347, 23633, 63, 17803, 1470, 8, 277, 12, 2414, 1304, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 2493, 13348, 1470, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 6517, 1393, 7850, 83, 272, 347, 23633, 63, 800, 1393, 63, 15171, 8, 277, 12, 2414, 1304, 12, 5893, 5535, 29, 549, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 12, 283, 607, 4923, 5535, 356, 5893, 5535, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 6517, 1393, 7850, 83, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 6517, 1393, 5535, 272, 347, 23633, 63, 800, 1393, 63, 1725, 8, 277, 12, 2414, 1304, 12, 4922, 1304, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 12, 283, 7850, 998, 356, 4922, 1304, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 6517, 1393, 5535, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 1858, 453, 11664, 780, 272, 347, 23633, 63, 10044, 63, 2993, 780, 8, 277, 12, 2414, 1304, 12, 5893, 6564, 83, 29, 549, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 12, 283, 607, 4923, 6564, 83, 356, 5893, 6564, 83, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 1858, 453, 11664, 780, 297, 1862, 12, 1790, 9, 2286, 327, 7046, 6639, 14, 29799, 1858, 453, 6564, 83, 272, 347, 23633, 63, 10044, 63, 18084, 8, 277, 12, 16631, 1304, 12, 7373, 29, 16, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 23818, 1304, 356, 16631, 1304, 12, 283, 13283, 356, 7373, 93, 267, 372, 2986, 14, 1250, 360, 29799, 1858, 453, 6564, 83, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 1858, 453, 63, 1123, 2445, 2175, 6564, 63, 6243, 272, 347, 23633, 63, 10044, 63, 525, 63, 793, 63, 991, 63, 1932, 8, 277, 12, 2963, 1304, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 6564, 998, 356, 2963, 1304, 93, 267, 372, 2986, 14, 1250, 360, 29799, 1858, 453, 63, 1123, 2445, 2175, 6564, 63, 6243, 297, 1862, 12, 1790, 12, 283, 1932, 358, 339, 327, 7046, 6639, 14, 29799, 1858, 453, 63, 4665, 12157, 63, 6243, 272, 347, 23633, 63, 10044, 63, 1222, 63, 5746, 8, 277, 12, 16631, 1304, 12, 2538, 12, 1245, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 23818, 998, 356, 16631, 1304, 12, 283, 6888, 356, 2538, 12, 283, 2209, 356, 1245, 93, 267, 372, 2986, 14, 1250, 360, 29799, 1858, 453, 63, 4665, 12157, 63, 6243, 297, 1862, 12, 1790, 12, 283, 1932, 358, 339, 327, 7046, 6639, 14, 29799, 1858, 453, 63, 14166, 6564, 63, 6243, 272, 347, 23633, 63, 10044, 63, 8102, 63, 1932, 8, 277, 12, 2963, 1304, 12, 2538, 12, 1245, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 6564, 998, 356, 2963, 1304, 12, 283, 6888, 356, 2538, 12, 283, 2209, 356, 1245, 93, 267, 372, 2986, 14, 1250, 360, 29799, 1858, 453, 63, 14166, 6564, 63, 6243, 297, 1862, 12, 1790, 12, 283, 1932, 358, 339, 327, 7046, 6639, 14, 29799, 5926, 4614, 272, 347, 23633, 63, 2520, 4614, 8, 277, 12, 2414, 1304, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 93, 267, 372, 2986, 14, 1250, 360, 29799, 5926, 4614, 297, 1862, 12, 1790, 9, 339, 327, 7046, 6639, 14, 29799, 63, 13005, 63, 6243, 272, 347, 23633, 63, 904, 8, 277, 12, 2414, 1304, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 356, 2414, 1304, 93, 267, 372, 2986, 14, 1250, 360, 29799, 63, 13005, 63, 6243, 297, 1862, 12, 1790, 12, 283, 1932, 358, 339, 327, 7046, 6639, 14, 29799, 63, 24145, 63, 6243, 272, 347, 23633, 63, 10589, 8, 277, 12, 2414, 1304, 12, 1790, 29, 549, 304, 267, 1862, 275, 791, 4373, 998, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chdecultot/frappe
frappe/integrations/doctype/webhook/webhook.py
15
2261
# -*- coding: utf-8 -*- # Copyright (c) 2017, Frappe Technologies and contributors # For license information, please see license.txt from __future__ import unicode_literals import frappe import json, requests from frappe import _ from frappe.model.document import Document from six.moves.urllib.parse import urlparse from time import sleep class Webhook(Document): def autoname(self): self.name = self.webhook_doctype + "-" + self.webhook_docevent def validate(self): self.validate_docevent() self.validate_request_url() self.validate_repeating_fields() def on_update(self): frappe.cache().delete_value('webhooks') def validate_docevent(self): if self.webhook_doctype: is_submittable = frappe.get_value("DocType", self.webhook_doctype, "is_submittable") if not is_submittable and self.webhook_docevent in ["on_submit", "on_cancel", "on_update_after_submit"]: frappe.throw(_("DocType must be Submittable for the selected Doc Event")) def validate_request_url(self): try: request_url = urlparse(self.request_url).netloc if not request_url: raise frappe.ValidationError except Exception as e: frappe.throw(_("Check Request URL"), exc=e) def validate_repeating_fields(self): """Error when Same Field is entered multiple times in webhook_data""" webhook_data = [] for entry in self.webhook_data: webhook_data.append(entry.fieldname) if len(webhook_data)!= len(set(webhook_data)): frappe.throw(_("Same Field is entered more than once")) def enqueue_webhook(doc, webhook): webhook = frappe.get_doc("Webhook", webhook.get("name")) headers = {} data = {} if webhook.webhook_headers: for h in webhook.webhook_headers: if h.get("key") and h.get("value"): headers[h.get("key")] = h.get("value") if webhook.webhook_data: for w in webhook.webhook_data: for k, v in doc.as_dict().items(): if k == w.fieldname: data[w.key] = v for i in range(3): try: r = requests.post(webhook.request_url, data=json.dumps(data), headers=headers, timeout=5) r.raise_for_status() frappe.logger().debug({"webhook_success":r.text}) break except Exception as e: frappe.logger().debug({"webhook_error":e, "try": i+1}) sleep(3*i + 1) if i !=2: continue else: raise e
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 334, 67, 9, 9708, 12, 481, 5034, 19215, 436, 8417, 199, 3, 2104, 4190, 2556, 12, 8749, 1937, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 646, 2022, 12, 4145, 199, 504, 6950, 492, 485, 199, 504, 6950, 14, 1238, 14, 3554, 492, 7543, 199, 504, 3816, 14, 4912, 14, 4078, 14, 1122, 492, 7097, 199, 504, 900, 492, 9435, 199, 199, 533, 6001, 3664, 8, 5564, 304, 199, 198, 318, 6384, 32203, 8, 277, 304, 507, 198, 277, 14, 354, 275, 291, 14, 22944, 63, 6356, 435, 17155, 435, 291, 14, 22944, 63, 1117, 301, 782, 421, 198, 318, 4107, 8, 277, 304, 507, 198, 277, 14, 3502, 63, 1117, 301, 782, 342, 507, 198, 277, 14, 3502, 63, 1069, 63, 633, 342, 507, 198, 277, 14, 3502, 63, 5028, 1958, 63, 955, 342, 421, 198, 318, 641, 63, 873, 8, 277, 304, 507, 198, 9098, 14, 1637, 1252, 1807, 63, 585, 360, 2520, 7922, 358, 421, 198, 318, 4107, 63, 1117, 301, 782, 8, 277, 304, 507, 198, 692, 291, 14, 22944, 63, 6356, 26, 686, 198, 374, 63, 7275, 1224, 275, 6950, 14, 362, 63, 585, 480, 3768, 804, 401, 291, 14, 22944, 63, 6356, 12, 298, 374, 63, 7275, 1224, 531, 686, 198, 692, 440, 365, 63, 7275, 1224, 436, 291, 14, 22944, 63, 1117, 301, 782, 315, 2097, 265, 63, 7275, 401, 298, 265, 63, 6406, 401, 298, 265, 63, 873, 63, 4399, 63, 7275, 6229, 1585, 198, 9098, 14, 11964, 6115, 3768, 804, 1471, 506, 28295, 1224, 367, 314, 4895, 5454, 6763, 2237, 421, 198, 318, 4107, 63, 1069, 63, 633, 8, 277, 304, 507, 198, 893, 26, 686, 198, 1069, 63, 633, 275, 7097, 8, 277, 14, 1069, 63, 633, 680, 12652, 686, 198, 692, 440, 1056, 63, 633, 26, 1585, 198, 3730, 6950, 14, 8172, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 9098, 14, 11964, 6115, 1799, 4784, 2851, 1288, 3178, 29, 69, 9, 421, 198, 318, 4107, 63, 5028, 1958, 63, 955, 8, 277, 304, 507, 198, 624, 547, 1380, 14766, 5024, 365, 19138, 3663, 5431, 315, 30053, 63, 576, 624, 507, 198, 22944, 63, 576, 275, 942, 507, 198, 509, 2397, 315, 291, 14, 22944, 63, 576, 26, 686, 198, 22944, 63, 576, 14, 740, 8, 2373, 14, 13646, 9, 2742, 198, 692, 822, 8, 22944, 63, 576, 9, 1111, 822, 8, 409, 8, 22944, 63, 576, 2298, 686, 198, 9098, 14, 11964, 6115, 8479, 5024, 365, 19138, 1655, 2419, 5403, 2237, 199, 199, 318, 14892, 63, 22944, 8, 1301, 12, 30053, 304, 199, 198, 22944, 275, 6950, 14, 362, 63, 1301, 480, 5926, 3664, 401, 30053, 14, 362, 480, 354, 2237, 199, 198, 2139, 275, 1052, 199, 198, 576, 275, 1052, 199, 198, 692, 30053, 14, 22944, 63, 2139, 26, 507, 198, 509, 394, 315, 30053, 14, 22944, 63, 2139, 26, 686, 198, 692, 394, 14, 362, 480, 498, 531, 436, 394, 14, 362, 480, 585, 2349, 1585, 198, 2139, 59, 72, 14, 362, 480, 498, 11323, 275, 394, 14, 362, 480, 585, 531, 199, 198, 692, 30053, 14, 22944, 63, 576, 26, 507, 198, 509, 336, 315, 30053, 14, 22944, 63, 576, 26, 686, 198, 509, 1022, 12, 373, 315, 1382, 14, 305, 63, 807, 1252, 1744, 837, 1585, 198, 692, 1022, 508, 336, 14, 13646, 26, 1871, 198, 576, 59, 87, 14, 498, 61, 275, 373, 199, 198, 509, 284, 315, 1425, 8, 19, 304, 507, 198, 893, 26, 686, 198, 82, 275, 4145, 14, 1932, 8, 22944, 14, 1069, 63, 633, 12, 666, 29, 1001, 14, 4180, 8, 576, 395, 2323, 29, 2139, 12, 2653, 29, 21, 9, 686, 198, 82, 14, 3730, 63, 509, 63, 1205, 342, 686, 198, 9098, 14, 2921, 1252, 1757, 6333, 22944, 63, 3742, 582, 82, 14, 505, 1552, 686, 198, 4785, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 9098, 14, 2921, 1252, 1757, 6333, 22944, 63, 705, 582, 69, 12, 298, 893, 582, 284, 11, 17, 1552, 686, 198, 4532, 8, 19, 10, 73, 435, 413, 9, 686, 198, 692, 284, 1137, 18, 26, 1585, 198, 6958, 686, 198, 2836, 26, 1585, 198, 3730, 325, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 334, 67, 9, 9708, 12, 481, 5034, 19215, 436, 8417, 199, 3, 2104, 4190, 2556, 12, 8749, 1937, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 646, 2022, 12, 4145, 199, 504, 6950, 492, 485, 199, 504, 6950, 14, 1238, 14, 3554, 492, 7543, 199, 504, 3816, 14, 4912, 14, 4078, 14, 1122, 492, 7097, 199, 504, 900, 492, 9435, 199, 199, 533, 6001, 3664, 8, 5564, 304, 199, 198, 318, 6384, 32203, 8, 277, 304, 507, 198, 277, 14, 354, 275, 291, 14, 22944, 63, 6356, 435, 17155, 435, 291, 14, 22944, 63, 1117, 301, 782, 421, 198, 318, 4107, 8, 277, 304, 507, 198, 277, 14, 3502, 63, 1117, 301, 782, 342, 507, 198, 277, 14, 3502, 63, 1069, 63, 633, 342, 507, 198, 277, 14, 3502, 63, 5028, 1958, 63, 955, 342, 421, 198, 318, 641, 63, 873, 8, 277, 304, 507, 198, 9098, 14, 1637, 1252, 1807, 63, 585, 360, 2520, 7922, 358, 421, 198, 318, 4107, 63, 1117, 301, 782, 8, 277, 304, 507, 198, 692, 291, 14, 22944, 63, 6356, 26, 686, 198, 374, 63, 7275, 1224, 275, 6950, 14, 362, 63, 585, 480, 3768, 804, 401, 291, 14, 22944, 63, 6356, 12, 298, 374, 63, 7275, 1224, 531, 686, 198, 692, 440, 365, 63, 7275, 1224, 436, 291, 14, 22944, 63, 1117, 301, 782, 315, 2097, 265, 63, 7275, 401, 298, 265, 63, 6406, 401, 298, 265, 63, 873, 63, 4399, 63, 7275, 6229, 1585, 198, 9098, 14, 11964, 6115, 3768, 804, 1471, 506, 28295, 1224, 367, 314, 4895, 5454, 6763, 2237, 421, 198, 318, 4107, 63, 1069, 63, 633, 8, 277, 304, 507, 198, 893, 26, 686, 198, 1069, 63, 633, 275, 7097, 8, 277, 14, 1069, 63, 633, 680, 12652, 686, 198, 692, 440, 1056, 63, 633, 26, 1585, 198, 3730, 6950, 14, 8172, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 9098, 14, 11964, 6115, 1799, 4784, 2851, 1288, 3178, 29, 69, 9, 421, 198, 318, 4107, 63, 5028, 1958, 63, 955, 8, 277, 304, 507, 198, 624, 547, 1380, 14766, 5024, 365, 19138, 3663, 5431, 315, 30053, 63, 576, 624, 507, 198, 22944, 63, 576, 275, 942, 507, 198, 509, 2397, 315, 291, 14, 22944, 63, 576, 26, 686, 198, 22944, 63, 576, 14, 740, 8, 2373, 14, 13646, 9, 2742, 198, 692, 822, 8, 22944, 63, 576, 9, 1111, 822, 8, 409, 8, 22944, 63, 576, 2298, 686, 198, 9098, 14, 11964, 6115, 8479, 5024, 365, 19138, 1655, 2419, 5403, 2237, 199, 199, 318, 14892, 63, 22944, 8, 1301, 12, 30053, 304, 199, 198, 22944, 275, 6950, 14, 362, 63, 1301, 480, 5926, 3664, 401, 30053, 14, 362, 480, 354, 2237, 199, 198, 2139, 275, 1052, 199, 198, 576, 275, 1052, 199, 198, 692, 30053, 14, 22944, 63, 2139, 26, 507, 198, 509, 394, 315, 30053, 14, 22944, 63, 2139, 26, 686, 198, 692, 394, 14, 362, 480, 498, 531, 436, 394, 14, 362, 480, 585, 2349, 1585, 198, 2139, 59, 72, 14, 362, 480, 498, 11323, 275, 394, 14, 362, 480, 585, 531, 199, 198, 692, 30053, 14, 22944, 63, 576, 26, 507, 198, 509, 336, 315, 30053, 14, 22944, 63, 576, 26, 686, 198, 509, 1022, 12, 373, 315, 1382, 14, 305, 63, 807, 1252, 1744, 837, 1585, 198, 692, 1022, 508, 336, 14, 13646, 26, 1871, 198, 576, 59, 87, 14, 498, 61, 275, 373, 199, 198, 509, 284, 315, 1425, 8, 19, 304, 507, 198, 893, 26, 686, 198, 82, 275, 4145, 14, 1932, 8, 22944, 14, 1069, 63, 633, 12, 666, 29, 1001, 14, 4180, 8, 576, 395, 2323, 29, 2139, 12, 2653, 29, 21, 9, 686, 198, 82, 14, 3730, 63, 509, 63, 1205, 342, 686, 198, 9098, 14, 2921, 1252, 1757, 6333, 22944, 63, 3742, 582, 82, 14, 505, 1552, 686, 198, 4785, 507, 198, 2590, 2186, 465, 325, 26, 686, 198, 9098, 14, 2921, 1252, 1757, 6333, 22944, 63, 705, 582, 69, 12, 298, 893, 582, 284, 11, 17, 1552, 686, 198, 4532, 8, 19, 10, 73, 435, 413, 9, 686, 198, 692, 284, 1137, 18, 26, 1585, 198, 6958, 686, 198, 2836, 26, 1585, 198, 3730, 325, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nikhilprathapani/python-for-android
python-modules/twisted/twisted/test/test_sip.py
59
33079
# -*- test-case-name: twisted.test.test_sip -*- # Copyright (c) 2001-2009 Twisted Matrix Laboratories. # See LICENSE for details. """Session Initialization Protocol tests.""" from twisted.trial import unittest, util from twisted.protocols import sip from twisted.internet import defer, reactor, utils from twisted.python.versions import Version from twisted.test import proto_helpers from twisted import cred import twisted.cred.portal import twisted.cred.checkers from zope.interface import implements # request, prefixed by random CRLFs request1 = "\n\r\n\n\r" + """\ INVITE sip:foo SIP/2.0 From: mo To: joe Content-Length: 4 abcd""".replace("\n", "\r\n") # request, no content-length request2 = """INVITE sip:foo SIP/2.0 From: mo To: joe 1234""".replace("\n", "\r\n") # request, with garbage after request3 = """INVITE sip:foo SIP/2.0 From: mo To: joe Content-Length: 4 1234 lalalal""".replace("\n", "\r\n") # three requests request4 = """INVITE sip:foo SIP/2.0 From: mo To: joe Content-Length: 0 INVITE sip:loop SIP/2.0 From: foo To: bar Content-Length: 4 abcdINVITE sip:loop SIP/2.0 From: foo To: bar Content-Length: 4 1234""".replace("\n", "\r\n") # response, no content response1 = """SIP/2.0 200 OK From: foo To:bar Content-Length: 0 """.replace("\n", "\r\n") # short header version request_short = """\ INVITE sip:foo SIP/2.0 f: mo t: joe l: 4 abcd""".replace("\n", "\r\n") request_natted = """\ INVITE sip:foo SIP/2.0 Via: SIP/2.0/UDP 10.0.0.1:5060;rport """.replace("\n", "\r\n") class TestRealm: def requestAvatar(self, avatarId, mind, *interfaces): return sip.IContact, None, lambda: None class MessageParsingTestCase(unittest.TestCase): def setUp(self): self.l = [] self.parser = sip.MessagesParser(self.l.append) def feedMessage(self, message): self.parser.dataReceived(message) self.parser.dataDone() def validateMessage(self, m, method, uri, headers, body): """Validate Requests.""" self.assertEquals(m.method, method) self.assertEquals(m.uri.toString(), uri) self.assertEquals(m.headers, headers) self.assertEquals(m.body, body) self.assertEquals(m.finished, 1) def testSimple(self): l = self.l self.feedMessage(request1) self.assertEquals(len(l), 1) self.validateMessage( l[0], "INVITE", "sip:foo", {"from": ["mo"], "to": ["joe"], "content-length": ["4"]}, "abcd") def testTwoMessages(self): l = self.l self.feedMessage(request1) self.feedMessage(request2) self.assertEquals(len(l), 2) self.validateMessage( l[0], "INVITE", "sip:foo", {"from": ["mo"], "to": ["joe"], "content-length": ["4"]}, "abcd") self.validateMessage(l[1], "INVITE", "sip:foo", {"from": ["mo"], "to": ["joe"]}, "1234") def testGarbage(self): l = self.l self.feedMessage(request3) self.assertEquals(len(l), 1) self.validateMessage( l[0], "INVITE", "sip:foo", {"from": ["mo"], "to": ["joe"], "content-length": ["4"]}, "1234") def testThreeInOne(self): l = self.l self.feedMessage(request4) self.assertEquals(len(l), 3) self.validateMessage( l[0], "INVITE", "sip:foo", {"from": ["mo"], "to": ["joe"], "content-length": ["0"]}, "") self.validateMessage( l[1], "INVITE", "sip:loop", {"from": ["foo"], "to": ["bar"], "content-length": ["4"]}, "abcd") self.validateMessage( l[2], "INVITE", "sip:loop", {"from": ["foo"], "to": ["bar"], "content-length": ["4"]}, "1234") def testShort(self): l = self.l self.feedMessage(request_short) self.assertEquals(len(l), 1) self.validateMessage( l[0], "INVITE", "sip:foo", {"from": ["mo"], "to": ["joe"], "content-length": ["4"]}, "abcd") def testSimpleResponse(self): l = self.l self.feedMessage(response1) self.assertEquals(len(l), 1) m = l[0] self.assertEquals(m.code, 200) self.assertEquals(m.phrase, "OK") self.assertEquals( m.headers, {"from": ["foo"], "to": ["bar"], "content-length": ["0"]}) self.assertEquals(m.body, "") self.assertEquals(m.finished, 1) class MessageParsingTestCase2(MessageParsingTestCase): """Same as base class, but feed data char by char.""" def feedMessage(self, message): for c in message: self.parser.dataReceived(c) self.parser.dataDone() class MakeMessageTestCase(unittest.TestCase): def testRequest(self): r = sip.Request("INVITE", "sip:foo") r.addHeader("foo", "bar") self.assertEquals( r.toString(), "INVITE sip:foo SIP/2.0\r\nFoo: bar\r\n\r\n") def testResponse(self): r = sip.Response(200, "OK") r.addHeader("foo", "bar") r.addHeader("Content-Length", "4") r.bodyDataReceived("1234") self.assertEquals( r.toString(), "SIP/2.0 200 OK\r\nFoo: bar\r\nContent-Length: 4\r\n\r\n1234") def testStatusCode(self): r = sip.Response(200) self.assertEquals(r.toString(), "SIP/2.0 200 OK\r\n\r\n") class ViaTestCase(unittest.TestCase): def checkRoundtrip(self, v): s = v.toString() self.assertEquals(s, sip.parseViaHeader(s).toString()) def testExtraWhitespace(self): v1 = sip.parseViaHeader('SIP/2.0/UDP 192.168.1.1:5060') v2 = sip.parseViaHeader('SIP/2.0/UDP 192.168.1.1:5060') self.assertEquals(v1.transport, v2.transport) self.assertEquals(v1.host, v2.host) self.assertEquals(v1.port, v2.port) def test_complex(self): """ Test parsing a Via header with one of everything. """ s = ("SIP/2.0/UDP first.example.com:4000;ttl=16;maddr=224.2.0.1" " ;branch=a7c6a8dlze (Example)") v = sip.parseViaHeader(s) self.assertEquals(v.transport, "UDP") self.assertEquals(v.host, "first.example.com") self.assertEquals(v.port, 4000) self.assertEquals(v.rport, None) self.assertEquals(v.rportValue, None) self.assertEquals(v.rportRequested, False) self.assertEquals(v.ttl, 16) self.assertEquals(v.maddr, "224.2.0.1") self.assertEquals(v.branch, "a7c6a8dlze") self.assertEquals(v.hidden, 0) self.assertEquals(v.toString(), "SIP/2.0/UDP first.example.com:4000" ";ttl=16;branch=a7c6a8dlze;maddr=224.2.0.1") self.checkRoundtrip(v) def test_simple(self): """ Test parsing a simple Via header. """ s = "SIP/2.0/UDP example.com;hidden" v = sip.parseViaHeader(s) self.assertEquals(v.transport, "UDP") self.assertEquals(v.host, "example.com") self.assertEquals(v.port, 5060) self.assertEquals(v.rport, None) self.assertEquals(v.rportValue, None) self.assertEquals(v.rportRequested, False) self.assertEquals(v.ttl, None) self.assertEquals(v.maddr, None) self.assertEquals(v.branch, None) self.assertEquals(v.hidden, True) self.assertEquals(v.toString(), "SIP/2.0/UDP example.com:5060;hidden") self.checkRoundtrip(v) def testSimpler(self): v = sip.Via("example.com") self.checkRoundtrip(v) def test_deprecatedRPort(self): """ Setting rport to True is deprecated, but still produces a Via header with the expected properties. """ v = sip.Via("foo.bar", rport=True) warnings = self.flushWarnings( offendingFunctions=[self.test_deprecatedRPort]) self.assertEqual(len(warnings), 1) self.assertEqual( warnings[0]['message'], 'rport=True is deprecated since Twisted 9.0.') self.assertEqual( warnings[0]['category'], DeprecationWarning) self.assertEqual(v.toString(), "SIP/2.0/UDP foo.bar:5060;rport") self.assertEqual(v.rport, True) self.assertEqual(v.rportRequested, True) self.assertEqual(v.rportValue, None) def test_rport(self): """ An rport setting of None should insert the parameter with no value. """ v = sip.Via("foo.bar", rport=None) self.assertEqual(v.toString(), "SIP/2.0/UDP foo.bar:5060;rport") self.assertEqual(v.rportRequested, True) self.assertEqual(v.rportValue, None) def test_rportValue(self): """ An rport numeric setting should insert the parameter with the number value given. """ v = sip.Via("foo.bar", rport=1) self.assertEqual(v.toString(), "SIP/2.0/UDP foo.bar:5060;rport=1") self.assertEqual(v.rportRequested, False) self.assertEqual(v.rportValue, 1) self.assertEqual(v.rport, 1) def testNAT(self): s = "SIP/2.0/UDP 10.0.0.1:5060;received=22.13.1.5;rport=12345" v = sip.parseViaHeader(s) self.assertEquals(v.transport, "UDP") self.assertEquals(v.host, "10.0.0.1") self.assertEquals(v.port, 5060) self.assertEquals(v.received, "22.13.1.5") self.assertEquals(v.rport, 12345) self.assertNotEquals(v.toString().find("rport=12345"), -1) def test_unknownParams(self): """ Parsing and serializing Via headers with unknown parameters should work. """ s = "SIP/2.0/UDP example.com:5060;branch=a12345b;bogus;pie=delicious" v = sip.parseViaHeader(s) self.assertEqual(v.toString(), s) class URLTestCase(unittest.TestCase): def testRoundtrip(self): for url in [ "sip:j.doe@big.com", "sip:j.doe:secret@big.com;transport=tcp", "sip:j.doe@big.com?subject=project", "sip:example.com", ]: self.assertEquals(sip.parseURL(url).toString(), url) def testComplex(self): s = ("sip:user:pass@hosta:123;transport=udp;user=phone;method=foo;" "ttl=12;maddr=1.2.3.4;blah;goo=bar?a=b&c=d") url = sip.parseURL(s) for k, v in [("username", "user"), ("password", "pass"), ("host", "hosta"), ("port", 123), ("transport", "udp"), ("usertype", "phone"), ("method", "foo"), ("ttl", 12), ("maddr", "1.2.3.4"), ("other", ["blah", "goo=bar"]), ("headers", {"a": "b", "c": "d"})]: self.assertEquals(getattr(url, k), v) class ParseTestCase(unittest.TestCase): def testParseAddress(self): for address, name, urls, params in [ ('"A. G. Bell" <sip:foo@example.com>', "A. G. Bell", "sip:foo@example.com", {}), ("Anon <sip:foo@example.com>", "Anon", "sip:foo@example.com", {}), ("sip:foo@example.com", "", "sip:foo@example.com", {}), ("<sip:foo@example.com>", "", "sip:foo@example.com", {}), ("foo <sip:foo@example.com>;tag=bar;foo=baz", "foo", "sip:foo@example.com", {"tag": "bar", "foo": "baz"}), ]: gname, gurl, gparams = sip.parseAddress(address) self.assertEquals(name, gname) self.assertEquals(gurl.toString(), urls) self.assertEquals(gparams, params) class DummyLocator: implements(sip.ILocator) def getAddress(self, logicalURL): return defer.succeed(sip.URL("server.com", port=5060)) class FailingLocator: implements(sip.ILocator) def getAddress(self, logicalURL): return defer.fail(LookupError()) class ProxyTestCase(unittest.TestCase): def setUp(self): self.proxy = sip.Proxy("127.0.0.1") self.proxy.locator = DummyLocator() self.sent = [] self.proxy.sendMessage = lambda dest, msg: self.sent.append((dest, msg)) def testRequestForward(self): r = sip.Request("INVITE", "sip:foo") r.addHeader("via", sip.Via("1.2.3.4").toString()) r.addHeader("via", sip.Via("1.2.3.5").toString()) r.addHeader("foo", "bar") r.addHeader("to", "<sip:joe@server.com>") r.addHeader("contact", "<sip:joe@1.2.3.5>") self.proxy.datagramReceived(r.toString(), ("1.2.3.4", 5060)) self.assertEquals(len(self.sent), 1) dest, m = self.sent[0] self.assertEquals(dest.port, 5060) self.assertEquals(dest.host, "server.com") self.assertEquals(m.uri.toString(), "sip:foo") self.assertEquals(m.method, "INVITE") self.assertEquals(m.headers["via"], ["SIP/2.0/UDP 127.0.0.1:5060", "SIP/2.0/UDP 1.2.3.4:5060", "SIP/2.0/UDP 1.2.3.5:5060"]) def testReceivedRequestForward(self): r = sip.Request("INVITE", "sip:foo") r.addHeader("via", sip.Via("1.2.3.4").toString()) r.addHeader("foo", "bar") r.addHeader("to", "<sip:joe@server.com>") r.addHeader("contact", "<sip:joe@1.2.3.4>") self.proxy.datagramReceived(r.toString(), ("1.1.1.1", 5060)) dest, m = self.sent[0] self.assertEquals(m.headers["via"], ["SIP/2.0/UDP 127.0.0.1:5060", "SIP/2.0/UDP 1.2.3.4:5060;received=1.1.1.1"]) def testResponseWrongVia(self): # first via must match proxy's address r = sip.Response(200) r.addHeader("via", sip.Via("foo.com").toString()) self.proxy.datagramReceived(r.toString(), ("1.1.1.1", 5060)) self.assertEquals(len(self.sent), 0) def testResponseForward(self): r = sip.Response(200) r.addHeader("via", sip.Via("127.0.0.1").toString()) r.addHeader("via", sip.Via("client.com", port=1234).toString()) self.proxy.datagramReceived(r.toString(), ("1.1.1.1", 5060)) self.assertEquals(len(self.sent), 1) dest, m = self.sent[0] self.assertEquals((dest.host, dest.port), ("client.com", 1234)) self.assertEquals(m.code, 200) self.assertEquals(m.headers["via"], ["SIP/2.0/UDP client.com:1234"]) def testReceivedResponseForward(self): r = sip.Response(200) r.addHeader("via", sip.Via("127.0.0.1").toString()) r.addHeader( "via", sip.Via("10.0.0.1", received="client.com").toString()) self.proxy.datagramReceived(r.toString(), ("1.1.1.1", 5060)) self.assertEquals(len(self.sent), 1) dest, m = self.sent[0] self.assertEquals((dest.host, dest.port), ("client.com", 5060)) def testResponseToUs(self): r = sip.Response(200) r.addHeader("via", sip.Via("127.0.0.1").toString()) l = [] self.proxy.gotResponse = lambda *a: l.append(a) self.proxy.datagramReceived(r.toString(), ("1.1.1.1", 5060)) self.assertEquals(len(l), 1) m, addr = l[0] self.assertEquals(len(m.headers.get("via", [])), 0) self.assertEquals(m.code, 200) def testLoop(self): r = sip.Request("INVITE", "sip:foo") r.addHeader("via", sip.Via("1.2.3.4").toString()) r.addHeader("via", sip.Via("127.0.0.1").toString()) self.proxy.datagramReceived(r.toString(), ("client.com", 5060)) self.assertEquals(self.sent, []) def testCantForwardRequest(self): r = sip.Request("INVITE", "sip:foo") r.addHeader("via", sip.Via("1.2.3.4").toString()) r.addHeader("to", "<sip:joe@server.com>") self.proxy.locator = FailingLocator() self.proxy.datagramReceived(r.toString(), ("1.2.3.4", 5060)) self.assertEquals(len(self.sent), 1) dest, m = self.sent[0] self.assertEquals((dest.host, dest.port), ("1.2.3.4", 5060)) self.assertEquals(m.code, 404) self.assertEquals(m.headers["via"], ["SIP/2.0/UDP 1.2.3.4:5060"]) def testCantForwardResponse(self): pass #testCantForwardResponse.skip = "not implemented yet" class RegistrationTestCase(unittest.TestCase): def setUp(self): self.proxy = sip.RegisterProxy(host="127.0.0.1") self.registry = sip.InMemoryRegistry("bell.example.com") self.proxy.registry = self.proxy.locator = self.registry self.sent = [] self.proxy.sendMessage = lambda dest, msg: self.sent.append((dest, msg)) setUp = utils.suppressWarnings(setUp, util.suppress(category=DeprecationWarning, message=r'twisted.protocols.sip.DigestAuthorizer was deprecated')) def tearDown(self): for d, uri in self.registry.users.values(): d.cancel() del self.proxy def register(self): r = sip.Request("REGISTER", "sip:bell.example.com") r.addHeader("to", "sip:joe@bell.example.com") r.addHeader("contact", "sip:joe@client.com:1234") r.addHeader("via", sip.Via("client.com").toString()) self.proxy.datagramReceived(r.toString(), ("client.com", 5060)) def unregister(self): r = sip.Request("REGISTER", "sip:bell.example.com") r.addHeader("to", "sip:joe@bell.example.com") r.addHeader("contact", "*") r.addHeader("via", sip.Via("client.com").toString()) r.addHeader("expires", "0") self.proxy.datagramReceived(r.toString(), ("client.com", 5060)) def testRegister(self): self.register() dest, m = self.sent[0] self.assertEquals((dest.host, dest.port), ("client.com", 5060)) self.assertEquals(m.code, 200) self.assertEquals(m.headers["via"], ["SIP/2.0/UDP client.com:5060"]) self.assertEquals(m.headers["to"], ["sip:joe@bell.example.com"]) self.assertEquals(m.headers["contact"], ["sip:joe@client.com:5060"]) self.failUnless( int(m.headers["expires"][0]) in (3600, 3601, 3599, 3598)) self.assertEquals(len(self.registry.users), 1) dc, uri = self.registry.users["joe"] self.assertEquals(uri.toString(), "sip:joe@client.com:5060") d = self.proxy.locator.getAddress(sip.URL(username="joe", host="bell.example.com")) d.addCallback(lambda desturl : (desturl.host, desturl.port)) d.addCallback(self.assertEquals, ('client.com', 5060)) return d def testUnregister(self): self.register() self.unregister() dest, m = self.sent[1] self.assertEquals((dest.host, dest.port), ("client.com", 5060)) self.assertEquals(m.code, 200) self.assertEquals(m.headers["via"], ["SIP/2.0/UDP client.com:5060"]) self.assertEquals(m.headers["to"], ["sip:joe@bell.example.com"]) self.assertEquals(m.headers["contact"], ["sip:joe@client.com:5060"]) self.assertEquals(m.headers["expires"], ["0"]) self.assertEquals(self.registry.users, {}) def addPortal(self): r = TestRealm() p = cred.portal.Portal(r) c = cred.checkers.InMemoryUsernamePasswordDatabaseDontUse() c.addUser('userXname@127.0.0.1', 'passXword') p.registerChecker(c) self.proxy.portal = p def testFailedAuthentication(self): self.addPortal() self.register() self.assertEquals(len(self.registry.users), 0) self.assertEquals(len(self.sent), 1) dest, m = self.sent[0] self.assertEquals(m.code, 401) def test_basicAuthentication(self): """ Test that registration with basic authentication suceeds. """ self.addPortal() self.proxy.authorizers = self.proxy.authorizers.copy() self.proxy.authorizers['basic'] = sip.BasicAuthorizer() warnings = self.flushWarnings( offendingFunctions=[self.test_basicAuthentication]) self.assertEqual(len(warnings), 1) self.assertEqual( warnings[0]['message'], "twisted.protocols.sip.BasicAuthorizer was deprecated in " "Twisted 9.0.0") self.assertEqual( warnings[0]['category'], DeprecationWarning) r = sip.Request("REGISTER", "sip:bell.example.com") r.addHeader("to", "sip:joe@bell.example.com") r.addHeader("contact", "sip:joe@client.com:1234") r.addHeader("via", sip.Via("client.com").toString()) r.addHeader("authorization", "Basic " + "userXname:passXword".encode('base64')) self.proxy.datagramReceived(r.toString(), ("client.com", 5060)) self.assertEquals(len(self.registry.users), 1) self.assertEquals(len(self.sent), 1) dest, m = self.sent[0] self.assertEquals(m.code, 200) def test_failedBasicAuthentication(self): """ Failed registration with basic authentication results in an unauthorized error response. """ self.addPortal() self.proxy.authorizers = self.proxy.authorizers.copy() self.proxy.authorizers['basic'] = sip.BasicAuthorizer() warnings = self.flushWarnings( offendingFunctions=[self.test_failedBasicAuthentication]) self.assertEqual(len(warnings), 1) self.assertEqual( warnings[0]['message'], "twisted.protocols.sip.BasicAuthorizer was deprecated in " "Twisted 9.0.0") self.assertEqual( warnings[0]['category'], DeprecationWarning) r = sip.Request("REGISTER", "sip:bell.example.com") r.addHeader("to", "sip:joe@bell.example.com") r.addHeader("contact", "sip:joe@client.com:1234") r.addHeader("via", sip.Via("client.com").toString()) r.addHeader( "authorization", "Basic " + "userXname:password".encode('base64')) self.proxy.datagramReceived(r.toString(), ("client.com", 5060)) self.assertEquals(len(self.registry.users), 0) self.assertEquals(len(self.sent), 1) dest, m = self.sent[0] self.assertEquals(m.code, 401) def testWrongDomainRegister(self): r = sip.Request("REGISTER", "sip:wrong.com") r.addHeader("to", "sip:joe@bell.example.com") r.addHeader("contact", "sip:joe@client.com:1234") r.addHeader("via", sip.Via("client.com").toString()) self.proxy.datagramReceived(r.toString(), ("client.com", 5060)) self.assertEquals(len(self.sent), 0) def testWrongToDomainRegister(self): r = sip.Request("REGISTER", "sip:bell.example.com") r.addHeader("to", "sip:joe@foo.com") r.addHeader("contact", "sip:joe@client.com:1234") r.addHeader("via", sip.Via("client.com").toString()) self.proxy.datagramReceived(r.toString(), ("client.com", 5060)) self.assertEquals(len(self.sent), 0) def testWrongDomainLookup(self): self.register() url = sip.URL(username="joe", host="foo.com") d = self.proxy.locator.getAddress(url) self.assertFailure(d, LookupError) return d def testNoContactLookup(self): self.register() url = sip.URL(username="jane", host="bell.example.com") d = self.proxy.locator.getAddress(url) self.assertFailure(d, LookupError) return d class Client(sip.Base): def __init__(self): sip.Base.__init__(self) self.received = [] self.deferred = defer.Deferred() def handle_response(self, response, addr): self.received.append(response) self.deferred.callback(self.received) class LiveTest(unittest.TestCase): def setUp(self): self.proxy = sip.RegisterProxy(host="127.0.0.1") self.registry = sip.InMemoryRegistry("bell.example.com") self.proxy.registry = self.proxy.locator = self.registry self.serverPort = reactor.listenUDP( 0, self.proxy, interface="127.0.0.1") self.client = Client() self.clientPort = reactor.listenUDP( 0, self.client, interface="127.0.0.1") self.serverAddress = (self.serverPort.getHost().host, self.serverPort.getHost().port) setUp = utils.suppressWarnings(setUp, util.suppress(category=DeprecationWarning, message=r'twisted.protocols.sip.DigestAuthorizer was deprecated')) def tearDown(self): for d, uri in self.registry.users.values(): d.cancel() d1 = defer.maybeDeferred(self.clientPort.stopListening) d2 = defer.maybeDeferred(self.serverPort.stopListening) return defer.gatherResults([d1, d2]) def testRegister(self): p = self.clientPort.getHost().port r = sip.Request("REGISTER", "sip:bell.example.com") r.addHeader("to", "sip:joe@bell.example.com") r.addHeader("contact", "sip:joe@127.0.0.1:%d" % p) r.addHeader("via", sip.Via("127.0.0.1", port=p).toString()) self.client.sendMessage( sip.URL(host="127.0.0.1", port=self.serverAddress[1]), r) d = self.client.deferred def check(received): self.assertEquals(len(received), 1) r = received[0] self.assertEquals(r.code, 200) d.addCallback(check) return d def test_amoralRPort(self): """ rport is allowed without a value, apparently because server implementors might be too stupid to check the received port against 5060 and see if they're equal, and because client implementors might be too stupid to bind to port 5060, or set a value on the rport parameter they send if they bind to another port. """ p = self.clientPort.getHost().port r = sip.Request("REGISTER", "sip:bell.example.com") r.addHeader("to", "sip:joe@bell.example.com") r.addHeader("contact", "sip:joe@127.0.0.1:%d" % p) r.addHeader("via", sip.Via("127.0.0.1", port=p, rport=True).toString()) warnings = self.flushWarnings( offendingFunctions=[self.test_amoralRPort]) self.assertEqual(len(warnings), 1) self.assertEqual( warnings[0]['message'], 'rport=True is deprecated since Twisted 9.0.') self.assertEqual( warnings[0]['category'], DeprecationWarning) self.client.sendMessage(sip.URL(host="127.0.0.1", port=self.serverAddress[1]), r) d = self.client.deferred def check(received): self.assertEquals(len(received), 1) r = received[0] self.assertEquals(r.code, 200) d.addCallback(check) return d registerRequest = """ REGISTER sip:intarweb.us SIP/2.0\r Via: SIP/2.0/UDP 192.168.1.100:50609\r From: <sip:exarkun@intarweb.us:50609>\r To: <sip:exarkun@intarweb.us:50609>\r Contact: "exarkun" <sip:exarkun@192.168.1.100:50609>\r Call-ID: 94E7E5DAF39111D791C6000393764646@intarweb.us\r CSeq: 9898 REGISTER\r Expires: 500\r User-Agent: X-Lite build 1061\r Content-Length: 0\r \r """ challengeResponse = """\ SIP/2.0 401 Unauthorized\r Via: SIP/2.0/UDP 192.168.1.100:50609;received=127.0.0.1;rport=5632\r To: <sip:exarkun@intarweb.us:50609>\r From: <sip:exarkun@intarweb.us:50609>\r Call-ID: 94E7E5DAF39111D791C6000393764646@intarweb.us\r CSeq: 9898 REGISTER\r WWW-Authenticate: Digest nonce="92956076410767313901322208775",opaque="1674186428",qop-options="auth",algorithm="MD5",realm="intarweb.us"\r \r """ authRequest = """\ REGISTER sip:intarweb.us SIP/2.0\r Via: SIP/2.0/UDP 192.168.1.100:50609\r From: <sip:exarkun@intarweb.us:50609>\r To: <sip:exarkun@intarweb.us:50609>\r Contact: "exarkun" <sip:exarkun@192.168.1.100:50609>\r Call-ID: 94E7E5DAF39111D791C6000393764646@intarweb.us\r CSeq: 9899 REGISTER\r Expires: 500\r Authorization: Digest username="exarkun",realm="intarweb.us",nonce="92956076410767313901322208775",response="4a47980eea31694f997369214292374b",uri="sip:intarweb.us",algorithm=MD5,opaque="1674186428"\r User-Agent: X-Lite build 1061\r Content-Length: 0\r \r """ okResponse = """\ SIP/2.0 200 OK\r Via: SIP/2.0/UDP 192.168.1.100:50609;received=127.0.0.1;rport=5632\r To: <sip:exarkun@intarweb.us:50609>\r From: <sip:exarkun@intarweb.us:50609>\r Call-ID: 94E7E5DAF39111D791C6000393764646@intarweb.us\r CSeq: 9899 REGISTER\r Contact: sip:exarkun@127.0.0.1:5632\r Expires: 3600\r Content-Length: 0\r \r """ class FakeDigestAuthorizer(sip.DigestAuthorizer): def generateNonce(self): return '92956076410767313901322208775' def generateOpaque(self): return '1674186428' class FakeRegistry(sip.InMemoryRegistry): """Make sure expiration is always seen to be 3600. Otherwise slow reactors fail tests incorrectly. """ def _cbReg(self, reg): if 3600 < reg.secondsToExpiry or reg.secondsToExpiry < 3598: raise RuntimeError( "bad seconds to expire: %s" % reg.secondsToExpiry) reg.secondsToExpiry = 3600 return reg def getRegistrationInfo(self, uri): d = sip.InMemoryRegistry.getRegistrationInfo(self, uri) return d.addCallback(self._cbReg) def registerAddress(self, domainURL, logicalURL, physicalURL): d = sip.InMemoryRegistry.registerAddress( self, domainURL, logicalURL, physicalURL) return d.addCallback(self._cbReg) class AuthorizationTestCase(unittest.TestCase): def setUp(self): self.proxy = sip.RegisterProxy(host="intarweb.us") self.proxy.authorizers = self.proxy.authorizers.copy() self.proxy.authorizers['digest'] = FakeDigestAuthorizer() self.registry = FakeRegistry("intarweb.us") self.proxy.registry = self.proxy.locator = self.registry self.transport = proto_helpers.FakeDatagramTransport() self.proxy.transport = self.transport r = TestRealm() p = cred.portal.Portal(r) c = cred.checkers.InMemoryUsernamePasswordDatabaseDontUse() c.addUser('exarkun@intarweb.us', 'password') p.registerChecker(c) self.proxy.portal = p setUp = utils.suppressWarnings(setUp, util.suppress(category=DeprecationWarning, message=r'twisted.protocols.sip.DigestAuthorizer was deprecated')) def tearDown(self): for d, uri in self.registry.users.values(): d.cancel() del self.proxy def testChallenge(self): self.proxy.datagramReceived(registerRequest, ("127.0.0.1", 5632)) self.assertEquals( self.transport.written[-1], ((challengeResponse, ("127.0.0.1", 5632))) ) self.transport.written = [] self.proxy.datagramReceived(authRequest, ("127.0.0.1", 5632)) self.assertEquals( self.transport.written[-1], ((okResponse, ("127.0.0.1", 5632))) ) testChallenge.suppress = [ util.suppress( category=DeprecationWarning, message=r'twisted.protocols.sip.DigestAuthorizer was deprecated'), util.suppress( category=DeprecationWarning, message=r'twisted.protocols.sip.DigestedCredentials was deprecated'), util.suppress( category=DeprecationWarning, message=r'twisted.protocols.sip.DigestCalcHA1 was deprecated'), util.suppress( category=DeprecationWarning, message=r'twisted.protocols.sip.DigestCalcResponse was deprecated')] class DeprecationTests(unittest.TestCase): """ Tests for deprecation of obsolete components of L{twisted.protocols.sip}. """ def test_deprecatedDigestCalcHA1(self): """ L{sip.DigestCalcHA1} is deprecated. """ self.callDeprecated(Version("Twisted", 9, 0, 0), sip.DigestCalcHA1, '', '', '', '', '', '') def test_deprecatedDigestCalcResponse(self): """ L{sip.DigestCalcResponse} is deprecated. """ self.callDeprecated(Version("Twisted", 9, 0, 0), sip.DigestCalcResponse, '', '', '', '', '', '', '', '') def test_deprecatedBasicAuthorizer(self): """ L{sip.BasicAuthorizer} is deprecated. """ self.callDeprecated(Version("Twisted", 9, 0, 0), sip.BasicAuthorizer) def test_deprecatedDigestAuthorizer(self): """ L{sip.DigestAuthorizer} is deprecated. """ self.callDeprecated(Version("Twisted", 9, 0, 0), sip.DigestAuthorizer) def test_deprecatedDigestedCredentials(self): """ L{sip.DigestedCredentials} is deprecated. """ self.callDeprecated(Version("Twisted", 9, 0, 0), sip.DigestedCredentials, '', {}, {})
apache-2.0
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 396, 14, 396, 63, 17839, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 4434, 6026, 2072, 11557, 2295, 1041, 199, 199, 504, 7390, 14, 14443, 492, 2882, 12, 4884, 199, 504, 7390, 14, 16541, 492, 25342, 199, 504, 7390, 14, 4901, 492, 10133, 12, 9655, 12, 3778, 199, 504, 7390, 14, 1548, 14, 6234, 492, 3394, 199, 199, 504, 7390, 14, 396, 492, 4104, 63, 7546, 199, 199, 504, 7390, 492, 22314, 199, 646, 7390, 14, 18639, 14, 8707, 199, 646, 7390, 14, 18639, 14, 32514, 199, 199, 504, 20110, 14, 3266, 492, 9031, 421, 199, 3, 1056, 12, 18239, 701, 2196, 445, 2431, 19239, 199, 1069, 17, 275, 1867, 78, 60, 82, 60, 78, 60, 78, 60, 82, 2, 435, 9638, 199, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 1303, 199, 1378, 26, 5225, 69, 199, 2714, 13, 4625, 26, 841, 199, 199, 13591, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 3, 1056, 12, 949, 1564, 13, 1267, 199, 1069, 18, 275, 408, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 1303, 199, 1378, 26, 5225, 69, 199, 199, 4321, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 3, 1056, 12, 543, 17516, 2410, 199, 1069, 19, 275, 408, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 1303, 199, 1378, 26, 5225, 69, 199, 2714, 13, 4625, 26, 841, 199, 199, 4321, 199, 199, 76, 279, 279, 279, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 3, 7795, 4145, 199, 1069, 20, 275, 408, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 1303, 199, 1378, 26, 5225, 69, 199, 2714, 13, 4625, 26, 378, 199, 199, 568, 54, 4427, 25342, 26, 3813, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 3925, 199, 1378, 26, 4681, 199, 2714, 13, 4625, 26, 841, 199, 199, 13591, 568, 54, 4427, 25342, 26, 3813, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 3925, 199, 1378, 26, 4681, 199, 2714, 13, 4625, 26, 841, 199, 199, 4321, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 3, 1177, 12, 949, 1564, 199, 1310, 17, 275, 408, 51, 1772, 15, 18, 14, 16, 1926, 9949, 199, 2532, 26, 221, 3925, 199, 1378, 26, 1700, 199, 2714, 13, 4625, 26, 378, 199, 199, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 3, 3974, 1406, 1015, 199, 1069, 63, 3612, 275, 9638, 199, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 70, 26, 1303, 199, 84, 26, 5225, 69, 199, 76, 26, 841, 199, 199, 13591, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 1069, 63, 9468, 471, 275, 9638, 199, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 2201, 65, 26, 428, 1772, 15, 18, 14, 16, 15, 17457, 1616, 14, 16, 14, 16, 14, 17, 26, 1400, 2259, 27, 82, 719, 199, 199, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 533, 1379, 27422, 26, 272, 347, 1056, 24916, 8, 277, 12, 20913, 1304, 12, 25169, 12, 627, 7436, 304, 267, 372, 25342, 14, 41, 14499, 12, 488, 12, 2400, 26, 488, 199, 199, 533, 6430, 17412, 1746, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 76, 275, 942, 267, 291, 14, 2087, 275, 25342, 14, 14508, 2842, 8, 277, 14, 76, 14, 740, 9, 339, 347, 4733, 2209, 8, 277, 12, 1245, 304, 267, 291, 14, 2087, 14, 25037, 8, 1188, 9, 267, 291, 14, 2087, 14, 576, 10759, 342, 339, 347, 4107, 2209, 8, 277, 12, 333, 12, 1083, 12, 5108, 12, 2323, 12, 2396, 304, 267, 408, 12584, 20260, 1041, 267, 291, 14, 2947, 8, 77, 14, 765, 12, 1083, 9, 267, 291, 14, 2947, 8, 77, 14, 2302, 14, 16695, 1062, 5108, 9, 267, 291, 14, 2947, 8, 77, 14, 2139, 12, 2323, 9, 267, 291, 14, 2947, 8, 77, 14, 2030, 12, 2396, 9, 267, 291, 14, 2947, 8, 77, 14, 8669, 12, 413, 9, 339, 347, 511, 3184, 8, 277, 304, 267, 634, 275, 291, 14, 76, 267, 291, 14, 3871, 2209, 8, 1069, 17, 9, 267, 291, 14, 2947, 8, 552, 8, 76, 395, 413, 9, 267, 291, 14, 3502, 2209, 8, 288, 634, 59, 16, 467, 298, 568, 54, 4427, 401, 298, 17839, 26, 1421, 401, 288, 2420, 504, 582, 2097, 573, 2255, 298, 475, 582, 2097, 20241, 2255, 298, 1317, 13, 1267, 582, 2097, 20, 19057, 288, 298, 13591, 531, 339, 347, 511, 11467, 14508, 8, 277, 304, 267, 634, 275, 291, 14, 76, 267, 291, 14, 3871, 2209, 8, 1069, 17, 9, 267, 291, 14, 3871, 2209, 8, 1069, 18, 9, 267, 291, 14, 2947, 8, 552, 8, 76, 395, 499, 9, 267, 291, 14, 3502, 2209, 8, 288, 634, 59, 16, 467, 298, 568, 54, 4427, 401, 298, 17839, 26, 1421, 401, 288, 2420, 504, 582, 2097, 573, 2255, 298, 475, 582, 2097, 20241, 2255, 298, 1317, 13, 1267, 582, 2097, 20, 19057, 288, 298, 13591, 531, 267, 291, 14, 3502, 2209, 8, 76, 59, 17, 467, 298, 568, 54, 4427, 401, 298, 17839, 26, 1421, 401, 2490, 2420, 504, 582, 2097, 573, 2255, 298, 475, 582, 2097, 20241, 19057, 2490, 298, 4321, 531, 339, 347, 511, 39, 13094, 8, 277, 304, 267, 634, 275, 291, 14, 76, 267, 291, 14, 3871, 2209, 8, 1069, 19, 9, 267, 291, 14, 2947, 8, 552, 8, 76, 395, 413, 9, 267, 291, 14, 3502, 2209, 8, 288, 634, 59, 16, 467, 298, 568, 54, 4427, 401, 298, 17839, 26, 1421, 401, 288, 2420, 504, 582, 2097, 573, 2255, 298, 475, 582, 2097, 20241, 2255, 298, 1317, 13, 1267, 582, 2097, 20, 19057, 288, 298, 4321, 531, 339, 347, 511 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 396, 14, 396, 63, 17839, 1882, 199, 3, 1898, 334, 67, 9, 12521, 13, 8664, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 421, 199, 624, 4434, 6026, 2072, 11557, 2295, 1041, 199, 199, 504, 7390, 14, 14443, 492, 2882, 12, 4884, 199, 504, 7390, 14, 16541, 492, 25342, 199, 504, 7390, 14, 4901, 492, 10133, 12, 9655, 12, 3778, 199, 504, 7390, 14, 1548, 14, 6234, 492, 3394, 199, 199, 504, 7390, 14, 396, 492, 4104, 63, 7546, 199, 199, 504, 7390, 492, 22314, 199, 646, 7390, 14, 18639, 14, 8707, 199, 646, 7390, 14, 18639, 14, 32514, 199, 199, 504, 20110, 14, 3266, 492, 9031, 421, 199, 3, 1056, 12, 18239, 701, 2196, 445, 2431, 19239, 199, 1069, 17, 275, 1867, 78, 60, 82, 60, 78, 60, 78, 60, 82, 2, 435, 9638, 199, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 1303, 199, 1378, 26, 5225, 69, 199, 2714, 13, 4625, 26, 841, 199, 199, 13591, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 3, 1056, 12, 949, 1564, 13, 1267, 199, 1069, 18, 275, 408, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 1303, 199, 1378, 26, 5225, 69, 199, 199, 4321, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 3, 1056, 12, 543, 17516, 2410, 199, 1069, 19, 275, 408, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 1303, 199, 1378, 26, 5225, 69, 199, 2714, 13, 4625, 26, 841, 199, 199, 4321, 199, 199, 76, 279, 279, 279, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 3, 7795, 4145, 199, 1069, 20, 275, 408, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 1303, 199, 1378, 26, 5225, 69, 199, 2714, 13, 4625, 26, 378, 199, 199, 568, 54, 4427, 25342, 26, 3813, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 3925, 199, 1378, 26, 4681, 199, 2714, 13, 4625, 26, 841, 199, 199, 13591, 568, 54, 4427, 25342, 26, 3813, 428, 1772, 15, 18, 14, 16, 199, 2532, 26, 3925, 199, 1378, 26, 4681, 199, 2714, 13, 4625, 26, 841, 199, 199, 4321, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 3, 1177, 12, 949, 1564, 199, 1310, 17, 275, 408, 51, 1772, 15, 18, 14, 16, 1926, 9949, 199, 2532, 26, 221, 3925, 199, 1378, 26, 1700, 199, 2714, 13, 4625, 26, 378, 199, 199, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 3, 3974, 1406, 1015, 199, 1069, 63, 3612, 275, 9638, 199, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 70, 26, 1303, 199, 84, 26, 5225, 69, 199, 76, 26, 841, 199, 199, 13591, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 1069, 63, 9468, 471, 275, 9638, 199, 568, 54, 4427, 25342, 26, 1421, 428, 1772, 15, 18, 14, 16, 199, 2201, 65, 26, 428, 1772, 15, 18, 14, 16, 15, 17457, 1616, 14, 16, 14, 16, 14, 17, 26, 1400, 2259, 27, 82, 719, 199, 199, 23045, 1814, 4582, 78, 401, 1867, 82, 60, 78, 531, 199, 199, 533, 1379, 27422, 26, 272, 347, 1056, 24916, 8, 277, 12, 20913, 1304, 12, 25169, 12, 627, 7436, 304, 267, 372, 25342, 14, 41, 14499, 12, 488, 12, 2400, 26, 488, 199, 199, 533, 6430, 17412, 1746, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 76, 275, 942, 267, 291, 14, 2087, 275, 25342, 14, 14508, 2842, 8, 277, 14, 76, 14, 740, 9, 339, 347, 4733, 2209, 8, 277, 12, 1245, 304, 267, 291, 14, 2087, 14, 25037, 8, 1188, 9, 267, 291, 14, 2087, 14, 576, 10759, 342, 339, 347, 4107, 2209, 8, 277, 12, 333, 12, 1083, 12, 5108, 12, 2323, 12, 2396, 304, 267, 408, 12584, 20260, 1041, 267, 291, 14, 2947, 8, 77, 14, 765, 12, 1083, 9, 267, 291, 14, 2947, 8, 77, 14, 2302, 14, 16695, 1062, 5108, 9, 267, 291, 14, 2947, 8, 77, 14, 2139, 12, 2323, 9, 267, 291, 14, 2947, 8, 77, 14, 2030, 12, 2396, 9, 267, 291, 14, 2947, 8, 77, 14, 8669, 12, 413, 9, 339, 347, 511, 3184, 8, 277, 304, 267, 634, 275, 291, 14, 76, 267, 291, 14, 3871, 2209, 8, 1069, 17, 9, 267, 291, 14, 2947, 8, 552, 8, 76, 395, 413, 9, 267, 291, 14, 3502, 2209, 8, 288, 634, 59, 16, 467, 298, 568, 54, 4427, 401, 298, 17839, 26, 1421, 401, 288, 2420, 504, 582, 2097, 573, 2255, 298, 475, 582, 2097, 20241, 2255, 298, 1317, 13, 1267, 582, 2097, 20, 19057, 288, 298, 13591, 531, 339, 347, 511, 11467, 14508, 8, 277, 304, 267, 634, 275, 291, 14, 76, 267, 291, 14, 3871, 2209, 8, 1069, 17, 9, 267, 291, 14, 3871, 2209, 8, 1069, 18, 9, 267, 291, 14, 2947, 8, 552, 8, 76, 395, 499, 9, 267, 291, 14, 3502, 2209, 8, 288, 634, 59, 16, 467, 298, 568, 54, 4427, 401, 298, 17839, 26, 1421, 401, 288, 2420, 504, 582, 2097, 573, 2255, 298, 475, 582, 2097, 20241, 2255, 298, 1317, 13, 1267, 582, 2097, 20, 19057, 288, 298, 13591, 531, 267, 291, 14, 3502, 2209, 8, 76, 59, 17, 467, 298, 568, 54, 4427, 401, 298, 17839, 26, 1421, 401, 2490, 2420, 504, 582, 2097, 573, 2255, 298, 475, 582, 2097, 20241, 19057, 2490, 298, 4321, 531, 339, 347, 511, 39, 13094, 8, 277, 304, 267, 634, 275, 291, 14, 76, 267, 291, 14, 3871, 2209, 8, 1069, 19, 9, 267, 291, 14, 2947, 8, 552, 8, 76, 395, 413, 9, 267, 291, 14, 3502, 2209, 8, 288, 634, 59, 16, 467, 298, 568, 54, 4427, 401, 298, 17839, 26, 1421, 401, 288, 2420, 504, 582, 2097, 573, 2255, 298, 475, 582, 2097, 20241, 2255, 298, 1317, 13, 1267, 582, 2097, 20, 19057, 288, 298, 4321, 531, 339, 347, 511, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
thaumos/ansible
lib/ansible/modules/cloud/vmware/vmware_datacenter.py
56
6522
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2015, Joseph Callen <jcallen () csc.com> # Copyright: (c) 2018, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = { 'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community' } DOCUMENTATION = ''' --- module: vmware_datacenter short_description: Manage VMware vSphere Datacenters description: - This module can be used to manage (create, delete) VMware vSphere Datacenters. version_added: 2.0 author: - Joseph Callen (@jcpowermac) - Kamil Szczygiel (@kamsz) notes: - Tested on vSphere 6.0, 6.5 requirements: - "python >= 2.6" - PyVmomi options: datacenter_name: description: - The name of the datacenter the cluster will be created in. required: True state: description: - If the datacenter should be present or absent. choices: [ present, absent ] default: present extends_documentation_fragment: vmware.documentation ''' EXAMPLES = ''' - name: Create Datacenter vmware_datacenter: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter_name: '{{ datacenter_name }}' state: present delegate_to: localhost - name: Delete Datacenter vmware_datacenter: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter_name: '{{ datacenter_name }}' state: absent delegate_to: localhost register: datacenter_delete_result ''' RETURN = """# """ try: from pyVmomi import vim, vmodl except ImportError: pass from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.vmware import PyVmomi, find_datacenter_by_name, vmware_argument_spec, wait_for_task from ansible.module_utils._text import to_native class VmwareDatacenterManager(PyVmomi): def __init__(self, module): super(VmwareDatacenterManager, self).__init__(module) self.datacenter_name = self.params.get('datacenter_name') self.datacenter_obj = self.get_datacenter() def ensure(self): state = self.module.params.get('state') if state == 'present': self.create_datacenter() if state == 'absent': self.destroy_datacenter() def get_datacenter(self): try: datacenter_obj = find_datacenter_by_name(self.content, self.datacenter_name) return datacenter_obj except (vmodl.MethodFault, vmodl.RuntimeFault) as runtime_fault: self.module.fail_json(msg="Failed to get datacenter '%s'" " due to : %s" % (self.datacenter_name, to_native(runtime_fault.msg))) except Exception as generic_exc: self.module.fail_json(msg="Failed to get datacenter" " '%s' due to generic error: %s" % (self.datacenter_name, to_native(generic_exc))) def create_datacenter(self): folder = self.content.rootFolder changed = False try: if not self.datacenter_obj and not self.module.check_mode: changed = True folder.CreateDatacenter(name=self.datacenter_name) self.module.exit_json(changed=changed) except vim.fault.DuplicateName as duplicate_name: self.module.exit_json(changed=changed) except vim.fault.InvalidName as invalid_name: self.module.fail_json(msg="Specified datacenter name '%s' is an" " invalid name : %s" % (self.datacenter_name, to_native(invalid_name.msg))) except vmodl.fault.NotSupported as not_supported: # This should never happen self.module.fail_json(msg="Trying to create a datacenter '%s' on" " an incorrect folder object : %s" % (self.datacenter_name, to_native(not_supported.msg))) except (vmodl.RuntimeFault, vmodl.MethodFault) as runtime_fault: self.module.fail_json(msg="Failed to create a datacenter" " '%s' due to : %s" % (self.datacenter_name, to_native(runtime_fault.msg))) except Exception as generic_exc: self.module.fail_json(msg="Failed to create a datacenter" " '%s' due to generic error: %s" % (self.datacenter_name, to_native(generic_exc))) def destroy_datacenter(self): results = dict(changed=False) try: if self.datacenter_obj and not self.module.check_mode: task = self.datacenter_obj.Destroy_Task() changed, result = wait_for_task(task) results['changed'] = changed results['result'] = result self.module.exit_json(**results) except (vim.fault.VimFault, vmodl.RuntimeFault, vmodl.MethodFault) as runtime_fault: self.module.fail_json(msg="Failed to delete a datacenter" " '%s' due to : %s" % (self.datacenter_name, to_native(runtime_fault.msg))) except Exception as generic_exc: self.module.fail_json(msg="Failed to delete a datacenter" " '%s' due to generic error: %s" % (self.datacenter_name, to_native(generic_exc))) def main(): argument_spec = vmware_argument_spec() argument_spec.update( dict( datacenter_name=dict(required=True, type='str'), state=dict(default='present', choices=['present', 'absent'], type='str') ) ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) vmware_datacenter_mgr = VmwareDatacenterManager(module) vmware_datacenter_mgr.ensure() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 26, 334, 67, 9, 6900, 12, 1603, 3362, 838, 445, 7670, 665, 74, 915, 552, 6248, 28308, 14, 957, 30, 199, 3, 1898, 26, 334, 67, 9, 14894, 12, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 469, 272, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 272, 283, 1205, 356, 788, 7780, 995, 272, 283, 4946, 63, 991, 356, 283, 9387, 7, 199, 93, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 19365, 63, 17770, 199, 3612, 63, 1802, 26, 14944, 27391, 373, 22385, 3918, 15660, 199, 1802, 26, 272, 446, 961, 859, 883, 506, 1202, 370, 9635, 334, 981, 12, 3145, 9, 27391, 373, 22385, 3918, 15660, 14, 199, 1023, 63, 3270, 26, 499, 14, 16, 199, 2502, 26, 199, 13, 1603, 3362, 838, 445, 7670, 8593, 22760, 5652, 3088, 9, 199, 13, 1804, 455, 382, 428, 26698, 3605, 6153, 352, 8593, 75, 455, 11803, 9, 199, 5983, 26, 272, 446, 30568, 641, 373, 22385, 1227, 14, 16, 12, 1227, 14, 21, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 1611, 54, 28603, 199, 1419, 26, 272, 16606, 63, 354, 26, 489, 1369, 26, 489, 446, 710, 536, 402, 314, 16606, 314, 4350, 911, 506, 2737, 315, 14, 489, 1415, 26, 715, 272, 1174, 26, 489, 1369, 26, 489, 446, 982, 314, 16606, 1077, 506, 3451, 503, 9552, 14, 489, 3415, 26, 359, 3451, 12, 9552, 1622, 489, 849, 26, 3451, 199, 11036, 63, 9970, 63, 7677, 26, 19365, 14, 9970, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 2790, 3918, 4218, 523, 19365, 63, 17770, 26, 272, 6246, 26, 11400, 27127, 63, 4269, 16339, 272, 3434, 26, 11400, 27127, 63, 2473, 16339, 272, 2505, 26, 11400, 27127, 63, 2060, 16339, 272, 16606, 63, 354, 26, 11400, 16606, 63, 354, 16339, 272, 1174, 26, 3451, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 8496, 3918, 4218, 523, 19365, 63, 17770, 26, 272, 6246, 26, 11400, 27127, 63, 4269, 16339, 272, 3434, 26, 11400, 27127, 63, 2473, 16339, 272, 2505, 26, 11400, 27127, 63, 2060, 16339, 272, 16606, 63, 354, 26, 11400, 16606, 63, 354, 16339, 272, 1174, 26, 9552, 523, 13080, 63, 475, 26, 11667, 523, 2274, 26, 16606, 63, 1807, 63, 1099, 199, 2344, 199, 199, 9677, 275, 408, 3, 199, 624, 199, 199, 893, 26, 272, 687, 1134, 54, 28603, 492, 6695, 12, 373, 1494, 76, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 18970, 492, 1611, 54, 28603, 12, 2342, 63, 17770, 63, 991, 63, 354, 12, 19365, 63, 2094, 63, 1650, 12, 3618, 63, 509, 63, 1765, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 421, 199, 533, 812, 77, 1068, 1451, 4218, 2988, 8, 2713, 54, 28603, 304, 272, 347, 636, 826, 721, 277, 12, 859, 304, 267, 1613, 8, 17402, 1068, 1451, 4218, 2988, 12, 291, 2843, 826, 721, 578, 9, 267, 291, 14, 17770, 63, 354, 275, 291, 14, 1162, 14, 362, 360, 17770, 63, 354, 358, 267, 291, 14, 17770, 63, 1113, 275, 291, 14, 362, 63, 17770, 342, 339, 347, 4868, 8, 277, 304, 267, 1174, 275, 291, 14, 578, 14, 1162, 14, 362, 360, 929, 358, 398, 340, 1174, 508, 283, 1881, 356, 288, 291, 14, 981, 63, 17770, 342, 398, 340, 1174, 508, 283, 5575, 356, 288, 291, 14, 7237, 63, 17770, 342, 339, 347, 664, 63, 17770, 8, 277, 304, 267, 862, 26, 288, 16606, 63, 1113, 275, 2342, 63, 17770, 63, 991, 63, 354, 8, 277, 14, 1317, 12, 291, 14, 17770, 63, 354, 9, 288, 372, 16606, 63, 1113, 267, 871, 334, 86, 1494, 76, 14, 3767, 16665, 12, 373, 1494, 76, 14, 14357, 16665, 9, 465, 8836, 63, 1879, 26, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 4276, 370, 664, 16606, 1543, 83, 4065, 4228, 298, 7037, 370, 520, 450, 83, 2, 450, 334, 277, 14, 17770, 63, 354, 12, 9144, 370, 63, 6106, 8, 7726, 63, 1879, 14, 1328, 1724, 267, 871, 2186, 465, 7809, 63, 2804, 26, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 4276, 370, 664, 16606, 2, 4228, 298, 1543, 83, 7, 7037, 370, 7809, 1125, 26, 450, 83, 2, 450, 334, 277, 14, 17770, 63, 354, 12, 6684, 3515, 370, 63, 6106, 8, 6767, 63, 2804, 1724, 339, 347, 1218, 63, 17770, 8, 277, 304, 267, 4922, 275, 291, 14, 1317, 14, 1231, 7850, 267, 2896, 275, 756, 267, 862, 26, 288, 340, 440, 291, 14, 17770, 63, 1113, 436, 440, 291, 14, 578, 14, 1074, 63, 632, 26, 355, 2896, 275, 715, 355, 4922, 14, 2499, 1451, 4218, 8, 354, 29, 277, 14, 17770, 63, 354, 9, 288, 291, 14, 578, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 9, 267, 871, 6695, 14, 1879, 14, 14773, 985, 465, 9250, 63, 354, 26, 288, 291, 14, 578, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 9, 267, 871, 6695, 14, 1879, 14, 3364, 985, 465, 3866, 63, 354, 26, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 6154, 1290, 16606, 536, 1543, 83, 7, 365, 376, 2, 4228, 298, 3866, 536, 520, 450, 83, 2, 450, 334, 277, 14, 17770, 63, 354, 12, 16854, 370, 63, 6106, 8, 3197, 63, 354, 14, 1328, 1724, 267, 871, 373, 1494, 76, 14, 1879, 14, 26077, 465, 440, 63, 4946, 26, 288, 327, 961, 1077, 7078, 5992, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 27693, 370, 1218, 282, 16606, 1543, 83, 7, 641, 2, 4228, 298, 376 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 26, 334, 67, 9, 6900, 12, 1603, 3362, 838, 445, 7670, 665, 74, 915, 552, 6248, 28308, 14, 957, 30, 199, 3, 1898, 26, 334, 67, 9, 14894, 12, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 469, 272, 283, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 272, 283, 1205, 356, 788, 7780, 995, 272, 283, 4946, 63, 991, 356, 283, 9387, 7, 199, 93, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 19365, 63, 17770, 199, 3612, 63, 1802, 26, 14944, 27391, 373, 22385, 3918, 15660, 199, 1802, 26, 272, 446, 961, 859, 883, 506, 1202, 370, 9635, 334, 981, 12, 3145, 9, 27391, 373, 22385, 3918, 15660, 14, 199, 1023, 63, 3270, 26, 499, 14, 16, 199, 2502, 26, 199, 13, 1603, 3362, 838, 445, 7670, 8593, 22760, 5652, 3088, 9, 199, 13, 1804, 455, 382, 428, 26698, 3605, 6153, 352, 8593, 75, 455, 11803, 9, 199, 5983, 26, 272, 446, 30568, 641, 373, 22385, 1227, 14, 16, 12, 1227, 14, 21, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 1611, 54, 28603, 199, 1419, 26, 272, 16606, 63, 354, 26, 489, 1369, 26, 489, 446, 710, 536, 402, 314, 16606, 314, 4350, 911, 506, 2737, 315, 14, 489, 1415, 26, 715, 272, 1174, 26, 489, 1369, 26, 489, 446, 982, 314, 16606, 1077, 506, 3451, 503, 9552, 14, 489, 3415, 26, 359, 3451, 12, 9552, 1622, 489, 849, 26, 3451, 199, 11036, 63, 9970, 63, 7677, 26, 19365, 14, 9970, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 2790, 3918, 4218, 523, 19365, 63, 17770, 26, 272, 6246, 26, 11400, 27127, 63, 4269, 16339, 272, 3434, 26, 11400, 27127, 63, 2473, 16339, 272, 2505, 26, 11400, 27127, 63, 2060, 16339, 272, 16606, 63, 354, 26, 11400, 16606, 63, 354, 16339, 272, 1174, 26, 3451, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 8496, 3918, 4218, 523, 19365, 63, 17770, 26, 272, 6246, 26, 11400, 27127, 63, 4269, 16339, 272, 3434, 26, 11400, 27127, 63, 2473, 16339, 272, 2505, 26, 11400, 27127, 63, 2060, 16339, 272, 16606, 63, 354, 26, 11400, 16606, 63, 354, 16339, 272, 1174, 26, 9552, 523, 13080, 63, 475, 26, 11667, 523, 2274, 26, 16606, 63, 1807, 63, 1099, 199, 2344, 199, 199, 9677, 275, 408, 3, 199, 624, 199, 199, 893, 26, 272, 687, 1134, 54, 28603, 492, 6695, 12, 373, 1494, 76, 199, 2590, 3545, 26, 272, 986, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 18970, 492, 1611, 54, 28603, 12, 2342, 63, 17770, 63, 991, 63, 354, 12, 19365, 63, 2094, 63, 1650, 12, 3618, 63, 509, 63, 1765, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 421, 199, 533, 812, 77, 1068, 1451, 4218, 2988, 8, 2713, 54, 28603, 304, 272, 347, 636, 826, 721, 277, 12, 859, 304, 267, 1613, 8, 17402, 1068, 1451, 4218, 2988, 12, 291, 2843, 826, 721, 578, 9, 267, 291, 14, 17770, 63, 354, 275, 291, 14, 1162, 14, 362, 360, 17770, 63, 354, 358, 267, 291, 14, 17770, 63, 1113, 275, 291, 14, 362, 63, 17770, 342, 339, 347, 4868, 8, 277, 304, 267, 1174, 275, 291, 14, 578, 14, 1162, 14, 362, 360, 929, 358, 398, 340, 1174, 508, 283, 1881, 356, 288, 291, 14, 981, 63, 17770, 342, 398, 340, 1174, 508, 283, 5575, 356, 288, 291, 14, 7237, 63, 17770, 342, 339, 347, 664, 63, 17770, 8, 277, 304, 267, 862, 26, 288, 16606, 63, 1113, 275, 2342, 63, 17770, 63, 991, 63, 354, 8, 277, 14, 1317, 12, 291, 14, 17770, 63, 354, 9, 288, 372, 16606, 63, 1113, 267, 871, 334, 86, 1494, 76, 14, 3767, 16665, 12, 373, 1494, 76, 14, 14357, 16665, 9, 465, 8836, 63, 1879, 26, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 4276, 370, 664, 16606, 1543, 83, 4065, 4228, 298, 7037, 370, 520, 450, 83, 2, 450, 334, 277, 14, 17770, 63, 354, 12, 9144, 370, 63, 6106, 8, 7726, 63, 1879, 14, 1328, 1724, 267, 871, 2186, 465, 7809, 63, 2804, 26, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 4276, 370, 664, 16606, 2, 4228, 298, 1543, 83, 7, 7037, 370, 7809, 1125, 26, 450, 83, 2, 450, 334, 277, 14, 17770, 63, 354, 12, 6684, 3515, 370, 63, 6106, 8, 6767, 63, 2804, 1724, 339, 347, 1218, 63, 17770, 8, 277, 304, 267, 4922, 275, 291, 14, 1317, 14, 1231, 7850, 267, 2896, 275, 756, 267, 862, 26, 288, 340, 440, 291, 14, 17770, 63, 1113, 436, 440, 291, 14, 578, 14, 1074, 63, 632, 26, 355, 2896, 275, 715, 355, 4922, 14, 2499, 1451, 4218, 8, 354, 29, 277, 14, 17770, 63, 354, 9, 288, 291, 14, 578, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 9, 267, 871, 6695, 14, 1879, 14, 14773, 985, 465, 9250, 63, 354, 26, 288, 291, 14, 578, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 9, 267, 871, 6695, 14, 1879, 14, 3364, 985, 465, 3866, 63, 354, 26, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 6154, 1290, 16606, 536, 1543, 83, 7, 365, 376, 2, 4228, 298, 3866, 536, 520, 450, 83, 2, 450, 334, 277, 14, 17770, 63, 354, 12, 16854, 370, 63, 6106, 8, 3197, 63, 354, 14, 1328, 1724, 267, 871, 373, 1494, 76, 14, 1879, 14, 26077, 465, 440, 63, 4946, 26, 288, 327, 961, 1077, 7078, 5992, 288, 291, 14, 578, 14, 1633, 63, 1001, 8, 1328, 628, 27693, 370, 1218, 282, 16606, 1543, 83, 7, 641, 2, 4228, 298, 376, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rcbops/python-django-buildpackage
tests/regressiontests/model_fields/tests.py
50
13789
import datetime from decimal import Decimal from django import test from django import forms from django.core.exceptions import ValidationError from django.db import models from django.db.models.fields.files import FieldFile from django.utils import unittest from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel, BooleanModel, Document # If PIL available, do these tests. if Image: from imagefield import \ ImageFieldTests, \ ImageFieldTwoDimensionsTests, \ ImageFieldNoDimensionsTests, \ ImageFieldOneDimensionTests, \ ImageFieldDimensionsFirstTests, \ ImageFieldUsingFileTests, \ TwoImageFieldTests class BasicFieldTests(test.TestCase): def test_show_hidden_initial(self): """ Regression test for #12913. Make sure fields with choices respect show_hidden_initial as a kwarg to models.Field.formfield() """ choices = [(0, 0), (1, 1)] model_field = models.Field(choices=choices) form_field = model_field.formfield(show_hidden_initial=True) self.assertTrue(form_field.show_hidden_initial) form_field = model_field.formfield(show_hidden_initial=False) self.assertFalse(form_field.show_hidden_initial) def test_nullbooleanfield_blank(self): """ Regression test for #13071: NullBooleanField should not throw a validation error when given a value of None. """ nullboolean = NullBooleanModel(nbfield=None) try: nullboolean.full_clean() except ValidationError, e: self.fail("NullBooleanField failed validation with value of None: %s" % e.messages) class DecimalFieldTests(test.TestCase): def test_to_python(self): f = models.DecimalField(max_digits=4, decimal_places=2) self.assertEqual(f.to_python(3), Decimal("3")) self.assertEqual(f.to_python("3.14"), Decimal("3.14")) self.assertRaises(ValidationError, f.to_python, "abc") def test_default(self): f = models.DecimalField(default=Decimal("0.00")) self.assertEqual(f.get_default(), Decimal("0.00")) def test_format(self): f = models.DecimalField(max_digits=5, decimal_places=1) self.assertEqual(f._format(f.to_python(2)), u'2.0') self.assertEqual(f._format(f.to_python('2.6')), u'2.6') self.assertEqual(f._format(None), None) def test_get_db_prep_lookup(self): from django.db import connection f = models.DecimalField(max_digits=5, decimal_places=1) self.assertEqual(f.get_db_prep_lookup('exact', None, connection=connection), [None]) def test_filter_with_strings(self): """ We should be able to filter decimal fields using strings (#8023) """ Foo.objects.create(id=1, a='abc', d=Decimal("12.34")) self.assertEqual(list(Foo.objects.filter(d=u'1.23')), []) def test_save_without_float_conversion(self): """ Ensure decimals don't go through a corrupting float conversion during save (#5079). """ bd = BigD(d="12.9") bd.save() bd = BigD.objects.get(pk=bd.pk) self.assertEqual(bd.d, Decimal("12.9")) def test_lookup_really_big_value(self): """ Ensure that really big values can be used in a filter statement, even with older Python versions. """ # This should not crash. That counts as a win for our purposes. Foo.objects.filter(d__gte=100000000000) class ForeignKeyTests(test.TestCase): def test_callable_default(self): """Test the use of a lazy callable for ForeignKey.default""" a = Foo.objects.create(id=1, a='abc', d=Decimal("12.34")) b = Bar.objects.create(b="bcd") self.assertEqual(b.a, a) class DateTimeFieldTests(unittest.TestCase): def test_datetimefield_to_python_usecs(self): """DateTimeField.to_python should support usecs""" f = models.DateTimeField() self.assertEqual(f.to_python('2001-01-02 03:04:05.000006'), datetime.datetime(2001, 1, 2, 3, 4, 5, 6)) self.assertEqual(f.to_python('2001-01-02 03:04:05.999999'), datetime.datetime(2001, 1, 2, 3, 4, 5, 999999)) def test_timefield_to_python_usecs(self): """TimeField.to_python should support usecs""" f = models.TimeField() self.assertEqual(f.to_python('01:02:03.000004'), datetime.time(1, 2, 3, 4)) self.assertEqual(f.to_python('01:02:03.999999'), datetime.time(1, 2, 3, 999999)) class BooleanFieldTests(unittest.TestCase): def _test_get_db_prep_lookup(self, f): from django.db import connection self.assertEqual(f.get_db_prep_lookup('exact', True, connection=connection), [True]) self.assertEqual(f.get_db_prep_lookup('exact', '1', connection=connection), [True]) self.assertEqual(f.get_db_prep_lookup('exact', 1, connection=connection), [True]) self.assertEqual(f.get_db_prep_lookup('exact', False, connection=connection), [False]) self.assertEqual(f.get_db_prep_lookup('exact', '0', connection=connection), [False]) self.assertEqual(f.get_db_prep_lookup('exact', 0, connection=connection), [False]) self.assertEqual(f.get_db_prep_lookup('exact', None, connection=connection), [None]) def _test_to_python(self, f): self.assertTrue(f.to_python(1) is True) self.assertTrue(f.to_python(0) is False) def test_booleanfield_get_db_prep_lookup(self): self._test_get_db_prep_lookup(models.BooleanField()) def test_nullbooleanfield_get_db_prep_lookup(self): self._test_get_db_prep_lookup(models.NullBooleanField()) def test_booleanfield_to_python(self): self._test_to_python(models.BooleanField()) def test_nullbooleanfield_to_python(self): self._test_to_python(models.NullBooleanField()) def test_booleanfield_choices_blank(self): """ Test that BooleanField with choices and defaults doesn't generate a formfield with the blank option (#9640, #10549). """ choices = [(1, u'Si'), (2, 'No')] f = models.BooleanField(choices=choices, default=1, null=True) self.assertEqual(f.formfield().choices, [('', '---------')] + choices) f = models.BooleanField(choices=choices, default=1, null=False) self.assertEqual(f.formfield().choices, choices) def test_return_type(self): b = BooleanModel() b.bfield = True b.save() b2 = BooleanModel.objects.get(pk=b.pk) self.assertTrue(isinstance(b2.bfield, bool)) self.assertEqual(b2.bfield, True) b3 = BooleanModel() b3.bfield = False b3.save() b4 = BooleanModel.objects.get(pk=b3.pk) self.assertTrue(isinstance(b4.bfield, bool)) self.assertEqual(b4.bfield, False) b = NullBooleanModel() b.nbfield = True b.save() b2 = NullBooleanModel.objects.get(pk=b.pk) self.assertTrue(isinstance(b2.nbfield, bool)) self.assertEqual(b2.nbfield, True) b3 = NullBooleanModel() b3.nbfield = False b3.save() b4 = NullBooleanModel.objects.get(pk=b3.pk) self.assertTrue(isinstance(b4.nbfield, bool)) self.assertEqual(b4.nbfield, False) # http://code.djangoproject.com/ticket/13293 # Verify that when an extra clause exists, the boolean # conversions are applied with an offset b5 = BooleanModel.objects.all().extra( select={'string_length': 'LENGTH(string)'})[0] self.assertFalse(isinstance(b5.pk, bool)) class ChoicesTests(test.TestCase): def test_choices_and_field_display(self): """ Check that get_choices and get_flatchoices interact with get_FIELD_display to return the expected values (#7913). """ self.assertEqual(Whiz(c=1).get_c_display(), 'First') # A nested value self.assertEqual(Whiz(c=0).get_c_display(), 'Other') # A top level value self.assertEqual(Whiz(c=9).get_c_display(), 9) # Invalid value self.assertEqual(Whiz(c=None).get_c_display(), None) # Blank value self.assertEqual(Whiz(c='').get_c_display(), '') # Empty value class SlugFieldTests(test.TestCase): def test_slugfield_max_length(self): """ Make sure SlugField honors max_length (#9706) """ bs = BigS.objects.create(s = 'slug'*50) bs = BigS.objects.get(pk=bs.pk) self.assertEqual(bs.s, 'slug'*50) class ValidationTest(test.TestCase): def test_charfield_raises_error_on_empty_string(self): f = models.CharField() self.assertRaises(ValidationError, f.clean, "", None) def test_charfield_cleans_empty_string_when_blank_true(self): f = models.CharField(blank=True) self.assertEqual('', f.clean('', None)) def test_integerfield_cleans_valid_string(self): f = models.IntegerField() self.assertEqual(2, f.clean('2', None)) def test_integerfield_raises_error_on_invalid_intput(self): f = models.IntegerField() self.assertRaises(ValidationError, f.clean, "a", None) def test_charfield_with_choices_cleans_valid_choice(self): f = models.CharField(max_length=1, choices=[('a','A'), ('b','B')]) self.assertEqual('a', f.clean('a', None)) def test_charfield_with_choices_raises_error_on_invalid_choice(self): f = models.CharField(choices=[('a','A'), ('b','B')]) self.assertRaises(ValidationError, f.clean, "not a", None) def test_choices_validation_supports_named_groups(self): f = models.IntegerField(choices=(('group',((10,'A'),(20,'B'))),(30,'C'))) self.assertEqual(10, f.clean(10, None)) def test_nullable_integerfield_raises_error_with_blank_false(self): f = models.IntegerField(null=True, blank=False) self.assertRaises(ValidationError, f.clean, None, None) def test_nullable_integerfield_cleans_none_on_null_and_blank_true(self): f = models.IntegerField(null=True, blank=True) self.assertEqual(None, f.clean(None, None)) def test_integerfield_raises_error_on_empty_input(self): f = models.IntegerField(null=False) self.assertRaises(ValidationError, f.clean, None, None) self.assertRaises(ValidationError, f.clean, '', None) def test_charfield_raises_error_on_empty_input(self): f = models.CharField(null=False) self.assertRaises(ValidationError, f.clean, None, None) def test_datefield_cleans_date(self): f = models.DateField() self.assertEqual(datetime.date(2008, 10, 10), f.clean('2008-10-10', None)) def test_boolean_field_doesnt_accept_empty_input(self): f = models.BooleanField() self.assertRaises(ValidationError, f.clean, None, None) class BigIntegerFieldTests(test.TestCase): def test_limits(self): # Ensure that values that are right at the limits can be saved # and then retrieved without corruption. maxval = 9223372036854775807 minval = -maxval - 1 BigInt.objects.create(value=maxval) qs = BigInt.objects.filter(value__gte=maxval) self.assertEqual(qs.count(), 1) self.assertEqual(qs[0].value, maxval) BigInt.objects.create(value=minval) qs = BigInt.objects.filter(value__lte=minval) self.assertEqual(qs.count(), 1) self.assertEqual(qs[0].value, minval) def test_types(self): b = BigInt(value = 0) self.assertTrue(isinstance(b.value, (int, long))) b.save() self.assertTrue(isinstance(b.value, (int, long))) b = BigInt.objects.all()[0] self.assertTrue(isinstance(b.value, (int, long))) def test_coercing(self): BigInt.objects.create(value ='10') b = BigInt.objects.get(value = '10') self.assertEqual(b.value, 10) class TypeCoercionTests(test.TestCase): """ Test that database lookups can accept the wrong types and convert them with no error: especially on Postgres 8.3+ which does not do automatic casting at the DB level. See #10015. """ def test_lookup_integer_in_charfield(self): self.assertEqual(Post.objects.filter(title=9).count(), 0) def test_lookup_integer_in_textfield(self): self.assertEqual(Post.objects.filter(body=24).count(), 0) class FileFieldTests(unittest.TestCase): def test_clearable(self): """ Test that FileField.save_form_data will clear its instance attribute value if passed False. """ d = Document(myfile='something.txt') self.assertEqual(d.myfile, 'something.txt') field = d._meta.get_field('myfile') field.save_form_data(d, False) self.assertEqual(d.myfile, '') def test_unchanged(self): """ Test that FileField.save_form_data considers None to mean "no change" rather than "clear". """ d = Document(myfile='something.txt') self.assertEqual(d.myfile, 'something.txt') field = d._meta.get_field('myfile') field.save_form_data(d, None) self.assertEqual(d.myfile, 'something.txt') def test_changed(self): """ Test that FileField.save_form_data, if passed a truthy value, updates its instance attribute. """ d = Document(myfile='something.txt') self.assertEqual(d.myfile, 'something.txt') field = d._meta.get_field('myfile') field.save_form_data(d, 'else.txt') self.assertEqual(d.myfile, 'else.txt')
bsd-3-clause
[ 646, 2197, 199, 504, 6107, 492, 6345, 199, 199, 504, 1639, 492, 511, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 14, 1725, 492, 5024, 1173, 199, 504, 1639, 14, 1208, 492, 2882, 199, 199, 504, 1709, 492, 8024, 12, 12377, 12, 2816, 565, 12, 13123, 36, 12, 13123, 51, 12, 6047, 12, 13123, 3241, 12, 7711, 12, 12119, 4082, 1685, 12, 9411, 1685, 12, 7543, 199, 199, 3, 982, 14937, 2808, 12, 886, 3520, 2295, 14, 199, 692, 6047, 26, 272, 687, 1834, 698, 492, 971, 288, 6047, 792, 2925, 12, 971, 288, 6047, 792, 11467, 23370, 2925, 12, 971, 288, 6047, 792, 1944, 23370, 2925, 12, 971, 288, 6047, 792, 4395, 17905, 2925, 12, 971, 288, 6047, 792, 23370, 7147, 2925, 12, 971, 288, 6047, 792, 10369, 1173, 2925, 12, 971, 288, 16853, 21910, 2925, 421, 199, 533, 10082, 792, 2925, 8, 396, 14, 1746, 304, 272, 347, 511, 63, 2384, 63, 5642, 63, 2747, 8, 277, 304, 267, 408, 267, 13262, 511, 367, 327, 7263, 969, 14, 4155, 3238, 1504, 543, 3415, 14021, 267, 2498, 63, 5642, 63, 2747, 465, 282, 17582, 370, 1709, 14, 792, 14, 20015, 342, 267, 408, 267, 3415, 275, 3842, 16, 12, 378, 395, 334, 17, 12, 413, 1874, 267, 1402, 63, 698, 275, 1709, 14, 792, 8, 4577, 29, 4577, 9, 267, 1824, 63, 698, 275, 1402, 63, 698, 14, 20015, 8, 2384, 63, 5642, 63, 2747, 29, 549, 9, 267, 291, 14, 1815, 8, 964, 63, 698, 14, 2384, 63, 5642, 63, 2747, 9, 398, 1824, 63, 698, 275, 1402, 63, 698, 14, 20015, 8, 2384, 63, 5642, 63, 2747, 29, 797, 9, 267, 291, 14, 3334, 8, 964, 63, 698, 14, 2384, 63, 5642, 63, 2747, 9, 339, 347, 511, 63, 2307, 4871, 698, 63, 2500, 8, 277, 304, 267, 408, 267, 13262, 511, 367, 327, 13421, 17, 26, 12119, 5036, 1077, 440, 7978, 267, 282, 6411, 1125, 1380, 1627, 282, 574, 402, 488, 14, 398, 408, 267, 2973, 4871, 275, 12119, 4082, 1685, 8, 4994, 698, 29, 403, 9, 267, 862, 26, 288, 2973, 4871, 14, 2861, 63, 3118, 342, 267, 871, 8505, 12, 325, 26, 288, 291, 14, 1633, 480, 29068, 3405, 6411, 543, 574, 402, 488, 26, 450, 83, 2, 450, 325, 14, 3431, 9, 199, 199, 533, 6345, 792, 2925, 8, 396, 14, 1746, 304, 272, 347, 511, 63, 475, 63, 1548, 8, 277, 304, 267, 289, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 20, 12, 6107, 63, 10696, 29, 18, 9, 267, 291, 14, 629, 8, 70, 14, 475, 63, 1548, 8, 19, 395, 6345, 480, 19, 2237, 267, 291, 14, 629, 8, 70, 14, 475, 63, 1548, 480, 19, 14, 1079, 1288, 6345, 480, 19, 14, 1079, 2237, 267, 291, 14, 1855, 8, 8172, 12, 289, 14, 475, 63, 1548, 12, 298, 3175, 531, 339, 347, 511, 63, 885, 8, 277, 304, 267, 289, 275, 1709, 14, 15975, 8, 885, 29, 6745, 480, 16, 14, 383, 2237, 267, 291, 14, 629, 8, 70, 14, 362, 63, 885, 1062, 6345, 480, 16, 14, 383, 2237, 339, 347, 511, 63, 908, 8, 277, 304, 267, 289, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 17, 9, 267, 291, 14, 629, 8, 70, 423, 908, 8, 70, 14, 475, 63, 1548, 8, 18, 1826, 399, 7, 18, 14, 16, 358, 267, 291, 14, 629, 8, 70, 423, 908, 8, 70, 14, 475, 63, 1548, 360, 18, 14, 22, 3855, 399, 7, 18, 14, 22, 358, 267, 291, 14, 629, 8, 70, 423, 908, 8, 403, 395, 488, 9, 339, 347, 511, 63, 362, 63, 697, 63, 10837, 63, 3892, 8, 277, 304, 267, 687, 1639, 14, 697, 492, 1950, 267, 289, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 17, 9, 267, 291, 14, 629, 8, 70, 14, 362, 63, 697, 63, 10837, 63, 3892, 360, 7327, 297, 488, 12, 1950, 29, 2105, 395, 359, 403, 566, 339, 347, 511, 63, 1541, 63, 1045, 63, 5465, 8, 277, 304, 267, 408, 267, 2136, 1077, 506, 7688, 370, 2457, 6107, 1504, 1808, 3326, 15196, 11366, 19, 9, 267, 408, 267, 8024, 14, 1462, 14, 981, 8, 344, 29, 17, 12, 282, 534, 3175, 297, 366, 29, 6745, 480, 713, 14, 1082, 2237, 267, 291, 14, 629, 8, 513, 8, 5686, 14, 1462, 14, 1541, 8, 68, 29, 85, 7, 17, 14, 1789, 3855, 3073, 339, 347, 511, 63, 2117, 63, 7395, 63, 1609, 63, 15083, 8, 277, 304, 267, 408, 267, 7523, 6107, 83, 2793, 1133, 2621, 4012, 282, 1970, 5505, 1337, 2069, 8603, 5309, 267, 3354, 15196, 1400, 1965, 680, 267, 408, 267, 21064, 275, 13123, 36, 8, 68, 628, 713, 14, 25, 531, 267, 21064, 14, 2117, 342, 267, 21064, 275, 13123, 36, 14, 1462, 14, 362, 8, 2051, 29, 3691, 14, 2051, 9, 267, 291, 14, 629, 8, 3691, 14, 68, 12, 6345, 480, 713, 14, 25, 2237, 339, 347, 511, 63, 3892, 63, 29428, 63, 5076, 63, 585, 8, 277, 304, 267, 408, 267, 7523, 626, 7710, 7282, 1338, 883, 506, 1202, 315, 282, 2457, 5164, 12, 2755, 267, 543, 12731, 2018, 5459, 14, 267, 408, 267, 327, 961, 1077, 440, 12420, 14, 10314, 8242, 465, 282, 4747, 367, 4154, 12901, 14, 267, 8024, 14, 1462, 14, 1541, 8, 68, 363, 19586, 29, 17, 3607, 1493, 9, 199, 199, 533, 12718, 2925, 8, 396, 14, 1746, 304, 272, 347, 511, 63, 8296, 63, 885, 8, 277, 304, 267, 408, 774, 314, 675, 402, 282, 9617, 4550, 367, 12718, 14, 885, 624, 267, 282, 275, 8024, 14, 1462, 14, 981, 8, 344, 29, 17, 12, 282, 534, 3175, 297, 366, 29, 6745, 480, 713, 14, 1082, 2237, 267, 330, 275, 12377, 14, 1462, 14, 981, 8, 66, 628, 26333, 531, 267, 291, 14, 629, 8, 66, 14, 65, 12, 282, 9, 199, 199, 533, 31637, 2925, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 2083, 698, 63, 475, 63 ]
[ 2197, 199, 504, 6107, 492, 6345, 199, 199, 504, 1639, 492, 511, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 14, 1725, 492, 5024, 1173, 199, 504, 1639, 14, 1208, 492, 2882, 199, 199, 504, 1709, 492, 8024, 12, 12377, 12, 2816, 565, 12, 13123, 36, 12, 13123, 51, 12, 6047, 12, 13123, 3241, 12, 7711, 12, 12119, 4082, 1685, 12, 9411, 1685, 12, 7543, 199, 199, 3, 982, 14937, 2808, 12, 886, 3520, 2295, 14, 199, 692, 6047, 26, 272, 687, 1834, 698, 492, 971, 288, 6047, 792, 2925, 12, 971, 288, 6047, 792, 11467, 23370, 2925, 12, 971, 288, 6047, 792, 1944, 23370, 2925, 12, 971, 288, 6047, 792, 4395, 17905, 2925, 12, 971, 288, 6047, 792, 23370, 7147, 2925, 12, 971, 288, 6047, 792, 10369, 1173, 2925, 12, 971, 288, 16853, 21910, 2925, 421, 199, 533, 10082, 792, 2925, 8, 396, 14, 1746, 304, 272, 347, 511, 63, 2384, 63, 5642, 63, 2747, 8, 277, 304, 267, 408, 267, 13262, 511, 367, 327, 7263, 969, 14, 4155, 3238, 1504, 543, 3415, 14021, 267, 2498, 63, 5642, 63, 2747, 465, 282, 17582, 370, 1709, 14, 792, 14, 20015, 342, 267, 408, 267, 3415, 275, 3842, 16, 12, 378, 395, 334, 17, 12, 413, 1874, 267, 1402, 63, 698, 275, 1709, 14, 792, 8, 4577, 29, 4577, 9, 267, 1824, 63, 698, 275, 1402, 63, 698, 14, 20015, 8, 2384, 63, 5642, 63, 2747, 29, 549, 9, 267, 291, 14, 1815, 8, 964, 63, 698, 14, 2384, 63, 5642, 63, 2747, 9, 398, 1824, 63, 698, 275, 1402, 63, 698, 14, 20015, 8, 2384, 63, 5642, 63, 2747, 29, 797, 9, 267, 291, 14, 3334, 8, 964, 63, 698, 14, 2384, 63, 5642, 63, 2747, 9, 339, 347, 511, 63, 2307, 4871, 698, 63, 2500, 8, 277, 304, 267, 408, 267, 13262, 511, 367, 327, 13421, 17, 26, 12119, 5036, 1077, 440, 7978, 267, 282, 6411, 1125, 1380, 1627, 282, 574, 402, 488, 14, 398, 408, 267, 2973, 4871, 275, 12119, 4082, 1685, 8, 4994, 698, 29, 403, 9, 267, 862, 26, 288, 2973, 4871, 14, 2861, 63, 3118, 342, 267, 871, 8505, 12, 325, 26, 288, 291, 14, 1633, 480, 29068, 3405, 6411, 543, 574, 402, 488, 26, 450, 83, 2, 450, 325, 14, 3431, 9, 199, 199, 533, 6345, 792, 2925, 8, 396, 14, 1746, 304, 272, 347, 511, 63, 475, 63, 1548, 8, 277, 304, 267, 289, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 20, 12, 6107, 63, 10696, 29, 18, 9, 267, 291, 14, 629, 8, 70, 14, 475, 63, 1548, 8, 19, 395, 6345, 480, 19, 2237, 267, 291, 14, 629, 8, 70, 14, 475, 63, 1548, 480, 19, 14, 1079, 1288, 6345, 480, 19, 14, 1079, 2237, 267, 291, 14, 1855, 8, 8172, 12, 289, 14, 475, 63, 1548, 12, 298, 3175, 531, 339, 347, 511, 63, 885, 8, 277, 304, 267, 289, 275, 1709, 14, 15975, 8, 885, 29, 6745, 480, 16, 14, 383, 2237, 267, 291, 14, 629, 8, 70, 14, 362, 63, 885, 1062, 6345, 480, 16, 14, 383, 2237, 339, 347, 511, 63, 908, 8, 277, 304, 267, 289, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 17, 9, 267, 291, 14, 629, 8, 70, 423, 908, 8, 70, 14, 475, 63, 1548, 8, 18, 1826, 399, 7, 18, 14, 16, 358, 267, 291, 14, 629, 8, 70, 423, 908, 8, 70, 14, 475, 63, 1548, 360, 18, 14, 22, 3855, 399, 7, 18, 14, 22, 358, 267, 291, 14, 629, 8, 70, 423, 908, 8, 403, 395, 488, 9, 339, 347, 511, 63, 362, 63, 697, 63, 10837, 63, 3892, 8, 277, 304, 267, 687, 1639, 14, 697, 492, 1950, 267, 289, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 17, 9, 267, 291, 14, 629, 8, 70, 14, 362, 63, 697, 63, 10837, 63, 3892, 360, 7327, 297, 488, 12, 1950, 29, 2105, 395, 359, 403, 566, 339, 347, 511, 63, 1541, 63, 1045, 63, 5465, 8, 277, 304, 267, 408, 267, 2136, 1077, 506, 7688, 370, 2457, 6107, 1504, 1808, 3326, 15196, 11366, 19, 9, 267, 408, 267, 8024, 14, 1462, 14, 981, 8, 344, 29, 17, 12, 282, 534, 3175, 297, 366, 29, 6745, 480, 713, 14, 1082, 2237, 267, 291, 14, 629, 8, 513, 8, 5686, 14, 1462, 14, 1541, 8, 68, 29, 85, 7, 17, 14, 1789, 3855, 3073, 339, 347, 511, 63, 2117, 63, 7395, 63, 1609, 63, 15083, 8, 277, 304, 267, 408, 267, 7523, 6107, 83, 2793, 1133, 2621, 4012, 282, 1970, 5505, 1337, 2069, 8603, 5309, 267, 3354, 15196, 1400, 1965, 680, 267, 408, 267, 21064, 275, 13123, 36, 8, 68, 628, 713, 14, 25, 531, 267, 21064, 14, 2117, 342, 267, 21064, 275, 13123, 36, 14, 1462, 14, 362, 8, 2051, 29, 3691, 14, 2051, 9, 267, 291, 14, 629, 8, 3691, 14, 68, 12, 6345, 480, 713, 14, 25, 2237, 339, 347, 511, 63, 3892, 63, 29428, 63, 5076, 63, 585, 8, 277, 304, 267, 408, 267, 7523, 626, 7710, 7282, 1338, 883, 506, 1202, 315, 282, 2457, 5164, 12, 2755, 267, 543, 12731, 2018, 5459, 14, 267, 408, 267, 327, 961, 1077, 440, 12420, 14, 10314, 8242, 465, 282, 4747, 367, 4154, 12901, 14, 267, 8024, 14, 1462, 14, 1541, 8, 68, 363, 19586, 29, 17, 3607, 1493, 9, 199, 199, 533, 12718, 2925, 8, 396, 14, 1746, 304, 272, 347, 511, 63, 8296, 63, 885, 8, 277, 304, 267, 408, 774, 314, 675, 402, 282, 9617, 4550, 367, 12718, 14, 885, 624, 267, 282, 275, 8024, 14, 1462, 14, 981, 8, 344, 29, 17, 12, 282, 534, 3175, 297, 366, 29, 6745, 480, 713, 14, 1082, 2237, 267, 330, 275, 12377, 14, 1462, 14, 981, 8, 66, 628, 26333, 531, 267, 291, 14, 629, 8, 66, 14, 65, 12, 282, 9, 199, 199, 533, 31637, 2925, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 2083, 698, 63, 475, 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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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 ]
leshchevds/ganeti
lib/cmdlib/__init__.py
4
3952
# # # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # 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. """Module implementing the master-side code. This file only imports all LU's (and other classes) in order to re-export them to clients of cmdlib. """ from ganeti.cmdlib.base import \ LogicalUnit, \ NoHooksLU, \ ResultWithJobs from ganeti.cmdlib.cluster import \ LUClusterActivateMasterIp, \ LUClusterDeactivateMasterIp, \ LUClusterConfigQuery, \ LUClusterDestroy, \ LUClusterPostInit, \ LUClusterQuery, \ LUClusterRedistConf, \ LUClusterRename, \ LUClusterRepairDiskSizes, \ LUClusterSetParams, \ LUClusterRenewCrypto from ganeti.cmdlib.cluster.verify import \ LUClusterVerify, \ LUClusterVerifyConfig, \ LUClusterVerifyGroup, \ LUClusterVerifyDisks from ganeti.cmdlib.group import \ LUGroupAdd, \ LUGroupAssignNodes, \ LUGroupSetParams, \ LUGroupRemove, \ LUGroupRename, \ LUGroupEvacuate, \ LUGroupVerifyDisks from ganeti.cmdlib.node import \ LUNodeAdd, \ LUNodeSetParams, \ LUNodePowercycle, \ LUNodeEvacuate, \ LUNodeMigrate, \ LUNodeModifyStorage, \ LUNodeQueryvols, \ LUNodeQueryStorage, \ LUNodeRemove, \ LURepairNodeStorage from ganeti.cmdlib.instance import \ LUInstanceRename, \ LUInstanceRemove, \ LUInstanceMove, \ LUInstanceMultiAlloc, \ LUInstanceChangeGroup from ganeti.cmdlib.instance_create import \ LUInstanceCreate from ganeti.cmdlib.instance_storage import \ LUInstanceRecreateDisks, \ LUInstanceGrowDisk, \ LUInstanceReplaceDisks, \ LUInstanceActivateDisks, \ LUInstanceDeactivateDisks from ganeti.cmdlib.instance_migration import \ LUInstanceFailover, \ LUInstanceMigrate from ganeti.cmdlib.instance_operation import \ LUInstanceStartup, \ LUInstanceShutdown, \ LUInstanceReinstall, \ LUInstanceReboot, \ LUInstanceConsole from ganeti.cmdlib.instance_set_params import \ LUInstanceSetParams from ganeti.cmdlib.instance_query import \ LUInstanceQueryData from ganeti.cmdlib.backup import \ LUBackupPrepare, \ LUBackupExport, \ LUBackupRemove from ganeti.cmdlib.query import \ LUQuery, \ LUQueryFields from ganeti.cmdlib.operating_system import \ LUOsDiagnose from ganeti.cmdlib.tags import \ LUTagsGet, \ LUTagsSearch, \ LUTagsSet, \ LUTagsDel from ganeti.cmdlib.network import \ LUNetworkAdd, \ LUNetworkRemove, \ LUNetworkSetParams, \ LUNetworkConnect, \ LUNetworkDisconnect from ganeti.cmdlib.misc import \ LUOobCommand, \ LUExtStorageDiagnose, \ LURestrictedCommand, \ LURepairCommand from ganeti.cmdlib.test import \ LUTestOsParams, \ LUTestDelay, \ LUTestJqueue, \ LUTestAllocator
bsd-2-clause
[ 3, 199, 3, 199, 199, 3, 1898, 334, 35, 9, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 12, 6029, 12, 6171, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 199, 3, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 199, 3, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 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, 421, 199, 624, 2377, 18234, 314, 5288, 13, 2441, 1233, 14, 199, 199, 2765, 570, 1454, 8925, 1006, 491, 53, 1159, 334, 460, 1163, 3992, 9, 315, 1865, 370, 295, 13, 3790, 3062, 199, 475, 13431, 402, 2088, 773, 14, 199, 199, 624, 199, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 1095, 492, 971, 523, 26303, 5072, 12, 971, 523, 3091, 8481, 83, 20237, 12, 971, 523, 10695, 3007, 20578, 199, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 4201, 492, 971, 523, 491, 53, 9581, 30120, 12288, 6583, 12, 971, 523, 491, 53, 9581, 872, 8222, 12288, 6583, 12, 971, 523, 491, 53, 9581, 2028, 3227, 12, 971, 523, 491, 53, 9581, 14704, 12, 971, 523, 491, 53, 9581, 6564, 9346, 12, 971, 523, 491, 53, 9581, 3227, 12, 971, 523, 491, 53, 9581, 497, 2686, 8930, 12, 971, 523, 491, 53, 9581, 16843, 12, 971, 523, 491, 53, 9581, 497, 3852, 10690, 29790, 12, 971, 523, 491, 53, 9581, 1084, 6007, 12, 971, 523, 491, 53, 9581, 5349, 546, 17134, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 4201, 14, 4712, 492, 971, 523, 491, 53, 9581, 7496, 12, 971, 523, 491, 53, 9581, 7496, 2028, 12, 971, 523, 491, 53, 9581, 7496, 2448, 12, 971, 523, 491, 53, 9581, 7496, 2825, 6080, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 923, 492, 971, 523, 491, 53, 2448, 1123, 12, 971, 523, 491, 53, 2448, 9595, 6300, 12, 971, 523, 491, 53, 2448, 1084, 6007, 12, 971, 523, 491, 53, 2448, 5587, 12, 971, 523, 491, 53, 2448, 16843, 12, 971, 523, 491, 53, 2448, 37, 15367, 4767, 12, 971, 523, 491, 53, 2448, 7496, 2825, 6080, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 932, 492, 971, 523, 491, 53, 1716, 1123, 12, 971, 523, 491, 53, 1716, 1084, 6007, 12, 971, 523, 491, 53, 1716, 6921, 7612, 12, 971, 523, 491, 53, 1716, 37, 15367, 4767, 12, 971, 523, 491, 53, 1716, 26641, 12, 971, 523, 491, 53, 1716, 18357, 6408, 12, 971, 523, 491, 53, 1716, 3227, 86, 1446, 12, 971, 523, 491, 53, 1716, 3227, 6408, 12, 971, 523, 491, 53, 1716, 5587, 12, 971, 523, 491, 53, 497, 3852, 1716, 6408, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 492, 971, 523, 491, 53, 3244, 16843, 12, 971, 523, 491, 53, 3244, 5587, 12, 971, 523, 491, 53, 3244, 10370, 12, 971, 523, 491, 53, 3244, 3947, 2439, 2102, 12, 971, 523, 491, 53, 3244, 4001, 2448, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 981, 492, 971, 523, 491, 53, 3244, 2499, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 3494, 492, 971, 523, 491, 53, 3244, 497, 981, 2825, 6080, 12, 971, 523, 491, 53, 3244, 39, 1143, 10690, 12, 971, 523, 491, 53, 3244, 11328, 2825, 6080, 12, 971, 523, 491, 53, 3244, 30120, 2825, 6080, 12, 971, 523, 491, 53, 3244, 872, 8222, 2825, 6080, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 8998, 492, 971, 523, 491, 53, 3244, 1906, 23165, 12, 971, 523, 491, 53, 3244, 26641, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 5735, 492, 971, 523, 491, 53, 3244, 18515, 12, 971, 523, 491, 53, 3244, 20043, 12, 971, 523, 491, 53, 3244, 497, 3174, 12, 971, 523, 491, 53, 3244, 497, 4930, 12, 971, 523, 491, 53, 3244, 9270, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 409, 63, 1162, 492, 971, 523, 491, 53, 3244, 1084, 6007, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 1131, 492, 971, 523, 491, 53, 3244, 3227, 1451, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 5751, 492, 971, 523, 491, 2533, 564, 384, 22281, 12, 971, 523, 491, 2533, 564, 384, 11399, 12, 971, 523, 491, 2533, 564, 384, 5587, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 1131, 492, 971, 523, 491, 53, 3227, 12, 971, 523, 491, 53, 3227, 7304, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 2262, 1958, 63, 2253, 492, 971, 523, 491, 53, 24351, 16094, 21085, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 2969, 492, 971, 523, 491, 934, 7391, 1002, 12, 971, 523, 491, 934, 7391, 5278, 12, 971 ]
[ 199, 3, 199, 199, 3, 1898, 334, 35, 9, 8315, 12, 10219, 12, 9079, 12, 8937, 12, 7129, 12, 7760, 12, 6029, 12, 6171, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 413, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 199, 3, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 199, 3, 499, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 199, 3, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 199, 3, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 199, 3, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 199, 3, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 199, 3, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 3, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 199, 3, 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, 421, 199, 624, 2377, 18234, 314, 5288, 13, 2441, 1233, 14, 199, 199, 2765, 570, 1454, 8925, 1006, 491, 53, 1159, 334, 460, 1163, 3992, 9, 315, 1865, 370, 295, 13, 3790, 3062, 199, 475, 13431, 402, 2088, 773, 14, 199, 199, 624, 199, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 1095, 492, 971, 523, 26303, 5072, 12, 971, 523, 3091, 8481, 83, 20237, 12, 971, 523, 10695, 3007, 20578, 199, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 4201, 492, 971, 523, 491, 53, 9581, 30120, 12288, 6583, 12, 971, 523, 491, 53, 9581, 872, 8222, 12288, 6583, 12, 971, 523, 491, 53, 9581, 2028, 3227, 12, 971, 523, 491, 53, 9581, 14704, 12, 971, 523, 491, 53, 9581, 6564, 9346, 12, 971, 523, 491, 53, 9581, 3227, 12, 971, 523, 491, 53, 9581, 497, 2686, 8930, 12, 971, 523, 491, 53, 9581, 16843, 12, 971, 523, 491, 53, 9581, 497, 3852, 10690, 29790, 12, 971, 523, 491, 53, 9581, 1084, 6007, 12, 971, 523, 491, 53, 9581, 5349, 546, 17134, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 4201, 14, 4712, 492, 971, 523, 491, 53, 9581, 7496, 12, 971, 523, 491, 53, 9581, 7496, 2028, 12, 971, 523, 491, 53, 9581, 7496, 2448, 12, 971, 523, 491, 53, 9581, 7496, 2825, 6080, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 923, 492, 971, 523, 491, 53, 2448, 1123, 12, 971, 523, 491, 53, 2448, 9595, 6300, 12, 971, 523, 491, 53, 2448, 1084, 6007, 12, 971, 523, 491, 53, 2448, 5587, 12, 971, 523, 491, 53, 2448, 16843, 12, 971, 523, 491, 53, 2448, 37, 15367, 4767, 12, 971, 523, 491, 53, 2448, 7496, 2825, 6080, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 932, 492, 971, 523, 491, 53, 1716, 1123, 12, 971, 523, 491, 53, 1716, 1084, 6007, 12, 971, 523, 491, 53, 1716, 6921, 7612, 12, 971, 523, 491, 53, 1716, 37, 15367, 4767, 12, 971, 523, 491, 53, 1716, 26641, 12, 971, 523, 491, 53, 1716, 18357, 6408, 12, 971, 523, 491, 53, 1716, 3227, 86, 1446, 12, 971, 523, 491, 53, 1716, 3227, 6408, 12, 971, 523, 491, 53, 1716, 5587, 12, 971, 523, 491, 53, 497, 3852, 1716, 6408, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 492, 971, 523, 491, 53, 3244, 16843, 12, 971, 523, 491, 53, 3244, 5587, 12, 971, 523, 491, 53, 3244, 10370, 12, 971, 523, 491, 53, 3244, 3947, 2439, 2102, 12, 971, 523, 491, 53, 3244, 4001, 2448, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 981, 492, 971, 523, 491, 53, 3244, 2499, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 3494, 492, 971, 523, 491, 53, 3244, 497, 981, 2825, 6080, 12, 971, 523, 491, 53, 3244, 39, 1143, 10690, 12, 971, 523, 491, 53, 3244, 11328, 2825, 6080, 12, 971, 523, 491, 53, 3244, 30120, 2825, 6080, 12, 971, 523, 491, 53, 3244, 872, 8222, 2825, 6080, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 8998, 492, 971, 523, 491, 53, 3244, 1906, 23165, 12, 971, 523, 491, 53, 3244, 26641, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 5735, 492, 971, 523, 491, 53, 3244, 18515, 12, 971, 523, 491, 53, 3244, 20043, 12, 971, 523, 491, 53, 3244, 497, 3174, 12, 971, 523, 491, 53, 3244, 497, 4930, 12, 971, 523, 491, 53, 3244, 9270, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 409, 63, 1162, 492, 971, 523, 491, 53, 3244, 1084, 6007, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 842, 63, 1131, 492, 971, 523, 491, 53, 3244, 3227, 1451, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 5751, 492, 971, 523, 491, 2533, 564, 384, 22281, 12, 971, 523, 491, 2533, 564, 384, 11399, 12, 971, 523, 491, 2533, 564, 384, 5587, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 1131, 492, 971, 523, 491, 53, 3227, 12, 971, 523, 491, 53, 3227, 7304, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 2262, 1958, 63, 2253, 492, 971, 523, 491, 53, 24351, 16094, 21085, 199, 504, 486, 5865, 280, 14, 1760, 773, 14, 2969, 492, 971, 523, 491, 934, 7391, 1002, 12, 971, 523, 491, 934, 7391, 5278, 12, 971, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
barseghyanartur/django-haystack
haystack/management/commands/update_index.py
6
14000
# encoding: utf-8 from __future__ import absolute_import, division, print_function, unicode_literals import logging import multiprocessing import os import time from datetime import timedelta from django.core.management.base import BaseCommand from django.db import close_old_connections, reset_queries from django.utils.encoding import force_text, smart_bytes from django.utils.timezone import now from haystack import connections as haystack_connections from haystack.exceptions import NotHandled from haystack.query import SearchQuerySet from haystack.utils.app_loading import haystack_get_models, haystack_load_apps DEFAULT_BATCH_SIZE = None DEFAULT_AGE = None DEFAULT_MAX_RETRIES = 5 LOG = multiprocessing.log_to_stderr(level=logging.WARNING) def update_worker(args): if len(args) != 10: LOG.error('update_worker received incorrect arguments: %r', args) raise ValueError('update_worker received incorrect arguments') model, start, end, total, using, start_date, end_date, verbosity, commit, max_retries = args # FIXME: confirm that this is still relevant with modern versions of Django: # We need to reset the connections, otherwise the different processes # will try to share the connection, which causes things to blow up. from django.db import connections for alias, info in connections.databases.items(): # We need to also tread lightly with SQLite, because blindly wiping # out connections (via ``... = {}``) destroys in-memory DBs. if 'sqlite3' not in info['ENGINE']: try: close_old_connections() if isinstance(connections._connections, dict): del connections._connections[alias] else: delattr(connections._connections, alias) except KeyError: pass # Request that the connection clear out any transient sessions, file handles, etc. haystack_connections[using].reset_sessions() unified_index = haystack_connections[using].get_unified_index() index = unified_index.get_index(model) backend = haystack_connections[using].get_backend() qs = index.build_queryset(start_date=start_date, end_date=end_date) do_update(backend, index, qs, start, end, total, verbosity, commit, max_retries) return args def do_update(backend, index, qs, start, end, total, verbosity=1, commit=True, max_retries=DEFAULT_MAX_RETRIES): # Get a clone of the QuerySet so that the cache doesn't bloat up # in memory. Useful when reindexing large amounts of data. small_cache_qs = qs.all() current_qs = small_cache_qs[start:end] is_parent_process = hasattr(os, 'getppid') and os.getpid() == os.getppid() if verbosity >= 2: if is_parent_process: print(" indexed %s - %d of %d." % (start + 1, end, total)) else: print(" indexed %s - %d of %d (worker PID: %s)." % (start + 1, end, total, os.getpid())) retries = 0 while retries < max_retries: try: # FIXME: Get the right backend. backend.update(index, current_qs, commit=commit) if verbosity >= 2 and retries: print('Completed indexing {} - {}, tried {}/{} times'.format(start + 1, end, retries + 1, max_retries)) break except Exception as exc: # Catch all exceptions which do not normally trigger a system exit, excluding SystemExit and # KeyboardInterrupt. This avoids needing to import the backend-specific exception subclasses # from pysolr, elasticsearch, whoosh, requests, etc. retries += 1 error_context = {'start': start + 1, 'end': end, 'retries': retries, 'max_retries': max_retries, 'pid': os.getpid(), 'exc': exc} error_msg = 'Failed indexing %(start)s - %(end)s (retry %(retries)s/%(max_retries)s): %(exc)s' if not is_parent_process: error_msg += ' (pid %(pid)s): %(exc)s' if retries >= max_retries: LOG.error(error_msg, error_context, exc_info=True) raise elif verbosity >= 2: LOG.warning(error_msg, error_context, exc_info=True) # If going to try again, sleep a bit before time.sleep(2 ** retries) # Clear out the DB connections queries because it bloats up RAM. reset_queries() class Command(BaseCommand): help = "Freshens the index for the given app(s)." def add_arguments(self, parser): parser.add_argument( 'app_label', nargs='*', help='App label of an application to update the search index.' ) parser.add_argument( '-a', '--age', type=int, default=DEFAULT_AGE, help='Number of hours back to consider objects new.' ) parser.add_argument( '-s', '--start', dest='start_date', help='The start date for indexing within. Can be any dateutil-parsable string, recommended to be YYYY-MM-DDTHH:MM:SS.' ) parser.add_argument( '-e', '--end', dest='end_date', help='The end date for indexing within. Can be any dateutil-parsable string, recommended to be YYYY-MM-DDTHH:MM:SS.' ) parser.add_argument( '-b', '--batch-size', dest='batchsize', type=int, help='Number of items to index at once.' ) parser.add_argument( '-r', '--remove', action='store_true', default=False, help='Remove objects from the index that are no longer present in the database.' ) parser.add_argument( '-u', '--using', action='append', default=[], help='Update only the named backend (can be used multiple times). ' 'By default all backends will be updated.' ) parser.add_argument( '-k', '--workers', type=int, default=0, help='Allows for the use multiple workers to parallelize indexing.' ) parser.add_argument( '--nocommit', action='store_false', dest='commit', default=True, help='Will pass commit=False to the backend.' ) parser.add_argument( '-t', '--max-retries', action='store', dest='max_retries', type=int, default=DEFAULT_MAX_RETRIES, help='Maximum number of attempts to write to the backend when an error occurs.' ) def handle(self, **options): self.verbosity = int(options.get('verbosity', 1)) self.batchsize = options.get('batchsize', DEFAULT_BATCH_SIZE) self.start_date = None self.end_date = None self.remove = options.get('remove', False) self.workers = options.get('workers', 0) self.commit = options.get('commit', True) self.max_retries = options.get('max_retries', DEFAULT_MAX_RETRIES) self.backends = options.get('using') if not self.backends: self.backends = haystack_connections.connections_info.keys() age = options.get('age', DEFAULT_AGE) start_date = options.get('start_date') end_date = options.get('end_date') if self.verbosity > 2: LOG.setLevel(logging.DEBUG) elif self.verbosity > 1: LOG.setLevel(logging.INFO) if age is not None: self.start_date = now() - timedelta(hours=int(age)) if start_date is not None: from dateutil.parser import parse as dateutil_parse try: self.start_date = dateutil_parse(start_date) except ValueError: pass if end_date is not None: from dateutil.parser import parse as dateutil_parse try: self.end_date = dateutil_parse(end_date) except ValueError: pass labels = options.get('app_label') or haystack_load_apps() for label in labels: for using in self.backends: try: self.update_backend(label, using) except: LOG.exception("Error updating %s using %s ", label, using) raise def update_backend(self, label, using): backend = haystack_connections[using].get_backend() unified_index = haystack_connections[using].get_unified_index() for model in haystack_get_models(label): try: index = unified_index.get_index(model) except NotHandled: if self.verbosity >= 2: self.stdout.write("Skipping '%s' - no index." % model) continue if self.workers > 0: # workers resetting connections leads to references to models / connections getting # stale and having their connection disconnected from under them. Resetting before # the loop continues and it accesses the ORM makes it better. close_old_connections() qs = index.build_queryset(using=using, start_date=self.start_date, end_date=self.end_date) total = qs.count() if self.verbosity >= 1: self.stdout.write(u"Indexing %d %s" % ( total, force_text(model._meta.verbose_name_plural)) ) batch_size = self.batchsize or backend.batch_size if self.workers > 0: ghetto_queue = [] for start in range(0, total, batch_size): end = min(start + batch_size, total) if self.workers == 0: do_update(backend, index, qs, start, end, total, verbosity=self.verbosity, commit=self.commit, max_retries=self.max_retries) else: ghetto_queue.append((model, start, end, total, using, self.start_date, self.end_date, self.verbosity, self.commit, self.max_retries)) if self.workers > 0: pool = multiprocessing.Pool(self.workers) successful_tasks = pool.map(update_worker, ghetto_queue) if len(ghetto_queue) != len(successful_tasks): self.stderr.write('Queued %d tasks but only %d completed' % (len(ghetto_queue), len(successful_tasks))) for i in ghetto_queue: if i not in successful_tasks: self.stderr.write('Incomplete task: %s' % repr(i)) pool.close() pool.join() if self.remove: if self.start_date or self.end_date or total <= 0: # They're using a reduced set, which may not incorporate # all pks. Rebuild the list with everything. qs = index.index_queryset().values_list('pk', flat=True) database_pks = set(smart_bytes(pk) for pk in qs) total = len(database_pks) else: database_pks = set(smart_bytes(pk) for pk in qs.values_list('pk', flat=True)) # Since records may still be in the search index but not the local database # we'll use that to create batches for processing. # See https://github.com/django-haystack/django-haystack/issues/1186 index_total = SearchQuerySet(using=backend.connection_alias).models(model).count() # Retrieve PKs from the index. Note that this cannot be a numeric range query because although # pks are normally numeric they can be non-numeric UUIDs or other custom values. To reduce # load on the search engine, we only retrieve the pk field, which will be checked against the # full list obtained from the database, and the id field, which will be used to delete the # record should it be found to be stale. index_pks = SearchQuerySet(using=backend.connection_alias).models(model) index_pks = index_pks.values_list('pk', 'id') # We'll collect all of the record IDs which are no longer present in the database and delete # them after walking the entire index. This uses more memory than the incremental approach but # avoids needing the pagination logic below to account for both commit modes: stale_records = set() for start in range(0, index_total, batch_size): upper_bound = start + batch_size # If the database pk is no longer present, queue the index key for removal: for pk, rec_id in index_pks[start:upper_bound]: if smart_bytes(pk) not in database_pks: stale_records.add(rec_id) if stale_records: if self.verbosity >= 1: self.stdout.write(" removing %d stale records." % len(stale_records)) for rec_id in stale_records: # Since the PK was not in the database list, we'll delete the record from the search # index: if self.verbosity >= 2: self.stdout.write(" removing %s." % rec_id) backend.remove(rec_id, commit=self.commit)
bsd-3-clause
[ 3, 2644, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 646, 2050, 199, 646, 12866, 199, 646, 747, 199, 646, 900, 199, 504, 2197, 492, 6871, 199, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 504, 1639, 14, 697, 492, 4002, 63, 1753, 63, 7995, 12, 5305, 63, 10590, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 11179, 63, 2394, 199, 504, 1639, 14, 1208, 14, 7145, 492, 3063, 199, 199, 504, 394, 1187, 2340, 492, 6947, 465, 394, 1187, 2340, 63, 7995, 199, 504, 394, 1187, 2340, 14, 3924, 492, 2832, 5940, 68, 199, 504, 394, 1187, 2340, 14, 1131, 492, 8730, 13689, 199, 504, 394, 1187, 2340, 14, 1208, 14, 571, 63, 8786, 492, 394, 1187, 2340, 63, 362, 63, 992, 12, 394, 1187, 2340, 63, 912, 63, 5181, 199, 199, 3472, 63, 20813, 63, 4305, 275, 488, 199, 3472, 63, 2962, 275, 488, 199, 3472, 63, 4283, 63, 32528, 275, 959, 199, 199, 4947, 275, 12866, 14, 793, 63, 475, 63, 3083, 8, 1896, 29, 4806, 14, 9171, 9, 421, 199, 318, 1678, 63, 6599, 8, 589, 304, 272, 340, 822, 8, 589, 9, 1137, 1616, 26, 267, 5051, 14, 705, 360, 873, 63, 6599, 3086, 8927, 2368, 26, 450, 82, 297, 1249, 9, 267, 746, 1722, 360, 873, 63, 6599, 3086, 8927, 2368, 358, 339, 1402, 12, 1343, 12, 1284, 12, 3141, 12, 1808, 12, 1343, 63, 602, 12, 1284, 63, 602, 12, 8661, 12, 5532, 12, 1390, 63, 10937, 275, 1249, 339, 327, 7600, 26, 12679, 626, 642, 365, 5139, 12082, 543, 818, 11641, 5459, 402, 5634, 26, 272, 327, 2136, 1929, 370, 5305, 314, 6947, 12, 4257, 314, 3365, 10358, 272, 327, 911, 862, 370, 8663, 314, 1950, 12, 1314, 14486, 7645, 370, 28511, 1536, 14, 272, 687, 1639, 14, 697, 492, 6947, 339, 367, 5162, 12, 2256, 315, 6947, 14, 17439, 14, 1744, 837, 267, 327, 2136, 1929, 370, 2597, 307, 739, 10540, 590, 543, 19245, 12, 2952, 330, 24491, 590, 336, 711, 316, 267, 327, 734, 6947, 334, 12897, 1124, 1396, 275, 1052, 16580, 2053, 293, 588, 315, 13, 4844, 6249, 83, 14, 267, 340, 283, 10659, 19, 7, 440, 315, 2256, 459, 15956, 2565, 288, 862, 26, 355, 4002, 63, 1753, 63, 7995, 342, 355, 340, 1228, 8, 7995, 423, 7995, 12, 1211, 304, 490, 2150, 6947, 423, 7995, 59, 3620, 61, 355, 587, 26, 490, 24358, 8, 7995, 423, 7995, 12, 5162, 9, 288, 871, 4067, 26, 355, 986, 339, 327, 4784, 626, 314, 1950, 5436, 734, 1263, 7115, 14928, 12184, 12, 570, 10022, 12, 5423, 14, 272, 394, 1187, 2340, 63, 7995, 59, 4941, 1055, 3958, 63, 11676, 342, 339, 25344, 63, 1080, 275, 394, 1187, 2340, 63, 7995, 59, 4941, 1055, 362, 63, 32180, 63, 1080, 342, 272, 1478, 275, 25344, 63, 1080, 14, 362, 63, 1080, 8, 1238, 9, 272, 4865, 275, 394, 1187, 2340, 63, 7995, 59, 4941, 1055, 362, 63, 4620, 342, 339, 6377, 275, 1478, 14, 1506, 63, 7924, 8, 928, 63, 602, 29, 928, 63, 602, 12, 1284, 63, 602, 29, 500, 63, 602, 9, 272, 886, 63, 873, 8, 4620, 12, 1478, 12, 6377, 12, 1343, 12, 1284, 12, 3141, 12, 8661, 12, 5532, 12, 1390, 63, 10937, 9, 272, 372, 1249, 421, 199, 318, 886, 63, 873, 8, 4620, 12, 1478, 12, 6377, 12, 1343, 12, 1284, 12, 3141, 12, 8661, 29, 17, 12, 5532, 29, 549, 12, 1598, 1390, 63, 10937, 29, 3472, 63, 4283, 63, 32528, 304, 339, 327, 2372, 282, 7289, 402, 314, 18397, 880, 626, 314, 2581, 3181, 1133, 330, 1088, 1536, 272, 327, 315, 4402, 14, 18491, 1380, 295, 28703, 7031, 32247, 402, 666, 14, 272, 7425, 63, 1637, 63, 6177, 275, 6377, 14, 452, 342, 272, 1453, 63, 6177, 275, 7425, 63, 1637, 63, 6177, 59, 928, 26, 500, 61, 339, 365, 63, 1708, 63, 1412, 275, 2688, 8, 736, 12, 283, 362, 802, 344, 358, 436, 747, 14, 17829, 342, 508, 747, 14, 362, 802, 344, 342, 339, 340, 8661, 2356, 499, 26, 267, 340, 365, 63, 1708, 63, 1412, 26, 288, 870, 480, 221, 15235, 450, 83, 446, 450, 68, 402, 450, 68, 2122, 450, 334, 928, 435, 413, 12, 1284, 12, 3141, 430, 267, 587, 26, 288, 870, 480, 221, 15235, 450, 83, 446, 450, 68, 402, 450, 68, 334, 6599, 20674, 26, 450, 83, 17617, 450, 334, 928, 435, 413, 12, 1284, 12, 3141, 12, 747, 14, 17829, 4059, 339, 10086, 275, 378, 272, 1830, 10086, 665, 1390, 63, 10937, 26, 267, 862, 26, 288, 327, 7600, 26, 2372, 314, 2451, 4865, 14, 288, 4865, 14, 873, 8, 1080, 12, 1453, 63, 6177, 12, 5532, 29, 3543, 9, 288, 340, 8661, 2356, 499, 436, 10086, 26, 355, 870, 360, 19908, 16356, 1052, 446, 5479, 16416, 1052, 14698, 5431, 1370, 908, 8, 928, 435, 413, 12, 6684, 3777, 1284, 12, 6684, 3777, 10086, 435, 413, 12, 6684, 3777, 1390, 63, 10937, 430, 288, 2059, 267, 871, 2186, 465, 3178, 26, 288, 327, 32754, 1006, 4967, 1314, 886, 440, 12252, 6804, 282, 2656, 4458, 12, 28529, 14838, 436, 288, 327, 13483, 14, 961, 23674, 1929, 316, 370, 492, 314, 4865, 13, 6100, 1919, 9180, 288, 327, 687, 10382, 393, 82, 12, 24380, 1733, 12, 3963, 22267, 12, 4145, 12, 5423, 14, 288, 10086, 847, 413, 953, 1125, 63, 1100, 275, 791, 928, 356, 1343, 435, 413, 12, 2490, 283, 500, 356, 1284, 12, 2490, 283, 10937, 356, 10086, 12, 2490, 283, 988, 63, 10937, 356, 1390, 63, 10937, 12, 2490, 283, 3150, 356, 747, 14, 17829, 1062, 2490, 283, 2804, 356, 3178, 93, 953, 1125, 63, 1328, 275, 283, 4276, 16356, 2818, 928, 9, 83, 446, 2818, 500, 9, 83, 334, 7154, 2818, 10937, 9, 83, 21275, 988, 63, 10937, 9, 83, 304, 2818, 2804, 9, 83, 7, 288, 340, 440, 365, 63, 1708, 63, 1412, 26, 355, 1125, 63, 1328, 847, 283, 334, 3150, 2818, 3150, 9, 83, 304, 2818, 2804, 9, 83, 7, 953, 340, 10086, 2356, 1390, 63, 10937 ]
[ 2644, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 2649, 63, 5955, 199, 199, 646, 2050, 199, 646, 12866, 199, 646, 747, 199, 646, 900, 199, 504, 2197, 492, 6871, 199, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 504, 1639, 14, 697, 492, 4002, 63, 1753, 63, 7995, 12, 5305, 63, 10590, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 12, 11179, 63, 2394, 199, 504, 1639, 14, 1208, 14, 7145, 492, 3063, 199, 199, 504, 394, 1187, 2340, 492, 6947, 465, 394, 1187, 2340, 63, 7995, 199, 504, 394, 1187, 2340, 14, 3924, 492, 2832, 5940, 68, 199, 504, 394, 1187, 2340, 14, 1131, 492, 8730, 13689, 199, 504, 394, 1187, 2340, 14, 1208, 14, 571, 63, 8786, 492, 394, 1187, 2340, 63, 362, 63, 992, 12, 394, 1187, 2340, 63, 912, 63, 5181, 199, 199, 3472, 63, 20813, 63, 4305, 275, 488, 199, 3472, 63, 2962, 275, 488, 199, 3472, 63, 4283, 63, 32528, 275, 959, 199, 199, 4947, 275, 12866, 14, 793, 63, 475, 63, 3083, 8, 1896, 29, 4806, 14, 9171, 9, 421, 199, 318, 1678, 63, 6599, 8, 589, 304, 272, 340, 822, 8, 589, 9, 1137, 1616, 26, 267, 5051, 14, 705, 360, 873, 63, 6599, 3086, 8927, 2368, 26, 450, 82, 297, 1249, 9, 267, 746, 1722, 360, 873, 63, 6599, 3086, 8927, 2368, 358, 339, 1402, 12, 1343, 12, 1284, 12, 3141, 12, 1808, 12, 1343, 63, 602, 12, 1284, 63, 602, 12, 8661, 12, 5532, 12, 1390, 63, 10937, 275, 1249, 339, 327, 7600, 26, 12679, 626, 642, 365, 5139, 12082, 543, 818, 11641, 5459, 402, 5634, 26, 272, 327, 2136, 1929, 370, 5305, 314, 6947, 12, 4257, 314, 3365, 10358, 272, 327, 911, 862, 370, 8663, 314, 1950, 12, 1314, 14486, 7645, 370, 28511, 1536, 14, 272, 687, 1639, 14, 697, 492, 6947, 339, 367, 5162, 12, 2256, 315, 6947, 14, 17439, 14, 1744, 837, 267, 327, 2136, 1929, 370, 2597, 307, 739, 10540, 590, 543, 19245, 12, 2952, 330, 24491, 590, 336, 711, 316, 267, 327, 734, 6947, 334, 12897, 1124, 1396, 275, 1052, 16580, 2053, 293, 588, 315, 13, 4844, 6249, 83, 14, 267, 340, 283, 10659, 19, 7, 440, 315, 2256, 459, 15956, 2565, 288, 862, 26, 355, 4002, 63, 1753, 63, 7995, 342, 355, 340, 1228, 8, 7995, 423, 7995, 12, 1211, 304, 490, 2150, 6947, 423, 7995, 59, 3620, 61, 355, 587, 26, 490, 24358, 8, 7995, 423, 7995, 12, 5162, 9, 288, 871, 4067, 26, 355, 986, 339, 327, 4784, 626, 314, 1950, 5436, 734, 1263, 7115, 14928, 12184, 12, 570, 10022, 12, 5423, 14, 272, 394, 1187, 2340, 63, 7995, 59, 4941, 1055, 3958, 63, 11676, 342, 339, 25344, 63, 1080, 275, 394, 1187, 2340, 63, 7995, 59, 4941, 1055, 362, 63, 32180, 63, 1080, 342, 272, 1478, 275, 25344, 63, 1080, 14, 362, 63, 1080, 8, 1238, 9, 272, 4865, 275, 394, 1187, 2340, 63, 7995, 59, 4941, 1055, 362, 63, 4620, 342, 339, 6377, 275, 1478, 14, 1506, 63, 7924, 8, 928, 63, 602, 29, 928, 63, 602, 12, 1284, 63, 602, 29, 500, 63, 602, 9, 272, 886, 63, 873, 8, 4620, 12, 1478, 12, 6377, 12, 1343, 12, 1284, 12, 3141, 12, 8661, 12, 5532, 12, 1390, 63, 10937, 9, 272, 372, 1249, 421, 199, 318, 886, 63, 873, 8, 4620, 12, 1478, 12, 6377, 12, 1343, 12, 1284, 12, 3141, 12, 8661, 29, 17, 12, 5532, 29, 549, 12, 1598, 1390, 63, 10937, 29, 3472, 63, 4283, 63, 32528, 304, 339, 327, 2372, 282, 7289, 402, 314, 18397, 880, 626, 314, 2581, 3181, 1133, 330, 1088, 1536, 272, 327, 315, 4402, 14, 18491, 1380, 295, 28703, 7031, 32247, 402, 666, 14, 272, 7425, 63, 1637, 63, 6177, 275, 6377, 14, 452, 342, 272, 1453, 63, 6177, 275, 7425, 63, 1637, 63, 6177, 59, 928, 26, 500, 61, 339, 365, 63, 1708, 63, 1412, 275, 2688, 8, 736, 12, 283, 362, 802, 344, 358, 436, 747, 14, 17829, 342, 508, 747, 14, 362, 802, 344, 342, 339, 340, 8661, 2356, 499, 26, 267, 340, 365, 63, 1708, 63, 1412, 26, 288, 870, 480, 221, 15235, 450, 83, 446, 450, 68, 402, 450, 68, 2122, 450, 334, 928, 435, 413, 12, 1284, 12, 3141, 430, 267, 587, 26, 288, 870, 480, 221, 15235, 450, 83, 446, 450, 68, 402, 450, 68, 334, 6599, 20674, 26, 450, 83, 17617, 450, 334, 928, 435, 413, 12, 1284, 12, 3141, 12, 747, 14, 17829, 4059, 339, 10086, 275, 378, 272, 1830, 10086, 665, 1390, 63, 10937, 26, 267, 862, 26, 288, 327, 7600, 26, 2372, 314, 2451, 4865, 14, 288, 4865, 14, 873, 8, 1080, 12, 1453, 63, 6177, 12, 5532, 29, 3543, 9, 288, 340, 8661, 2356, 499, 436, 10086, 26, 355, 870, 360, 19908, 16356, 1052, 446, 5479, 16416, 1052, 14698, 5431, 1370, 908, 8, 928, 435, 413, 12, 6684, 3777, 1284, 12, 6684, 3777, 10086, 435, 413, 12, 6684, 3777, 1390, 63, 10937, 430, 288, 2059, 267, 871, 2186, 465, 3178, 26, 288, 327, 32754, 1006, 4967, 1314, 886, 440, 12252, 6804, 282, 2656, 4458, 12, 28529, 14838, 436, 288, 327, 13483, 14, 961, 23674, 1929, 316, 370, 492, 314, 4865, 13, 6100, 1919, 9180, 288, 327, 687, 10382, 393, 82, 12, 24380, 1733, 12, 3963, 22267, 12, 4145, 12, 5423, 14, 288, 10086, 847, 413, 953, 1125, 63, 1100, 275, 791, 928, 356, 1343, 435, 413, 12, 2490, 283, 500, 356, 1284, 12, 2490, 283, 10937, 356, 10086, 12, 2490, 283, 988, 63, 10937, 356, 1390, 63, 10937, 12, 2490, 283, 3150, 356, 747, 14, 17829, 1062, 2490, 283, 2804, 356, 3178, 93, 953, 1125, 63, 1328, 275, 283, 4276, 16356, 2818, 928, 9, 83, 446, 2818, 500, 9, 83, 334, 7154, 2818, 10937, 9, 83, 21275, 988, 63, 10937, 9, 83, 304, 2818, 2804, 9, 83, 7, 288, 340, 440, 365, 63, 1708, 63, 1412, 26, 355, 1125, 63, 1328, 847, 283, 334, 3150, 2818, 3150, 9, 83, 304, 2818, 2804, 9, 83, 7, 953, 340, 10086, 2356, 1390, 63, 10937, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
stormi/weblate
weblate/accounts/management/commands/importusers.py
9
2983
# -*- 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/>. # from django.core.management.base import BaseCommand, CommandError from django.contrib.auth.models import User from optparse import make_option import json class Command(BaseCommand): help = 'imports users from JSON dump of database' args = '<json-file>' option_list = BaseCommand.option_list + ( make_option( '--check', action='store_true', help='Only check import, do not actually create users' ), ) def handle(self, *args, **options): ''' Creates default set of groups and optionally updates them and moves users around to default group. ''' if len(args) != 1: raise CommandError('Please specify JSON file to import!') data = json.load(open(args[0])) for line in data: if 'fields' in line: line = line['fields'] if 'is_active' in line and not line['is_active']: continue if not line['email'] or not line['username']: self.stderr.write( 'Skipping {}, has blank username or email'.format(line) ) continue if User.objects.filter(username=line['username']).exists(): self.stderr.write( 'Skipping {}, username exists'.format(line['username']) ) continue if User.objects.filter(email=line['email']).exists(): self.stderr.write( 'Skipping {}, email exists'.format(line['email']) ) continue if not line['last_name'] in line['first_name']: full_name = u'{0} {1}'.format( line['first_name'], line['last_name'] ) else: full_name = line['first_name'] if not options['check']: User.objects.create( username=line['username'], first_name=full_name, last_name='', password=line['password'], email=line['email'] )
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, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 8691, 492, 1852, 63, 1422, 199, 646, 2022, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 283, 12775, 4390, 687, 4840, 5461, 402, 3050, 7, 272, 1249, 275, 2650, 1001, 13, 493, 3524, 272, 945, 63, 513, 275, 22239, 14, 1422, 63, 513, 435, 334, 267, 1852, 63, 1422, 8, 288, 2850, 1074, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 534, 5903, 1104, 492, 12, 886, 440, 5965, 1218, 4390, 7, 267, 2318, 272, 776, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 1449, 267, 10560, 849, 663, 402, 4652, 436, 14190, 7029, 3062, 436, 14569, 267, 4390, 6818, 370, 849, 1572, 14, 267, 1449, 267, 340, 822, 8, 589, 9, 1137, 413, 26, 288, 746, 14393, 360, 8254, 4165, 4840, 570, 370, 492, 10916, 398, 666, 275, 2022, 14, 912, 8, 1490, 8, 589, 59, 16, 2459, 398, 367, 1004, 315, 666, 26, 288, 340, 283, 955, 7, 315, 1004, 26, 355, 1004, 275, 1004, 459, 955, 418, 953, 340, 283, 374, 63, 2682, 7, 315, 1004, 436, 440, 1004, 459, 374, 63, 2682, 2565, 355, 1980, 953, 340, 440, 1004, 459, 2123, 418, 503, 440, 1004, 459, 2473, 2565, 355, 291, 14, 3083, 14, 952, 8, 490, 283, 18297, 5479, 965, 4596, 3434, 503, 3031, 1370, 908, 8, 604, 9, 355, 776, 355, 1980, 953, 340, 2876, 14, 1462, 14, 1541, 8, 2473, 29, 604, 459, 2473, 13227, 2444, 837, 355, 291, 14, 3083, 14, 952, 8, 490, 283, 18297, 5479, 3434, 3495, 1370, 908, 8, 604, 459, 2473, 1105, 355, 776, 355, 1980, 953, 340, 2876, 14, 1462, 14, 1541, 8, 2123, 29, 604, 459, 2123, 13227, 2444, 837, 355, 291, 14, 3083, 14, 952, 8, 490, 283, 18297, 5479, 3031, 3495, 1370, 908, 8, 604, 459, 2123, 1105, 355, 776, 355, 1980, 953, 340, 440, 1004, 459, 2019, 63, 354, 418, 315, 1004, 459, 2246, 63, 354, 2565, 355, 2615, 63, 354, 275, 399, 16019, 16, 93, 469, 17, 5285, 908, 8, 490, 1004, 459, 2246, 63, 354, 995, 490, 1004, 459, 2019, 63, 354, 418, 355, 776, 288, 587, 26, 355, 2615, 63, 354, 275, 1004, 459, 2246, 63, 354, 418, 953, 340, 440, 1511, 459, 1074, 2565, 355, 2876, 14, 1462, 14, 981, 8, 490, 3434, 29, 604, 459, 2473, 995, 490, 1642, 63, 354, 29, 2861, 63, 354, 12, 490, 2061, 63, 354, 4581, 490, 2505, 29, 604, 459, 2060, 995, 490, 3031, 29, 604, 459, 2123, 418, 355, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 12, 14393, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 8691, 492, 1852, 63, 1422, 199, 646, 2022, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 283, 12775, 4390, 687, 4840, 5461, 402, 3050, 7, 272, 1249, 275, 2650, 1001, 13, 493, 3524, 272, 945, 63, 513, 275, 22239, 14, 1422, 63, 513, 435, 334, 267, 1852, 63, 1422, 8, 288, 2850, 1074, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 1720, 534, 5903, 1104, 492, 12, 886, 440, 5965, 1218, 4390, 7, 267, 2318, 272, 776, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 1449, 267, 10560, 849, 663, 402, 4652, 436, 14190, 7029, 3062, 436, 14569, 267, 4390, 6818, 370, 849, 1572, 14, 267, 1449, 267, 340, 822, 8, 589, 9, 1137, 413, 26, 288, 746, 14393, 360, 8254, 4165, 4840, 570, 370, 492, 10916, 398, 666, 275, 2022, 14, 912, 8, 1490, 8, 589, 59, 16, 2459, 398, 367, 1004, 315, 666, 26, 288, 340, 283, 955, 7, 315, 1004, 26, 355, 1004, 275, 1004, 459, 955, 418, 953, 340, 283, 374, 63, 2682, 7, 315, 1004, 436, 440, 1004, 459, 374, 63, 2682, 2565, 355, 1980, 953, 340, 440, 1004, 459, 2123, 418, 503, 440, 1004, 459, 2473, 2565, 355, 291, 14, 3083, 14, 952, 8, 490, 283, 18297, 5479, 965, 4596, 3434, 503, 3031, 1370, 908, 8, 604, 9, 355, 776, 355, 1980, 953, 340, 2876, 14, 1462, 14, 1541, 8, 2473, 29, 604, 459, 2473, 13227, 2444, 837, 355, 291, 14, 3083, 14, 952, 8, 490, 283, 18297, 5479, 3434, 3495, 1370, 908, 8, 604, 459, 2473, 1105, 355, 776, 355, 1980, 953, 340, 2876, 14, 1462, 14, 1541, 8, 2123, 29, 604, 459, 2123, 13227, 2444, 837, 355, 291, 14, 3083, 14, 952, 8, 490, 283, 18297, 5479, 3031, 3495, 1370, 908, 8, 604, 459, 2123, 1105, 355, 776, 355, 1980, 953, 340, 440, 1004, 459, 2019, 63, 354, 418, 315, 1004, 459, 2246, 63, 354, 2565, 355, 2615, 63, 354, 275, 399, 16019, 16, 93, 469, 17, 5285, 908, 8, 490, 1004, 459, 2246, 63, 354, 995, 490, 1004, 459, 2019, 63, 354, 418, 355, 776, 288, 587, 26, 355, 2615, 63, 354, 275, 1004, 459, 2246, 63, 354, 418, 953, 340, 440, 1511, 459, 1074, 2565, 355, 2876, 14, 1462, 14, 981, 8, 490, 3434, 29, 604, 459, 2473, 995, 490, 1642, 63, 354, 29, 2861, 63, 354, 12, 490, 2061, 63, 354, 4581, 490, 2505, 29, 604, 459, 2060, 995, 490, 3031, 29, 604, 459, 2123, 418, 355, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Yannig/ansible
lib/ansible/modules/files/assemble.py
26
8673
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2012, Stephen Fromm <sfromm@gmail.com> # Copyright: (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com> # Copyright: (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['stableinterface'], 'supported_by': 'core'} DOCUMENTATION = ''' --- module: assemble short_description: Assembles a configuration file from fragments description: - Assembles a configuration file from fragments. Often a particular program will take a single configuration file and does not support a C(conf.d) style structure where it is easy to build up the configuration from multiple sources. C(assemble) will take a directory of files that can be local or have already been transferred to the system, and concatenate them together to produce a destination file. Files are assembled in string sorting order. Puppet calls this idea I(fragments). version_added: "0.5" options: src: description: - An already existing directory full of source files. required: true default: null aliases: [] dest: description: - A file to create using the concatenation of all of the source files. required: true default: null backup: description: - Create a backup file (if C(yes)), including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly. required: false choices: [ "yes", "no" ] default: "no" delimiter: description: - A delimiter to separate the file contents. version_added: "1.4" required: false default: null remote_src: description: - If False, it will search for src at originating/master machine, if True it will go to the remote/target machine for the src. Default is True. choices: [ "True", "False" ] required: false default: "True" version_added: "1.4" regexp: description: - Assemble files only if C(regex) matches the filename. If not set, all files are assembled. All "\\" (backslash) must be escaped as "\\\\" to comply yaml syntax. Uses Python regular expressions; see U(http://docs.python.org/2/library/re.html). required: false default: null ignore_hidden: description: - A boolean that controls if files that start with a '.' will be included or not. required: false default: false version_added: "2.0" validate: description: - The validation command to run before copying into place. The path to the file to validate is passed in via '%s' which must be present as in the sshd example below. The command is passed securely so shell features like expansion and pipes won't work. required: false default: null version_added: "2.0" author: "Stephen Fromm (@sfromm)" extends_documentation_fragment: - files - decrypt ''' EXAMPLES = ''' # Example from Ansible Playbooks - assemble: src: /etc/someapp/fragments dest: /etc/someapp/someapp.conf # When a delimiter is specified, it will be inserted in between each fragment - assemble: src: /etc/someapp/fragments dest: /etc/someapp/someapp.conf delimiter: '### START FRAGMENT ###' # Copy a new "sshd_config" file into place, after passing validation with sshd - assemble: src: /etc/ssh/conf.d/ dest: /etc/ssh/sshd_config validate: '/usr/sbin/sshd -t -f %s' ''' import codecs import os import os.path import re import tempfile from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.six import b from ansible.module_utils._text import to_native # =========================================== # Support method def assemble_from_fragments(src_path, delimiter=None, compiled_regexp=None, ignore_hidden=False): ''' assemble a file from a directory of fragments ''' tmpfd, temp_path = tempfile.mkstemp() tmp = os.fdopen(tmpfd, 'wb') delimit_me = False add_newline = False for f in sorted(os.listdir(src_path)): if compiled_regexp and not compiled_regexp.search(f): continue fragment = os.path.join(src_path, f) if not os.path.isfile(fragment) or (ignore_hidden and os.path.basename(fragment).startswith('.')): continue fragment_content = open(fragment, 'rb').read() # always put a newline between fragments if the previous fragment didn't end with a newline. if add_newline: tmp.write(b('\n')) # delimiters should only appear between fragments if delimit_me: if delimiter: # un-escape anything like newlines delimiter = codecs.escape_decode(delimiter)[0] tmp.write(delimiter) # always make sure there's a newline after the # delimiter, so lines don't run together if delimiter[-1] != b('\n'): tmp.write(b('\n')) tmp.write(fragment_content) delimit_me = True if fragment_content.endswith(b('\n')): add_newline = False else: add_newline = True tmp.close() return temp_path def cleanup(path, result=None): # cleanup just in case if os.path.exists(path): try: os.remove(path) except (IOError, OSError) as e: # don't error on possible race conditions, but keep warning if result is not None: result['warnings'] = ['Unable to remove temp file (%s): %s' % (path, to_native(e))] def main(): module = AnsibleModule( # not checking because of daisy chain to file module argument_spec = dict( src = dict(required=True, type='path'), delimiter = dict(required=False), dest = dict(required=True, type='path'), backup=dict(default=False, type='bool'), remote_src=dict(default=False, type='bool'), regexp = dict(required=False), ignore_hidden = dict(default=False, type='bool'), validate = dict(required=False, type='str'), ), add_file_common_args=True ) changed = False path_hash = None dest_hash = None src = module.params['src'] dest = module.params['dest'] backup = module.params['backup'] delimiter = module.params['delimiter'] regexp = module.params['regexp'] compiled_regexp = None ignore_hidden = module.params['ignore_hidden'] validate = module.params.get('validate', None) result = dict(src=src, dest=dest) if not os.path.exists(src): module.fail_json(msg="Source (%s) does not exist" % src) if not os.path.isdir(src): module.fail_json(msg="Source (%s) is not a directory" % src) if regexp is not None: try: compiled_regexp = re.compile(regexp) except re.error as e: module.fail_json(msg="Invalid Regexp (%s) in \"%s\"" % (to_native(e), regexp)) if validate and "%s" not in validate: module.fail_json(msg="validate must contain %%s: %s" % validate) path = assemble_from_fragments(src, delimiter, compiled_regexp, ignore_hidden) path_hash = module.sha1(path) result['checksum'] = path_hash # Backwards compat. This won't return data if FIPS mode is active try: pathmd5 = module.md5(path) except ValueError: pathmd5 = None result['md5sum'] = pathmd5 if os.path.exists(dest): dest_hash = module.sha1(dest) if path_hash != dest_hash: if validate: (rc, out, err) = module.run_command(validate % path) result['validation'] = dict(rc=rc, stdout=out, stderr=err) if rc != 0: cleanup(path) module.fail_json(msg="failed to validate: rc:%s error:%s" % (rc, err)) if backup and dest_hash is not None: result['backup_file'] = module.backup_local(dest) module.atomic_move(path, dest, unsafe_writes=module.params['unsafe_writes']) changed = True cleanup(path, result) # handle file permissions file_args = module.load_file_common_arguments(module.params) result['changed'] = module.set_fs_attributes_if_different(file_args, changed) # Mission complete result['msg'] = "OK" module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 6029, 12, 17854, 17579, 11606, 77, 665, 83, 504, 77, 32, 6799, 14, 957, 30, 199, 3, 1898, 26, 334, 67, 9, 7800, 12, 4005, 609, 2308, 1804, 300, 4188, 73, 665, 2663, 300, 4188, 73, 32, 4853, 14, 957, 30, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 22931, 199, 3612, 63, 1802, 26, 3709, 8834, 83, 282, 2897, 570, 687, 21495, 199, 1802, 26, 1362, 446, 3709, 8834, 83, 282, 2897, 570, 687, 21495, 14, 24545, 724, 282, 6770, 2126, 2240, 911, 5452, 282, 2849, 2897, 570, 436, 1630, 440, 2291, 282, 2126, 445, 8, 2190, 14, 68, 9, 3449, 5523, 2382, 652, 365, 8837, 370, 1900, 1536, 314, 2897, 2126, 687, 3663, 5274, 14, 445, 8, 21263, 9, 911, 5452, 282, 2082, 402, 1584, 626, 883, 506, 2126, 2257, 503, 1172, 2575, 2757, 1752, 5057, 370, 314, 2656, 12, 436, 24788, 3062, 2126, 10451, 370, 7389, 282, 5724, 570, 14, 16920, 787, 22931, 68, 315, 1059, 13351, 1865, 14, 2126, 510, 17934, 4882, 642, 16819, 473, 8, 18047, 680, 199, 1023, 63, 3270, 26, 298, 16, 14, 21, 2, 199, 1419, 26, 523, 2928, 26, 272, 1369, 26, 489, 446, 1626, 2575, 3411, 2082, 2615, 402, 1350, 1584, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 2053, 26, 272, 1369, 26, 489, 446, 437, 570, 370, 1218, 1808, 314, 28207, 402, 1006, 402, 314, 1350, 1584, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 6902, 26, 272, 1369, 26, 489, 446, 2790, 282, 6902, 570, 334, 692, 445, 8, 5066, 1826, 5893, 314, 4913, 2556, 880, 267, 1265, 883, 664, 314, 3379, 570, 1771, 340, 1265, 29437, 286, 1191, 18897, 652, 267, 22743, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 849, 26, 298, 889, 2, 523, 11172, 26, 272, 1369, 26, 489, 446, 437, 11172, 370, 7396, 314, 570, 4072, 14, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 3982, 63, 2164, 26, 272, 1369, 26, 489, 446, 982, 756, 12, 652, 911, 2754, 367, 2928, 737, 6330, 1958, 15, 4133, 6844, 12, 340, 715, 652, 911, 267, 2621, 370, 314, 3982, 15, 1375, 6844, 367, 314, 2928, 14, 3758, 365, 715, 14, 272, 3415, 26, 359, 298, 549, 401, 298, 797, 2, 1622, 272, 1415, 26, 3055, 272, 849, 26, 298, 549, 2, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 523, 13156, 26, 272, 1369, 26, 489, 446, 3709, 8834, 1584, 1454, 340, 445, 8, 3821, 9, 4450, 314, 1788, 14, 982, 440, 663, 12, 267, 1006, 1584, 787, 22931, 68, 14, 2900, 9926, 2, 334, 21509, 9, 1471, 506, 11077, 465, 267, 298, 8712, 2, 370, 1013, 590, 8864, 6302, 14, 14911, 2018, 5578, 8455, 27, 1937, 267, 738, 8, 1014, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 264, 14, 1360, 680, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 3686, 63, 5642, 26, 272, 1369, 26, 489, 446, 437, 5046, 626, 13467, 340, 1584, 626, 1343, 543, 282, 7815, 911, 506, 5120, 503, 440, 14, 272, 1415, 26, 3055, 272, 849, 26, 3055, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 523, 4107, 26, 272, 1369, 26, 489, 446, 710, 6411, 1414, 370, 1255, 2544, 16743, 1901, 4192, 14, 221, 710, 931, 370, 314, 570, 370, 267, 4107, 365, 3032, 315, 4799, 1543, 83, 7, 1314, 1471, 506, 3451, 465, 315, 314, 8635, 68, 2893, 5084, 14, 267, 710, 1414, 365, 3032, 11153, 590, 880, 5218, 4534, 2839, 14819, 436, 20988, 7859, 1133, 1736, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 298, 26696, 17579, 11606, 77, 8593, 83, 504, 77, 2924, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 1584, 272, 446, 20090, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5679, 687, 2622, 16527, 8858, 199, 13, 22931, 26, 272, 2928, 26, 1182, 6839, 15, 3972, 571, 15, 18047, 272, 2053, 26, 1182, 6839, 15, 3972, 571, 15, 3972, 571, 14, 2190, 199, 199, 3, 3979, 282, 11172, 365, 2013, 12, 652, 911, 506, 11788, 315, 3382, 1924, 7956, 199, 13, 22931, 26, 272, 2928, 26, 1182, 6839, 15, 3972, 571, 15, 18047, 272, 2053, 26, 1182, 6839, 15, 3972, 571, 15, 3972, 571, 14, 2190, 272, 11172, 26, 283, 5680, 13910, 28671, 1254, 4479, 6754, 7, 199, 199, 3, 11247, 282, 892, 298, 5510, 68, 63, 888, 2, 570, 1901, 4192, 12, 2410, 9476, 6411, 543, 8635, 68, 199, 13, 22931, 26, 272, 2928, 26, 1182, 6839, 15, 5510, 15, 2190, 14, 68, 15, 272, 2053, 26, 1182, 6839, 15, 5510, 15, 5510, 68, 63, 888, 272, 4107, 26, 1994, 2647, 15, 21457, 15, 5510, 68, 446, 84, 446, 70, 450, 83, 7, 199, 2344, 199, 199, 646, 6010, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 5549, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 330, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 421, 199, 3, 19469, 17575, 199, 3, 12502, 1083, 199, 199, 318, 22931, 63, 504, 63, 18047, 8, 2164, 63, 515, 12, 11172, 29, 403, 12, 10311 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 6029, 12, 17854, 17579, 11606, 77, 665, 83, 504, 77, 32, 6799, 14, 957, 30, 199, 3, 1898, 26, 334, 67, 9, 7800, 12, 4005, 609, 2308, 1804, 300, 4188, 73, 665, 2663, 300, 4188, 73, 32, 4853, 14, 957, 30, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 2622, 7290, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 22931, 199, 3612, 63, 1802, 26, 3709, 8834, 83, 282, 2897, 570, 687, 21495, 199, 1802, 26, 1362, 446, 3709, 8834, 83, 282, 2897, 570, 687, 21495, 14, 24545, 724, 282, 6770, 2126, 2240, 911, 5452, 282, 2849, 2897, 570, 436, 1630, 440, 2291, 282, 2126, 445, 8, 2190, 14, 68, 9, 3449, 5523, 2382, 652, 365, 8837, 370, 1900, 1536, 314, 2897, 2126, 687, 3663, 5274, 14, 445, 8, 21263, 9, 911, 5452, 282, 2082, 402, 1584, 626, 883, 506, 2126, 2257, 503, 1172, 2575, 2757, 1752, 5057, 370, 314, 2656, 12, 436, 24788, 3062, 2126, 10451, 370, 7389, 282, 5724, 570, 14, 16920, 787, 22931, 68, 315, 1059, 13351, 1865, 14, 2126, 510, 17934, 4882, 642, 16819, 473, 8, 18047, 680, 199, 1023, 63, 3270, 26, 298, 16, 14, 21, 2, 199, 1419, 26, 523, 2928, 26, 272, 1369, 26, 489, 446, 1626, 2575, 3411, 2082, 2615, 402, 1350, 1584, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 2053, 26, 272, 1369, 26, 489, 446, 437, 570, 370, 1218, 1808, 314, 28207, 402, 1006, 402, 314, 1350, 1584, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 6902, 26, 272, 1369, 26, 489, 446, 2790, 282, 6902, 570, 334, 692, 445, 8, 5066, 1826, 5893, 314, 4913, 2556, 880, 267, 1265, 883, 664, 314, 3379, 570, 1771, 340, 1265, 29437, 286, 1191, 18897, 652, 267, 22743, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 849, 26, 298, 889, 2, 523, 11172, 26, 272, 1369, 26, 489, 446, 437, 11172, 370, 7396, 314, 570, 4072, 14, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 3982, 63, 2164, 26, 272, 1369, 26, 489, 446, 982, 756, 12, 652, 911, 2754, 367, 2928, 737, 6330, 1958, 15, 4133, 6844, 12, 340, 715, 652, 911, 267, 2621, 370, 314, 3982, 15, 1375, 6844, 367, 314, 2928, 14, 3758, 365, 715, 14, 272, 3415, 26, 359, 298, 549, 401, 298, 797, 2, 1622, 272, 1415, 26, 3055, 272, 849, 26, 298, 549, 2, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 523, 13156, 26, 272, 1369, 26, 489, 446, 3709, 8834, 1584, 1454, 340, 445, 8, 3821, 9, 4450, 314, 1788, 14, 982, 440, 663, 12, 267, 1006, 1584, 787, 22931, 68, 14, 2900, 9926, 2, 334, 21509, 9, 1471, 506, 11077, 465, 267, 298, 8712, 2, 370, 1013, 590, 8864, 6302, 14, 14911, 2018, 5578, 8455, 27, 1937, 267, 738, 8, 1014, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 264, 14, 1360, 680, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 3686, 63, 5642, 26, 272, 1369, 26, 489, 446, 437, 5046, 626, 13467, 340, 1584, 626, 1343, 543, 282, 7815, 911, 506, 5120, 503, 440, 14, 272, 1415, 26, 3055, 272, 849, 26, 3055, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 523, 4107, 26, 272, 1369, 26, 489, 446, 710, 6411, 1414, 370, 1255, 2544, 16743, 1901, 4192, 14, 221, 710, 931, 370, 314, 570, 370, 267, 4107, 365, 3032, 315, 4799, 1543, 83, 7, 1314, 1471, 506, 3451, 465, 315, 314, 8635, 68, 2893, 5084, 14, 267, 710, 1414, 365, 3032, 11153, 590, 880, 5218, 4534, 2839, 14819, 436, 20988, 7859, 1133, 1736, 14, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 298, 26696, 17579, 11606, 77, 8593, 83, 504, 77, 2924, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 1584, 272, 446, 20090, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5679, 687, 2622, 16527, 8858, 199, 13, 22931, 26, 272, 2928, 26, 1182, 6839, 15, 3972, 571, 15, 18047, 272, 2053, 26, 1182, 6839, 15, 3972, 571, 15, 3972, 571, 14, 2190, 199, 199, 3, 3979, 282, 11172, 365, 2013, 12, 652, 911, 506, 11788, 315, 3382, 1924, 7956, 199, 13, 22931, 26, 272, 2928, 26, 1182, 6839, 15, 3972, 571, 15, 18047, 272, 2053, 26, 1182, 6839, 15, 3972, 571, 15, 3972, 571, 14, 2190, 272, 11172, 26, 283, 5680, 13910, 28671, 1254, 4479, 6754, 7, 199, 199, 3, 11247, 282, 892, 298, 5510, 68, 63, 888, 2, 570, 1901, 4192, 12, 2410, 9476, 6411, 543, 8635, 68, 199, 13, 22931, 26, 272, 2928, 26, 1182, 6839, 15, 5510, 15, 2190, 14, 68, 15, 272, 2053, 26, 1182, 6839, 15, 5510, 15, 5510, 68, 63, 888, 272, 4107, 26, 1994, 2647, 15, 21457, 15, 5510, 68, 446, 84, 446, 70, 450, 83, 7, 199, 2344, 199, 199, 646, 6010, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 5549, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 330, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 421, 199, 3, 19469, 17575, 199, 3, 12502, 1083, 199, 199, 318, 22931, 63, 504, 63, 18047, 8, 2164, 63, 515, 12, 11172, 29, 403, 12, 10311, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
be-cloud-be/horizon-addons
server/addons/account/models/partner.py
4
22365
# -*- coding: utf-8 -*- from operator import itemgetter import time from openerp import api, fields, models, _ from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT from openerp.exceptions import ValidationError class AccountFiscalPosition(models.Model): _name = 'account.fiscal.position' _description = 'Fiscal Position' _order = 'sequence' sequence = fields.Integer() name = fields.Char(string='Fiscal Position', required=True) active = fields.Boolean(default=True, help="By unchecking the active field, you may hide a fiscal position without deleting it.") company_id = fields.Many2one('res.company', string='Company') account_ids = fields.One2many('account.fiscal.position.account', 'position_id', string='Account Mapping', copy=True) tax_ids = fields.One2many('account.fiscal.position.tax', 'position_id', string='Tax Mapping', copy=True) note = fields.Text('Notes', help="Legal mentions that have to be printed on the invoices.") auto_apply = fields.Boolean(string='Detect Automatically', help="Apply automatically this fiscal position.") vat_required = fields.Boolean(string='VAT required', help="Apply only if partner has a VAT number.") country_id = fields.Many2one('res.country', string='Country', help="Apply only if delivery or invoicing country match.") country_group_id = fields.Many2one('res.country.group', string='Country Group', help="Apply only if delivery or invocing country match the group.") state_ids = fields.Many2many('res.country.state', string='Federal States') zip_from = fields.Integer(string='Zip Range From', default=0) zip_to = fields.Integer(string='Zip Range To', default=0) # To be used in hiding the 'Federal States' field('attrs' in view side) when selected 'Country' has 0 states. states_count = fields.Integer(compute='_compute_states_count') @api.one def _compute_states_count(self): self.states_count = len(self.country_id.state_ids) @api.one @api.constrains('zip_from', 'zip_to') def _check_zip(self): if self.zip_from > self.zip_to: raise ValidationError(_('Invalid "Zip Range", please configure it properly.')) return True @api.v7 def map_tax(self, cr, uid, fposition_id, taxes, context=None): if not taxes: return [] if not fposition_id: return map(lambda x: x.id, taxes) result = set() for t in taxes: ok = False for tax in fposition_id.tax_ids: if tax.tax_src_id.id == t.id: if tax.tax_dest_id: result.add(tax.tax_dest_id.id) ok = True if not ok: result.add(t.id) return list(result) @api.v8 # noqa def map_tax(self, taxes): result = self.env['account.tax'].browse() for tax in taxes: tax_count = 0 for t in self.tax_ids: if t.tax_src_id == tax: tax_count += 1 if t.tax_dest_id: result |= t.tax_dest_id if not tax_count: result |= tax return result @api.v7 def map_account(self, cr, uid, fposition_id, account_id, context=None): if not fposition_id: return account_id for pos in fposition_id.account_ids: if pos.account_src_id.id == account_id: account_id = pos.account_dest_id.id break return account_id @api.v8 def map_account(self, account): for pos in self.account_ids: if pos.account_src_id == account: return pos.account_dest_id return account @api.v8 def map_accounts(self, accounts): """ Receive a dictionary having accounts in values and try to replace those accounts accordingly to the fiscal position. """ ref_dict = {} for line in self.account_ids: ref_dict[line.account_src_id] = line.account_dest_id for key, acc in accounts.items(): if acc in ref_dict: accounts[key] = ref_dict[acc] return accounts @api.onchange('country_id') def _onchange_country_id(self): if self.country_id: self.zip_from = self.zip_to = self.country_group_id = False self.state_ids = [(5,)] self.states_count = len(self.country_id.state_ids) @api.onchange('country_group_id') def _onchange_country_group_id(self): if self.country_group_id: self.zip_from = self.zip_to = self.country_id = False self.state_ids = [(5,)] @api.model def _get_fpos_by_region(self, country_id=False, state_id=False, zipcode=False, vat_required=False): if not country_id: return False base_domain = [('auto_apply', '=', True), ('vat_required', '=', vat_required)] if self.env.context.get('force_company'): base_domain.append(('company_id', '=', self.env.context.get('force_company'))) null_state_dom = state_domain = [('state_ids', '=', False)] null_zip_dom = zip_domain = [('zip_from', '=', 0), ('zip_to', '=', 0)] null_country_dom = [('country_id', '=', False), ('country_group_id', '=', False)] if zipcode and zipcode.isdigit(): zipcode = int(zipcode) zip_domain = [('zip_from', '<=', zipcode), ('zip_to', '>=', zipcode)] else: zipcode = 0 if state_id: state_domain = [('state_ids', '=', state_id)] domain_country = base_domain + [('country_id', '=', country_id)] domain_group = base_domain + [('country_group_id.country_ids', '=', country_id)] # Build domain to search records with exact matching criteria fpos = self.search(domain_country + state_domain + zip_domain, limit=1) # return records that fit the most the criteria, and fallback on less specific fiscal positions if any can be found if not fpos and state_id: fpos = self.search(domain_country + null_state_dom + zip_domain, limit=1) if not fpos and zipcode: fpos = self.search(domain_country + state_domain + null_zip_dom, limit=1) if not fpos and state_id and zipcode: fpos = self.search(domain_country + null_state_dom + null_zip_dom, limit=1) # fallback: country group with no state/zip range if not fpos: fpos = self.search(domain_group + null_state_dom + null_zip_dom, limit=1) if not fpos: # Fallback on catchall (no country, no group) fpos = self.search(base_domain + null_country_dom, limit=1) return fpos or False @api.model def get_fiscal_position(self, partner_id, delivery_id=None): if not partner_id: return False # This can be easily overriden to apply more complex fiscal rules PartnerObj = self.env['res.partner'] partner = PartnerObj.browse(partner_id) # if no delivery use invoicing if delivery_id: delivery = PartnerObj.browse(delivery_id) else: delivery = partner # partner manually set fiscal position always win if delivery.property_account_position_id or partner.property_account_position_id: return delivery.property_account_position_id.id or partner.property_account_position_id.id # First search only matching VAT positions vat_required = bool(partner.vat) fp = self._get_fpos_by_region(delivery.country_id.id, delivery.state_id.id, delivery.zip, vat_required) # Then if VAT required found no match, try positions that do not require it if not fp and vat_required: fp = self._get_fpos_by_region(delivery.country_id.id, delivery.state_id.id, delivery.zip, False) return fp.id if fp else False class AccountFiscalPositionTax(models.Model): _name = 'account.fiscal.position.tax' _description = 'Taxes Fiscal Position' _rec_name = 'position_id' position_id = fields.Many2one('account.fiscal.position', string='Fiscal Position', required=True, ondelete='cascade') tax_src_id = fields.Many2one('account.tax', string='Tax on Product', required=True) tax_dest_id = fields.Many2one('account.tax', string='Tax to Apply') _sql_constraints = [ ('tax_src_dest_uniq', 'unique (position_id,tax_src_id,tax_dest_id)', 'A tax fiscal position could be defined only once time on same taxes.') ] class AccountFiscalPositionAccount(models.Model): _name = 'account.fiscal.position.account' _description = 'Accounts Fiscal Position' _rec_name = 'position_id' position_id = fields.Many2one('account.fiscal.position', string='Fiscal Position', required=True, ondelete='cascade') account_src_id = fields.Many2one('account.account', string='Account on Product', domain=[('deprecated', '=', False)], required=True) account_dest_id = fields.Many2one('account.account', string='Account to Use Instead', domain=[('deprecated', '=', False)], required=True) _sql_constraints = [ ('account_src_dest_uniq', 'unique (position_id,account_src_id,account_dest_id)', 'An account fiscal position could be defined only once time on same accounts.') ] class ResPartner(models.Model): _name = 'res.partner' _inherit = 'res.partner' _description = 'Partner' @api.multi def _credit_debit_get(self): tables, where_clause, where_params = self.env['account.move.line']._query_get() where_params = [tuple(self.ids)] + where_params if where_clause: where_clause = 'AND ' + where_clause self._cr.execute("""SELECT account_move_line.partner_id, act.type, SUM(account_move_line.amount_residual) FROM account_move_line LEFT JOIN account_account a ON (account_move_line.account_id=a.id) LEFT JOIN account_account_type act ON (a.user_type_id=act.id) WHERE act.type IN ('receivable','payable') AND account_move_line.partner_id IN %s AND account_move_line.reconciled IS FALSE """ + where_clause + """ GROUP BY account_move_line.partner_id, act.type """, where_params) for pid, type, val in self._cr.fetchall(): partner = self.browse(pid) if type == 'receivable': partner.credit = val elif type == 'payable': partner.debit = -val @api.multi def _asset_difference_search(self, account_type, operator, operand): if operator not in ('<', '=', '>', '>=', '<='): return [] if type(operand) not in (float, int): return [] sign = 1 if account_type == 'payable': sign = -1 res = self._cr.execute(''' SELECT partner.id FROM res_partner partner LEFT JOIN account_move_line aml ON aml.partner_id = partner.id RIGHT JOIN account_account acc ON aml.account_id = acc.id WHERE acc.internal_type = %s AND NOT acc.deprecated GROUP BY partner.id HAVING %s * COALESCE(SUM(aml.amount_residual), 0) ''' + operator + ''' %s''', (account_type, sign, operand)) res = self._cr.fetchall() if not res: return [('id', '=', '0')] return [('id', 'in', map(itemgetter(0), res))] @api.model def _credit_search(self, operator, operand): return self._asset_difference_search('receivable', operator, operand) @api.model def _debit_search(self, operator, operand): return self._asset_difference_search('payable', operator, operand) @api.multi def _invoice_total(self): account_invoice_report = self.env['account.invoice.report'] if not self.ids: self.total_invoiced = 0.0 return True user_currency_id = self.env.user.company_id.currency_id.id all_partners_and_children = {} all_partner_ids = [] for partner in self: # price_total is in the company currency all_partners_and_children[partner] = self.search([('id', 'child_of', partner.id)]).ids all_partner_ids += all_partners_and_children[partner] # searching account.invoice.report via the orm is comparatively expensive # (generates queries "id in []" forcing to build the full table). # In simple cases where all invoices are in the same currency than the user's company # access directly these elements # generate where clause to include multicompany rules where_query = account_invoice_report._where_calc([ ('partner_id', 'in', all_partner_ids), ('state', 'not in', ['draft', 'cancel']), ('company_id', '=', self.env.user.company_id.id), ('type', 'in', ('out_invoice', 'out_refund')) ]) account_invoice_report._apply_ir_rules(where_query, 'read') from_clause, where_clause, where_clause_params = where_query.get_sql() # price_total is in the company currency query = """ SELECT SUM(price_total) as total, partner_id FROM account_invoice_report account_invoice_report WHERE %s GROUP BY partner_id """ % where_clause self.env.cr.execute(query, where_clause_params) price_totals = self.env.cr.dictfetchall() for partner, child_ids in all_partners_and_children.items(): partner.total_invoiced = sum(price['total'] for price in price_totals if price['partner_id'] in child_ids) @api.multi def _journal_item_count(self): for partner in self: partner.journal_item_count = self.env['account.move.line'].search_count([('partner_id', '=', partner.id)]) partner.contracts_count = self.env['account.analytic.account'].search_count([('partner_id', '=', partner.id)]) def get_followup_lines_domain(self, date, overdue_only=False, only_unblocked=False): domain = [('reconciled', '=', False), ('account_id.deprecated', '=', False), ('account_id.internal_type', '=', 'receivable'), '|', ('debit', '!=', 0), ('credit', '!=', 0), ('company_id', '=', self.env.user.company_id.id)] if only_unblocked: domain += [('blocked', '=', False)] if self.ids: if 'exclude_given_ids' in self._context: domain += [('partner_id', 'not in', self.ids)] else: domain += [('partner_id', 'in', self.ids)] #adding the overdue lines overdue_domain = ['|', '&', ('date_maturity', '!=', False), ('date_maturity', '<', date), '&', ('date_maturity', '=', False), ('date', '<', date)] if overdue_only: domain += overdue_domain return domain @api.multi def _compute_issued_total(self): """ Returns the issued total as will be displayed on partner view """ today = fields.Date.context_today(self) for partner in self: domain = partner.get_followup_lines_domain(today, overdue_only=True) issued_total = 0 for aml in self.env['account.move.line'].search(domain): issued_total += aml.amount_residual partner.issued_total = issued_total @api.one def _compute_has_unreconciled_entries(self): # Avoid useless work if has_unreconciled_entries is not relevant for this partner if not self.active or not self.is_company and self.parent_id: return self.env.cr.execute( """ SELECT 1 FROM( SELECT p.last_time_entries_checked AS last_time_entries_checked, MAX(l.write_date) AS max_date FROM account_move_line l RIGHT JOIN account_account a ON (a.id = l.account_id) RIGHT JOIN res_partner p ON (l.partner_id = p.id) WHERE p.id = %s AND EXISTS ( SELECT 1 FROM account_move_line l WHERE l.account_id = a.id AND l.partner_id = p.id AND l.amount_residual > 0 ) AND EXISTS ( SELECT 1 FROM account_move_line l WHERE l.account_id = a.id AND l.partner_id = p.id AND l.amount_residual < 0 ) GROUP BY p.last_time_entries_checked ) as s WHERE (last_time_entries_checked IS NULL OR max_date > last_time_entries_checked) """, (self.id,)) self.has_unreconciled_entries = self.env.cr.rowcount == 1 @api.multi def mark_as_reconciled(self): self.env['account.partial.reconcile'].check_access_rights('write') return self.sudo().write({'last_time_entries_checked': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)}) @api.one def _get_company_currency(self): if self.company_id: self.currency_id = self.sudo().company_id.currency_id else: self.currency_id = self.env.user.company_id.currency_id credit = fields.Monetary(compute='_credit_debit_get', search=_credit_search, string='Total Receivable', help="Total amount this customer owes you.") debit = fields.Monetary(compute='_credit_debit_get', search=_debit_search, string='Total Payable', help="Total amount you have to pay to this vendor.") debit_limit = fields.Monetary('Payable Limit') total_invoiced = fields.Monetary(compute='_invoice_total', string="Total Invoiced", groups='account.group_account_invoice') currency_id = fields.Many2one('res.currency', compute='_get_company_currency', readonly=True, string="Currency", help='Utility field to express amount currency') contracts_count = fields.Integer(compute='_journal_item_count', string="Contracts", type='integer') journal_item_count = fields.Integer(compute='_journal_item_count', string="Journal Items", type="integer") issued_total = fields.Monetary(compute='_compute_issued_total', string="Journal Items") property_account_payable_id = fields.Many2one('account.account', company_dependent=True, string="Account Payable", oldname="property_account_payable", domain="[('internal_type', '=', 'payable'), ('deprecated', '=', False)]", help="This account will be used instead of the default one as the payable account for the current partner", required=True) property_account_receivable_id = fields.Many2one('account.account', company_dependent=True, string="Account Receivable", oldname="property_account_receivable", domain="[('internal_type', '=', 'receivable'), ('deprecated', '=', False)]", help="This account will be used instead of the default one as the receivable account for the current partner", required=True) property_account_position_id = fields.Many2one('account.fiscal.position', company_dependent=True, string="Fiscal Position", help="The fiscal position will determine taxes and accounts used for the partner.", oldname="property_account_position") property_payment_term_id = fields.Many2one('account.payment.term', company_dependent=True, string ='Customer Payment Term', help="This payment term will be used instead of the default one for sale orders and customer invoices", oldname="property_payment_term") property_supplier_payment_term_id = fields.Many2one('account.payment.term', company_dependent=True, string ='Vendor Payment Term', help="This payment term will be used instead of the default one for purchase orders and vendor bills", oldname="property_supplier_payment_term") ref_company_ids = fields.One2many('res.company', 'partner_id', string='Companies that refers to partner', oldname="ref_companies") has_unreconciled_entries = fields.Boolean(compute='_compute_has_unreconciled_entries', help="The partner has at least one unreconciled debit and credit since last time the invoices & payments matching was performed.") last_time_entries_checked = fields.Datetime(oldname='last_reconciliation_date', string='Latest Invoices & Payments Matching Date', readonly=True, copy=False, help='Last time the invoices & payments matching was performed for this partner. ' 'It is set either if there\'s not at least an unreconciled debit and an unreconciled credit ' 'or if you click the "Done" button.') invoice_ids = fields.One2many('account.invoice', 'partner_id', string='Invoices', readonly=True, copy=False) contract_ids = fields.One2many('account.analytic.account', 'partner_id', string='Contracts', readonly=True) bank_account_count = fields.Integer(compute='_compute_bank_count', string="Bank") @api.multi def _compute_bank_count(self): bank_data = self.env['res.partner.bank'].read_group([('partner_id', 'in', self.ids)], ['partner_id'], ['partner_id']) mapped_data = dict([(bank['partner_id'][0], bank['partner_id_count']) for bank in bank_data]) for partner in self: partner.bank_account_count = mapped_data.get(partner.id, 0) def _find_accounting_partner(self, partner): ''' Find the partner for which the accounting entries will be created ''' return partner.commercial_partner_id @api.model def _commercial_fields(self): return super(ResPartner, self)._commercial_fields() + \ ['debit_limit', 'property_account_payable_id', 'property_account_receivable_id', 'property_account_position_id', 'property_payment_term_id', 'property_supplier_payment_term_id', 'last_time_entries_checked']
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 4182, 492, 1242, 7416, 199, 646, 900, 199, 199, 504, 5166, 492, 2986, 12, 1504, 12, 1709, 12, 485, 199, 504, 5166, 14, 2537, 492, 6186, 63, 6613, 63, 12488, 63, 4807, 199, 504, 5166, 14, 3924, 492, 8505, 421, 199, 533, 9973, 38, 15734, 5625, 8, 992, 14, 1685, 304, 272, 485, 354, 275, 283, 2048, 14, 18646, 14, 3124, 7, 272, 485, 1802, 275, 283, 38, 15734, 15483, 7, 272, 485, 1648, 275, 283, 4041, 7, 339, 3414, 275, 1504, 14, 2674, 342, 272, 536, 275, 1504, 14, 1610, 8, 875, 534, 38, 15734, 15483, 297, 1415, 29, 549, 9, 272, 4702, 275, 1504, 14, 4082, 8, 885, 29, 549, 12, 267, 1720, 628, 2175, 625, 19527, 314, 4702, 901, 12, 1265, 1443, 13714, 282, 18672, 3421, 1928, 13794, 652, 2685, 272, 7233, 63, 344, 275, 1504, 14, 4089, 18, 368, 360, 470, 14, 4627, 297, 1059, 534, 16063, 358, 272, 2933, 63, 1580, 275, 1504, 14, 4395, 18, 3479, 360, 2048, 14, 18646, 14, 3124, 14, 2048, 297, 283, 3124, 63, 344, 297, 1059, 534, 6009, 12340, 297, 1331, 29, 549, 9, 272, 9067, 63, 1580, 275, 1504, 14, 4395, 18, 3479, 360, 2048, 14, 18646, 14, 3124, 14, 5530, 297, 283, 3124, 63, 344, 297, 1059, 534, 26019, 12340, 297, 1331, 29, 549, 9, 272, 5317, 275, 1504, 14, 1872, 360, 18685, 297, 1720, 628, 13257, 279, 12953, 852, 626, 1172, 370, 506, 12487, 641, 314, 26175, 2685, 272, 2599, 63, 4998, 275, 1504, 14, 4082, 8, 875, 534, 20064, 9195, 17174, 297, 1720, 628, 16581, 5847, 642, 18672, 3421, 2685, 272, 373, 292, 63, 2427, 275, 1504, 14, 4082, 8, 875, 534, 54, 619, 1415, 297, 1720, 628, 16581, 1454, 340, 5854, 965, 282, 812, 619, 1329, 2685, 272, 9023, 63, 344, 275, 1504, 14, 4089, 18, 368, 360, 470, 14, 6063, 297, 1059, 534, 17393, 297, 267, 1720, 628, 16581, 1454, 340, 18719, 503, 315, 2392, 31713, 9023, 1336, 2685, 272, 9023, 63, 923, 63, 344, 275, 1504, 14, 4089, 18, 368, 360, 470, 14, 6063, 14, 923, 297, 1059, 534, 17393, 5611, 297, 267, 1720, 628, 16581, 1454, 340, 18719, 503, 4572, 679, 316, 9023, 1336, 314, 1572, 2685, 272, 1174, 63, 1580, 275, 1504, 14, 4089, 18, 3479, 360, 470, 14, 6063, 14, 929, 297, 1059, 534, 3456, 424, 279, 24230, 358, 272, 3482, 63, 504, 275, 1504, 14, 2674, 8, 875, 534, 8674, 13114, 11606, 297, 849, 29, 16, 9, 272, 3482, 63, 475, 275, 1504, 14, 2674, 8, 875, 534, 8674, 13114, 4005, 297, 849, 29, 16, 9, 272, 327, 4005, 506, 1202, 315, 27276, 316, 314, 283, 3456, 424, 279, 24230, 7, 901, 360, 3288, 7, 315, 2455, 5366, 9, 1380, 4895, 283, 17393, 7, 965, 378, 6363, 14, 272, 6363, 63, 835, 275, 1504, 14, 2674, 8, 3357, 17574, 3357, 63, 4981, 63, 835, 358, 339, 768, 1246, 14, 368, 272, 347, 485, 3357, 63, 4981, 63, 835, 8, 277, 304, 267, 291, 14, 4981, 63, 835, 275, 822, 8, 277, 14, 6063, 63, 344, 14, 929, 63, 1580, 9, 339, 768, 1246, 14, 368, 272, 768, 1246, 14, 1297, 345, 3617, 360, 3065, 63, 504, 297, 283, 3065, 63, 475, 358, 272, 347, 485, 1074, 63, 3065, 8, 277, 304, 267, 340, 291, 14, 3065, 63, 504, 690, 291, 14, 3065, 63, 475, 26, 288, 746, 8505, 6723, 3364, 298, 8674, 13114, 401, 8749, 7908, 652, 7684, 12459, 267, 372, 715, 339, 768, 1246, 14, 86, 23, 272, 347, 2341, 63, 5530, 8, 277, 12, 2467, 12, 1747, 12, 289, 3124, 63, 344, 12, 21139, 12, 1067, 29, 403, 304, 267, 340, 440, 21139, 26, 288, 372, 942, 267, 340, 440, 289, 3124, 63, 344, 26, 288, 372, 2341, 8, 2734, 671, 26, 671, 14, 344, 12, 21139, 9, 267, 754, 275, 663, 342, 267, 367, 307, 315, 21139, 26, 288, 4112, 275, 756, 288, 367, 9067, 315, 289, 3124, 63, 344, 14, 5530, 63, 1580, 26, 355, 340, 9067, 14, 5530, 63, 2164, 63, 344, 14, 344, 508, 307, 14, 344, 26, 490, 340, 9067, 14, 5530, 63, 2614, 63, 344, 26, 717, 754, 14, 525, 8, 5530, 14, 5530, 63, 2614, 63, 344, 14, 344, 9, 490, 4112, 275, 715, 288, 340, 440, 4112, 26, 355, 754, 14, 525, 8, 84, 14, 344, 9, 267, 372, 769, 8, 1099, 9, 339, 768, 1246, 14, 86, 24, 258, 327, 8151, 272, 347, 2341, 63, 5530, 8, 277, 12, 21139, 304, 267, 754, 275, 291, 14, 1813, 459, 2048, 14, 5530, 2278, 4570, 342, 267, 367, 9067, 315, 21139, 26, 288, 9067, 63, 835, 275, 378, 288, 367, 307, 315, 291, 14, 5530, 63, 1580, 26, 355, 340, 307, 14, 5530, 63, 2164, 63, 344, 508, 9067, 26, 490, 9067, 63, 835, 847, 413, 490, 340, 307, 14, 5530, 63, 2614, 63, 344, 26, 717, 754, 8901, 307, 14, 5530, 63, 2614, 63, 344, 288, 340, 440, 9067, 63, 835, 26, 355, 754, 8901, 9067, 267, 372, 754, 339, 768, 1246, 14, 86, 23, 272, 347, 2341, 63, 2048, 8, 277, 12, 2467, 12, 1747, 12, 289, 3124, 63, 344, 12, 2933, 63, 344, 12, 1067, 29, 403, 304, 267, 340, 440, 289, 3124, 63, 344, 26, 288, 372, 2933, 63, 344, 267, 367, 2086, 315, 289, 3124, 63, 344, 14, 2048, 63, 1580, 26, 288, 340, 2086, 14, 2048, 63, 2164, 63, 344, 14, 344, 508, 2933, 63, 344, 26, 355, 2933, 63, 344, 275, 2086, 14, 2048, 63, 2614, 63, 344, 14, 344, 355, 2059, 267, 372, 2933, 63, 344, 339, 768, 1246, 14, 86, 24, 272, 347, 2341, 63, 2048, 8, 277, 12, 2933, 304, 267, 367, 2086, 315, 291, 14, 2048, 63, 1580, 26, 288, 340, 2086, 14, 2048, 63, 2164, 63, 344, 508, 2933, 26, 355, 372, 2086, 14, 2048, 63, 2614, 63, 344, 267, 372, 2933, 339, 768, 1246, 14, 86, 24, 272, 347, 2341, 63, 8370, 8, 277, 12, 12639, 304, 267, 408, 799, 5251, 282, 2600, 9445, 12639, 315, 1338, 436, 862, 370, 3350, 5204, 12639, 24137, 370, 314, 18672, 3421, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 4182, 492, 1242, 7416, 199, 646, 900, 199, 199, 504, 5166, 492, 2986, 12, 1504, 12, 1709, 12, 485, 199, 504, 5166, 14, 2537, 492, 6186, 63, 6613, 63, 12488, 63, 4807, 199, 504, 5166, 14, 3924, 492, 8505, 421, 199, 533, 9973, 38, 15734, 5625, 8, 992, 14, 1685, 304, 272, 485, 354, 275, 283, 2048, 14, 18646, 14, 3124, 7, 272, 485, 1802, 275, 283, 38, 15734, 15483, 7, 272, 485, 1648, 275, 283, 4041, 7, 339, 3414, 275, 1504, 14, 2674, 342, 272, 536, 275, 1504, 14, 1610, 8, 875, 534, 38, 15734, 15483, 297, 1415, 29, 549, 9, 272, 4702, 275, 1504, 14, 4082, 8, 885, 29, 549, 12, 267, 1720, 628, 2175, 625, 19527, 314, 4702, 901, 12, 1265, 1443, 13714, 282, 18672, 3421, 1928, 13794, 652, 2685, 272, 7233, 63, 344, 275, 1504, 14, 4089, 18, 368, 360, 470, 14, 4627, 297, 1059, 534, 16063, 358, 272, 2933, 63, 1580, 275, 1504, 14, 4395, 18, 3479, 360, 2048, 14, 18646, 14, 3124, 14, 2048, 297, 283, 3124, 63, 344, 297, 1059, 534, 6009, 12340, 297, 1331, 29, 549, 9, 272, 9067, 63, 1580, 275, 1504, 14, 4395, 18, 3479, 360, 2048, 14, 18646, 14, 3124, 14, 5530, 297, 283, 3124, 63, 344, 297, 1059, 534, 26019, 12340, 297, 1331, 29, 549, 9, 272, 5317, 275, 1504, 14, 1872, 360, 18685, 297, 1720, 628, 13257, 279, 12953, 852, 626, 1172, 370, 506, 12487, 641, 314, 26175, 2685, 272, 2599, 63, 4998, 275, 1504, 14, 4082, 8, 875, 534, 20064, 9195, 17174, 297, 1720, 628, 16581, 5847, 642, 18672, 3421, 2685, 272, 373, 292, 63, 2427, 275, 1504, 14, 4082, 8, 875, 534, 54, 619, 1415, 297, 1720, 628, 16581, 1454, 340, 5854, 965, 282, 812, 619, 1329, 2685, 272, 9023, 63, 344, 275, 1504, 14, 4089, 18, 368, 360, 470, 14, 6063, 297, 1059, 534, 17393, 297, 267, 1720, 628, 16581, 1454, 340, 18719, 503, 315, 2392, 31713, 9023, 1336, 2685, 272, 9023, 63, 923, 63, 344, 275, 1504, 14, 4089, 18, 368, 360, 470, 14, 6063, 14, 923, 297, 1059, 534, 17393, 5611, 297, 267, 1720, 628, 16581, 1454, 340, 18719, 503, 4572, 679, 316, 9023, 1336, 314, 1572, 2685, 272, 1174, 63, 1580, 275, 1504, 14, 4089, 18, 3479, 360, 470, 14, 6063, 14, 929, 297, 1059, 534, 3456, 424, 279, 24230, 358, 272, 3482, 63, 504, 275, 1504, 14, 2674, 8, 875, 534, 8674, 13114, 11606, 297, 849, 29, 16, 9, 272, 3482, 63, 475, 275, 1504, 14, 2674, 8, 875, 534, 8674, 13114, 4005, 297, 849, 29, 16, 9, 272, 327, 4005, 506, 1202, 315, 27276, 316, 314, 283, 3456, 424, 279, 24230, 7, 901, 360, 3288, 7, 315, 2455, 5366, 9, 1380, 4895, 283, 17393, 7, 965, 378, 6363, 14, 272, 6363, 63, 835, 275, 1504, 14, 2674, 8, 3357, 17574, 3357, 63, 4981, 63, 835, 358, 339, 768, 1246, 14, 368, 272, 347, 485, 3357, 63, 4981, 63, 835, 8, 277, 304, 267, 291, 14, 4981, 63, 835, 275, 822, 8, 277, 14, 6063, 63, 344, 14, 929, 63, 1580, 9, 339, 768, 1246, 14, 368, 272, 768, 1246, 14, 1297, 345, 3617, 360, 3065, 63, 504, 297, 283, 3065, 63, 475, 358, 272, 347, 485, 1074, 63, 3065, 8, 277, 304, 267, 340, 291, 14, 3065, 63, 504, 690, 291, 14, 3065, 63, 475, 26, 288, 746, 8505, 6723, 3364, 298, 8674, 13114, 401, 8749, 7908, 652, 7684, 12459, 267, 372, 715, 339, 768, 1246, 14, 86, 23, 272, 347, 2341, 63, 5530, 8, 277, 12, 2467, 12, 1747, 12, 289, 3124, 63, 344, 12, 21139, 12, 1067, 29, 403, 304, 267, 340, 440, 21139, 26, 288, 372, 942, 267, 340, 440, 289, 3124, 63, 344, 26, 288, 372, 2341, 8, 2734, 671, 26, 671, 14, 344, 12, 21139, 9, 267, 754, 275, 663, 342, 267, 367, 307, 315, 21139, 26, 288, 4112, 275, 756, 288, 367, 9067, 315, 289, 3124, 63, 344, 14, 5530, 63, 1580, 26, 355, 340, 9067, 14, 5530, 63, 2164, 63, 344, 14, 344, 508, 307, 14, 344, 26, 490, 340, 9067, 14, 5530, 63, 2614, 63, 344, 26, 717, 754, 14, 525, 8, 5530, 14, 5530, 63, 2614, 63, 344, 14, 344, 9, 490, 4112, 275, 715, 288, 340, 440, 4112, 26, 355, 754, 14, 525, 8, 84, 14, 344, 9, 267, 372, 769, 8, 1099, 9, 339, 768, 1246, 14, 86, 24, 258, 327, 8151, 272, 347, 2341, 63, 5530, 8, 277, 12, 21139, 304, 267, 754, 275, 291, 14, 1813, 459, 2048, 14, 5530, 2278, 4570, 342, 267, 367, 9067, 315, 21139, 26, 288, 9067, 63, 835, 275, 378, 288, 367, 307, 315, 291, 14, 5530, 63, 1580, 26, 355, 340, 307, 14, 5530, 63, 2164, 63, 344, 508, 9067, 26, 490, 9067, 63, 835, 847, 413, 490, 340, 307, 14, 5530, 63, 2614, 63, 344, 26, 717, 754, 8901, 307, 14, 5530, 63, 2614, 63, 344, 288, 340, 440, 9067, 63, 835, 26, 355, 754, 8901, 9067, 267, 372, 754, 339, 768, 1246, 14, 86, 23, 272, 347, 2341, 63, 2048, 8, 277, 12, 2467, 12, 1747, 12, 289, 3124, 63, 344, 12, 2933, 63, 344, 12, 1067, 29, 403, 304, 267, 340, 440, 289, 3124, 63, 344, 26, 288, 372, 2933, 63, 344, 267, 367, 2086, 315, 289, 3124, 63, 344, 14, 2048, 63, 1580, 26, 288, 340, 2086, 14, 2048, 63, 2164, 63, 344, 14, 344, 508, 2933, 63, 344, 26, 355, 2933, 63, 344, 275, 2086, 14, 2048, 63, 2614, 63, 344, 14, 344, 355, 2059, 267, 372, 2933, 63, 344, 339, 768, 1246, 14, 86, 24, 272, 347, 2341, 63, 2048, 8, 277, 12, 2933, 304, 267, 367, 2086, 315, 291, 14, 2048, 63, 1580, 26, 288, 340, 2086, 14, 2048, 63, 2164, 63, 344, 508, 2933, 26, 355, 372, 2086, 14, 2048, 63, 2614, 63, 344, 267, 372, 2933, 339, 768, 1246, 14, 86, 24, 272, 347, 2341, 63, 8370, 8, 277, 12, 12639, 304, 267, 408, 799, 5251, 282, 2600, 9445, 12639, 315, 1338, 436, 862, 370, 3350, 5204, 12639, 24137, 370, 314, 18672, 3421, 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, 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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 ]
gvlproject/libcloudbridge
cloudbridge/providers/openstack/subservices.py
2
1583
import logging from cloudbridge.base.subservices import BaseBucketObjectSubService from cloudbridge.base.subservices import BaseDnsRecordSubService from cloudbridge.base.subservices import BaseFloatingIPSubService from cloudbridge.base.subservices import BaseGatewaySubService from cloudbridge.base.subservices import BaseSubnetSubService from cloudbridge.base.subservices import BaseVMFirewallRuleSubService log = logging.getLogger(__name__) class OpenStackBucketObjectSubService(BaseBucketObjectSubService): def __init__(self, provider, bucket): super(OpenStackBucketObjectSubService, self).__init__(provider, bucket) class OpenStackGatewaySubService(BaseGatewaySubService): def __init__(self, provider, network): super(OpenStackGatewaySubService, self).__init__(provider, network) class OpenStackFloatingIPSubService(BaseFloatingIPSubService): def __init__(self, provider, gateway): super(OpenStackFloatingIPSubService, self).__init__(provider, gateway) class OpenStackVMFirewallRuleSubService(BaseVMFirewallRuleSubService): def __init__(self, provider, firewall): super(OpenStackVMFirewallRuleSubService, self).__init__( provider, firewall) class OpenStackSubnetSubService(BaseSubnetSubService): def __init__(self, provider, network): super(OpenStackSubnetSubService, self).__init__(provider, network) class OpenStackDnsRecordSubService(BaseDnsRecordSubService): def __init__(self, provider, dns_zone): super(OpenStackDnsRecordSubService, self).__init__(provider, dns_zone)
mit
[ 646, 2050, 199, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 12311, 1692, 2610, 3167, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 27664, 5433, 2610, 3167, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 17895, 1772, 2610, 3167, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 12455, 2610, 3167, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 15238, 2610, 3167, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 6849, 24260, 5065, 2610, 3167, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 14260, 12311, 1692, 2610, 3167, 8, 1563, 12311, 1692, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 5315, 304, 267, 1613, 8, 26208, 12311, 1692, 2610, 3167, 12, 291, 2843, 826, 721, 3780, 12, 5315, 9, 421, 199, 533, 14260, 12455, 2610, 3167, 8, 1563, 12455, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 2784, 304, 267, 1613, 8, 26208, 12455, 2610, 3167, 12, 291, 2843, 826, 721, 3780, 12, 2784, 9, 421, 199, 533, 14260, 17895, 1772, 2610, 3167, 8, 1563, 17895, 1772, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 10391, 304, 267, 1613, 8, 26208, 17895, 1772, 2610, 3167, 12, 291, 2843, 826, 721, 3780, 12, 10391, 9, 421, 199, 533, 14260, 6849, 24260, 5065, 2610, 3167, 8, 1563, 6849, 24260, 5065, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 12042, 304, 267, 1613, 8, 26208, 6849, 24260, 5065, 2610, 3167, 12, 291, 2843, 826, 721, 288, 5022, 12, 12042, 9, 421, 199, 533, 14260, 15238, 2610, 3167, 8, 1563, 15238, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 2784, 304, 267, 1613, 8, 26208, 15238, 2610, 3167, 12, 291, 2843, 826, 721, 3780, 12, 2784, 9, 421, 199, 533, 14260, 27664, 5433, 2610, 3167, 8, 1563, 27664, 5433, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 6715, 63, 2619, 304, 267, 1613, 8, 26208, 27664, 5433, 2610, 3167, 12, 291, 2843, 826, 721, 3780, 12, 6715, 63, 2619, 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 ]
[ 2050, 199, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 12311, 1692, 2610, 3167, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 27664, 5433, 2610, 3167, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 17895, 1772, 2610, 3167, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 12455, 2610, 3167, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 15238, 2610, 3167, 199, 504, 2463, 8301, 5562, 14, 1095, 14, 954, 5950, 492, 3523, 6849, 24260, 5065, 2610, 3167, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 14260, 12311, 1692, 2610, 3167, 8, 1563, 12311, 1692, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 5315, 304, 267, 1613, 8, 26208, 12311, 1692, 2610, 3167, 12, 291, 2843, 826, 721, 3780, 12, 5315, 9, 421, 199, 533, 14260, 12455, 2610, 3167, 8, 1563, 12455, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 2784, 304, 267, 1613, 8, 26208, 12455, 2610, 3167, 12, 291, 2843, 826, 721, 3780, 12, 2784, 9, 421, 199, 533, 14260, 17895, 1772, 2610, 3167, 8, 1563, 17895, 1772, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 10391, 304, 267, 1613, 8, 26208, 17895, 1772, 2610, 3167, 12, 291, 2843, 826, 721, 3780, 12, 10391, 9, 421, 199, 533, 14260, 6849, 24260, 5065, 2610, 3167, 8, 1563, 6849, 24260, 5065, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 12042, 304, 267, 1613, 8, 26208, 6849, 24260, 5065, 2610, 3167, 12, 291, 2843, 826, 721, 288, 5022, 12, 12042, 9, 421, 199, 533, 14260, 15238, 2610, 3167, 8, 1563, 15238, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 2784, 304, 267, 1613, 8, 26208, 15238, 2610, 3167, 12, 291, 2843, 826, 721, 3780, 12, 2784, 9, 421, 199, 533, 14260, 27664, 5433, 2610, 3167, 8, 1563, 27664, 5433, 2610, 3167, 304, 339, 347, 636, 826, 721, 277, 12, 5022, 12, 6715, 63, 2619, 304, 267, 1613, 8, 26208, 27664, 5433, 2610, 3167, 12, 291, 2843, 826, 721, 3780, 12, 6715, 63, 2619, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jcoady9/python-for-android
python3-alpha/extra_modules/gdata/spreadsheets/client.py
47
29482
#!/usr/bin/env python # # Copyright (C) 2009 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Contains a client to communicate with the Google Spreadsheets servers. For documentation on the Spreadsheets API, see: http://code.google.com/apis/spreadsheets/ """ __author__ = 'j.s@google.com (Jeff Scudder)' import gdata.client import gdata.gauth import gdata.spreadsheets.data import atom.data import atom.http_core SPREADSHEETS_URL = ('https://spreadsheets.google.com/feeds/spreadsheets' '/private/full') WORKSHEETS_URL = ('https://spreadsheets.google.com/feeds/worksheets/' '%s/private/full') WORKSHEET_URL = ('https://spreadsheets.google.com/feeds/worksheets/' '%s/private/full/%s') TABLES_URL = 'https://spreadsheets.google.com/feeds/%s/tables' RECORDS_URL = 'https://spreadsheets.google.com/feeds/%s/records/%s' RECORD_URL = 'https://spreadsheets.google.com/feeds/%s/records/%s/%s' CELLS_URL = 'https://spreadsheets.google.com/feeds/cells/%s/%s/private/full' CELL_URL = ('https://spreadsheets.google.com/feeds/cells/%s/%s/private/full/' 'R%sC%s') LISTS_URL = 'https://spreadsheets.google.com/feeds/list/%s/%s/private/full' class SpreadsheetsClient(gdata.client.GDClient): api_version = '3' auth_service = 'wise' auth_scopes = gdata.gauth.AUTH_SCOPES['wise'] ssl = True def get_spreadsheets(self, auth_token=None, desired_class=gdata.spreadsheets.data.SpreadsheetsFeed, **kwargs): """Obtains a feed with the spreadsheets belonging to the current user. Args: auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. desired_class: class descended from atom.core.XmlElement to which a successful response should be converted. If there is no converter function specified (converter=None) then the desired_class will be used in calling the atom.core.parse function. If neither the desired_class nor the converter is specified, an HTTP reponse object will be returned. Defaults to gdata.spreadsheets.data.SpreadsheetsFeed. """ return self.get_feed(SPREADSHEETS_URL, auth_token=auth_token, desired_class=desired_class, **kwargs) GetSpreadsheets = get_spreadsheets def get_worksheets(self, spreadsheet_key, auth_token=None, desired_class=gdata.spreadsheets.data.WorksheetsFeed, **kwargs): """Finds the worksheets within a given spreadsheet. Args: spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. desired_class: class descended from atom.core.XmlElement to which a successful response should be converted. If there is no converter function specified (converter=None) then the desired_class will be used in calling the atom.core.parse function. If neither the desired_class nor the converter is specified, an HTTP reponse object will be returned. Defaults to gdata.spreadsheets.data.WorksheetsFeed. """ return self.get_feed(WORKSHEETS_URL % spreadsheet_key, auth_token=auth_token, desired_class=desired_class, **kwargs) GetWorksheets = get_worksheets def add_worksheet(self, spreadsheet_key, title, rows, cols, auth_token=None, **kwargs): """Creates a new worksheet entry in the spreadsheet. Args: spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. title: str, The title to be used in for the worksheet. rows: str or int, The number of rows this worksheet should start with. cols: str or int, The number of columns this worksheet should start with. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. """ new_worksheet = gdata.spreadsheets.data.WorksheetEntry( title=atom.data.Title(text=title), row_count=gdata.spreadsheets.data.RowCount(text=str(rows)), col_count=gdata.spreadsheets.data.ColCount(text=str(cols))) return self.post(new_worksheet, WORKSHEETS_URL % spreadsheet_key, auth_token=auth_token, **kwargs) AddWorksheet = add_worksheet def get_worksheet(self, spreadsheet_key, worksheet_id, desired_class=gdata.spreadsheets.data.WorksheetEntry, auth_token=None, **kwargs): """Retrieves a single worksheet. Args: spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. worksheet_id: str, The unique ID for the worksheet withing the desired spreadsheet. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. desired_class: class descended from atom.core.XmlElement to which a successful response should be converted. If there is no converter function specified (converter=None) then the desired_class will be used in calling the atom.core.parse function. If neither the desired_class nor the converter is specified, an HTTP reponse object will be returned. Defaults to gdata.spreadsheets.data.WorksheetEntry. """ return self.get_entry(WORKSHEET_URL % (spreadsheet_key, worksheet_id,), auth_token=auth_token, desired_class=desired_class, **kwargs) GetWorksheet = get_worksheet def add_table(self, spreadsheet_key, title, summary, worksheet_name, header_row, num_rows, start_row, insertion_mode, column_headers, auth_token=None, **kwargs): """Creates a new table within the worksheet. Args: spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. title: str, The title for the new table within a worksheet. summary: str, A description of the table. worksheet_name: str The name of the worksheet in which this table should live. header_row: int or str, The number of the row in the worksheet which will contain the column names for the data in this table. num_rows: int or str, The number of adjacent rows in this table. start_row: int or str, The number of the row at which the data begins. insertion_mode: str column_headers: dict of strings, maps the column letters (A, B, C) to the desired name which will be viewable in the worksheet. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. """ data = gdata.spreadsheets.data.Data( insertion_mode=insertion_mode, num_rows=str(num_rows), start_row=str(start_row)) for index, name in column_headers.items(): data.column.append(gdata.spreadsheets.data.Column( index=index, name=name)) new_table = gdata.spreadsheets.data.Table( title=atom.data.Title(text=title), summary=atom.data.Summary(summary), worksheet=gdata.spreadsheets.data.Worksheet(name=worksheet_name), header=gdata.spreadsheets.data.Header(row=str(header_row)), data=data) return self.post(new_table, TABLES_URL % spreadsheet_key, auth_token=auth_token, **kwargs) AddTable = add_table def get_tables(self, spreadsheet_key, desired_class=gdata.spreadsheets.data.TablesFeed, auth_token=None, **kwargs): """Retrieves a feed listing the tables in this spreadsheet. Args: spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. desired_class: class descended from atom.core.XmlElement to which a successful response should be converted. If there is no converter function specified (converter=None) then the desired_class will be used in calling the atom.core.parse function. If neither the desired_class nor the converter is specified, an HTTP reponse object will be returned. Defaults to gdata.spreadsheets.data.TablesFeed. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. """ return self.get_feed(TABLES_URL % spreadsheet_key, desired_class=desired_class, auth_token=auth_token, **kwargs) GetTables = get_tables def add_record(self, spreadsheet_key, table_id, fields, title=None, auth_token=None, **kwargs): """Adds a new row to the table. Args: spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. table_id: str, The ID of the table within the worksheet which should receive this new record. The table ID can be found using the get_table_id method of a gdata.spreadsheets.data.Table. fields: dict of strings mapping column names to values. title: str, optional The title for this row. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. """ new_record = gdata.spreadsheets.data.Record() if title is not None: new_record.title = atom.data.Title(text=title) for name, value in fields.items(): new_record.field.append(gdata.spreadsheets.data.Field( name=name, text=value)) return self.post(new_record, RECORDS_URL % (spreadsheet_key, table_id), auth_token=auth_token, **kwargs) AddRecord = add_record def get_records(self, spreadsheet_key, table_id, desired_class=gdata.spreadsheets.data.RecordsFeed, auth_token=None, **kwargs): """Retrieves the records in a table. Args: spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. table_id: str, The ID of the table within the worksheet whose records we would like to fetch. The table ID can be found using the get_table_id method of a gdata.spreadsheets.data.Table. desired_class: class descended from atom.core.XmlElement to which a successful response should be converted. If there is no converter function specified (converter=None) then the desired_class will be used in calling the atom.core.parse function. If neither the desired_class nor the converter is specified, an HTTP reponse object will be returned. Defaults to gdata.spreadsheets.data.RecordsFeed. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. """ return self.get_feed(RECORDS_URL % (spreadsheet_key, table_id), desired_class=desired_class, auth_token=auth_token, **kwargs) GetRecords = get_records def get_record(self, spreadsheet_key, table_id, record_id, desired_class=gdata.spreadsheets.data.Record, auth_token=None, **kwargs): """Retrieves a single record from the table. Args: spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. table_id: str, The ID of the table within the worksheet whose records we would like to fetch. The table ID can be found using the get_table_id method of a gdata.spreadsheets.data.Table. record_id: str, The ID of the record within this table which we want to fetch. You can find the record ID using get_record_id() on an instance of the gdata.spreadsheets.data.Record class. desired_class: class descended from atom.core.XmlElement to which a successful response should be converted. If there is no converter function specified (converter=None) then the desired_class will be used in calling the atom.core.parse function. If neither the desired_class nor the converter is specified, an HTTP reponse object will be returned. Defaults to gdata.spreadsheets.data.RecordsFeed. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. """ return self.get_entry(RECORD_URL % (spreadsheet_key, table_id, record_id), desired_class=desired_class, auth_token=auth_token, **kwargs) GetRecord = get_record def get_cells(self, spreadsheet_key, worksheet_id, desired_class=gdata.spreadsheets.data.CellsFeed, auth_token=None, **kwargs): """Retrieves the cells which have values in this spreadsheet. Blank cells are not included. Args: spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. worksheet_id: str, The unique ID of the worksheet in this spreadsheet whose cells we want. This can be obtained using WorksheetEntry's get_worksheet_id method. desired_class: class descended from atom.core.XmlElement to which a successful response should be converted. If there is no converter function specified (converter=None) then the desired_class will be used in calling the atom.core.parse function. If neither the desired_class nor the converter is specified, an HTTP reponse object will be returned. Defaults to gdata.spreadsheets.data.CellsFeed. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. """ return self.get_feed(CELLS_URL % (spreadsheet_key, worksheet_id), auth_token=auth_token, desired_class=desired_class, **kwargs) GetCells = get_cells def get_cell(self, spreadsheet_key, worksheet_id, row_num, col_num, desired_class=gdata.spreadsheets.data.CellEntry, auth_token=None, **kwargs): """Retrieves a single cell from the worksheet. Indexes are 1 based so the first cell in the worksheet is 1, 1. Args: spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. worksheet_id: str, The unique ID of the worksheet in this spreadsheet whose cells we want. This can be obtained using WorksheetEntry's get_worksheet_id method. row_num: int, The row of the cell that we want. Numbering starts with 1. col_num: int, The column of the cell we want. Numbering starts with 1. desired_class: class descended from atom.core.XmlElement to which a successful response should be converted. If there is no converter function specified (converter=None) then the desired_class will be used in calling the atom.core.parse function. If neither the desired_class nor the converter is specified, an HTTP reponse object will be returned. Defaults to gdata.spreadsheets.data.CellEntry. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. """ return self.get_entry( CELL_URL % (spreadsheet_key, worksheet_id, row_num, col_num), auth_token=auth_token, desired_class=desired_class, **kwargs) GetCell = get_cell def get_list_feed(self, spreadsheet_key, worksheet_id, desired_class=gdata.spreadsheets.data.ListsFeed, auth_token=None, **kwargs): """Retrieves the value rows from the worksheet's list feed. The list feed is a view of the spreadsheet in which the first row is used for column names and subsequent rows up to the first blank line are records. Args: spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. worksheet_id: str, The unique ID of the worksheet in this spreadsheet whose cells we want. This can be obtained using WorksheetEntry's get_worksheet_id method. desired_class: class descended from atom.core.XmlElement to which a successful response should be converted. If there is no converter function specified (converter=None) then the desired_class will be used in calling the atom.core.parse function. If neither the desired_class nor the converter is specified, an HTTP reponse object will be returned. Defaults to gdata.spreadsheets.data.ListsFeed. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. """ return self.get_feed(LISTS_URL % (spreadsheet_key, worksheet_id), auth_token=auth_token, desired_class=desired_class, **kwargs) GetListFeed = get_list_feed def add_list_entry(self, list_entry, spreadsheet_key, worksheet_id, auth_token=None, **kwargs): """Adds a new row to the worksheet's list feed. Args: list_entry: gdata.spreadsheets.data.ListsEntry An entry which contains the values which should be set for the columns in this record. spreadsheet_key: str, The unique ID of this containing spreadsheet. This can be the ID from the URL or as provided in a Spreadsheet entry. worksheet_id: str, The unique ID of the worksheet in this spreadsheet whose cells we want. This can be obtained using WorksheetEntry's get_worksheet_id method. auth_token: An object which sets the Authorization HTTP header in its modify_request method. Recommended classes include gdata.gauth.ClientLoginToken and gdata.gauth.AuthSubToken among others. Represents the current user. Defaults to None and if None, this method will look for a value in the auth_token member of SpreadsheetsClient. """ return self.post(list_entry, LISTS_URL % (spreadsheet_key, worksheet_id), auth_token=auth_token, **kwargs) AddListEntry = add_list_entry class SpreadsheetQuery(gdata.client.Query): def __init__(self, title=None, title_exact=None, **kwargs): """Adds Spreadsheets feed query parameters to a request. Args: title: str Specifies the search terms for the title of a document. This parameter used without title-exact will only submit partial queries, not exact queries. title_exact: str Specifies whether the title query should be taken as an exact string. Meaningless without title. Possible values are 'true' and 'false'. """ gdata.client.Query.__init__(self, **kwargs) self.title = title self.title_exact = title_exact def modify_request(self, http_request): gdata.client._add_query_param('title', self.title, http_request) gdata.client._add_query_param('title-exact', self.title_exact, http_request) gdata.client.Query.modify_request(self, http_request) ModifyRequest = modify_request class WorksheetQuery(SpreadsheetQuery): pass class ListQuery(gdata.client.Query): def __init__(self, order_by=None, reverse=None, sq=None, **kwargs): """Adds List-feed specific query parameters to a request. Args: order_by: str Specifies what column to use in ordering the entries in the feed. By position (the default): 'position' returns rows in the order in which they appear in the GUI. Row 1, then row 2, then row 3, and so on. By column: 'column:columnName' sorts rows in ascending order based on the values in the column with the given columnName, where columnName is the value in the header row for that column. reverse: str Specifies whether to sort in descending or ascending order. Reverses default sort order: 'true' results in a descending sort; 'false' (the default) results in an ascending sort. sq: str Structured query on the full text in the worksheet. [columnName][binaryOperator][value] Supported binaryOperators are: - (), for overriding order of operations - = or ==, for strict equality - <> or !=, for strict inequality - and or &&, for boolean and - or or ||, for boolean or """ gdata.client.Query.__init__(self, **kwargs) self.order_by = order_by self.reverse = reverse self.sq = sq def modify_request(self, http_request): gdata.client._add_query_param('orderby', self.order_by, http_request) gdata.client._add_query_param('reverse', self.reverse, http_request) gdata.client._add_query_param('sq', self.sq, http_request) gdata.client.Query.modify_request(self, http_request) ModifyRequest = modify_request class TableQuery(ListQuery): pass class CellQuery(gdata.client.Query): def __init__(self, min_row=None, max_row=None, min_col=None, max_col=None, range=None, return_empty=None, **kwargs): """Adds Cells-feed specific query parameters to a request. Args: min_row: str or int Positional number of minimum row returned in query. max_row: str or int Positional number of maximum row returned in query. min_col: str or int Positional number of minimum column returned in query. max_col: str or int Positional number of maximum column returned in query. range: str A single cell or a range of cells. Use standard spreadsheet cell-range notations, using a colon to separate start and end of range. Examples: - 'A1' and 'R1C1' both specify only cell A1. - 'D1:F3' and 'R1C4:R3C6' both specify the rectangle of cells with corners at D1 and F3. return_empty: str If 'true' then empty cells will be returned in the feed. If omitted, the default is 'false'. """ gdata.client.Query.__init__(self, **kwargs) self.min_row = min_row self.max_row = max_row self.min_col = min_col self.max_col = max_col self.range = range self.return_empty = return_empty def modify_request(self, http_request): gdata.client._add_query_param('min-row', self.min_row, http_request) gdata.client._add_query_param('max-row', self.max_row, http_request) gdata.client._add_query_param('min-col', self.min_col, http_request) gdata.client._add_query_param('max-col', self.max_col, http_request) gdata.client._add_query_param('range', self.range, http_request) gdata.client._add_query_param('return-empty', self.return_empty, http_request) gdata.client.Query.modify_request(self, http_request) ModifyRequest = modify_request
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 421, 199, 624, 6906, 282, 1890, 370, 26808, 543, 314, 4475, 428, 12032, 83, 8037, 14, 199, 199, 1858, 3794, 641, 314, 428, 12032, 83, 3261, 12, 1937, 26, 199, 1014, 921, 600, 14, 3098, 14, 957, 15, 12662, 15, 19930, 83, 15, 199, 624, 421, 199, 363, 2502, 363, 275, 283, 74, 14, 83, 32, 3098, 14, 957, 334, 42, 3609, 13916, 1181, 424, 3171, 421, 199, 646, 11006, 14, 1258, 199, 646, 11006, 14, 71, 1178, 199, 646, 11006, 14, 19930, 83, 14, 576, 199, 646, 6222, 14, 576, 199, 646, 6222, 14, 1014, 63, 1018, 421, 199, 51, 4225, 1554, 20255, 30416, 63, 2632, 275, 661, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 19930, 83, 7, 490, 1994, 4239, 15, 2861, 358, 199, 8406, 20255, 30416, 63, 2632, 275, 661, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 800, 24376, 4805, 2116, 1543, 83, 15, 4239, 15, 2861, 358, 199, 8406, 20255, 775, 63, 2632, 275, 661, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 800, 24376, 4805, 326, 1543, 83, 15, 4239, 15, 2861, 3149, 83, 358, 199, 10129, 11344, 63, 2632, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 3149, 83, 15, 5987, 7, 199, 9481, 726, 3177, 63, 2632, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 3149, 83, 15, 6502, 3149, 83, 7, 199, 15060, 63, 2632, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 3149, 83, 15, 6502, 3149, 83, 3149, 83, 7, 199, 26474, 51, 63, 2632, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 9041, 3149, 83, 3149, 83, 15, 4239, 15, 2861, 7, 199, 26474, 63, 2632, 275, 661, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 9041, 3149, 83, 3149, 83, 15, 4239, 15, 2861, 4805, 288, 283, 50, 5, 83, 35, 5, 83, 358, 199, 4924, 51, 63, 2632, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 513, 3149, 83, 3149, 83, 15, 4239, 15, 2861, 7, 421, 199, 533, 428, 12032, 83, 3041, 8, 15275, 14, 1258, 14, 27046, 3041, 304, 523, 2986, 63, 1023, 275, 283, 19, 7, 523, 1790, 63, 1364, 275, 283, 2605, 7, 523, 1790, 63, 14129, 275, 11006, 14, 71, 1178, 14, 5580, 63, 15901, 48, 654, 459, 2605, 418, 523, 6149, 275, 715, 819, 347, 664, 63, 19930, 83, 8, 277, 12, 1790, 63, 1418, 29, 403, 12, 2432, 6387, 63, 533, 29, 15275, 14, 19930, 83, 14, 576, 14, 30693, 83, 7658, 12, 2432, 1011, 958, 304, 272, 408, 11394, 3953, 282, 4733, 543, 314, 27076, 83, 30226, 370, 314, 1453, 922, 14, 339, 3033, 26, 489, 1790, 63, 1418, 26, 1626, 909, 1314, 5951, 314, 21527, 3101, 1406, 315, 2399, 2116, 2811, 63, 1069, 1083, 14, 799, 11902, 3992, 2387, 2116, 11006, 14, 71, 1178, 14, 3041, 8880, 3264, 436, 11006, 14, 71, 1178, 14, 2817, 2610, 3264, 2116, 16885, 11789, 14, 21591, 314, 1453, 922, 14, 7827, 370, 488, 2116, 436, 340, 488, 12, 642, 1083, 911, 3648, 367, 282, 574, 315, 314, 2116, 1790, 63, 1418, 3653, 402, 428, 12032, 83, 3041, 14, 489, 6387, 63, 533, 26, 1021, 4328, 8960, 687, 6222, 14, 1018, 14, 26928, 370, 1314, 282, 2151, 9512, 1177, 1077, 506, 6702, 14, 982, 2337, 365, 949, 2151, 11109, 805, 2013, 334, 11256, 29, 403, 9, 2066, 314, 2151, 6387, 63, 533, 911, 506, 1202, 315, 6358, 314, 2151, 6222, 14, 1018, 14, 1122, 805, 14, 982, 15564, 2151, 314, 6387, 63, 533, 6590, 314, 11109, 365, 2013, 12, 376, 2151, 3101, 295, 732, 909, 911, 506, 2138, 14, 7827, 370, 2151, 11006, 14, 19930, 83, 14, 576, 14, 30693, 83, 7658, 14, 272, 408, 272, 372, 291, 14, 362, 63, 3871, 8, 51, 4225, 1554, 20255, 30416, 63, 2632, 12, 1790, 63, 1418, 29, 1178, 63, 1418, 12, 586, 6387, 63, 533, 29, 16035, 63, 533, 12, 1011, 958, 9, 819, 2372, 30693, 83, 275, 664, 63, 19930, 83, 819, 347, 664, 63, 800, 24376, 8, 277, 12, 27076, 63, 498, 12, 1790, 63, 1418, 29, 403, 12, 2151, 6387, 63, 533, 29, 15275, 14, 19930, 83, 14, 576, 14, 6517, 24376, 7658, 12, 2151, 1011, 958, 304, 272, 408, 30344, 314, 21127, 83, 4453, 282, 1627, 27076, 14, 339, 3033, 26, 489, 27076, 63, 498, 26, 620, 12, 710, 3747, 2870, 402, 642, 3035, 27076, 14, 961, 2432, 883, 506, 314, 2870, 687, 314, 2851, 503, 465, 2741, 315, 282, 2432, 428, 12032, 2397, 14, 489, 1790, 63, 1418, 26, 1626, 909, 1314, 5951, 314, 21527, 3101, 1406, 315, 2399, 2116, 2811, 63, 1069, 1083, 14, 799, 11902, 3992, 2387, 2116, 11006, 14, 71, 1178, 14, 3041, 8880, 3264, 436, 11006, 14, 71, 1178, 14, 2817, 2610, 3264, 2116, 16885, 11789, 14, 21591, 314, 1453, 922, 14, 7827, 370, 488, 2116, 436, 340, 488, 12, 642, 1083, 911, 3648, 367, 282, 574, 315, 314, 2116, 1790, 63, 1418, 3653, 402, 428, 12032, 83, 3041, 14, 489, 6387, 63, 533, 26, 1021, 4328, 8960, 687, 6222, 14, 1018, 14, 26928, 370, 1314, 282, 2151, 9512, 1177, 1077, 506, 6702, 14 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 421, 199, 624, 6906, 282, 1890, 370, 26808, 543, 314, 4475, 428, 12032, 83, 8037, 14, 199, 199, 1858, 3794, 641, 314, 428, 12032, 83, 3261, 12, 1937, 26, 199, 1014, 921, 600, 14, 3098, 14, 957, 15, 12662, 15, 19930, 83, 15, 199, 624, 421, 199, 363, 2502, 363, 275, 283, 74, 14, 83, 32, 3098, 14, 957, 334, 42, 3609, 13916, 1181, 424, 3171, 421, 199, 646, 11006, 14, 1258, 199, 646, 11006, 14, 71, 1178, 199, 646, 11006, 14, 19930, 83, 14, 576, 199, 646, 6222, 14, 576, 199, 646, 6222, 14, 1014, 63, 1018, 421, 199, 51, 4225, 1554, 20255, 30416, 63, 2632, 275, 661, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 19930, 83, 7, 490, 1994, 4239, 15, 2861, 358, 199, 8406, 20255, 30416, 63, 2632, 275, 661, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 800, 24376, 4805, 2116, 1543, 83, 15, 4239, 15, 2861, 358, 199, 8406, 20255, 775, 63, 2632, 275, 661, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 800, 24376, 4805, 326, 1543, 83, 15, 4239, 15, 2861, 3149, 83, 358, 199, 10129, 11344, 63, 2632, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 3149, 83, 15, 5987, 7, 199, 9481, 726, 3177, 63, 2632, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 3149, 83, 15, 6502, 3149, 83, 7, 199, 15060, 63, 2632, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 3149, 83, 15, 6502, 3149, 83, 3149, 83, 7, 199, 26474, 51, 63, 2632, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 9041, 3149, 83, 3149, 83, 15, 4239, 15, 2861, 7, 199, 26474, 63, 2632, 275, 661, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 9041, 3149, 83, 3149, 83, 15, 4239, 15, 2861, 4805, 288, 283, 50, 5, 83, 35, 5, 83, 358, 199, 4924, 51, 63, 2632, 275, 283, 2859, 921, 19930, 83, 14, 3098, 14, 957, 15, 11522, 15, 513, 3149, 83, 3149, 83, 15, 4239, 15, 2861, 7, 421, 199, 533, 428, 12032, 83, 3041, 8, 15275, 14, 1258, 14, 27046, 3041, 304, 523, 2986, 63, 1023, 275, 283, 19, 7, 523, 1790, 63, 1364, 275, 283, 2605, 7, 523, 1790, 63, 14129, 275, 11006, 14, 71, 1178, 14, 5580, 63, 15901, 48, 654, 459, 2605, 418, 523, 6149, 275, 715, 819, 347, 664, 63, 19930, 83, 8, 277, 12, 1790, 63, 1418, 29, 403, 12, 2432, 6387, 63, 533, 29, 15275, 14, 19930, 83, 14, 576, 14, 30693, 83, 7658, 12, 2432, 1011, 958, 304, 272, 408, 11394, 3953, 282, 4733, 543, 314, 27076, 83, 30226, 370, 314, 1453, 922, 14, 339, 3033, 26, 489, 1790, 63, 1418, 26, 1626, 909, 1314, 5951, 314, 21527, 3101, 1406, 315, 2399, 2116, 2811, 63, 1069, 1083, 14, 799, 11902, 3992, 2387, 2116, 11006, 14, 71, 1178, 14, 3041, 8880, 3264, 436, 11006, 14, 71, 1178, 14, 2817, 2610, 3264, 2116, 16885, 11789, 14, 21591, 314, 1453, 922, 14, 7827, 370, 488, 2116, 436, 340, 488, 12, 642, 1083, 911, 3648, 367, 282, 574, 315, 314, 2116, 1790, 63, 1418, 3653, 402, 428, 12032, 83, 3041, 14, 489, 6387, 63, 533, 26, 1021, 4328, 8960, 687, 6222, 14, 1018, 14, 26928, 370, 1314, 282, 2151, 9512, 1177, 1077, 506, 6702, 14, 982, 2337, 365, 949, 2151, 11109, 805, 2013, 334, 11256, 29, 403, 9, 2066, 314, 2151, 6387, 63, 533, 911, 506, 1202, 315, 6358, 314, 2151, 6222, 14, 1018, 14, 1122, 805, 14, 982, 15564, 2151, 314, 6387, 63, 533, 6590, 314, 11109, 365, 2013, 12, 376, 2151, 3101, 295, 732, 909, 911, 506, 2138, 14, 7827, 370, 2151, 11006, 14, 19930, 83, 14, 576, 14, 30693, 83, 7658, 14, 272, 408, 272, 372, 291, 14, 362, 63, 3871, 8, 51, 4225, 1554, 20255, 30416, 63, 2632, 12, 1790, 63, 1418, 29, 1178, 63, 1418, 12, 586, 6387, 63, 533, 29, 16035, 63, 533, 12, 1011, 958, 9, 819, 2372, 30693, 83, 275, 664, 63, 19930, 83, 819, 347, 664, 63, 800, 24376, 8, 277, 12, 27076, 63, 498, 12, 1790, 63, 1418, 29, 403, 12, 2151, 6387, 63, 533, 29, 15275, 14, 19930, 83, 14, 576, 14, 6517, 24376, 7658, 12, 2151, 1011, 958, 304, 272, 408, 30344, 314, 21127, 83, 4453, 282, 1627, 27076, 14, 339, 3033, 26, 489, 27076, 63, 498, 26, 620, 12, 710, 3747, 2870, 402, 642, 3035, 27076, 14, 961, 2432, 883, 506, 314, 2870, 687, 314, 2851, 503, 465, 2741, 315, 282, 2432, 428, 12032, 2397, 14, 489, 1790, 63, 1418, 26, 1626, 909, 1314, 5951, 314, 21527, 3101, 1406, 315, 2399, 2116, 2811, 63, 1069, 1083, 14, 799, 11902, 3992, 2387, 2116, 11006, 14, 71, 1178, 14, 3041, 8880, 3264, 436, 11006, 14, 71, 1178, 14, 2817, 2610, 3264, 2116, 16885, 11789, 14, 21591, 314, 1453, 922, 14, 7827, 370, 488, 2116,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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 ]
tudorbarascu/QGIS
tests/src/python/test_layer_dependencies.py
10
14386
# -*- coding: utf-8 -*- """QGIS Unit tests for QgsSnappingUtils (complement to C++-based tests) .. note:: 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__ = 'Hugo Mercier' __date__ = '12/07/2016' __copyright__ = 'Copyright 2016, The QGIS Project' import qgis # NOQA import os from qgis.core import (QgsProject, QgsVectorLayer, QgsMapSettings, QgsSnappingUtils, QgsSnappingConfig, QgsTolerance, QgsRectangle, QgsPointXY, QgsFeature, QgsGeometry, QgsLayerDefinition, QgsMapLayerDependency ) from qgis.testing import start_app, unittest from qgis.PyQt.QtCore import QSize, QPoint from qgis.PyQt.QtTest import QSignalSpy import tempfile from qgis.utils import spatialite_connect # Convenience instances in case you may need them start_app() class TestLayerDependencies(unittest.TestCase): @classmethod def setUpClass(cls): """Run before all tests""" pass @classmethod def tearDownClass(cls): """Run after all tests""" pass def setUp(self): """Run before each test.""" # create a temp SpatiaLite db with a trigger fo = tempfile.NamedTemporaryFile() fn = fo.name fo.close() self.fn = fn con = spatialite_connect(fn) cur = con.cursor() cur.execute("SELECT InitSpatialMetadata(1)") cur.execute("create table node(id integer primary key autoincrement);") cur.execute("select AddGeometryColumn('node', 'geom', 4326, 'POINT');") cur.execute("create table section(id integer primary key autoincrement, node1 integer, node2 integer);") cur.execute("select AddGeometryColumn('section', 'geom', 4326, 'LINESTRING');") cur.execute("create trigger add_nodes after insert on section begin insert into node (geom) values (st_startpoint(NEW.geom)); insert into node (geom) values (st_endpoint(NEW.geom)); end;") cur.execute("insert into node (geom) values (geomfromtext('point(0 0)', 4326));") cur.execute("insert into node (geom) values (geomfromtext('point(1 0)', 4326));") cur.execute("create table node2(id integer primary key autoincrement);") cur.execute("select AddGeometryColumn('node2', 'geom', 4326, 'POINT');") cur.execute("create trigger add_nodes2 after insert on node begin insert into node2 (geom) values (st_translate(NEW.geom, 0.2, 0, 0)); end;") con.commit() con.close() self.pointsLayer = QgsVectorLayer("dbname='%s' table=\"node\" (geom) sql=" % fn, "points", "spatialite") assert (self.pointsLayer.isValid()) self.linesLayer = QgsVectorLayer("dbname='%s' table=\"section\" (geom) sql=" % fn, "lines", "spatialite") assert (self.linesLayer.isValid()) self.pointsLayer2 = QgsVectorLayer("dbname='%s' table=\"node2\" (geom) sql=" % fn, "_points2", "spatialite") assert (self.pointsLayer2.isValid()) QgsProject.instance().addMapLayers([self.pointsLayer, self.linesLayer, self.pointsLayer2]) # save the project file fo = tempfile.NamedTemporaryFile() fn = fo.name fo.close() self.projectFile = fn QgsProject.instance().setFileName(self.projectFile) QgsProject.instance().write() def tearDown(self): """Run after each test.""" QgsProject.instance().clear() pass def test_resetSnappingIndex(self): self.pointsLayer.setDependencies([]) self.linesLayer.setDependencies([]) self.pointsLayer2.setDependencies([]) ms = QgsMapSettings() ms.setOutputSize(QSize(100, 100)) ms.setExtent(QgsRectangle(0, 0, 1, 1)) self.assertTrue(ms.hasValidSettings()) u = QgsSnappingUtils() u.setMapSettings(ms) cfg = u.config() cfg.setEnabled(True) cfg.setMode(QgsSnappingConfig.AdvancedConfiguration) cfg.setIndividualLayerSettings(self.pointsLayer, QgsSnappingConfig.IndividualLayerSettings(True, QgsSnappingConfig.Vertex, 20, QgsTolerance.Pixels)) u.setConfig(cfg) m = u.snapToMap(QPoint(95, 100)) self.assertTrue(m.isValid()) self.assertTrue(m.hasVertex()) self.assertEqual(m.point(), QgsPointXY(1, 0)) f = QgsFeature(self.linesLayer.fields()) f.setId(1) geom = QgsGeometry.fromWkt("LINESTRING(0 0,1 1)") f.setGeometry(geom) self.linesLayer.startEditing() self.linesLayer.addFeatures([f]) self.linesLayer.commitChanges() l1 = len([f for f in self.pointsLayer.getFeatures()]) self.assertEqual(l1, 4) m = u.snapToMap(QPoint(95, 0)) # snapping not updated self.pointsLayer.setDependencies([]) self.assertEqual(m.isValid(), False) # set layer dependencies self.pointsLayer.setDependencies([QgsMapLayerDependency(self.linesLayer.id())]) # add another line f = QgsFeature(self.linesLayer.fields()) f.setId(2) geom = QgsGeometry.fromWkt("LINESTRING(0 0,0.5 0.5)") f.setGeometry(geom) self.linesLayer.startEditing() self.linesLayer.addFeatures([f]) self.linesLayer.commitChanges() # check the snapped point is OK m = u.snapToMap(QPoint(45, 50)) self.assertTrue(m.isValid()) self.assertTrue(m.hasVertex()) self.assertEqual(m.point(), QgsPointXY(0.5, 0.5)) self.pointsLayer.setDependencies([]) # test chained layer dependencies A -> B -> C cfg.setIndividualLayerSettings(self.pointsLayer2, QgsSnappingConfig.IndividualLayerSettings(True, QgsSnappingConfig.Vertex, 20, QgsTolerance.Pixels)) u.setConfig(cfg) self.pointsLayer.setDependencies([QgsMapLayerDependency(self.linesLayer.id())]) self.pointsLayer2.setDependencies([QgsMapLayerDependency(self.pointsLayer.id())]) # add another line f = QgsFeature(self.linesLayer.fields()) f.setId(3) geom = QgsGeometry.fromWkt("LINESTRING(0 0.2,0.5 0.8)") f.setGeometry(geom) self.linesLayer.startEditing() self.linesLayer.addFeatures([f]) self.linesLayer.commitChanges() # check the second snapped point is OK m = u.snapToMap(QPoint(75, 100 - 80)) self.assertTrue(m.isValid()) self.assertTrue(m.hasVertex()) self.assertEqual(m.point(), QgsPointXY(0.7, 0.8)) self.pointsLayer.setDependencies([]) self.pointsLayer2.setDependencies([]) def test_circular_dependencies_with_2_layers(self): spy_points_data_changed = QSignalSpy(self.pointsLayer.dataChanged) spy_lines_data_changed = QSignalSpy(self.linesLayer.dataChanged) spy_points_repaint_requested = QSignalSpy(self.pointsLayer.repaintRequested) spy_lines_repaint_requested = QSignalSpy(self.linesLayer.repaintRequested) # only points fire dataChanged because we change its dependencies self.assertTrue(self.pointsLayer.setDependencies([QgsMapLayerDependency(self.linesLayer.id())])) self.assertEqual(len(spy_points_data_changed), 1) self.assertEqual(len(spy_lines_data_changed), 0) # lines fire dataChanged because we changes its dependencies # points fire dataChanged because it depends on line self.assertTrue(self.linesLayer.setDependencies([QgsMapLayerDependency(self.pointsLayer.id())])) self.assertEqual(len(spy_points_data_changed), 2) self.assertEqual(len(spy_lines_data_changed), 1) f = QgsFeature(self.pointsLayer.fields()) f.setId(1) geom = QgsGeometry.fromWkt("POINT(0 0)") f.setGeometry(geom) self.pointsLayer.startEditing() # new point fire featureAdded so depending line fire dataChanged # point depends on line, so fire dataChanged self.pointsLayer.addFeatures([f]) self.assertEqual(len(spy_points_data_changed), 3) self.assertEqual(len(spy_lines_data_changed), 2) # added feature is deleted and added with its new defined id # (it was -1 before) so it fires 2 more signal dataChanged on # depending line (on featureAdded and on featureDeleted) # and so 2 more signal on points because it depends on line self.pointsLayer.commitChanges() self.assertEqual(len(spy_points_data_changed), 5) self.assertEqual(len(spy_lines_data_changed), 4) # repaintRequested is called on commit changes on point # so it is on depending line self.assertEqual(len(spy_lines_repaint_requested), 1) self.assertEqual(len(spy_points_repaint_requested), 1) def test_circular_dependencies_with_1_layer(self): # You can define a layer dependent on it self (for instance, a line # layer that trigger connected lines modifications when you modify # one line) spy_lines_data_changed = QSignalSpy(self.linesLayer.dataChanged) spy_lines_repaint_requested = QSignalSpy(self.linesLayer.repaintRequested) # line fire dataChanged because we change its dependencies self.assertTrue(self.linesLayer.setDependencies([QgsMapLayerDependency(self.linesLayer.id())])) self.assertEqual(len(spy_lines_data_changed), 1) f = QgsFeature(self.linesLayer.fields()) f.setId(1) geom = QgsGeometry.fromWkt("LINESTRING(0 0,1 1)") f.setGeometry(geom) self.linesLayer.startEditing() # line fire featureAdded so depending line fire dataChanged once more self.linesLayer.addFeatures([f]) self.assertEqual(len(spy_lines_data_changed), 2) # added feature is deleted and added with its new defined id # (it was -1 before) so it fires 2 more signal dataChanged on # depending line (on featureAdded and on featureDeleted) self.linesLayer.commitChanges() self.assertEqual(len(spy_lines_data_changed), 4) # repaintRequested is called only once on commit changes on line self.assertEqual(len(spy_lines_repaint_requested), 1) def test_layerDefinitionRewriteId(self): tmpfile = os.path.join(tempfile.tempdir, "test.qlr") ltr = QgsProject.instance().layerTreeRoot() self.pointsLayer.setDependencies([QgsMapLayerDependency(self.linesLayer.id())]) QgsLayerDefinition.exportLayerDefinition(tmpfile, [ltr]) grp = ltr.addGroup("imported") QgsLayerDefinition.loadLayerDefinition(tmpfile, QgsProject.instance(), grp) newPointsLayer = None newLinesLayer = None for l in grp.findLayers(): if l.layerId().startswith('points'): newPointsLayer = l.layer() elif l.layerId().startswith('lines'): newLinesLayer = l.layer() self.assertIsNotNone(newPointsLayer) self.assertIsNotNone(newLinesLayer) self.assertTrue(newLinesLayer.id() in [dep.layerId() for dep in newPointsLayer.dependencies()]) self.pointsLayer.setDependencies([]) def test_signalConnection(self): # remove all layers QgsProject.instance().removeAllMapLayers() # set dependencies and add back layers self.pointsLayer = QgsVectorLayer("dbname='%s' table=\"node\" (geom) sql=" % self.fn, "points", "spatialite") assert (self.pointsLayer.isValid()) self.linesLayer = QgsVectorLayer("dbname='%s' table=\"section\" (geom) sql=" % self.fn, "lines", "spatialite") assert (self.linesLayer.isValid()) self.pointsLayer2 = QgsVectorLayer("dbname='%s' table=\"node2\" (geom) sql=" % self.fn, "_points2", "spatialite") assert (self.pointsLayer2.isValid()) self.pointsLayer.setDependencies([QgsMapLayerDependency(self.linesLayer.id())]) self.pointsLayer2.setDependencies([QgsMapLayerDependency(self.pointsLayer.id())]) # this should update connections between layers QgsProject.instance().addMapLayers([self.pointsLayer]) QgsProject.instance().addMapLayers([self.linesLayer]) QgsProject.instance().addMapLayers([self.pointsLayer2]) ms = QgsMapSettings() ms.setOutputSize(QSize(100, 100)) ms.setExtent(QgsRectangle(0, 0, 1, 1)) self.assertTrue(ms.hasValidSettings()) u = QgsSnappingUtils() u.setMapSettings(ms) cfg = u.config() cfg.setEnabled(True) cfg.setMode(QgsSnappingConfig.AdvancedConfiguration) cfg.setIndividualLayerSettings(self.pointsLayer, QgsSnappingConfig.IndividualLayerSettings(True, QgsSnappingConfig.Vertex, 20, QgsTolerance.Pixels)) cfg.setIndividualLayerSettings(self.pointsLayer2, QgsSnappingConfig.IndividualLayerSettings(True, QgsSnappingConfig.Vertex, 20, QgsTolerance.Pixels)) u.setConfig(cfg) # add another line f = QgsFeature(self.linesLayer.fields()) f.setId(4) geom = QgsGeometry.fromWkt("LINESTRING(0.5 0.2,0.6 0)") f.setGeometry(geom) self.linesLayer.startEditing() self.linesLayer.addFeatures([f]) self.linesLayer.commitChanges() # check the second snapped point is OK m = u.snapToMap(QPoint(75, 100 - 0)) self.assertTrue(m.isValid()) self.assertTrue(m.hasVertex()) self.assertEqual(m.point(), QgsPointXY(0.8, 0.0)) self.pointsLayer.setDependencies([]) self.pointsLayer2.setDependencies([]) if __name__ == '__main__': unittest.main()
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 31329, 12008, 2295, 367, 4888, 20821, 3262, 7535, 334, 2731, 434, 370, 445, 4176, 13, 6788, 2295, 9, 199, 199, 703, 5317, 447, 961, 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, 624, 199, 363, 2502, 363, 275, 283, 40, 1518, 79, 18880, 559, 281, 7, 199, 363, 602, 363, 275, 283, 713, 15, 1780, 15, 9261, 7, 199, 363, 7307, 363, 275, 283, 7384, 7800, 12, 710, 27024, 7290, 7, 199, 199, 646, 15640, 221, 327, 20432, 199, 646, 747, 199, 199, 504, 15640, 14, 1018, 492, 334, 7350, 4761, 12, 2432, 22507, 12, 2432, 31545, 5268, 12, 2432, 4888, 20821, 3262, 7535, 12, 2432, 4888, 20821, 3262, 2028, 12, 2432, 4888, 1378, 8807, 12, 2432, 4888, 18127, 12, 2432, 4888, 30466, 12, 2432, 26833, 12, 2432, 4888, 6831, 12, 2432, 4888, 5003, 10701, 12, 2432, 31545, 5003, 14403, 2432, 776, 199, 199, 504, 15640, 14, 4776, 492, 1343, 63, 571, 12, 2882, 199, 199, 504, 15640, 14, 24107, 14, 10901, 492, 1413, 2320, 12, 1413, 3428, 199, 504, 15640, 14, 24107, 14, 4238, 774, 492, 1413, 11274, 51, 647, 199, 199, 646, 5549, 199, 199, 504, 15640, 14, 1208, 492, 11469, 1175, 63, 2242, 199, 199, 3, 1448, 23329, 4454, 315, 1930, 1265, 1443, 1929, 3062, 199, 928, 63, 571, 342, 421, 199, 533, 1379, 5003, 11927, 8, 2796, 14, 1746, 304, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 408, 2540, 2544, 1006, 2295, 624, 267, 986, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 408, 2540, 2410, 1006, 2295, 624, 267, 986, 339, 347, 3613, 8, 277, 304, 267, 408, 2540, 2544, 1924, 511, 1041, 267, 327, 1218, 282, 2388, 25177, 1592, 543, 282, 6804, 267, 7090, 275, 5549, 14, 19320, 342, 267, 4325, 275, 7090, 14, 354, 267, 7090, 14, 1600, 342, 267, 291, 14, 2324, 275, 4325, 267, 406, 275, 11469, 1175, 63, 2242, 8, 2324, 9, 267, 1094, 275, 406, 14, 3937, 342, 267, 1094, 14, 2526, 480, 4859, 21026, 18075, 5142, 8, 17, 6320, 267, 1094, 14, 2526, 480, 981, 1817, 1031, 8, 344, 3000, 5062, 790, 32497, 2736, 531, 267, 1094, 14, 2526, 480, 2416, 2654, 6831, 4547, 360, 932, 297, 283, 6481, 297, 26719, 12, 283, 7217, 11339, 531, 267, 1094, 14, 2526, 480, 981, 1817, 3420, 8, 344, 3000, 5062, 790, 32497, 12, 1031, 17, 3000, 12, 1031, 18, 3000, 2736, 531, 267, 1094, 14, 2526, 480, 2416, 2654, 6831, 4547, 360, 2792, 297, 283, 6481, 297, 26719, 12, 283, 6143, 29780, 11339, 531, 267, 1094, 14, 2526, 480, 981, 6804, 1050, 63, 2415, 2410, 5518, 641, 3420, 5386, 5518, 1901, 1031, 334, 6481, 9, 1338, 334, 270, 63, 928, 1403, 8, 11365, 14, 6481, 16674, 5518, 1901, 1031, 334, 6481, 9, 1338, 334, 270, 63, 6520, 8, 11365, 14, 6481, 16674, 1284, 15027, 267, 1094, 14, 2526, 480, 3176, 1901, 1031, 334, 6481, 9, 1338, 334, 6481, 504, 505, 360, 1403, 8, 16, 378, 3196, 26719, 430, 15027, 267, 1094, 14, 2526, 480, 3176, 1901, 1031, 334, 6481, 9, 1338, 334, 6481, 504, 505, 360, 1403, 8, 17, 378, 3196, 26719, 430, 15027, 267, 1094, 14, 2526, 480, 981, 1817, 1031, 18, 8, 344, 3000, 5062, 790, 32497, 2736, 531, 267, 1094, 14, 2526, 480, 2416, 2654, 6831, 4547, 360, 932, 18, 297, 283, 6481, 297, 26719, 12, 283, 7217, 11339, 531, 267, 1094, 14, 2526, 480, 981, 6804, 1050, 63, 2415, 18, 2410, 5518, 641, 1031, 5386, 5518, 1901, 1031, 18, 334, 6481, 9, 1338, 334, 270, 63, 5275, 8, 11365, 14, 6481, 12, 378, 14, 18, 12, 378, 12, 378, 16674, 1284, 15027, 267, 406, 14, 3543, 342, 267, 406, 14, 1600, 342, 398, 291, 14, 3438, 5003, 275, 22507, 480, 13238, 9569, 83, 7, 1817, 8178, 932, 4451, 334, 6481, 9, 3875, 628, 450, 4325, 12, 298, 3438, 401, 298, 25873, 531, 267, 702, 334, 277, 14, 3438, 5003, 14, 18728, 1012, 267, 291, 14, 1278, 5003, 275, 22507, 480, 13238, 9569, 83, 7, 1817, 8178, 2792, 4451, 334, 6481, 9, 3875, 628, 450, 4325, 12, 298, 1278, 401, 298, 25873, 531, 267, 702, 334, 277, 14, 1278, 5003, 14, 18728, 1012, 267, 291, 14, 3438, 5003, 18, 275, 22507, 480, 13238, 9569, 83, 7, 1817, 8178, 932, 18, 4451, 334, 6481, 9, 3875, 628, 450, 4325, 12, 2668, 3438, 18, 401, 298, 25873, 531, 267, 702, 334, 277, 14, 3438, 5003, 18, 14, 18728, 1012, 267, 4888, 4761, 14, 842, 1252, 525, 2956, 16862, 779, 277, 14, 3438, 5003, 12, 291, 14, 1278, 5003, 12, 291, 14, 3438, 5003, 18, 566, 398, 327, 3354, 314, 2199, 570, 267, 7090, 275, 5549, 14, 19320, 342, 267, 4325, 275, 7090, 14, 354, 267, 7090, 14, 1600, 342, 267, 291, 14, 1715, 1173, 275, 4325, 267, 4888, 4761, 14, 842, 1252, 409, 7733, 8, 277, 14, 1715, 1173, 9, 267, 4888, 4761, 14, 842, 1252, 952, 342, 339, 347, 6766, 8, 277, 304, 267, 408, 2540, 2410, 1924, 511, 1041, 267, 4888, 4761, 14, 842, 1252, 3584, 342, 267, 986, 339, 347, 511, 63, 3958, 20821, 3262, 2681, 8, 277, 304, 267, 291, 14, 3438, 5003, 14, 409, 11927, 4157, 267, 291, 14, 1278, 5003, 14, 409, 11927, 4157, 267, 291, 14, 3438, 5003, 18, 14, 409, 11927, 4157, 398, 6605, 275, 31545, 5268, 342, 267, 6605, 14, 409, 2959, 2320, 8, 15531, 8, 1960, 12, 2948, 430, 267, 6605, 14, 409, 19808, 8, 7350, 18127, 8, 16, 12, 378, 12, 413, 12, 413, 430, 267, 291, 14, 1815, 8, 706, 14, 1989, 3490, 5268, 1012, 398, 399, 275, 4888, 20821, 3262, 7535, 342, 267, 399, 14, 409, 2956, 5268, 8, 706, 9, 267, 4810, 275, 399, 14, 888, 342, 267, 4810, 14, 14329, 8, 549, 9, 267, 4810, 14, 409, 1385, 8, 7350, 20821, 3262, 2028, 14, 23613, 5688, 9, 267, 4810 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 31329, 12008, 2295, 367, 4888, 20821, 3262, 7535, 334, 2731, 434, 370, 445, 4176, 13, 6788, 2295, 9, 199, 199, 703, 5317, 447, 961, 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, 624, 199, 363, 2502, 363, 275, 283, 40, 1518, 79, 18880, 559, 281, 7, 199, 363, 602, 363, 275, 283, 713, 15, 1780, 15, 9261, 7, 199, 363, 7307, 363, 275, 283, 7384, 7800, 12, 710, 27024, 7290, 7, 199, 199, 646, 15640, 221, 327, 20432, 199, 646, 747, 199, 199, 504, 15640, 14, 1018, 492, 334, 7350, 4761, 12, 2432, 22507, 12, 2432, 31545, 5268, 12, 2432, 4888, 20821, 3262, 7535, 12, 2432, 4888, 20821, 3262, 2028, 12, 2432, 4888, 1378, 8807, 12, 2432, 4888, 18127, 12, 2432, 4888, 30466, 12, 2432, 26833, 12, 2432, 4888, 6831, 12, 2432, 4888, 5003, 10701, 12, 2432, 31545, 5003, 14403, 2432, 776, 199, 199, 504, 15640, 14, 4776, 492, 1343, 63, 571, 12, 2882, 199, 199, 504, 15640, 14, 24107, 14, 10901, 492, 1413, 2320, 12, 1413, 3428, 199, 504, 15640, 14, 24107, 14, 4238, 774, 492, 1413, 11274, 51, 647, 199, 199, 646, 5549, 199, 199, 504, 15640, 14, 1208, 492, 11469, 1175, 63, 2242, 199, 199, 3, 1448, 23329, 4454, 315, 1930, 1265, 1443, 1929, 3062, 199, 928, 63, 571, 342, 421, 199, 533, 1379, 5003, 11927, 8, 2796, 14, 1746, 304, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 408, 2540, 2544, 1006, 2295, 624, 267, 986, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 408, 2540, 2410, 1006, 2295, 624, 267, 986, 339, 347, 3613, 8, 277, 304, 267, 408, 2540, 2544, 1924, 511, 1041, 267, 327, 1218, 282, 2388, 25177, 1592, 543, 282, 6804, 267, 7090, 275, 5549, 14, 19320, 342, 267, 4325, 275, 7090, 14, 354, 267, 7090, 14, 1600, 342, 267, 291, 14, 2324, 275, 4325, 267, 406, 275, 11469, 1175, 63, 2242, 8, 2324, 9, 267, 1094, 275, 406, 14, 3937, 342, 267, 1094, 14, 2526, 480, 4859, 21026, 18075, 5142, 8, 17, 6320, 267, 1094, 14, 2526, 480, 981, 1817, 1031, 8, 344, 3000, 5062, 790, 32497, 2736, 531, 267, 1094, 14, 2526, 480, 2416, 2654, 6831, 4547, 360, 932, 297, 283, 6481, 297, 26719, 12, 283, 7217, 11339, 531, 267, 1094, 14, 2526, 480, 981, 1817, 3420, 8, 344, 3000, 5062, 790, 32497, 12, 1031, 17, 3000, 12, 1031, 18, 3000, 2736, 531, 267, 1094, 14, 2526, 480, 2416, 2654, 6831, 4547, 360, 2792, 297, 283, 6481, 297, 26719, 12, 283, 6143, 29780, 11339, 531, 267, 1094, 14, 2526, 480, 981, 6804, 1050, 63, 2415, 2410, 5518, 641, 3420, 5386, 5518, 1901, 1031, 334, 6481, 9, 1338, 334, 270, 63, 928, 1403, 8, 11365, 14, 6481, 16674, 5518, 1901, 1031, 334, 6481, 9, 1338, 334, 270, 63, 6520, 8, 11365, 14, 6481, 16674, 1284, 15027, 267, 1094, 14, 2526, 480, 3176, 1901, 1031, 334, 6481, 9, 1338, 334, 6481, 504, 505, 360, 1403, 8, 16, 378, 3196, 26719, 430, 15027, 267, 1094, 14, 2526, 480, 3176, 1901, 1031, 334, 6481, 9, 1338, 334, 6481, 504, 505, 360, 1403, 8, 17, 378, 3196, 26719, 430, 15027, 267, 1094, 14, 2526, 480, 981, 1817, 1031, 18, 8, 344, 3000, 5062, 790, 32497, 2736, 531, 267, 1094, 14, 2526, 480, 2416, 2654, 6831, 4547, 360, 932, 18, 297, 283, 6481, 297, 26719, 12, 283, 7217, 11339, 531, 267, 1094, 14, 2526, 480, 981, 6804, 1050, 63, 2415, 18, 2410, 5518, 641, 1031, 5386, 5518, 1901, 1031, 18, 334, 6481, 9, 1338, 334, 270, 63, 5275, 8, 11365, 14, 6481, 12, 378, 14, 18, 12, 378, 12, 378, 16674, 1284, 15027, 267, 406, 14, 3543, 342, 267, 406, 14, 1600, 342, 398, 291, 14, 3438, 5003, 275, 22507, 480, 13238, 9569, 83, 7, 1817, 8178, 932, 4451, 334, 6481, 9, 3875, 628, 450, 4325, 12, 298, 3438, 401, 298, 25873, 531, 267, 702, 334, 277, 14, 3438, 5003, 14, 18728, 1012, 267, 291, 14, 1278, 5003, 275, 22507, 480, 13238, 9569, 83, 7, 1817, 8178, 2792, 4451, 334, 6481, 9, 3875, 628, 450, 4325, 12, 298, 1278, 401, 298, 25873, 531, 267, 702, 334, 277, 14, 1278, 5003, 14, 18728, 1012, 267, 291, 14, 3438, 5003, 18, 275, 22507, 480, 13238, 9569, 83, 7, 1817, 8178, 932, 18, 4451, 334, 6481, 9, 3875, 628, 450, 4325, 12, 2668, 3438, 18, 401, 298, 25873, 531, 267, 702, 334, 277, 14, 3438, 5003, 18, 14, 18728, 1012, 267, 4888, 4761, 14, 842, 1252, 525, 2956, 16862, 779, 277, 14, 3438, 5003, 12, 291, 14, 1278, 5003, 12, 291, 14, 3438, 5003, 18, 566, 398, 327, 3354, 314, 2199, 570, 267, 7090, 275, 5549, 14, 19320, 342, 267, 4325, 275, 7090, 14, 354, 267, 7090, 14, 1600, 342, 267, 291, 14, 1715, 1173, 275, 4325, 267, 4888, 4761, 14, 842, 1252, 409, 7733, 8, 277, 14, 1715, 1173, 9, 267, 4888, 4761, 14, 842, 1252, 952, 342, 339, 347, 6766, 8, 277, 304, 267, 408, 2540, 2410, 1924, 511, 1041, 267, 4888, 4761, 14, 842, 1252, 3584, 342, 267, 986, 339, 347, 511, 63, 3958, 20821, 3262, 2681, 8, 277, 304, 267, 291, 14, 3438, 5003, 14, 409, 11927, 4157, 267, 291, 14, 1278, 5003, 14, 409, 11927, 4157, 267, 291, 14, 3438, 5003, 18, 14, 409, 11927, 4157, 398, 6605, 275, 31545, 5268, 342, 267, 6605, 14, 409, 2959, 2320, 8, 15531, 8, 1960, 12, 2948, 430, 267, 6605, 14, 409, 19808, 8, 7350, 18127, 8, 16, 12, 378, 12, 413, 12, 413, 430, 267, 291, 14, 1815, 8, 706, 14, 1989, 3490, 5268, 1012, 398, 399, 275, 4888, 20821, 3262, 7535, 342, 267, 399, 14, 409, 2956, 5268, 8, 706, 9, 267, 4810, 275, 399, 14, 888, 342, 267, 4810, 14, 14329, 8, 549, 9, 267, 4810, 14, 409, 1385, 8, 7350, 20821, 3262, 2028, 14, 23613, 5688, 9, 267, 4810, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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