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
dirtycoder/opbeat_python
tests/contrib/flask/flask_tests.py
2
4558
from flask import Flask from django.test import TestCase from opbeat.contrib.flask import Opbeat from tests.helpers import get_tempstoreclient def create_app(): app = Flask(__name__) @app.route('/an-error/', methods=['GET', 'POST']) def an_error(): raise ValueError('hello world') return app class FlaskTest(TestCase): def setUp(self): self.app = create_app() self.client = self.app.test_client() def test_error_handler(self): client = get_tempstoreclient() opbeat = Opbeat(self.app, client=client) response = self.client.get('/an-error/') self.assertEquals(response.status_code, 500) self.assertEquals(len(client.events), 1) event = client.events.pop(0) self.assertTrue('exception' in event) exc = event['exception'] self.assertEquals(exc['type'], 'ValueError') self.assertEquals(exc['value'], 'hello world') self.assertEquals(event['level'], "error") self.assertEquals(event['message'], 'ValueError: hello world') self.assertEquals(event['culprit'], 'tests.contrib.flask.flask_tests.an_error') def test_get(self): client = get_tempstoreclient() opbeat = Opbeat(self.app, client=client) response = self.client.get('/an-error/?foo=bar') self.assertEquals(response.status_code, 500) self.assertEquals(len(client.events), 1) event = client.events.pop(0) self.assertTrue('http' in event) http = event['http'] self.assertEquals(http['url'], 'http://localhost/an-error/') self.assertEquals(http['query_string'], 'foo=bar') self.assertEquals(http['method'], 'GET') self.assertEquals(http['data'], {}) self.assertTrue('headers' in http) headers = http['headers'] self.assertTrue('Content-Length' in headers, headers.keys()) self.assertEquals(headers['Content-Length'], '0') self.assertTrue('Content-Type' in headers, headers.keys()) self.assertEquals(headers['Content-Type'], '') self.assertTrue('Host' in headers, headers.keys()) self.assertEquals(headers['Host'], 'localhost') env = http['env'] self.assertTrue('SERVER_NAME' in env, env.keys()) self.assertEquals(env['SERVER_NAME'], 'localhost') self.assertTrue('SERVER_PORT' in env, env.keys()) self.assertEquals(env['SERVER_PORT'], '80') def test_get_debug(self): client = get_tempstoreclient() opbeat = Opbeat(self.app, client=client) self.app.config['DEBUG'] = True self.app.config['TESTING'] = False self.assertRaises(ValueError, self.app.test_client().get, '/an-error/?foo=bar') self.assertEquals(len(client.events), 0) def test_get_debug_opbeat(self): client = get_tempstoreclient() opbeat = Opbeat(self.app, client=client) self.app.config['DEBUG'] = True self.app.config['TESTING'] = True self.app.config['OPBEAT'] = {'DEBUG': True} self.assertRaises(ValueError, self.app.test_client().get, '/an-error/?foo=bar') self.assertEquals(len(client.events), 1) def test_post(self): client = get_tempstoreclient() opbeat = Opbeat(self.app, client=client) response = self.client.post('/an-error/?biz=baz', data={'foo': 'bar'}) self.assertEquals(response.status_code, 500) self.assertEquals(len(client.events), 1) event = client.events.pop(0) self.assertTrue('http' in event) http = event['http'] self.assertEquals(http['url'], 'http://localhost/an-error/') self.assertEquals(http['query_string'], 'biz=baz') self.assertEquals(http['method'], 'POST') self.assertEquals(http['data'], {'foo': 'bar'}) self.assertTrue('headers' in http) headers = http['headers'] self.assertTrue('Content-Length' in headers, headers.keys()) self.assertEquals(headers['Content-Length'], '7') self.assertTrue('Content-Type' in headers, headers.keys()) self.assertEquals(headers['Content-Type'], 'application/x-www-form-urlencoded') self.assertTrue('Host' in headers, headers.keys()) self.assertEquals(headers['Host'], 'localhost') env = http['env'] self.assertTrue('SERVER_NAME' in env, env.keys()) self.assertEquals(env['SERVER_NAME'], 'localhost') self.assertTrue('SERVER_PORT' in env, env.keys()) self.assertEquals(env['SERVER_PORT'], '80')
bsd-3-clause
[ 504, 7209, 492, 16704, 199, 199, 504, 1639, 14, 396, 492, 7640, 421, 199, 504, 1687, 12522, 14, 2828, 14, 15720, 492, 9319, 12522, 199, 199, 504, 2295, 14, 7546, 492, 664, 63, 808, 1617, 1258, 421, 199, 318, 1218, 63, 571, 837, 272, 1145, 275, 16704, 3460, 354, 3368, 339, 768, 571, 14, 4449, 2336, 290, 13, 705, 3678, 3102, 2968, 2970, 297, 283, 4030, 1105, 272, 347, 376, 63, 705, 837, 267, 746, 1722, 360, 5006, 6701, 358, 339, 372, 1145, 421, 199, 533, 16704, 774, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 571, 275, 1218, 63, 571, 342, 267, 291, 14, 1258, 275, 291, 14, 571, 14, 396, 63, 1258, 342, 339, 347, 511, 63, 705, 63, 2232, 8, 277, 304, 267, 1890, 275, 664, 63, 808, 1617, 1258, 342, 267, 1687, 12522, 275, 9319, 12522, 8, 277, 14, 571, 12, 1890, 29, 1258, 9, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 290, 13, 705, 6217, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 2947, 8, 552, 8, 1258, 14, 4368, 395, 413, 9, 398, 1566, 275, 1890, 14, 4368, 14, 1935, 8, 16, 9, 398, 291, 14, 1815, 360, 1971, 7, 315, 1566, 9, 267, 3178, 275, 1566, 459, 1971, 418, 267, 291, 14, 2947, 8, 2804, 459, 466, 995, 283, 3393, 358, 267, 291, 14, 2947, 8, 2804, 459, 585, 995, 283, 5006, 6701, 358, 267, 291, 14, 2947, 8, 1430, 459, 1896, 995, 298, 705, 531, 267, 291, 14, 2947, 8, 1430, 459, 1188, 995, 283, 3393, 26, 16509, 6701, 358, 267, 291, 14, 2947, 8, 1430, 459, 3119, 1359, 84, 995, 283, 2219, 14, 2828, 14, 15720, 14, 15720, 63, 2219, 14, 290, 63, 705, 358, 339, 347, 511, 63, 362, 8, 277, 304, 267, 1890, 275, 664, 63, 808, 1617, 1258, 342, 267, 1687, 12522, 275, 9319, 12522, 8, 277, 14, 571, 12, 1890, 29, 1258, 9, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 290, 13, 705, 10197, 1421, 29, 1700, 358, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 2947, 8, 552, 8, 1258, 14, 4368, 395, 413, 9, 398, 1566, 275, 1890, 14, 4368, 14, 1935, 8, 16, 9, 398, 291, 14, 1815, 360, 1014, 7, 315, 1566, 9, 267, 1455, 275, 1566, 459, 1014, 418, 267, 291, 14, 2947, 8, 1014, 459, 633, 995, 283, 1014, 921, 5967, 15, 290, 13, 705, 6217, 267, 291, 14, 2947, 8, 1014, 459, 1131, 63, 875, 995, 283, 1421, 29, 1700, 358, 267, 291, 14, 2947, 8, 1014, 459, 765, 995, 283, 2970, 358, 267, 291, 14, 2947, 8, 1014, 459, 576, 995, 5009, 267, 291, 14, 1815, 360, 2139, 7, 315, 1455, 9, 267, 2323, 275, 1455, 459, 2139, 418, 267, 291, 14, 1815, 360, 2714, 13, 4625, 7, 315, 2323, 12, 2323, 14, 1612, 1012, 267, 291, 14, 2947, 8, 2139, 459, 2714, 13, 4625, 995, 283, 16, 358, 267, 291, 14, 1815, 360, 2714, 13, 804, 7, 315, 2323, 12, 2323, 14, 1612, 1012, 267, 291, 14, 2947, 8, 2139, 459, 2714, 13, 804, 995, 4074, 267, 291, 14, 1815, 360, 4965, 7, 315, 2323, 12, 2323, 14, 1612, 1012, 267, 291, 14, 2947, 8, 2139, 459, 4965, 995, 283, 5967, 358, 267, 2589, 275, 1455, 459, 1813, 418, 267, 291, 14, 1815, 360, 6613, 63, 2339, 7, 315, 2589, 12, 2589, 14, 1612, 1012, 267, 291, 14, 2947, 8, 1813, 459, 6613, 63, 2339, 995, 283, 5967, 358, 267, 291, 14, 1815, 360, 6613, 63, 3657, 7, 315, 2589, 12, 2589, 14, 1612, 1012, 267, 291, 14, 2947, 8, 1813, 459, 6613, 63, 3657, 995, 283, 1257, 358, 339, 347, 511, 63, 362, 63, 1757, 8, 277, 304, 267, 1890, 275, 664, 63, 808, 1617, 1258, 342, 267, 1687, 12522, 275, 9319, 12522, 8, 277, 14, 571, 12, 1890, 29, 1258, 9, 267, 291, 14, 571, 14, 888, 459, 5287, 418, 275, 715, 267, 291, 14, 571, 14, 888, 459, 2864, 1206, 418, 275, 756, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 571, 14, 396, 63, 1258, 1252, 362, 12, 1994, 290, 13, 705, 10197, 1421, 29, 1700, 358, 267, 291, 14, 2947, 8, 552, 8, 1258, 14, 4368, 395, 378, 9, 339, 347, 511, 63, 362, 63, 1757, 63, 411, 12522, 8, 277, 304, 267, 1890, 275, 664, 63, 808, 1617, 1258, 342, 267, 1687, 12522, 275, 9319, 12522, 8, 277, 14, 571, 12, 1890, 29, 1258, 9, 267, 291, 14, 571, 14, 888, 459, 5287, 418, 275, 715, 267, 291, 14, 571, 14, 888, 459, 2864, 1206, 418, 275, 715, 267, 291, 14, 571, 14, 888, 459, 1938, 6773, 619, 418, 275, 791, 5287, 356, 715, 93, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 571, 14, 396, 63, 1258, 1252, 362, 12, 1994, 290, 13, 705, 10197, 1421, 29, 1700, 358, 267, 291, 14, 2947, 8, 552, 8, 1258, 14, 4368, 395, 413, 9, 339, 347, 511, 63, 1932, 8, 277, 304, 267, 1890, 275, 664, 63, 808, 1617, 1258, 342, 267, 1687, 12522, 275, 9319, 12522, 8, 277, 14, 571, 12, 1890, 29, 1258, 9, 267, 1177, 275, 291, 14, 1258, 14, 1932, 2336, 290, 13, 705, 10197, 66, 565, 29, 6185, 297, 666, 3713, 1421, 356, 283, 1700, 3071, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 2947, 8, 552, 8, 1258, 14, 4368, 395, 413, 9, 398, 1566, 275, 1890, 14, 4368, 14, 1935, 8, 16, 9, 398, 291, 14, 1815, 360, 1014, 7, 315, 1566, 9, 267, 1455, 275, 1566, 459, 1014, 418, 267, 291, 14, 2947, 8, 1014, 459, 633, 995, 283, 1014, 921, 5967, 15, 290, 13, 705, 6217, 267, 291, 14, 2947, 8, 1014, 459, 1131, 63, 875, 995, 283, 66, 565, 29, 6185, 358, 267, 291, 14, 2947, 8, 1014, 459, 765, 995, 283, 4030, 358, 267, 291, 14, 2947, 8, 1014, 459, 576, 995, 791, 1421, 356, 283, 1700, 3071, 267, 291, 14, 1815, 360, 2139, 7, 315, 1455, 9, 267, 2323, 275, 1455 ]
[ 7209, 492, 16704, 199, 199, 504, 1639, 14, 396, 492, 7640, 421, 199, 504, 1687, 12522, 14, 2828, 14, 15720, 492, 9319, 12522, 199, 199, 504, 2295, 14, 7546, 492, 664, 63, 808, 1617, 1258, 421, 199, 318, 1218, 63, 571, 837, 272, 1145, 275, 16704, 3460, 354, 3368, 339, 768, 571, 14, 4449, 2336, 290, 13, 705, 3678, 3102, 2968, 2970, 297, 283, 4030, 1105, 272, 347, 376, 63, 705, 837, 267, 746, 1722, 360, 5006, 6701, 358, 339, 372, 1145, 421, 199, 533, 16704, 774, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 571, 275, 1218, 63, 571, 342, 267, 291, 14, 1258, 275, 291, 14, 571, 14, 396, 63, 1258, 342, 339, 347, 511, 63, 705, 63, 2232, 8, 277, 304, 267, 1890, 275, 664, 63, 808, 1617, 1258, 342, 267, 1687, 12522, 275, 9319, 12522, 8, 277, 14, 571, 12, 1890, 29, 1258, 9, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 290, 13, 705, 6217, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 2947, 8, 552, 8, 1258, 14, 4368, 395, 413, 9, 398, 1566, 275, 1890, 14, 4368, 14, 1935, 8, 16, 9, 398, 291, 14, 1815, 360, 1971, 7, 315, 1566, 9, 267, 3178, 275, 1566, 459, 1971, 418, 267, 291, 14, 2947, 8, 2804, 459, 466, 995, 283, 3393, 358, 267, 291, 14, 2947, 8, 2804, 459, 585, 995, 283, 5006, 6701, 358, 267, 291, 14, 2947, 8, 1430, 459, 1896, 995, 298, 705, 531, 267, 291, 14, 2947, 8, 1430, 459, 1188, 995, 283, 3393, 26, 16509, 6701, 358, 267, 291, 14, 2947, 8, 1430, 459, 3119, 1359, 84, 995, 283, 2219, 14, 2828, 14, 15720, 14, 15720, 63, 2219, 14, 290, 63, 705, 358, 339, 347, 511, 63, 362, 8, 277, 304, 267, 1890, 275, 664, 63, 808, 1617, 1258, 342, 267, 1687, 12522, 275, 9319, 12522, 8, 277, 14, 571, 12, 1890, 29, 1258, 9, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 290, 13, 705, 10197, 1421, 29, 1700, 358, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 2947, 8, 552, 8, 1258, 14, 4368, 395, 413, 9, 398, 1566, 275, 1890, 14, 4368, 14, 1935, 8, 16, 9, 398, 291, 14, 1815, 360, 1014, 7, 315, 1566, 9, 267, 1455, 275, 1566, 459, 1014, 418, 267, 291, 14, 2947, 8, 1014, 459, 633, 995, 283, 1014, 921, 5967, 15, 290, 13, 705, 6217, 267, 291, 14, 2947, 8, 1014, 459, 1131, 63, 875, 995, 283, 1421, 29, 1700, 358, 267, 291, 14, 2947, 8, 1014, 459, 765, 995, 283, 2970, 358, 267, 291, 14, 2947, 8, 1014, 459, 576, 995, 5009, 267, 291, 14, 1815, 360, 2139, 7, 315, 1455, 9, 267, 2323, 275, 1455, 459, 2139, 418, 267, 291, 14, 1815, 360, 2714, 13, 4625, 7, 315, 2323, 12, 2323, 14, 1612, 1012, 267, 291, 14, 2947, 8, 2139, 459, 2714, 13, 4625, 995, 283, 16, 358, 267, 291, 14, 1815, 360, 2714, 13, 804, 7, 315, 2323, 12, 2323, 14, 1612, 1012, 267, 291, 14, 2947, 8, 2139, 459, 2714, 13, 804, 995, 4074, 267, 291, 14, 1815, 360, 4965, 7, 315, 2323, 12, 2323, 14, 1612, 1012, 267, 291, 14, 2947, 8, 2139, 459, 4965, 995, 283, 5967, 358, 267, 2589, 275, 1455, 459, 1813, 418, 267, 291, 14, 1815, 360, 6613, 63, 2339, 7, 315, 2589, 12, 2589, 14, 1612, 1012, 267, 291, 14, 2947, 8, 1813, 459, 6613, 63, 2339, 995, 283, 5967, 358, 267, 291, 14, 1815, 360, 6613, 63, 3657, 7, 315, 2589, 12, 2589, 14, 1612, 1012, 267, 291, 14, 2947, 8, 1813, 459, 6613, 63, 3657, 995, 283, 1257, 358, 339, 347, 511, 63, 362, 63, 1757, 8, 277, 304, 267, 1890, 275, 664, 63, 808, 1617, 1258, 342, 267, 1687, 12522, 275, 9319, 12522, 8, 277, 14, 571, 12, 1890, 29, 1258, 9, 267, 291, 14, 571, 14, 888, 459, 5287, 418, 275, 715, 267, 291, 14, 571, 14, 888, 459, 2864, 1206, 418, 275, 756, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 571, 14, 396, 63, 1258, 1252, 362, 12, 1994, 290, 13, 705, 10197, 1421, 29, 1700, 358, 267, 291, 14, 2947, 8, 552, 8, 1258, 14, 4368, 395, 378, 9, 339, 347, 511, 63, 362, 63, 1757, 63, 411, 12522, 8, 277, 304, 267, 1890, 275, 664, 63, 808, 1617, 1258, 342, 267, 1687, 12522, 275, 9319, 12522, 8, 277, 14, 571, 12, 1890, 29, 1258, 9, 267, 291, 14, 571, 14, 888, 459, 5287, 418, 275, 715, 267, 291, 14, 571, 14, 888, 459, 2864, 1206, 418, 275, 715, 267, 291, 14, 571, 14, 888, 459, 1938, 6773, 619, 418, 275, 791, 5287, 356, 715, 93, 267, 291, 14, 1855, 8, 3393, 12, 291, 14, 571, 14, 396, 63, 1258, 1252, 362, 12, 1994, 290, 13, 705, 10197, 1421, 29, 1700, 358, 267, 291, 14, 2947, 8, 552, 8, 1258, 14, 4368, 395, 413, 9, 339, 347, 511, 63, 1932, 8, 277, 304, 267, 1890, 275, 664, 63, 808, 1617, 1258, 342, 267, 1687, 12522, 275, 9319, 12522, 8, 277, 14, 571, 12, 1890, 29, 1258, 9, 267, 1177, 275, 291, 14, 1258, 14, 1932, 2336, 290, 13, 705, 10197, 66, 565, 29, 6185, 297, 666, 3713, 1421, 356, 283, 1700, 3071, 267, 291, 14, 2947, 8, 1310, 14, 1205, 63, 600, 12, 6891, 9, 267, 291, 14, 2947, 8, 552, 8, 1258, 14, 4368, 395, 413, 9, 398, 1566, 275, 1890, 14, 4368, 14, 1935, 8, 16, 9, 398, 291, 14, 1815, 360, 1014, 7, 315, 1566, 9, 267, 1455, 275, 1566, 459, 1014, 418, 267, 291, 14, 2947, 8, 1014, 459, 633, 995, 283, 1014, 921, 5967, 15, 290, 13, 705, 6217, 267, 291, 14, 2947, 8, 1014, 459, 1131, 63, 875, 995, 283, 66, 565, 29, 6185, 358, 267, 291, 14, 2947, 8, 1014, 459, 765, 995, 283, 4030, 358, 267, 291, 14, 2947, 8, 1014, 459, 576, 995, 791, 1421, 356, 283, 1700, 3071, 267, 291, 14, 1815, 360, 2139, 7, 315, 1455, 9, 267, 2323, 275, 1455, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
PyCQA/pylint
tests/functional/p/postponed_evaluation_pep585_error.py
2
3904
"""Test PEP 585 without postponed evaluation. Everything should fail. This check requires Python 3.7 or Python 3.8! Testing with 3.8 only, to support TypedDict. """ # pylint: disable=missing-docstring,unused-argument,unused-import,too-few-public-methods,invalid-name,inherit-non-class,unsupported-binary-operation,unused-variable,line-too-long import collections import dataclasses import typing from dataclasses import dataclass from typing import Any, Dict, NamedTuple, TypedDict, Union AliasInvalid = list[int] # [unsubscriptable-object] class CustomIntList(typing.List[int]): pass class CustomIntListError(list[int]): # [unsubscriptable-object] pass cast_variable = [1, 2, 3] cast_variable = typing.cast(list[int], cast_variable) # [unsubscriptable-object] T = typing.TypeVar("T", list[int], str) # [unsubscriptable-object] (lambda x: 2)(list[int]) # [unsubscriptable-object] # Check typing.NamedTuple CustomNamedTuple = typing.NamedTuple( "CustomNamedTuple", [("my_var", list[int])]) # [unsubscriptable-object] class CustomNamedTuple2(NamedTuple): my_var: list[int] # [unsubscriptable-object] class CustomNamedTuple3(typing.NamedTuple): my_var: list[int] # [unsubscriptable-object] # Check typing.TypedDict CustomTypedDict = TypedDict("CustomTypedDict", my_var=list[int]) # [unsubscriptable-object] CustomTypedDict2 = TypedDict("CustomTypedDict2", {"my_var": list[int]}) # [unsubscriptable-object] class CustomTypedDict3(TypedDict): my_var: list[int] # [unsubscriptable-object] class CustomTypedDict4(typing.TypedDict): my_var: list[int] # [unsubscriptable-object] # Check dataclasses def my_decorator(*args, **kwargs): def wraps(*args, **kwargs): pass return wraps @dataclass class CustomDataClass: my_var: list[int] # [unsubscriptable-object] @dataclasses.dataclass class CustomDataClass2: my_var: list[int] # [unsubscriptable-object] @dataclass() class CustomDataClass3: my_var: list[int] # [unsubscriptable-object] @my_decorator @dataclasses.dataclass class CustomDataClass4: my_var: list[int] # [unsubscriptable-object] var1: set[int] # [unsubscriptable-object] var2: collections.OrderedDict[str, int] # [unsubscriptable-object] var3: dict[str, list[int]] # [unsubscriptable-object,unsubscriptable-object] var4: Dict[str, list[int]] # [unsubscriptable-object] var5: dict[tuple[int, int], str] # [unsubscriptable-object,unsubscriptable-object] var6: Dict[tuple[int, int], str] # [unsubscriptable-object] var7: list[list[int]] # [unsubscriptable-object,unsubscriptable-object] var8: tuple[list[int]] # [unsubscriptable-object,unsubscriptable-object] var9: int | list[str | int] # [unsubscriptable-object] var10: Union[list[str], None] # [unsubscriptable-object] var11: Union[Union[list[int], int]] # [unsubscriptable-object] def func(arg: list[int]): # [unsubscriptable-object] pass def func2() -> list[int]: # [unsubscriptable-object] pass Alias2 = Union[list[str], None] # [unsubscriptable-object] Alias3 = Union[Union[list[int], int]] # [unsubscriptable-object] Alias5 = Dict[str, list[int]] # [unsubscriptable-object] Alias6 = int | list[int] # [unsubscriptable-object] Alias7 = list[list[int]] # [unsubscriptable-object,unsubscriptable-object] def func3(): AliasInvalid2 = list[int] # [unsubscriptable-object] cast_variable2 = [1, 2, 3] cast_variable2 = typing.cast(list[int], cast_variable2) # [unsubscriptable-object] var12: list[int] # [unsubscriptable-object] def func4(var=list[int]): # [unsubscriptable-object] pass def func5(arg1: list[int], arg2=set[int]): # [unsubscriptable-object,unsubscriptable-object] pass def func6(arg1: list[int], /, *args: tuple[str], arg2: set[int], **kwargs: dict[str, Any]): # -1:[unsubscriptable-object,unsubscriptable-object,unsubscriptable-object,unsubscriptable-object] pass
gpl-2.0
[ 624, 774, 13663, 959, 2426, 1928, 2963, 80, 28918, 11735, 14, 18414, 2127, 1077, 2449, 14, 199, 199, 2765, 1104, 5074, 2018, 650, 14, 23, 503, 2018, 650, 14, 24, 1, 199, 9029, 543, 650, 14, 24, 1454, 12, 370, 2291, 31906, 2141, 14, 199, 624, 199, 3, 4287, 26, 3507, 29, 4752, 13, 12485, 12, 8618, 13, 2094, 12, 8618, 13, 646, 12, 7354, 13, 70, 546, 13, 3455, 13, 2474, 12, 3197, 13, 354, 12, 6486, 13, 2865, 13, 533, 12, 15267, 13, 3008, 13, 5735, 12, 8618, 13, 1975, 12, 604, 13, 7354, 13, 2809, 199, 646, 5055, 199, 646, 666, 2888, 199, 646, 14090, 199, 504, 666, 2888, 492, 666, 533, 199, 504, 14090, 492, 6184, 12, 7448, 12, 16198, 7075, 12, 31906, 2141, 12, 15961, 421, 199, 14149, 3364, 275, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 533, 8388, 3241, 1296, 8, 29747, 14, 1296, 59, 442, 4682, 272, 986, 199, 199, 533, 8388, 3241, 1296, 547, 8, 513, 59, 442, 4682, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 272, 986, 199, 199, 2931, 63, 1975, 275, 359, 17, 12, 499, 12, 650, 61, 199, 2931, 63, 1975, 275, 14090, 14, 2931, 8, 513, 59, 442, 467, 9106, 63, 1975, 9, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 52, 275, 14090, 14, 804, 5894, 480, 52, 401, 769, 59, 442, 467, 620, 9, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 8, 2734, 671, 26, 499, 5130, 513, 59, 442, 566, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 421, 199, 3, 2670, 14090, 14, 7989, 7075, 199, 7223, 7989, 7075, 275, 14090, 14, 7989, 7075, 8, 272, 298, 7223, 7989, 7075, 401, 10003, 1662, 63, 1391, 401, 769, 59, 442, 24310, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 533, 8388, 7989, 7075, 18, 8, 7989, 7075, 304, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 533, 8388, 7989, 7075, 19, 8, 29747, 14, 7989, 7075, 304, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 421, 199, 3, 2670, 14090, 14, 22193, 2141, 199, 7223, 22193, 2141, 275, 31906, 2141, 480, 7223, 22193, 2141, 401, 3002, 63, 1391, 29, 513, 59, 442, 566, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 7223, 22193, 2141, 18, 275, 31906, 2141, 480, 7223, 22193, 2141, 18, 401, 2420, 1662, 63, 1391, 582, 769, 59, 442, 13412, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 533, 8388, 22193, 2141, 19, 8, 22193, 2141, 304, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 533, 8388, 22193, 2141, 20, 8, 29747, 14, 22193, 2141, 304, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 421, 199, 3, 2670, 666, 2888, 199, 318, 3002, 63, 11547, 2031, 589, 12, 1011, 958, 304, 272, 347, 14018, 2031, 589, 12, 1011, 958, 304, 267, 986, 272, 372, 14018, 199, 199, 32, 576, 533, 199, 533, 8388, 1451, 2543, 26, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 32, 576, 2888, 14, 576, 533, 199, 533, 8388, 1451, 2543, 18, 26, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 32, 576, 533, 342, 199, 533, 8388, 1451, 2543, 19, 26, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 32, 1662, 63, 11547, 199, 32, 576, 2888, 14, 576, 533, 199, 533, 8388, 1451, 2543, 20, 26, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 421, 199, 1391, 17, 26, 663, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 18, 26, 5055, 14, 16882, 59, 495, 12, 1109, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 19, 26, 1211, 59, 495, 12, 769, 59, 442, 2677, 221, 327, 359, 324, 30907, 461, 13, 785, 12, 324, 30907, 461, 13, 785, 61, 199, 1391, 20, 26, 7448, 59, 495, 12, 769, 59, 442, 2677, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 21, 26, 1211, 59, 2960, 59, 442, 12, 1109, 467, 620, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 12, 324, 30907, 461, 13, 785, 61, 199, 1391, 22, 26, 7448, 59, 2960, 59, 442, 12, 1109, 467, 620, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 23, 26, 769, 59, 513, 59, 442, 2677, 221, 327, 359, 324, 30907, 461, 13, 785, 12, 324, 30907, 461, 13, 785, 61, 199, 1391, 24, 26, 2008, 59, 513, 59, 442, 2677, 221, 327, 359, 324, 30907, 461, 13, 785, 12, 324, 30907, 461, 13, 785, 61, 199, 1391, 25, 26, 1109, 1204, 769, 59, 495, 1204, 1109, 61, 257, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 709, 26, 15961, 59, 513, 59, 495, 467, 488, 61, 257, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 845, 26, 15961, 59, 15540, 59, 513, 59, 442, 467, 1109, 2677, 257, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 318, 2562, 8, 1273, 26, 769, 59, 442, 4682, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 272, 986, 199, 199, 318, 2562, 18, 342, 1035, 769, 59, 442, 2189, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 272, 986, 199, 199, 14149, 18, 275, 15961, 59, 513, 59, 495, 467, 488, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 14149, 19, 275, 15961, 59, 15540, 59, 513, 59, 442, 467, 1109, 2677, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 14149, 21, 275, 7448, 59, 495, 12, 769, 59, 442, 2677, 221, 327, 359 ]
[ 774, 13663, 959, 2426, 1928, 2963, 80, 28918, 11735, 14, 18414, 2127, 1077, 2449, 14, 199, 199, 2765, 1104, 5074, 2018, 650, 14, 23, 503, 2018, 650, 14, 24, 1, 199, 9029, 543, 650, 14, 24, 1454, 12, 370, 2291, 31906, 2141, 14, 199, 624, 199, 3, 4287, 26, 3507, 29, 4752, 13, 12485, 12, 8618, 13, 2094, 12, 8618, 13, 646, 12, 7354, 13, 70, 546, 13, 3455, 13, 2474, 12, 3197, 13, 354, 12, 6486, 13, 2865, 13, 533, 12, 15267, 13, 3008, 13, 5735, 12, 8618, 13, 1975, 12, 604, 13, 7354, 13, 2809, 199, 646, 5055, 199, 646, 666, 2888, 199, 646, 14090, 199, 504, 666, 2888, 492, 666, 533, 199, 504, 14090, 492, 6184, 12, 7448, 12, 16198, 7075, 12, 31906, 2141, 12, 15961, 421, 199, 14149, 3364, 275, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 533, 8388, 3241, 1296, 8, 29747, 14, 1296, 59, 442, 4682, 272, 986, 199, 199, 533, 8388, 3241, 1296, 547, 8, 513, 59, 442, 4682, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 272, 986, 199, 199, 2931, 63, 1975, 275, 359, 17, 12, 499, 12, 650, 61, 199, 2931, 63, 1975, 275, 14090, 14, 2931, 8, 513, 59, 442, 467, 9106, 63, 1975, 9, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 52, 275, 14090, 14, 804, 5894, 480, 52, 401, 769, 59, 442, 467, 620, 9, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 8, 2734, 671, 26, 499, 5130, 513, 59, 442, 566, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 421, 199, 3, 2670, 14090, 14, 7989, 7075, 199, 7223, 7989, 7075, 275, 14090, 14, 7989, 7075, 8, 272, 298, 7223, 7989, 7075, 401, 10003, 1662, 63, 1391, 401, 769, 59, 442, 24310, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 533, 8388, 7989, 7075, 18, 8, 7989, 7075, 304, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 533, 8388, 7989, 7075, 19, 8, 29747, 14, 7989, 7075, 304, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 421, 199, 3, 2670, 14090, 14, 22193, 2141, 199, 7223, 22193, 2141, 275, 31906, 2141, 480, 7223, 22193, 2141, 401, 3002, 63, 1391, 29, 513, 59, 442, 566, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 7223, 22193, 2141, 18, 275, 31906, 2141, 480, 7223, 22193, 2141, 18, 401, 2420, 1662, 63, 1391, 582, 769, 59, 442, 13412, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 533, 8388, 22193, 2141, 19, 8, 22193, 2141, 304, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 533, 8388, 22193, 2141, 20, 8, 29747, 14, 22193, 2141, 304, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 421, 199, 3, 2670, 666, 2888, 199, 318, 3002, 63, 11547, 2031, 589, 12, 1011, 958, 304, 272, 347, 14018, 2031, 589, 12, 1011, 958, 304, 267, 986, 272, 372, 14018, 199, 199, 32, 576, 533, 199, 533, 8388, 1451, 2543, 26, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 32, 576, 2888, 14, 576, 533, 199, 533, 8388, 1451, 2543, 18, 26, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 32, 576, 533, 342, 199, 533, 8388, 1451, 2543, 19, 26, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 32, 1662, 63, 11547, 199, 32, 576, 2888, 14, 576, 533, 199, 533, 8388, 1451, 2543, 20, 26, 272, 3002, 63, 1391, 26, 769, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 421, 199, 1391, 17, 26, 663, 59, 442, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 18, 26, 5055, 14, 16882, 59, 495, 12, 1109, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 19, 26, 1211, 59, 495, 12, 769, 59, 442, 2677, 221, 327, 359, 324, 30907, 461, 13, 785, 12, 324, 30907, 461, 13, 785, 61, 199, 1391, 20, 26, 7448, 59, 495, 12, 769, 59, 442, 2677, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 21, 26, 1211, 59, 2960, 59, 442, 12, 1109, 467, 620, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 12, 324, 30907, 461, 13, 785, 61, 199, 1391, 22, 26, 7448, 59, 2960, 59, 442, 12, 1109, 467, 620, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 23, 26, 769, 59, 513, 59, 442, 2677, 221, 327, 359, 324, 30907, 461, 13, 785, 12, 324, 30907, 461, 13, 785, 61, 199, 1391, 24, 26, 2008, 59, 513, 59, 442, 2677, 221, 327, 359, 324, 30907, 461, 13, 785, 12, 324, 30907, 461, 13, 785, 61, 199, 1391, 25, 26, 1109, 1204, 769, 59, 495, 1204, 1109, 61, 257, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 709, 26, 15961, 59, 513, 59, 495, 467, 488, 61, 257, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 1391, 845, 26, 15961, 59, 15540, 59, 513, 59, 442, 467, 1109, 2677, 257, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 199, 318, 2562, 8, 1273, 26, 769, 59, 442, 4682, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 272, 986, 199, 199, 318, 2562, 18, 342, 1035, 769, 59, 442, 2189, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 272, 986, 199, 199, 14149, 18, 275, 15961, 59, 513, 59, 495, 467, 488, 61, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 14149, 19, 275, 15961, 59, 15540, 59, 513, 59, 442, 467, 1109, 2677, 221, 327, 359, 324, 30907, 461, 13, 785, 61, 199, 14149, 21, 275, 7448, 59, 495, 12, 769, 59, 442, 2677, 221, 327, 359, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
stefanfoulis/django-filer-test
filer/models/filer_file_storage.py
2
1383
from django.core.files.storage import FileSystemStorage from django.utils.text import get_valid_filename as get_valid_filename_django from django.template.defaultfilters import slugify from django.utils.encoding import force_unicode, smart_str import os import datetime from filer.settings import FILER_PUBLICMEDIA_PREFIX, FILER_PRIVATEMEDIA_PREFIX from django.core.exceptions import ImproperlyConfigured def get_valid_filename(s): ''' like the regular get_valid_filename, but also slugifies away umlauts and stuff. ''' s = get_valid_filename_django(s) filename, ext = os.path.splitext(s) filename = slugify(filename) ext = slugify(ext) if ext: return u"%s.%s" % (filename, ext) else: return u"%s" % (filename,) # TODO: public/private media is going to change with a custom FileField and Storate # class that supports files that are not in MEDIA_ROOT def get_directory_name(instance, filename): ''' returns the path relative to the base path (media root ''' datepart = force_unicode(datetime.datetime.now().strftime(smart_str("%Y/%m/%d"))) if instance.is_public: private_or_public = FILER_PUBLICMEDIA_PREFIX else: private_or_public = FILER_PRIVATEMEDIA_PREFIX return os.path.normpath( os.path.join(private_or_public, datepart, get_valid_filename(filename)) )
mit
[ 504, 1639, 14, 1018, 14, 1725, 14, 3494, 492, 23754, 6408, 199, 504, 1639, 14, 1208, 14, 505, 492, 664, 63, 1078, 63, 1501, 465, 664, 63, 1078, 63, 1501, 63, 1176, 199, 504, 1639, 14, 1160, 14, 885, 4273, 492, 29864, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 12, 11179, 63, 495, 199, 646, 747, 199, 646, 2197, 199, 504, 570, 82, 14, 1751, 492, 16444, 540, 63, 19476, 13669, 63, 6351, 12, 16444, 540, 63, 18748, 13669, 63, 6351, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 199, 318, 664, 63, 1078, 63, 1501, 8, 83, 304, 272, 1449, 272, 2839, 314, 5578, 664, 63, 1078, 63, 1501, 12, 1325, 2597, 8889, 11594, 13437, 272, 28236, 416, 14608, 436, 8292, 14, 272, 1449, 272, 308, 275, 664, 63, 1078, 63, 1501, 63, 1176, 8, 83, 9, 272, 1788, 12, 1599, 275, 747, 14, 515, 14, 7973, 8, 83, 9, 272, 1788, 275, 29864, 8, 1501, 9, 272, 1599, 275, 29864, 8, 832, 9, 272, 340, 1599, 26, 267, 372, 399, 6808, 83, 4111, 83, 2, 450, 334, 1501, 12, 1599, 9, 272, 587, 26, 267, 372, 399, 6808, 83, 2, 450, 334, 1501, 4258, 199, 199, 3, 3254, 26, 4575, 15, 4239, 5898, 365, 9995, 370, 1570, 543, 282, 3537, 3814, 792, 436, 1933, 269, 323, 199, 3, 755, 1021, 626, 5171, 1584, 626, 787, 440, 315, 31460, 63, 5441, 199, 318, 664, 63, 3619, 63, 354, 8, 842, 12, 1788, 304, 272, 1449, 272, 2529, 314, 931, 3847, 370, 314, 1300, 931, 334, 4603, 1738, 272, 1449, 272, 1434, 2064, 275, 3542, 63, 2975, 8, 2083, 14, 2083, 14, 2131, 1252, 6205, 8, 7853, 63, 495, 3647, 57, 3149, 77, 3149, 68, 13324, 272, 340, 1256, 14, 374, 63, 3455, 26, 267, 5726, 63, 269, 63, 3455, 275, 16444, 540, 63, 19476, 13669, 63, 6351, 272, 587, 26, 267, 5726, 63, 269, 63, 3455, 275, 16444, 540, 63, 18748, 13669, 63, 6351, 272, 372, 747, 14, 515, 14, 9267, 8, 747, 14, 515, 14, 904, 8, 4239, 63, 269, 63, 3455, 12, 1434, 2064, 12, 664, 63, 1078, 63, 1501, 8, 1501, 430, 776, 26339, 27404, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 1018, 14, 1725, 14, 3494, 492, 23754, 6408, 199, 504, 1639, 14, 1208, 14, 505, 492, 664, 63, 1078, 63, 1501, 465, 664, 63, 1078, 63, 1501, 63, 1176, 199, 504, 1639, 14, 1160, 14, 885, 4273, 492, 29864, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 12, 11179, 63, 495, 199, 646, 747, 199, 646, 2197, 199, 504, 570, 82, 14, 1751, 492, 16444, 540, 63, 19476, 13669, 63, 6351, 12, 16444, 540, 63, 18748, 13669, 63, 6351, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 199, 318, 664, 63, 1078, 63, 1501, 8, 83, 304, 272, 1449, 272, 2839, 314, 5578, 664, 63, 1078, 63, 1501, 12, 1325, 2597, 8889, 11594, 13437, 272, 28236, 416, 14608, 436, 8292, 14, 272, 1449, 272, 308, 275, 664, 63, 1078, 63, 1501, 63, 1176, 8, 83, 9, 272, 1788, 12, 1599, 275, 747, 14, 515, 14, 7973, 8, 83, 9, 272, 1788, 275, 29864, 8, 1501, 9, 272, 1599, 275, 29864, 8, 832, 9, 272, 340, 1599, 26, 267, 372, 399, 6808, 83, 4111, 83, 2, 450, 334, 1501, 12, 1599, 9, 272, 587, 26, 267, 372, 399, 6808, 83, 2, 450, 334, 1501, 4258, 199, 199, 3, 3254, 26, 4575, 15, 4239, 5898, 365, 9995, 370, 1570, 543, 282, 3537, 3814, 792, 436, 1933, 269, 323, 199, 3, 755, 1021, 626, 5171, 1584, 626, 787, 440, 315, 31460, 63, 5441, 199, 318, 664, 63, 3619, 63, 354, 8, 842, 12, 1788, 304, 272, 1449, 272, 2529, 314, 931, 3847, 370, 314, 1300, 931, 334, 4603, 1738, 272, 1449, 272, 1434, 2064, 275, 3542, 63, 2975, 8, 2083, 14, 2083, 14, 2131, 1252, 6205, 8, 7853, 63, 495, 3647, 57, 3149, 77, 3149, 68, 13324, 272, 340, 1256, 14, 374, 63, 3455, 26, 267, 5726, 63, 269, 63, 3455, 275, 16444, 540, 63, 19476, 13669, 63, 6351, 272, 587, 26, 267, 5726, 63, 269, 63, 3455, 275, 16444, 540, 63, 18748, 13669, 63, 6351, 272, 372, 747, 14, 515, 14, 9267, 8, 747, 14, 515, 14, 904, 8, 4239, 63, 269, 63, 3455, 12, 1434, 2064, 12, 664, 63, 1078, 63, 1501, 8, 1501, 430, 776, 26339, 27404, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
MechanisM/musicdb
musicdb/common/management/commands/initial_import_fixups.py
1
3570
from django.core.management.base import NoArgsCommand from musicdb.classical.models import * class Command(NoArgsCommand): def handle_noargs(self, **options): work_pairs = ( ('felix-mendelssohn', ('string-quartet-in-e-flat', 'string-quartet-in-e-flat-1')), ('ludvig-van-beethoven', ('piano-trio-in-e-flat-triosatz', 'piano-trio-in-e-flat-triosatz-1')), ('fryderyk-chopin', ('ballade-no-4-op-52-in-f-minor', 'ballade-no-4-op-52-in-f-minor-1')), ) for a, (b, c) in work_pairs: try: Work.objects.get(composer__slug=a, slug=b).merge_from( Work.objects.get(composer__slug=a, slug=c) ) except Work.DoesNotExist: print "W: Skipping", a, b, c ensemble_pairs = ( ('chamber-orchestra-of-europe', 'chamber-orchestra-of-europe-1'), ('orquestra-sinfonica-haydn-de-bolzano-e-trento', 'orquestra-sinfonica-haydn-de-bolzano-e-trento-1'), ('i-solisti-veneti', 'i-solisti-veneti-1'), ('london-symphony-orchestra', 'london-symphony-orchestra-principals'), ('vienna-philharmonic-orchestra', 'wiener-philharmoniker'), ) for a, b in ensemble_pairs: try: Ensemble.objects.get(slug=a).merge_from(Ensemble.objects.get(slug=b)) except Ensemble.DoesNotExist: print "W: Skipping", a, b relationships = { 'arrangement': ( ('orchesographie', 'capriol-suite-for-string-orchestra'), ), 'revision': ( ('brandenburg-concerto-no-5-early-version-bwv-1050a-in-d', 'brandenburg-concerto-no-5-bwv-1050-in-d'), ('brandenburg-concerto-no-1-early-version-bwv-1046a-in-f', 'brandenburg-concerto-no-1-bwv-1046-in-f'), ), 'variations': ( ('twelve-variations-on-ah-vous-dirai-je-maman-k-265-in-c', 'romantic-piece-op-18'), ), 'transcription': ( ('brandenburg-concerto-no-4-bwv-1049-in-g', 'concerto-for-harpsichord-and-two-recorders-transcription-of-brandenburg-concerto-no-4-bwv-1057'), ('violin-concerto-bwv-1041-in-a-minor', 'harpsichord-concerto-bwv-1058r-in-g-minor'), ('violin-concerto-bwv-1042-in-e', 'harpsichord-concerto-bwv-1054-in-d'), ('concerto-for-oboe-and-violin-bwv-1060r-in-g-minor', 'concerto-for-two-harpsichords-bwv-1060-in-c-minor'), ('double-violin-concerto-bwv-1043-in-d-minor', 'concerto-for-two-harpsichords-bwv-1062-in-c-minor'), ('concerto-for-three-violins-bwv-1064r-in-d', 'concerto-for-three-harpsichords-bwv-1064-in-c'), ('concerto-for-four-violins-op-3-no-10-rv-580-in-b-minor', 'concerto-for-three-harpsichords-bwv-1064-in-c'), ('concerto-for-oboe-damore-bwv-1055r-in-a', 'harpsichord-concerto-bwv-1055-in-a'), ) } for nature, data in relationships.items(): for x, y in data: WorkRelationship.objects.create( source=Work.objects.get(slug=x), derived=Work.objects.get(slug=y), nature=nature, ) to_delete = () for klass, pks in to_delete: for pk in pks: try: klass.objects.get(pk=pk).delete() except klass.DoesNotExist: print "W: Skipping deletion of", klass, pk
agpl-3.0
[ 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 3091, 6213, 3110, 199, 199, 504, 30891, 697, 14, 12334, 915, 14, 992, 492, 627, 199, 199, 533, 5817, 8, 27099, 3110, 304, 272, 347, 2429, 63, 889, 589, 8, 277, 12, 1011, 1419, 304, 398, 1736, 63, 7322, 275, 334, 288, 661, 771, 20528, 13, 1410, 2264, 25479, 6164, 297, 661, 875, 13, 30438, 10288, 13, 262, 13, 69, 13, 7088, 297, 283, 875, 13, 30438, 10288, 13, 262, 13, 69, 13, 7088, 13, 17, 3855, 288, 661, 76, 1181, 433, 71, 13, 20662, 13, 19446, 273, 79, 1856, 297, 661, 1038, 8143, 13, 599, 79, 13, 262, 13, 69, 13, 7088, 13, 599, 736, 10214, 297, 283, 1038, 8143, 13, 599, 79, 13, 262, 13, 69, 13, 7088, 13, 599, 736, 10214, 13, 17, 3855, 288, 661, 70, 651, 424, 89, 75, 13, 335, 411, 262, 297, 661, 4982, 17236, 13, 889, 13, 20, 13, 411, 13, 2528, 13, 262, 13, 70, 13, 11067, 297, 283, 4982, 17236, 13, 889, 13, 20, 13, 411, 13, 2528, 13, 262, 13, 70, 13, 11067, 13, 17, 3855, 267, 776, 398, 367, 282, 12, 334, 66, 12, 286, 9, 315, 1736, 63, 7322, 26, 288, 862, 26, 355, 9361, 14, 1462, 14, 362, 8, 7784, 332, 363, 5464, 29, 65, 12, 8889, 29, 66, 680, 5628, 63, 504, 8, 490, 9361, 14, 1462, 14, 362, 8, 7784, 332, 363, 5464, 29, 65, 12, 8889, 29, 67, 9, 355, 776, 288, 871, 9361, 14, 7400, 26, 355, 870, 298, 55, 26, 8232, 4073, 401, 282, 12, 330, 12, 286, 398, 19965, 63, 7322, 275, 334, 288, 661, 335, 455, 605, 13, 269, 595, 14183, 13, 1618, 13, 69, 12646, 297, 283, 335, 455, 605, 13, 269, 595, 14183, 13, 1618, 13, 69, 12646, 13, 17, 659, 288, 661, 269, 613, 345, 13, 83, 4904, 12732, 65, 13, 72, 1187, 4272, 13, 271, 13, 23484, 90, 8143, 13, 69, 13, 84, 640, 79, 297, 283, 269, 613, 345, 13, 83, 4904, 12732, 65, 13, 72, 1187, 4272, 13, 271, 13, 23484, 90, 8143, 13, 69, 13, 84, 640, 79, 13, 17, 659, 288, 661, 73, 13, 1152, 513, 73, 13, 1856, 69, 280, 297, 283, 73, 13, 1152, 513, 73, 13, 1856, 69, 280, 13, 17, 659, 288, 661, 5298, 13196, 13, 1786, 311, 72, 5220, 13, 269, 595, 14183, 297, 283, 5298, 13196, 13, 1786, 311, 72, 5220, 13, 269, 595, 14183, 13, 2700, 10352, 2551, 659, 288, 661, 433, 287, 3540, 13, 838, 382, 8210, 16082, 13, 269, 595, 14183, 297, 283, 14249, 727, 13, 838, 382, 8210, 2106, 73, 2570, 659, 267, 776, 398, 367, 282, 12, 330, 315, 19965, 63, 7322, 26, 288, 862, 26, 355, 3447, 8834, 14, 1462, 14, 362, 8, 5464, 29, 65, 680, 5628, 63, 504, 8, 1327, 8834, 14, 1462, 14, 362, 8, 5464, 29, 66, 430, 288, 871, 3447, 8834, 14, 7400, 26, 355, 870, 298, 55, 26, 8232, 4073, 401, 282, 12, 330, 398, 20045, 275, 469, 288, 283, 285, 1842, 434, 356, 334, 355, 661, 269, 12253, 79, 2180, 1873, 297, 283, 2874, 322, 393, 13, 5768, 13, 509, 13, 875, 13, 269, 595, 14183, 659, 288, 2318, 288, 283, 5792, 356, 334, 355, 661, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 21, 13, 21423, 13, 1023, 13, 12415, 86, 13, 709, 1400, 65, 13, 262, 13, 68, 297, 283, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 21, 13, 12415, 86, 13, 709, 1400, 13, 262, 13, 68, 659, 355, 661, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 17, 13, 21423, 13, 1023, 13, 12415, 86, 13, 709, 2466, 65, 13, 262, 13, 70, 297, 283, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 17, 13, 12415, 86, 13, 709, 2466, 13, 262, 13, 70, 659, 288, 2318, 288, 283, 3808, 1298, 356, 334, 355, 661, 8122, 15320, 13, 3808, 1298, 13, 265, 13, 11326, 13, 86, 1785, 13, 328, 345, 73, 13, 6532, 13, 391, 1237, 13, 75, 13, 13730, 13, 262, 13, 67, 297, 283, 20971, 764, 13, 20082, 13, 411, 13, 1085, 659, 288, 2318, 288, 283, 3936, 956, 356, 334, 355, 661, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 20, 13, 12415, 86, 13, 709, 1887, 13, 262, 13, 71, 297, 283, 388, 2247, 475, 13, 509, 13, 8210, 18645, 335, 2181, 13, 460, 13, 5601, 13, 264, 989, 7735, 13, 3936, 956, 13, 1618, 13, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 20, 13, 12415, 86, 13, 709, 1641, 659, 355, 661, 433, 393, 262, 13, 388, 2247, 475, 13, 12415, 86, 13, 709, 2953, 13, 262, 13, 65, 13, 11067, 297, 283, 8210, 18645, 335, 2181, 13, 388, 2247, 475, 13, 12415, 86, 13, 709, 2010, 82, 13, 262, 13, 71, 13, 11067, 659, 355, 661, 433, 393, 262, 13, 388, 2247, 475, 13, 12415, 86, 13, 709, 2260, 13, 262, 13, 69, 297, 283, 8210, 18645, 335, 2181, 13, 388, 2247, 475, 13, 12415, 86, 13, 709, 1477, 13, 262, 13, 68, 659, 355, 661, 388, 2247, 475, 13, 509, 13, 79, 656, 69, 13, 460, 13, 433, 393, 262, 13, 12415, 86, 13, 709, 2259, 82, 13, 262, 13, 71, 13, 11067, 297, 283, 388, 2247, 475, 13, 509, 13, 5601, 13, 8210, 18645, 335, 5630, 13, 12415, 86, 13, 709, 2259, 13, 262, 13, 67, 13, 11067, 659, 355, 661, 3157, 13, 433, 393, 262, 13, 388, 2247, 475, 13, 12415, 86, 13, 709, 2824, 13, 262, 13, 68, 13, 11067, 297, 283, 388, 2247, 475, 13, 509, 13, 5601, 13, 8210, 18645, 335, 5630, 13, 12415, 86, 13, 709, 2789, 13, 262, 13, 67, 13, 11067, 659, 355, 661, 388, 2247, 475, 13, 509, 13, 10480, 13, 433, 393, 3617, 13, 12415, 86, 13, 709, 772, 82, 13, 262, 13, 68, 297, 283, 388, 2247, 475, 13, 509, 13, 10480, 13, 8210, 18645, 335, 5630, 13, 12415, 86, 13, 709, 772, 13, 262, 13, 67, 659, 355, 661, 388, 2247, 475, 13, 509 ]
[ 1639, 14, 1018, 14, 8110, 14, 1095, 492, 3091, 6213, 3110, 199, 199, 504, 30891, 697, 14, 12334, 915, 14, 992, 492, 627, 199, 199, 533, 5817, 8, 27099, 3110, 304, 272, 347, 2429, 63, 889, 589, 8, 277, 12, 1011, 1419, 304, 398, 1736, 63, 7322, 275, 334, 288, 661, 771, 20528, 13, 1410, 2264, 25479, 6164, 297, 661, 875, 13, 30438, 10288, 13, 262, 13, 69, 13, 7088, 297, 283, 875, 13, 30438, 10288, 13, 262, 13, 69, 13, 7088, 13, 17, 3855, 288, 661, 76, 1181, 433, 71, 13, 20662, 13, 19446, 273, 79, 1856, 297, 661, 1038, 8143, 13, 599, 79, 13, 262, 13, 69, 13, 7088, 13, 599, 736, 10214, 297, 283, 1038, 8143, 13, 599, 79, 13, 262, 13, 69, 13, 7088, 13, 599, 736, 10214, 13, 17, 3855, 288, 661, 70, 651, 424, 89, 75, 13, 335, 411, 262, 297, 661, 4982, 17236, 13, 889, 13, 20, 13, 411, 13, 2528, 13, 262, 13, 70, 13, 11067, 297, 283, 4982, 17236, 13, 889, 13, 20, 13, 411, 13, 2528, 13, 262, 13, 70, 13, 11067, 13, 17, 3855, 267, 776, 398, 367, 282, 12, 334, 66, 12, 286, 9, 315, 1736, 63, 7322, 26, 288, 862, 26, 355, 9361, 14, 1462, 14, 362, 8, 7784, 332, 363, 5464, 29, 65, 12, 8889, 29, 66, 680, 5628, 63, 504, 8, 490, 9361, 14, 1462, 14, 362, 8, 7784, 332, 363, 5464, 29, 65, 12, 8889, 29, 67, 9, 355, 776, 288, 871, 9361, 14, 7400, 26, 355, 870, 298, 55, 26, 8232, 4073, 401, 282, 12, 330, 12, 286, 398, 19965, 63, 7322, 275, 334, 288, 661, 335, 455, 605, 13, 269, 595, 14183, 13, 1618, 13, 69, 12646, 297, 283, 335, 455, 605, 13, 269, 595, 14183, 13, 1618, 13, 69, 12646, 13, 17, 659, 288, 661, 269, 613, 345, 13, 83, 4904, 12732, 65, 13, 72, 1187, 4272, 13, 271, 13, 23484, 90, 8143, 13, 69, 13, 84, 640, 79, 297, 283, 269, 613, 345, 13, 83, 4904, 12732, 65, 13, 72, 1187, 4272, 13, 271, 13, 23484, 90, 8143, 13, 69, 13, 84, 640, 79, 13, 17, 659, 288, 661, 73, 13, 1152, 513, 73, 13, 1856, 69, 280, 297, 283, 73, 13, 1152, 513, 73, 13, 1856, 69, 280, 13, 17, 659, 288, 661, 5298, 13196, 13, 1786, 311, 72, 5220, 13, 269, 595, 14183, 297, 283, 5298, 13196, 13, 1786, 311, 72, 5220, 13, 269, 595, 14183, 13, 2700, 10352, 2551, 659, 288, 661, 433, 287, 3540, 13, 838, 382, 8210, 16082, 13, 269, 595, 14183, 297, 283, 14249, 727, 13, 838, 382, 8210, 2106, 73, 2570, 659, 267, 776, 398, 367, 282, 12, 330, 315, 19965, 63, 7322, 26, 288, 862, 26, 355, 3447, 8834, 14, 1462, 14, 362, 8, 5464, 29, 65, 680, 5628, 63, 504, 8, 1327, 8834, 14, 1462, 14, 362, 8, 5464, 29, 66, 430, 288, 871, 3447, 8834, 14, 7400, 26, 355, 870, 298, 55, 26, 8232, 4073, 401, 282, 12, 330, 398, 20045, 275, 469, 288, 283, 285, 1842, 434, 356, 334, 355, 661, 269, 12253, 79, 2180, 1873, 297, 283, 2874, 322, 393, 13, 5768, 13, 509, 13, 875, 13, 269, 595, 14183, 659, 288, 2318, 288, 283, 5792, 356, 334, 355, 661, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 21, 13, 21423, 13, 1023, 13, 12415, 86, 13, 709, 1400, 65, 13, 262, 13, 68, 297, 283, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 21, 13, 12415, 86, 13, 709, 1400, 13, 262, 13, 68, 659, 355, 661, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 17, 13, 21423, 13, 1023, 13, 12415, 86, 13, 709, 2466, 65, 13, 262, 13, 70, 297, 283, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 17, 13, 12415, 86, 13, 709, 2466, 13, 262, 13, 70, 659, 288, 2318, 288, 283, 3808, 1298, 356, 334, 355, 661, 8122, 15320, 13, 3808, 1298, 13, 265, 13, 11326, 13, 86, 1785, 13, 328, 345, 73, 13, 6532, 13, 391, 1237, 13, 75, 13, 13730, 13, 262, 13, 67, 297, 283, 20971, 764, 13, 20082, 13, 411, 13, 1085, 659, 288, 2318, 288, 283, 3936, 956, 356, 334, 355, 661, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 20, 13, 12415, 86, 13, 709, 1887, 13, 262, 13, 71, 297, 283, 388, 2247, 475, 13, 509, 13, 8210, 18645, 335, 2181, 13, 460, 13, 5601, 13, 264, 989, 7735, 13, 3936, 956, 13, 1618, 13, 66, 1312, 848, 29291, 13, 388, 2247, 475, 13, 889, 13, 20, 13, 12415, 86, 13, 709, 1641, 659, 355, 661, 433, 393, 262, 13, 388, 2247, 475, 13, 12415, 86, 13, 709, 2953, 13, 262, 13, 65, 13, 11067, 297, 283, 8210, 18645, 335, 2181, 13, 388, 2247, 475, 13, 12415, 86, 13, 709, 2010, 82, 13, 262, 13, 71, 13, 11067, 659, 355, 661, 433, 393, 262, 13, 388, 2247, 475, 13, 12415, 86, 13, 709, 2260, 13, 262, 13, 69, 297, 283, 8210, 18645, 335, 2181, 13, 388, 2247, 475, 13, 12415, 86, 13, 709, 1477, 13, 262, 13, 68, 659, 355, 661, 388, 2247, 475, 13, 509, 13, 79, 656, 69, 13, 460, 13, 433, 393, 262, 13, 12415, 86, 13, 709, 2259, 82, 13, 262, 13, 71, 13, 11067, 297, 283, 388, 2247, 475, 13, 509, 13, 5601, 13, 8210, 18645, 335, 5630, 13, 12415, 86, 13, 709, 2259, 13, 262, 13, 67, 13, 11067, 659, 355, 661, 3157, 13, 433, 393, 262, 13, 388, 2247, 475, 13, 12415, 86, 13, 709, 2824, 13, 262, 13, 68, 13, 11067, 297, 283, 388, 2247, 475, 13, 509, 13, 5601, 13, 8210, 18645, 335, 5630, 13, 12415, 86, 13, 709, 2789, 13, 262, 13, 67, 13, 11067, 659, 355, 661, 388, 2247, 475, 13, 509, 13, 10480, 13, 433, 393, 3617, 13, 12415, 86, 13, 709, 772, 82, 13, 262, 13, 68, 297, 283, 388, 2247, 475, 13, 509, 13, 10480, 13, 8210, 18645, 335, 5630, 13, 12415, 86, 13, 709, 772, 13, 262, 13, 67, 659, 355, 661, 388, 2247, 475, 13, 509, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lgiordani/punch
tests/script/test_complex_serializers.py
1
2035
import pytest pytestmark = pytest.mark.slow version_file_content = """ major = 1 minor = 0 patch = 0 """ config_file_content = """ __config_version__ = 1 GLOBALS = { 'serializer': { 'semver': { 'search': 'Next Release', 'replace': '{{major}}.{{minor}}.{{patch}}' } }, } FILES = ["CHANGELOG.rst"] VERSION = ['major', 'minor', 'patch'] """ config_file_content_dedicated_serializer = """ __config_version__ = 1 GLOBALS = { 'serializer': '{{major}}.{{minor}}.{{patch}}', } FILES = [ { 'path': "CHANGELOG.rst", 'serializer': { 'semver': { 'search': 'Next Release', 'replace': '{{major}}.{{minor}}.{{patch}}' }, } } ] VERSION = ['major', 'minor', 'patch'] """ changelog = """ Changelog ========= Next Release ------------ **Added** * Added some new feature """ expected_changelog = """ Changelog ========= 2.0.0 ------------ **Added** * Added some new feature """ def test_complex_serializer(test_environment): test_environment.ensure_file_is_present("CHANGELOG.rst", changelog) test_environment.ensure_file_is_present( "punch_version.py", version_file_content ) test_environment.ensure_file_is_present( "punch_config.py", config_file_content ) test_environment.call(["punch", "--part", "major"]) assert test_environment.get_file_content("CHANGELOG.rst") == \ expected_changelog def test_complex_serializer_dedicated_serializers(test_environment): test_environment.ensure_file_is_present("CHANGELOG.rst", changelog) test_environment.ensure_file_is_present( "punch_version.py", version_file_content ) test_environment.ensure_file_is_present( "punch_config.py", config_file_content_dedicated_serializer ) test_environment.call(["punch", "--part", "major"]) assert test_environment.get_file_content("CHANGELOG.rst") == \ expected_changelog
isc
[ 646, 4613, 199, 199, 4462, 1657, 275, 4613, 14, 1657, 14, 14362, 199, 199, 1023, 63, 493, 63, 1317, 275, 408, 199, 8452, 275, 413, 199, 11067, 275, 378, 199, 2068, 275, 378, 199, 624, 199, 199, 888, 63, 493, 63, 1317, 275, 408, 199, 363, 888, 63, 1023, 363, 275, 413, 199, 199, 13808, 51, 275, 469, 272, 283, 8349, 356, 469, 267, 283, 21678, 422, 356, 469, 288, 283, 1733, 356, 283, 5765, 17646, 297, 288, 283, 1814, 356, 11400, 8452, 4863, 14, 3638, 11067, 4863, 14, 3638, 2068, 4863, 7, 267, 789, 272, 1660, 199, 93, 199, 199, 9472, 275, 2097, 16062, 4947, 14, 8332, 937, 199, 199, 4612, 275, 788, 8452, 297, 283, 11067, 297, 283, 2068, 418, 199, 624, 199, 199, 888, 63, 493, 63, 1317, 63, 271, 24489, 63, 8349, 275, 408, 199, 363, 888, 63, 1023, 363, 275, 413, 199, 199, 13808, 51, 275, 469, 272, 283, 8349, 356, 11400, 8452, 4863, 14, 3638, 11067, 4863, 14, 3638, 2068, 29223, 199, 93, 199, 199, 9472, 275, 359, 272, 469, 267, 283, 515, 356, 298, 16062, 4947, 14, 8332, 401, 267, 283, 8349, 356, 469, 288, 283, 21678, 422, 356, 469, 355, 283, 1733, 356, 283, 5765, 17646, 297, 355, 283, 1814, 356, 11400, 8452, 4863, 14, 3638, 11067, 4863, 14, 3638, 2068, 4863, 7, 288, 1660, 267, 789, 272, 789, 199, 61, 199, 199, 4612, 275, 788, 8452, 297, 283, 11067, 297, 283, 2068, 418, 199, 624, 199, 199, 23436, 275, 408, 199, 4001, 793, 199, 15495, 199, 199, 5765, 17646, 199, 4559, 199, 538, 20201, 538, 199, 199, 10, 16230, 2005, 892, 3878, 199, 624, 199, 199, 2062, 63, 23436, 275, 408, 199, 4001, 793, 199, 15495, 199, 199, 18, 14, 16, 14, 16, 199, 4559, 199, 538, 20201, 538, 199, 199, 10, 16230, 2005, 892, 3878, 199, 624, 421, 199, 318, 511, 63, 5254, 63, 8349, 8, 396, 63, 5418, 304, 272, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 480, 16062, 4947, 14, 8332, 401, 1570, 793, 9, 339, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 8, 267, 298, 80, 4689, 63, 1023, 14, 647, 401, 267, 1015, 63, 493, 63, 1317, 272, 776, 339, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 8, 267, 298, 80, 4689, 63, 888, 14, 647, 401, 267, 1101, 63, 493, 63, 1317, 272, 776, 339, 511, 63, 5418, 14, 1250, 5234, 80, 4689, 401, 4320, 2064, 401, 298, 8452, 3135, 339, 702, 511, 63, 5418, 14, 362, 63, 493, 63, 1317, 480, 16062, 4947, 14, 8332, 531, 508, 971, 267, 1420, 63, 23436, 421, 199, 318, 511, 63, 5254, 63, 8349, 63, 271, 24489, 63, 12844, 8, 396, 63, 5418, 304, 272, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 480, 16062, 4947, 14, 8332, 401, 1570, 793, 9, 339, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 8, 267, 298, 80, 4689, 63, 1023, 14, 647, 401, 267, 1015, 63, 493, 63, 1317, 272, 776, 339, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 8, 267, 298, 80, 4689, 63, 888, 14, 647, 401, 267, 1101, 63, 493, 63, 1317, 63, 271, 24489, 63, 8349, 272, 776, 339, 511, 63, 5418, 14, 1250, 5234, 80, 4689, 401, 4320, 2064, 401, 298, 8452, 3135, 339, 702, 511, 63, 5418, 14, 362, 63, 493, 63, 1317, 480, 16062, 4947, 14, 8332, 531, 508, 971, 267, 1420, 63, 23436, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4613, 199, 199, 4462, 1657, 275, 4613, 14, 1657, 14, 14362, 199, 199, 1023, 63, 493, 63, 1317, 275, 408, 199, 8452, 275, 413, 199, 11067, 275, 378, 199, 2068, 275, 378, 199, 624, 199, 199, 888, 63, 493, 63, 1317, 275, 408, 199, 363, 888, 63, 1023, 363, 275, 413, 199, 199, 13808, 51, 275, 469, 272, 283, 8349, 356, 469, 267, 283, 21678, 422, 356, 469, 288, 283, 1733, 356, 283, 5765, 17646, 297, 288, 283, 1814, 356, 11400, 8452, 4863, 14, 3638, 11067, 4863, 14, 3638, 2068, 4863, 7, 267, 789, 272, 1660, 199, 93, 199, 199, 9472, 275, 2097, 16062, 4947, 14, 8332, 937, 199, 199, 4612, 275, 788, 8452, 297, 283, 11067, 297, 283, 2068, 418, 199, 624, 199, 199, 888, 63, 493, 63, 1317, 63, 271, 24489, 63, 8349, 275, 408, 199, 363, 888, 63, 1023, 363, 275, 413, 199, 199, 13808, 51, 275, 469, 272, 283, 8349, 356, 11400, 8452, 4863, 14, 3638, 11067, 4863, 14, 3638, 2068, 29223, 199, 93, 199, 199, 9472, 275, 359, 272, 469, 267, 283, 515, 356, 298, 16062, 4947, 14, 8332, 401, 267, 283, 8349, 356, 469, 288, 283, 21678, 422, 356, 469, 355, 283, 1733, 356, 283, 5765, 17646, 297, 355, 283, 1814, 356, 11400, 8452, 4863, 14, 3638, 11067, 4863, 14, 3638, 2068, 4863, 7, 288, 1660, 267, 789, 272, 789, 199, 61, 199, 199, 4612, 275, 788, 8452, 297, 283, 11067, 297, 283, 2068, 418, 199, 624, 199, 199, 23436, 275, 408, 199, 4001, 793, 199, 15495, 199, 199, 5765, 17646, 199, 4559, 199, 538, 20201, 538, 199, 199, 10, 16230, 2005, 892, 3878, 199, 624, 199, 199, 2062, 63, 23436, 275, 408, 199, 4001, 793, 199, 15495, 199, 199, 18, 14, 16, 14, 16, 199, 4559, 199, 538, 20201, 538, 199, 199, 10, 16230, 2005, 892, 3878, 199, 624, 421, 199, 318, 511, 63, 5254, 63, 8349, 8, 396, 63, 5418, 304, 272, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 480, 16062, 4947, 14, 8332, 401, 1570, 793, 9, 339, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 8, 267, 298, 80, 4689, 63, 1023, 14, 647, 401, 267, 1015, 63, 493, 63, 1317, 272, 776, 339, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 8, 267, 298, 80, 4689, 63, 888, 14, 647, 401, 267, 1101, 63, 493, 63, 1317, 272, 776, 339, 511, 63, 5418, 14, 1250, 5234, 80, 4689, 401, 4320, 2064, 401, 298, 8452, 3135, 339, 702, 511, 63, 5418, 14, 362, 63, 493, 63, 1317, 480, 16062, 4947, 14, 8332, 531, 508, 971, 267, 1420, 63, 23436, 421, 199, 318, 511, 63, 5254, 63, 8349, 63, 271, 24489, 63, 12844, 8, 396, 63, 5418, 304, 272, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 480, 16062, 4947, 14, 8332, 401, 1570, 793, 9, 339, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 8, 267, 298, 80, 4689, 63, 1023, 14, 647, 401, 267, 1015, 63, 493, 63, 1317, 272, 776, 339, 511, 63, 5418, 14, 7505, 63, 493, 63, 374, 63, 1881, 8, 267, 298, 80, 4689, 63, 888, 14, 647, 401, 267, 1101, 63, 493, 63, 1317, 63, 271, 24489, 63, 8349, 272, 776, 339, 511, 63, 5418, 14, 1250, 5234, 80, 4689, 401, 4320, 2064, 401, 298, 8452, 3135, 339, 702, 511, 63, 5418, 14, 362, 63, 493, 63, 1317, 480, 16062, 4947, 14, 8332, 531, 508, 971, 267, 1420, 63, 23436, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
michaelBenin/sqlalchemy
lib/sqlalchemy/sql/naming.py
1
5728
# sqlalchemy/naming.py # Copyright (C) 2005-2014 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 """Establish constraint and index naming conventions. """ from .schema import Constraint, ForeignKeyConstraint, PrimaryKeyConstraint, \ UniqueConstraint, CheckConstraint, Index, Table, Column from .. import event, events from .. import exc from .elements import _truncated_label import re class conv(_truncated_label): """Mark a string indicating that a name has already been converted by a naming convention. This is a string subclass that indicates a name that should not be subject to any further naming conventions. E.g. when we create a :class:`.Constraint` using a naming convention as follows:: m = MetaData(naming_convention={"ck": "ck_%(table_name)s_%(constraint_name)s"}) t = Table('t', m, Column('x', Integer), CheckConstraint('x > 5', name='x5')) The name of the above constraint will be rendered as ``"ck_t_x5"``. That is, the existing name ``x5`` is used in the naming convention as the ``constraint_name`` token. In some situations, such as in migration scripts, we may be rendering the above :class:`.CheckConstraint` with a name that's already been converted. In order to make sure the name isn't double-modified, the new name is applied using the :func:`.schema.conv` marker. We can use this explicitly as follows:: m = MetaData(naming_convention={"ck": "ck_%(table_name)s_%(constraint_name)s"}) t = Table('t', m, Column('x', Integer), CheckConstraint('x > 5', name=conv('ck_t_x5'))) Where above, the :func:`.schema.conv` marker indicates that the constraint name here is final, and the name will render as ``"ck_t_x5"`` and not ``"ck_t_ck_t_x5"`` .. versionadded:: 0.9.4 .. seealso:: :ref:`constraint_naming_conventions` """ class ConventionDict(object): def __init__(self, const, table, convention): self.const = const self._is_fk = isinstance(const, ForeignKeyConstraint) self.table = table self.convention = convention self._const_name = const.name def _key_table_name(self): return self.table.name def _column_X(self, idx): if self._is_fk: fk = self.const.elements[idx] return fk.parent else: return list(self.const.columns)[idx] def _key_constraint_name(self): if not self._const_name: raise exc.InvalidRequestError( "Naming convention including " "%(constraint_name)s token requires that " "constraint is explicitly named." ) if not isinstance(self._const_name, conv): self.const.name = None return self._const_name def _key_column_X_name(self, idx): return self._column_X(idx).name def _key_column_X_label(self, idx): return self._column_X(idx)._label def _key_referred_table_name(self): fk = self.const.elements[0] refs = fk.target_fullname.split(".") if len(refs) == 3: refschema, reftable, refcol = refs else: reftable, refcol = refs return reftable def _key_referred_column_X_name(self, idx): fk = self.const.elements[idx] refs = fk.target_fullname.split(".") if len(refs) == 3: refschema, reftable, refcol = refs else: reftable, refcol = refs return refcol def __getitem__(self, key): if key in self.convention: return self.convention[key](self.const, self.table) elif hasattr(self, '_key_%s' % key): return getattr(self, '_key_%s' % key)() else: col_template = re.match(r".*_?column_(\d+)_.+", key) if col_template: idx = col_template.group(1) attr = "_key_" + key.replace(idx, "X") idx = int(idx) if hasattr(self, attr): return getattr(self, attr)(idx) raise KeyError(key) _prefix_dict = { Index: "ix", PrimaryKeyConstraint: "pk", CheckConstraint: "ck", UniqueConstraint: "uq", ForeignKeyConstraint: "fk" } def _get_convention(dict_, key): for super_ in key.__mro__: if super_ in _prefix_dict and _prefix_dict[super_] in dict_: return dict_[_prefix_dict[super_]] elif super_ in dict_: return dict_[super_] else: return None @event.listens_for(Constraint, "after_parent_attach") @event.listens_for(Index, "after_parent_attach") def _constraint_name(const, table): if isinstance(table, Column): # for column-attached constraint, set another event # to link the column attached to the table as this constraint # associated with the table. event.listen(table, "after_parent_attach", lambda col, table: _constraint_name(const, table) ) elif isinstance(table, Table): metadata = table.metadata convention = _get_convention(metadata.naming_convention, type(const)) if convention is not None: if const.name is None or "constraint_name" in convention: newname = conv( convention % ConventionDict(const, table, metadata.naming_convention) ) if const.name is None: const.name = newname
mit
[ 3, 8335, 15, 26919, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7280, 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, 624, 9169, 13306, 5828, 436, 1478, 19720, 8758, 852, 14, 421, 199, 624, 199, 199, 504, 1275, 3629, 492, 25889, 12, 12718, 8463, 12, 26710, 1197, 8463, 12, 971, 355, 18276, 8463, 12, 2670, 8463, 12, 5499, 12, 6957, 12, 4996, 199, 504, 2508, 492, 1566, 12, 4474, 199, 504, 2508, 492, 3178, 199, 504, 1275, 5527, 492, 485, 19347, 63, 1302, 199, 646, 295, 199, 199, 533, 8260, 1547, 19347, 63, 1302, 304, 272, 408, 6470, 282, 1059, 9297, 626, 282, 536, 965, 2575, 2757, 6702, 272, 701, 282, 19720, 16129, 14, 339, 961, 365, 282, 1059, 5516, 626, 9126, 282, 536, 626, 1077, 440, 506, 272, 5420, 370, 1263, 9848, 19720, 8758, 852, 14, 339, 662, 14, 71, 14, 1380, 781, 1218, 282, 520, 533, 5026, 8463, 64, 1808, 282, 19720, 16129, 272, 465, 11924, 447, 398, 333, 275, 24905, 8, 26919, 63, 388, 18803, 8871, 346, 582, 298, 346, 20892, 1224, 63, 354, 9, 83, 20892, 5631, 63, 354, 9, 83, 5984, 267, 307, 275, 6957, 360, 84, 297, 333, 12, 4996, 360, 88, 297, 7225, 395, 717, 2670, 8463, 360, 88, 690, 959, 297, 536, 534, 88, 21, 1333, 339, 710, 536, 402, 314, 3432, 5828, 911, 506, 8018, 465, 25916, 346, 63, 84, 63, 88, 21, 2, 4345, 221, 10314, 365, 12, 272, 314, 3411, 536, 1124, 88, 21, 1040, 365, 1202, 315, 314, 19720, 16129, 465, 314, 1124, 5631, 63, 354, 1040, 272, 1526, 14, 339, 1010, 2005, 24325, 12, 4066, 465, 315, 8367, 10554, 12, 781, 1443, 506, 14066, 272, 314, 3432, 520, 533, 5026, 1799, 8463, 64, 543, 282, 536, 626, 1159, 2575, 2757, 272, 6702, 14, 221, 1010, 1865, 370, 1852, 3238, 314, 536, 5712, 1133, 4270, 13, 5540, 12, 314, 272, 892, 536, 365, 6781, 1808, 314, 520, 1532, 5026, 3629, 14, 5598, 64, 3608, 14, 221, 2136, 883, 272, 675, 642, 7662, 465, 11924, 447, 7318, 333, 275, 24905, 8, 26919, 63, 388, 18803, 8871, 346, 582, 298, 346, 20892, 1224, 63, 354, 9, 83, 20892, 5631, 63, 354, 9, 83, 5984, 267, 307, 275, 6957, 360, 84, 297, 333, 12, 4996, 360, 88, 297, 7225, 395, 717, 2670, 8463, 360, 88, 690, 959, 297, 536, 29, 5598, 360, 346, 63, 84, 63, 88, 21, 7058, 339, 17685, 3432, 12, 314, 520, 1532, 5026, 3629, 14, 5598, 64, 3608, 9126, 626, 314, 5828, 272, 536, 2348, 365, 4242, 12, 436, 314, 536, 911, 3795, 465, 25916, 346, 63, 84, 63, 88, 21, 31002, 436, 440, 272, 25916, 346, 63, 84, 63, 346, 63, 84, 63, 88, 21, 31002, 339, 2508, 7445, 447, 378, 14, 25, 14, 20, 339, 2508, 19352, 447, 398, 520, 1121, 1705, 5631, 63, 26919, 63, 388, 1856, 852, 64, 339, 408, 199, 199, 533, 1448, 18803, 2141, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 950, 12, 1817, 12, 16129, 304, 267, 291, 14, 1297, 275, 950, 267, 291, 423, 374, 63, 9010, 275, 1228, 8, 1297, 12, 12718, 8463, 9, 267, 291, 14, 1224, 275, 1817, 267, 291, 14, 388, 18803, 275, 16129, 267, 291, 423, 1297, 63, 354, 275, 950, 14, 354, 339, 347, 485, 498, 63, 1224, 63, 354, 8, 277, 304, 267, 372, 291, 14, 1224, 14, 354, 339, 347, 485, 2301, 63, 56, 8, 277, 12, 4280, 304, 267, 340, 291, 423, 374, 63, 9010, 26, 288, 14830, 275, 291, 14, 1297, 14, 5527, 59, 2996, 61, 288, 372, 14830, 14, 1708, 267, 587, 26, 288, 372, 769, 8, 277, 14, 1297, 14, 3406, 2788, 2996, 61, 339, 347, 485, 498, 63, 5631, 63, 354, 8, 277, 304, 267, 340, 440, 291, 423, 1297, 63, 354, 26, 288, 746, 3178, 14, 26585, 8, 490, 298, 46, 9568, 16129, 5893, 298, 490, 11792, 5631, 63, 354, 9, 83, 1526, 5074, 626, 298, 490, 298, 5631, 365, 7662, 4310, 2122, 355, 776, 267, 340, 440, 1228, 8, 277, 423, 1297, 63, 354, 12, 8260, 304, 288, 291, 14, 1297, 14, 354, 275, 488, 267, 372, 291, 423, 1297, 63, 354, 339, 347, 485, 498, 63, 2301, 63, 56, 63, 354, 8, 277, 12, 4280, 304, 267, 372, 291, 423, 2301, 63, 56, 8, 2996, 680, 354, 339, 347, 485, 498, 63, 2301, 63, 56, 63, 1302, 8, 277, 12, 4280, 304, 267, 372, 291, 423, 2301, 63, 56, 8, 2996, 10445, 1302, 339, 347, 485, 498, 63, 1121, 7165, 63, 1224, 63, 354, 8, 277, 304, 267, 14830, 275, 291, 14, 1297, 14, 5527, 59, 16, 61, 267, 15749, 275, 14830, 14, 1375, 63, 9930, 14, 1294, 15857, 267, 340, 822, 8, 7655, 9, 508, 650, 26, 288, 15749, 2095, 12, 295, 856, 461, 12, 2984, 761, 275, 15749, 267, 587, 26, 288, 295, 856, 461, 12, 2984, 761, 275, 15749, 267, 372, 295, 856, 461, 339, 347, 485, 498, 63, 1121, 7165, 63, 2301, 63, 56, 63, 354, 8, 277, 12, 4280, 304, 267, 14830, 275, 291, 14, 1297, 14, 5527, 59, 2996, 61, 267, 15749, 275, 14830, 14, 1375, 63, 9930, 14, 1294, 15857, 267, 340, 822, 8, 7655, 9, 508, 650, 26, 288, 15749, 2095, 12, 295, 856, 461, 12, 2984, 761, 275, 15749, 267, 587, 26, 288, 295, 856, 461, 12, 2984, 761, 275, 15749, 267, 372, 2984, 761, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 790, 315, 291, 14, 388, 18803, 26, 288, 372, 291, 14, 388, 18803, 59, 498, 8738, 277, 14, 1297, 12, 291, 14, 1224, 9, 267, 916, 2688, 8, 277, 12, 2513, 498, 4970, 83, 7, 450, 790, 304, 288, 372, 2519, 8, 277, 12, 2513, 498, 4970, 83, 7, 450, 790, 16315, 267, 587, 26, 288, 1048, 63, 1160, 275, 295, 14, 1431, 8, 82, 1674, 10, 63, 31, 2301, 2531, 60, 68, 8771, 3754, 22758, 790, 9 ]
[ 8335, 15, 26919, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 7280, 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, 624, 9169, 13306, 5828, 436, 1478, 19720, 8758, 852, 14, 421, 199, 624, 199, 199, 504, 1275, 3629, 492, 25889, 12, 12718, 8463, 12, 26710, 1197, 8463, 12, 971, 355, 18276, 8463, 12, 2670, 8463, 12, 5499, 12, 6957, 12, 4996, 199, 504, 2508, 492, 1566, 12, 4474, 199, 504, 2508, 492, 3178, 199, 504, 1275, 5527, 492, 485, 19347, 63, 1302, 199, 646, 295, 199, 199, 533, 8260, 1547, 19347, 63, 1302, 304, 272, 408, 6470, 282, 1059, 9297, 626, 282, 536, 965, 2575, 2757, 6702, 272, 701, 282, 19720, 16129, 14, 339, 961, 365, 282, 1059, 5516, 626, 9126, 282, 536, 626, 1077, 440, 506, 272, 5420, 370, 1263, 9848, 19720, 8758, 852, 14, 339, 662, 14, 71, 14, 1380, 781, 1218, 282, 520, 533, 5026, 8463, 64, 1808, 282, 19720, 16129, 272, 465, 11924, 447, 398, 333, 275, 24905, 8, 26919, 63, 388, 18803, 8871, 346, 582, 298, 346, 20892, 1224, 63, 354, 9, 83, 20892, 5631, 63, 354, 9, 83, 5984, 267, 307, 275, 6957, 360, 84, 297, 333, 12, 4996, 360, 88, 297, 7225, 395, 717, 2670, 8463, 360, 88, 690, 959, 297, 536, 534, 88, 21, 1333, 339, 710, 536, 402, 314, 3432, 5828, 911, 506, 8018, 465, 25916, 346, 63, 84, 63, 88, 21, 2, 4345, 221, 10314, 365, 12, 272, 314, 3411, 536, 1124, 88, 21, 1040, 365, 1202, 315, 314, 19720, 16129, 465, 314, 1124, 5631, 63, 354, 1040, 272, 1526, 14, 339, 1010, 2005, 24325, 12, 4066, 465, 315, 8367, 10554, 12, 781, 1443, 506, 14066, 272, 314, 3432, 520, 533, 5026, 1799, 8463, 64, 543, 282, 536, 626, 1159, 2575, 2757, 272, 6702, 14, 221, 1010, 1865, 370, 1852, 3238, 314, 536, 5712, 1133, 4270, 13, 5540, 12, 314, 272, 892, 536, 365, 6781, 1808, 314, 520, 1532, 5026, 3629, 14, 5598, 64, 3608, 14, 221, 2136, 883, 272, 675, 642, 7662, 465, 11924, 447, 7318, 333, 275, 24905, 8, 26919, 63, 388, 18803, 8871, 346, 582, 298, 346, 20892, 1224, 63, 354, 9, 83, 20892, 5631, 63, 354, 9, 83, 5984, 267, 307, 275, 6957, 360, 84, 297, 333, 12, 4996, 360, 88, 297, 7225, 395, 717, 2670, 8463, 360, 88, 690, 959, 297, 536, 29, 5598, 360, 346, 63, 84, 63, 88, 21, 7058, 339, 17685, 3432, 12, 314, 520, 1532, 5026, 3629, 14, 5598, 64, 3608, 9126, 626, 314, 5828, 272, 536, 2348, 365, 4242, 12, 436, 314, 536, 911, 3795, 465, 25916, 346, 63, 84, 63, 88, 21, 31002, 436, 440, 272, 25916, 346, 63, 84, 63, 346, 63, 84, 63, 88, 21, 31002, 339, 2508, 7445, 447, 378, 14, 25, 14, 20, 339, 2508, 19352, 447, 398, 520, 1121, 1705, 5631, 63, 26919, 63, 388, 1856, 852, 64, 339, 408, 199, 199, 533, 1448, 18803, 2141, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 950, 12, 1817, 12, 16129, 304, 267, 291, 14, 1297, 275, 950, 267, 291, 423, 374, 63, 9010, 275, 1228, 8, 1297, 12, 12718, 8463, 9, 267, 291, 14, 1224, 275, 1817, 267, 291, 14, 388, 18803, 275, 16129, 267, 291, 423, 1297, 63, 354, 275, 950, 14, 354, 339, 347, 485, 498, 63, 1224, 63, 354, 8, 277, 304, 267, 372, 291, 14, 1224, 14, 354, 339, 347, 485, 2301, 63, 56, 8, 277, 12, 4280, 304, 267, 340, 291, 423, 374, 63, 9010, 26, 288, 14830, 275, 291, 14, 1297, 14, 5527, 59, 2996, 61, 288, 372, 14830, 14, 1708, 267, 587, 26, 288, 372, 769, 8, 277, 14, 1297, 14, 3406, 2788, 2996, 61, 339, 347, 485, 498, 63, 5631, 63, 354, 8, 277, 304, 267, 340, 440, 291, 423, 1297, 63, 354, 26, 288, 746, 3178, 14, 26585, 8, 490, 298, 46, 9568, 16129, 5893, 298, 490, 11792, 5631, 63, 354, 9, 83, 1526, 5074, 626, 298, 490, 298, 5631, 365, 7662, 4310, 2122, 355, 776, 267, 340, 440, 1228, 8, 277, 423, 1297, 63, 354, 12, 8260, 304, 288, 291, 14, 1297, 14, 354, 275, 488, 267, 372, 291, 423, 1297, 63, 354, 339, 347, 485, 498, 63, 2301, 63, 56, 63, 354, 8, 277, 12, 4280, 304, 267, 372, 291, 423, 2301, 63, 56, 8, 2996, 680, 354, 339, 347, 485, 498, 63, 2301, 63, 56, 63, 1302, 8, 277, 12, 4280, 304, 267, 372, 291, 423, 2301, 63, 56, 8, 2996, 10445, 1302, 339, 347, 485, 498, 63, 1121, 7165, 63, 1224, 63, 354, 8, 277, 304, 267, 14830, 275, 291, 14, 1297, 14, 5527, 59, 16, 61, 267, 15749, 275, 14830, 14, 1375, 63, 9930, 14, 1294, 15857, 267, 340, 822, 8, 7655, 9, 508, 650, 26, 288, 15749, 2095, 12, 295, 856, 461, 12, 2984, 761, 275, 15749, 267, 587, 26, 288, 295, 856, 461, 12, 2984, 761, 275, 15749, 267, 372, 295, 856, 461, 339, 347, 485, 498, 63, 1121, 7165, 63, 2301, 63, 56, 63, 354, 8, 277, 12, 4280, 304, 267, 14830, 275, 291, 14, 1297, 14, 5527, 59, 2996, 61, 267, 15749, 275, 14830, 14, 1375, 63, 9930, 14, 1294, 15857, 267, 340, 822, 8, 7655, 9, 508, 650, 26, 288, 15749, 2095, 12, 295, 856, 461, 12, 2984, 761, 275, 15749, 267, 587, 26, 288, 295, 856, 461, 12, 2984, 761, 275, 15749, 267, 372, 2984, 761, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 790, 315, 291, 14, 388, 18803, 26, 288, 372, 291, 14, 388, 18803, 59, 498, 8738, 277, 14, 1297, 12, 291, 14, 1224, 9, 267, 916, 2688, 8, 277, 12, 2513, 498, 4970, 83, 7, 450, 790, 304, 288, 372, 2519, 8, 277, 12, 2513, 498, 4970, 83, 7, 450, 790, 16315, 267, 587, 26,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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 ]
nsnam/ns-3-dev-git
bindings/python/ns3modulegen_core_customizations.py
7
19495
from __future__ import print_function import sys import re from pybindgen.typehandlers import base as typehandlers from pybindgen import ReturnValue, Parameter from pybindgen.cppmethod import CustomCppMethodWrapper, CustomCppConstructorWrapper from pybindgen.typehandlers.codesink import MemoryCodeSink from pybindgen.typehandlers import ctypeparser from pybindgen.typehandlers.base import ForwardWrapperBase from pybindgen import cppclass import warnings from pybindgen.typehandlers.base import CodeGenerationError import sys class SmartPointerTransformation(typehandlers.TypeTransformation): """ This class provides a "type transformation" that tends to support NS-3 smart pointers. Parameters such as "Ptr<Foo> foo" are transformed into something like Parameter.new("Foo*", "foo", transfer_ownership=False). Return values such as Ptr<Foo> are transformed into ReturnValue.new("Foo*", caller_owns_return=False). Since the underlying objects have reference counting, PyBindGen does the right thing. """ def __init__(self): super(SmartPointerTransformation, self).__init__() self.rx = re.compile(r'(ns3::|::ns3::|)Ptr<([^>]+)>\s*$') print("{0!r}".format(self), file=sys.stderr) def _get_untransformed_type_traits(self, name): m = self.rx.match(name) is_const = False if m is None: print("{0!r} did not match".format(name), file=sys.stderr) return None, False else: name1 = m.group(2).strip() if name1.startswith('const '): name1 = name1[len('const '):] is_const = True if name1.endswith(' const'): name1 = name1[:-len(' const')] is_const = True new_name = name1+' *' if new_name.startswith('::'): new_name = new_name[2:] return new_name, is_const def get_untransformed_name(self, name): new_name, dummy_is_const = self._get_untransformed_type_traits(name) return new_name def create_type_handler(self, type_handler, *args, **kwargs): if issubclass(type_handler, Parameter): kwargs['transfer_ownership'] = False elif issubclass(type_handler, ReturnValue): kwargs['caller_owns_return'] = False else: raise AssertionError ## fix the ctype, add ns3:: namespace orig_ctype, is_const = self._get_untransformed_type_traits(args[0]) if is_const: correct_ctype = 'ns3::Ptr< {0} const >'.format(orig_ctype[:-2]) else: correct_ctype = 'ns3::Ptr< {0} >'.format(orig_ctype[:-2]) args = tuple([correct_ctype] + list(args[1:])) handler = type_handler(*args, **kwargs) handler.set_transformation(self, orig_ctype) return handler def untransform(self, type_handler, declarations, code_block, expression): return 'const_cast<%s> (ns3::PeekPointer (%s))' % (type_handler.untransformed_ctype, expression) def transform(self, type_handler, declarations, code_block, expression): assert type_handler.untransformed_ctype[-1] == '*' return 'ns3::Ptr< %s > (%s)' % (type_handler.untransformed_ctype[:-1], expression) ## register the type transformation transf = SmartPointerTransformation() typehandlers.return_type_matcher.register_transformation(transf) typehandlers.param_type_matcher.register_transformation(transf) del transf class CallbackImplProxyMethod(typehandlers.ReverseWrapperBase): """ Class that generates a proxy virtual method that calls a similarly named python method. """ def __init__(self, return_value, parameters): super(CallbackImplProxyMethod, self).__init__(return_value, parameters) def generate_python_call(self): """code to call the python method""" build_params = self.build_params.get_parameters(force_tuple_creation=True) if build_params[0][0] == '"': build_params[0] = '(char *) ' + build_params[0] args = self.before_call.declare_variable('PyObject*', 'args') self.before_call.write_code('%s = Py_BuildValue(%s);' % (args, ', '.join(build_params))) self.before_call.add_cleanup_code('Py_DECREF(%s);' % args) self.before_call.write_code('py_retval = PyObject_CallObject(m_callback, %s);' % args) self.before_call.write_error_check('py_retval == NULL') self.before_call.add_cleanup_code('Py_DECREF(py_retval);') def register_callback_classes(out, callbacks): for callback_impl_num, template_parameters in enumerate(callbacks): cls_name = "ns3::Callback< %s >" % ', '.join(template_parameters) #print >> sys.stderr, "***** trying to register callback: %r" % cls_name class_name = "PythonCallbackImpl%i" % callback_impl_num class PythonCallbackParameter(Parameter): "Class handlers" CTYPES = [cls_name] print("***** registering callback handler: %r (%r)" % (ctypeparser.normalize_type_string(cls_name), cls_name), file=sys.stderr) DIRECTIONS = [Parameter.DIRECTION_IN] PYTHON_CALLBACK_IMPL_NAME = class_name TEMPLATE_ARGS = template_parameters DISABLED = False def convert_python_to_c(self, wrapper): "parses python args to get C++ value" assert isinstance(wrapper, typehandlers.ForwardWrapperBase) if self.DISABLED: raise CodeGenerationError("wrapper could not be generated") if self.default_value is None: py_callback = wrapper.declarations.declare_variable('PyObject*', self.name) wrapper.parse_params.add_parameter('O', ['&'+py_callback], self.name) wrapper.before_call.write_error_check( '!PyCallable_Check(%s)' % py_callback, 'PyErr_SetString(PyExc_TypeError, "parameter \'%s\' must be callbale");' % self.name) callback_impl = wrapper.declarations.declare_variable( 'ns3::Ptr<%s>' % self.PYTHON_CALLBACK_IMPL_NAME, '%s_cb_impl' % self.name) wrapper.before_call.write_code("%s = ns3::Create<%s> (%s);" % (callback_impl, self.PYTHON_CALLBACK_IMPL_NAME, py_callback)) wrapper.call_params.append( 'ns3::Callback<%s> (%s)' % (', '.join(self.TEMPLATE_ARGS), callback_impl)) else: py_callback = wrapper.declarations.declare_variable('PyObject*', self.name, 'NULL') wrapper.parse_params.add_parameter('O', ['&'+py_callback], self.name, optional=True) value = wrapper.declarations.declare_variable( 'ns3::Callback<%s>' % ', '.join(self.TEMPLATE_ARGS), self.name+'_value', self.default_value) wrapper.before_call.write_code("if (%s) {" % (py_callback,)) wrapper.before_call.indent() wrapper.before_call.write_error_check( '!PyCallable_Check(%s)' % py_callback, 'PyErr_SetString(PyExc_TypeError, "parameter \'%s\' must be callbale");' % self.name) wrapper.before_call.write_code("%s = ns3::Callback<%s> (ns3::Create<%s> (%s));" % (value, ', '.join(self.TEMPLATE_ARGS), self.PYTHON_CALLBACK_IMPL_NAME, py_callback)) wrapper.before_call.unindent() wrapper.before_call.write_code("}") # closes: if (py_callback) { wrapper.call_params.append(value) def convert_c_to_python(self, wrapper): raise typehandlers.NotSupportedError("Reverse wrappers for ns3::Callback<...> types " "(python using callbacks defined in C++) not implemented.") def generate_callback_classes(module, callbacks): out = module.after_forward_declarations for callback_impl_num, template_parameters in enumerate(callbacks): sink = MemoryCodeSink() cls_name = "ns3::Callback< %s >" % ', '.join(template_parameters) #print >> sys.stderr, "***** trying to register callback: %r" % cls_name class_name = "PythonCallbackImpl%i" % callback_impl_num sink.writeln(''' class %s : public ns3::CallbackImpl<%s> { public: PyObject *m_callback; %s(PyObject *callback) { Py_INCREF(callback); m_callback = callback; } virtual ~%s() { PyGILState_STATE __py_gil_state; __py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0); Py_DECREF(m_callback); m_callback = NULL; PyGILState_Release(__py_gil_state); } virtual bool IsEqual(ns3::Ptr<const ns3::CallbackImplBase> other_base) const { const %s *other = dynamic_cast<const %s*> (ns3::PeekPointer (other_base)); if (other != NULL) return (other->m_callback == m_callback); else return false; } ''' % (class_name, ', '.join(template_parameters), class_name, class_name, class_name, class_name)) sink.indent() callback_return = template_parameters[0] return_ctype = ctypeparser.parse_type(callback_return) if ('const' in return_ctype.remove_modifiers()): kwargs = {'is_const': True} else: kwargs = {} try: return_type = ReturnValue.new(str(return_ctype), **kwargs) except (typehandlers.TypeLookupError, typehandlers.TypeConfigurationError) as ex: warnings.warn("***** Unable to register callback; Return value '%s' error (used in %s): %r" % (callback_return, cls_name, ex), Warning) continue arguments = [] ok = True callback_parameters = [arg for arg in template_parameters[1:] if arg != 'ns3::empty'] for arg_num, arg_type in enumerate(callback_parameters): arg_name = 'arg%i' % (arg_num+1) param_ctype = ctypeparser.parse_type(arg_type) if ('const' in param_ctype.remove_modifiers()): kwargs = {'is_const': True} else: kwargs = {} try: param = Parameter.new(str(param_ctype), arg_name, **kwargs) cpp_class = getattr(param, "cpp_class", None) if isinstance(cpp_class, cppclass.CppClass): # check if the "helper class" can be constructed if cpp_class.helper_class is not None: cpp_class.helper_class.generate_forward_declarations( MemoryCodeSink()) if cpp_class.helper_class.cannot_be_constructed: cpp_class.helper_class = None cpp_class.helper_class_disabled = True arguments.append(param) except (typehandlers.TypeLookupError, typehandlers.TypeConfigurationError) as ex: warnings.warn("***** Unable to register callback; parameter '%s %s' error (used in %s): %r" % (arg_type, arg_name, cls_name, ex), Warning) ok = False if not ok: try: typehandlers.return_type_matcher.lookup(cls_name)[0].DISABLED = True except typehandlers.TypeLookupError: pass try: typehandlers.param_type_matcher.lookup(cls_name)[0].DISABLED = True except typehandlers.TypeLookupError: pass continue wrapper = CallbackImplProxyMethod(return_type, arguments) wrapper.generate(sink, 'operator()', decl_modifiers=[]) sink.unindent() sink.writeln('};\n') print("Flushing to ", out, file=sys.stderr) sink.flush_to(out) # def write_preamble(out): # pybindgen.write_preamble(out) # out.writeln("#include \"ns3/everything.h\"") def Simulator_customizations(module): Simulator = module['ns3::Simulator'] ## Simulator::Schedule(delay, callback, ...user..args...) Simulator.add_custom_method_wrapper("Schedule", "_wrap_Simulator_Schedule", flags=["METH_VARARGS", "METH_KEYWORDS", "METH_STATIC"]) ## Simulator::ScheduleNow(callback, ...user..args...) Simulator.add_custom_method_wrapper("ScheduleNow", "_wrap_Simulator_ScheduleNow", flags=["METH_VARARGS", "METH_KEYWORDS", "METH_STATIC"]) ## Simulator::ScheduleDestroy(callback, ...user..args...) Simulator.add_custom_method_wrapper("ScheduleDestroy", "_wrap_Simulator_ScheduleDestroy", flags=["METH_VARARGS", "METH_KEYWORDS", "METH_STATIC"]) Simulator.add_custom_method_wrapper("Run", "_wrap_Simulator_Run", flags=["METH_VARARGS", "METH_KEYWORDS", "METH_STATIC"]) def CommandLine_customizations(module): CommandLine = module['ns3::CommandLine'] CommandLine.add_method('Parse', None, [ArgvParam(None, 'argv')], is_static=False) CommandLine.add_custom_method_wrapper("AddValue", "_wrap_CommandLine_AddValue", flags=["METH_VARARGS", "METH_KEYWORDS"]) def Object_customizations(module): ## --------------------------------------------------------------------- ## Here we generate custom constructor code for all classes that ## derive from ns3::Object. The custom constructors are needed in ## order to support kwargs only and to translate kwargs into ns3 ## attributes, etc. ## --------------------------------------------------------------------- try: Object = module['ns3::Object'] except KeyError: return ## add a GetTypeId method to all generatd helper classes def helper_class_hook(helper_class): decl = """ static ns3::TypeId GetTypeId (void) { static ns3::TypeId tid = ns3::TypeId ("%s") .SetParent< %s > () ; return tid; }""" % (helper_class.name, helper_class.class_.full_name) helper_class.add_custom_method(decl) helper_class.add_post_generation_code( "NS_OBJECT_ENSURE_REGISTERED (%s);" % helper_class.name) Object.add_helper_class_hook(helper_class_hook) def ns3_object_instance_creation_function(cpp_class, code_block, lvalue, parameters, construct_type_name): assert lvalue assert not lvalue.startswith('None') if cpp_class.cannot_be_constructed: raise CodeGenerationError("%s cannot be constructed (%s)" % cpp_class.full_name) if cpp_class.incomplete_type: raise CodeGenerationError("%s cannot be constructed (incomplete type)" % cpp_class.full_name) code_block.write_code("%s = new %s(%s);" % (lvalue, construct_type_name, parameters)) code_block.write_code("%s->Ref ();" % (lvalue)) def ns3_object_post_instance_creation_function(cpp_class, code_block, lvalue, parameters, construct_type_name): code_block.write_code("ns3::CompleteConstruct(%s);" % (lvalue, )) Object.set_instance_creation_function(ns3_object_instance_creation_function) Object.set_post_instance_creation_function(ns3_object_post_instance_creation_function) def Attribute_customizations(module): # Fix up for the "const AttributeValue &v = EmptyAttribute()" # case, as used extensively by helper classes. # Here's why we need to do this: pybindgen.gccxmlscanner, when # scanning parameter default values, is only provided with the # value as a simple C expression string. (py)gccxml does not # report the type of the default value. # As a workaround, here we iterate over all parameters of all # methods of all classes and tell pybindgen what is the type of # the default value for attributes. for cls in module.classes: for meth in cls.get_all_methods(): for param in meth.parameters: if isinstance(param, cppclass.CppClassRefParameter): if param.cpp_class.name == 'AttributeValue' \ and param.default_value is not None \ and param.default_value_type is None: param.default_value_type = 'ns3::EmptyAttributeValue' def TypeId_customizations(module): TypeId = module['ns3::TypeId'] TypeId.add_custom_method_wrapper("LookupByNameFailSafe", "_wrap_TypeId_LookupByNameFailSafe", flags=["METH_VARARGS", "METH_KEYWORDS", "METH_STATIC"]) def add_std_ofstream(module): module.add_include('<fstream>') ostream = module.add_class('ostream', foreign_cpp_namespace='::std') ostream.set_cannot_be_constructed("abstract base class") ofstream = module.add_class('ofstream', foreign_cpp_namespace='::std', parent=ostream) ofstream.add_enum('openmode', [ ('app', 'std::ios_base::app'), ('ate', 'std::ios_base::ate'), ('binary', 'std::ios_base::binary'), ('in', 'std::ios_base::in'), ('out', 'std::ios_base::out'), ('trunc', 'std::ios_base::trunc'), ]) ofstream.add_constructor([Parameter.new("const char *", 'filename'), Parameter.new("::std::ofstream::openmode", 'mode', default_value="std::ios_base::out")]) ofstream.add_method('close', None, []) add_std_ios_openmode(module) class IosOpenmodeParam(Parameter): DIRECTIONS = [Parameter.DIRECTION_IN] CTYPES = ['std::ios_base::openmode', 'std::_Ios_Openmode'] def convert_c_to_python(self, wrapper): assert isinstance(wrapper, ReverseWrapperBase) wrapper.build_params.add_parameter('i', [self.value]) def convert_python_to_c(self, wrapper): assert isinstance(wrapper, ForwardWrapperBase) name = wrapper.declarations.declare_variable("std::ios_base::openmode", self.name, self.default_value) wrapper.parse_params.add_parameter('i', ['&'+name], self.name, optional=bool(self.default_value)) wrapper.call_params.append(name) def add_std_ios_openmode(module): for flag in 'in', 'out', 'ate', 'app', 'trunc', 'binary': module.after_init.write_code('PyModule_AddIntConstant(m, (char *) "STD_IOS_%s", std::ios::%s);' % (flag.upper(), flag)) def add_ipv4_address_tp_hash(module): module.body.writeln(''' long _ns3_Ipv4Address_tp_hash (PyObject *obj) { PyNs3Ipv4Address *addr = reinterpret_cast<PyNs3Ipv4Address *> (obj); return static_cast<long> (ns3::Ipv4AddressHash () (*addr->obj)); } ''') module.header.writeln('long _ns3_Ipv4Address_tp_hash (PyObject *obj);') module['Ipv4Address'].pytype.slots['tp_hash'] = "_ns3_Ipv4Address_tp_hash"
gpl-2.0
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 199, 646, 295, 199, 199, 504, 1134, 31297, 14, 466, 5586, 492, 1300, 465, 14330, 199, 504, 1134, 31297, 492, 1432, 1110, 12, 12009, 199, 504, 1134, 31297, 14, 5910, 765, 492, 8388, 19705, 3767, 4590, 12, 8388, 19705, 11447, 4590, 199, 504, 1134, 31297, 14, 466, 5586, 14, 6021, 2292, 492, 15825, 3034, 17111, 199, 504, 1134, 31297, 14, 466, 5586, 492, 16360, 2087, 199, 504, 1134, 31297, 14, 466, 5586, 14, 1095, 492, 22536, 4590, 1563, 199, 504, 1134, 31297, 492, 7246, 533, 199, 646, 3598, 199, 199, 504, 1134, 31297, 14, 466, 5586, 14, 1095, 492, 5495, 3139, 5263, 199, 199, 646, 984, 199, 199, 533, 26017, 12190, 26283, 8, 466, 5586, 14, 804, 26283, 304, 272, 408, 272, 961, 1021, 6571, 282, 298, 466, 13315, 2, 626, 16685, 795, 370, 2291, 272, 9380, 13, 19, 11179, 21116, 14, 221, 3897, 4066, 465, 298, 2115, 28, 5686, 30, 3925, 2, 787, 272, 14834, 1901, 6020, 2839, 12009, 14, 1222, 480, 5686, 14421, 298, 1421, 401, 272, 9307, 63, 22495, 29, 797, 680, 221, 1432, 1338, 4066, 465, 20636, 28, 5686, 30, 787, 272, 14834, 1901, 1432, 1110, 14, 1222, 480, 5686, 14421, 272, 8025, 63, 23311, 63, 1107, 29, 797, 680, 221, 9336, 314, 8793, 2251, 1172, 272, 3659, 23190, 12, 1611, 8198, 8168, 1630, 314, 2451, 8377, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 29111, 12190, 26283, 12, 291, 2843, 826, 4533, 267, 291, 14, 6872, 275, 295, 14, 2014, 8, 82, 6774, 561, 19, 447, 92, 447, 561, 19, 447, 92, 9, 2115, 28, 7059, 30, 11896, 3072, 83, 10, 9988, 267, 870, 13076, 16, 1, 82, 5469, 908, 8, 277, 395, 570, 29, 1274, 14, 3083, 9, 339, 347, 485, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 277, 12, 536, 304, 267, 333, 275, 291, 14, 6872, 14, 1431, 8, 354, 9, 267, 365, 63, 1297, 275, 756, 267, 340, 333, 365, 488, 26, 288, 870, 13076, 16, 1, 82, 93, 8103, 440, 1336, 1674, 908, 8, 354, 395, 570, 29, 1274, 14, 3083, 9, 288, 372, 488, 12, 756, 267, 587, 26, 288, 536, 17, 275, 333, 14, 923, 8, 18, 680, 1913, 342, 288, 340, 536, 17, 14, 2460, 360, 1297, 18927, 355, 536, 17, 275, 536, 17, 59, 552, 360, 1297, 283, 15405, 355, 365, 63, 1297, 275, 715, 288, 340, 536, 17, 14, 4130, 360, 950, 735, 355, 536, 17, 275, 536, 17, 4439, 552, 360, 950, 5440, 355, 365, 63, 1297, 275, 715, 288, 892, 63, 354, 275, 536, 17, 4786, 627, 7, 953, 340, 892, 63, 354, 14, 2460, 6176, 23117, 355, 892, 63, 354, 275, 892, 63, 354, 59, 18, 2938, 288, 372, 892, 63, 354, 12, 365, 63, 1297, 339, 347, 664, 63, 324, 20209, 63, 354, 8, 277, 12, 536, 304, 267, 892, 63, 354, 12, 7283, 63, 374, 63, 1297, 275, 291, 423, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 354, 9, 267, 372, 892, 63, 354, 339, 347, 1218, 63, 466, 63, 2232, 8, 277, 12, 730, 63, 2232, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 11602, 8, 466, 63, 2232, 12, 12009, 304, 288, 2074, 459, 9609, 63, 22495, 418, 275, 756, 267, 916, 11602, 8, 466, 63, 2232, 12, 1432, 1110, 304, 288, 2074, 459, 11219, 63, 23311, 63, 1107, 418, 275, 756, 267, 587, 26, 288, 746, 9070, 398, 925, 5325, 314, 16360, 12, 1050, 700, 19, 447, 3231, 267, 2306, 63, 3667, 12, 365, 63, 1297, 275, 291, 423, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 589, 59, 16, 566, 267, 340, 365, 63, 1297, 26, 288, 3211, 63, 3667, 275, 283, 561, 19, 447, 2115, 28, 469, 16, 93, 950, 690, 1370, 908, 8, 2981, 63, 3667, 4439, 18, 566, 267, 587, 26, 288, 3211, 63, 3667, 275, 283, 561, 19, 447, 2115, 28, 469, 16, 93, 690, 1370, 908, 8, 2981, 63, 3667, 4439, 18, 566, 267, 1249, 275, 2008, 779, 4525, 63, 3667, 61, 435, 769, 8, 589, 59, 17, 16720, 398, 3016, 275, 730, 63, 2232, 2031, 589, 12, 1011, 958, 9, 267, 3016, 14, 409, 63, 31400, 8, 277, 12, 2306, 63, 3667, 9, 267, 372, 3016, 339, 347, 625, 4711, 8, 277, 12, 730, 63, 2232, 12, 18707, 12, 1233, 63, 1457, 12, 3965, 304, 267, 372, 283, 1297, 63, 2931, 21110, 83, 30, 334, 561, 19, 447, 17093, 12190, 4366, 83, 23089, 450, 334, 466, 63, 2232, 14, 324, 20209, 63, 3667, 12, 3965, 9, 339, 347, 5793, 8, 277, 12, 730, 63, 2232, 12, 18707, 12, 1233, 63, 1457, 12, 3965, 304, 267, 702, 730, 63, 2232, 14, 324, 20209, 63, 3667, 1988, 17, 61, 508, 13626, 267, 372, 283, 561, 19, 447, 2115, 28, 450, 83, 690, 4366, 83, 3171, 450, 334, 466, 63, 2232, 14, 324, 20209, 63, 3667, 4439, 17, 467, 3965, 9, 199, 199, 309, 2274, 314, 730, 13315, 199, 1515, 70, 275, 26017, 12190, 26283, 342, 199, 466, 5586, 14, 1107, 63, 466, 63, 16135, 14, 2683, 63, 31400, 8, 1515, 70, 9, 199, 466, 5586, 14, 635, 63, 466, 63, 16135, 14, 2683, 63, 31400, 8, 1515, 70, 9, 199, 2264, 28183, 421, 199, 533, 17555, 4748, 4936, 3767, 8, 466, 5586, 14, 14987, 4590, 1563, 304, 272, 408, 272, 8089, 626, 12821, 282, 4566, 5791, 1083, 626, 4882, 282, 8545, 590, 4310, 2366, 1083, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 372, 63, 585, 12, 2633, 304, 267, 1613, 8, 8415, 4936, 3767, 12, 291, 2843, 826, 721, 1107, 63, 585, 12, 2633, 9, 339, 347, 3550, 63, 1548, 63, 1250, 8, 277, 304, 267, 408, 600, 370, 1240, 314, 2366, 1083, 624, 267, 1900, 63, 1162, 275, 291, 14, 1506, 63, 1162, 14, 362, 63, 3214, 8, 3990, 63, 2960, 63, 8782, 29, 549, 9, 267, 340, 1900, 63, 1162, 59, 16, 1527, 16, 61, 508, 24536, 288, 1900, 63, 1162, 59, 16, 61, 275, 8189, 1560, 24104, 283, 435, 1900, 63, 1162, 59, 16, 61, 267, 1249, 275 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 984, 199, 646, 295, 199, 199, 504, 1134, 31297, 14, 466, 5586, 492, 1300, 465, 14330, 199, 504, 1134, 31297, 492, 1432, 1110, 12, 12009, 199, 504, 1134, 31297, 14, 5910, 765, 492, 8388, 19705, 3767, 4590, 12, 8388, 19705, 11447, 4590, 199, 504, 1134, 31297, 14, 466, 5586, 14, 6021, 2292, 492, 15825, 3034, 17111, 199, 504, 1134, 31297, 14, 466, 5586, 492, 16360, 2087, 199, 504, 1134, 31297, 14, 466, 5586, 14, 1095, 492, 22536, 4590, 1563, 199, 504, 1134, 31297, 492, 7246, 533, 199, 646, 3598, 199, 199, 504, 1134, 31297, 14, 466, 5586, 14, 1095, 492, 5495, 3139, 5263, 199, 199, 646, 984, 199, 199, 533, 26017, 12190, 26283, 8, 466, 5586, 14, 804, 26283, 304, 272, 408, 272, 961, 1021, 6571, 282, 298, 466, 13315, 2, 626, 16685, 795, 370, 2291, 272, 9380, 13, 19, 11179, 21116, 14, 221, 3897, 4066, 465, 298, 2115, 28, 5686, 30, 3925, 2, 787, 272, 14834, 1901, 6020, 2839, 12009, 14, 1222, 480, 5686, 14421, 298, 1421, 401, 272, 9307, 63, 22495, 29, 797, 680, 221, 1432, 1338, 4066, 465, 20636, 28, 5686, 30, 787, 272, 14834, 1901, 1432, 1110, 14, 1222, 480, 5686, 14421, 272, 8025, 63, 23311, 63, 1107, 29, 797, 680, 221, 9336, 314, 8793, 2251, 1172, 272, 3659, 23190, 12, 1611, 8198, 8168, 1630, 314, 2451, 8377, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 29111, 12190, 26283, 12, 291, 2843, 826, 4533, 267, 291, 14, 6872, 275, 295, 14, 2014, 8, 82, 6774, 561, 19, 447, 92, 447, 561, 19, 447, 92, 9, 2115, 28, 7059, 30, 11896, 3072, 83, 10, 9988, 267, 870, 13076, 16, 1, 82, 5469, 908, 8, 277, 395, 570, 29, 1274, 14, 3083, 9, 339, 347, 485, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 277, 12, 536, 304, 267, 333, 275, 291, 14, 6872, 14, 1431, 8, 354, 9, 267, 365, 63, 1297, 275, 756, 267, 340, 333, 365, 488, 26, 288, 870, 13076, 16, 1, 82, 93, 8103, 440, 1336, 1674, 908, 8, 354, 395, 570, 29, 1274, 14, 3083, 9, 288, 372, 488, 12, 756, 267, 587, 26, 288, 536, 17, 275, 333, 14, 923, 8, 18, 680, 1913, 342, 288, 340, 536, 17, 14, 2460, 360, 1297, 18927, 355, 536, 17, 275, 536, 17, 59, 552, 360, 1297, 283, 15405, 355, 365, 63, 1297, 275, 715, 288, 340, 536, 17, 14, 4130, 360, 950, 735, 355, 536, 17, 275, 536, 17, 4439, 552, 360, 950, 5440, 355, 365, 63, 1297, 275, 715, 288, 892, 63, 354, 275, 536, 17, 4786, 627, 7, 953, 340, 892, 63, 354, 14, 2460, 6176, 23117, 355, 892, 63, 354, 275, 892, 63, 354, 59, 18, 2938, 288, 372, 892, 63, 354, 12, 365, 63, 1297, 339, 347, 664, 63, 324, 20209, 63, 354, 8, 277, 12, 536, 304, 267, 892, 63, 354, 12, 7283, 63, 374, 63, 1297, 275, 291, 423, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 354, 9, 267, 372, 892, 63, 354, 339, 347, 1218, 63, 466, 63, 2232, 8, 277, 12, 730, 63, 2232, 12, 627, 589, 12, 1011, 958, 304, 267, 340, 11602, 8, 466, 63, 2232, 12, 12009, 304, 288, 2074, 459, 9609, 63, 22495, 418, 275, 756, 267, 916, 11602, 8, 466, 63, 2232, 12, 1432, 1110, 304, 288, 2074, 459, 11219, 63, 23311, 63, 1107, 418, 275, 756, 267, 587, 26, 288, 746, 9070, 398, 925, 5325, 314, 16360, 12, 1050, 700, 19, 447, 3231, 267, 2306, 63, 3667, 12, 365, 63, 1297, 275, 291, 423, 362, 63, 324, 20209, 63, 466, 63, 17668, 8, 589, 59, 16, 566, 267, 340, 365, 63, 1297, 26, 288, 3211, 63, 3667, 275, 283, 561, 19, 447, 2115, 28, 469, 16, 93, 950, 690, 1370, 908, 8, 2981, 63, 3667, 4439, 18, 566, 267, 587, 26, 288, 3211, 63, 3667, 275, 283, 561, 19, 447, 2115, 28, 469, 16, 93, 690, 1370, 908, 8, 2981, 63, 3667, 4439, 18, 566, 267, 1249, 275, 2008, 779, 4525, 63, 3667, 61, 435, 769, 8, 589, 59, 17, 16720, 398, 3016, 275, 730, 63, 2232, 2031, 589, 12, 1011, 958, 9, 267, 3016, 14, 409, 63, 31400, 8, 277, 12, 2306, 63, 3667, 9, 267, 372, 3016, 339, 347, 625, 4711, 8, 277, 12, 730, 63, 2232, 12, 18707, 12, 1233, 63, 1457, 12, 3965, 304, 267, 372, 283, 1297, 63, 2931, 21110, 83, 30, 334, 561, 19, 447, 17093, 12190, 4366, 83, 23089, 450, 334, 466, 63, 2232, 14, 324, 20209, 63, 3667, 12, 3965, 9, 339, 347, 5793, 8, 277, 12, 730, 63, 2232, 12, 18707, 12, 1233, 63, 1457, 12, 3965, 304, 267, 702, 730, 63, 2232, 14, 324, 20209, 63, 3667, 1988, 17, 61, 508, 13626, 267, 372, 283, 561, 19, 447, 2115, 28, 450, 83, 690, 4366, 83, 3171, 450, 334, 466, 63, 2232, 14, 324, 20209, 63, 3667, 4439, 17, 467, 3965, 9, 199, 199, 309, 2274, 314, 730, 13315, 199, 1515, 70, 275, 26017, 12190, 26283, 342, 199, 466, 5586, 14, 1107, 63, 466, 63, 16135, 14, 2683, 63, 31400, 8, 1515, 70, 9, 199, 466, 5586, 14, 635, 63, 466, 63, 16135, 14, 2683, 63, 31400, 8, 1515, 70, 9, 199, 2264, 28183, 421, 199, 533, 17555, 4748, 4936, 3767, 8, 466, 5586, 14, 14987, 4590, 1563, 304, 272, 408, 272, 8089, 626, 12821, 282, 4566, 5791, 1083, 626, 4882, 282, 8545, 590, 4310, 2366, 1083, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 372, 63, 585, 12, 2633, 304, 267, 1613, 8, 8415, 4936, 3767, 12, 291, 2843, 826, 721, 1107, 63, 585, 12, 2633, 9, 339, 347, 3550, 63, 1548, 63, 1250, 8, 277, 304, 267, 408, 600, 370, 1240, 314, 2366, 1083, 624, 267, 1900, 63, 1162, 275, 291, 14, 1506, 63, 1162, 14, 362, 63, 3214, 8, 3990, 63, 2960, 63, 8782, 29, 549, 9, 267, 340, 1900, 63, 1162, 59, 16, 1527, 16, 61, 508, 24536, 288, 1900, 63, 1162, 59, 16, 61, 275, 8189, 1560, 24104, 283, 435, 1900, 63, 1162, 59, 16, 61, 267, 1249, 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, 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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 ]
janocat/odoo
addons/l10n_ma/__init__.py
430
1071
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import l10n_ma # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2644, 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, 8664, 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, 646, 634, 709, 78, 63, 391, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 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, 8664, 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, 646, 634, 709, 78, 63, 391, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ojengwa/grr
client/comms.py
2
43816
#!/usr/bin/env python """This class handles the GRR Client Communication. Tests are in lib/communicator_test.py """ import hashlib import os import pdb import posixpath import Queue import sys import threading import time import traceback import urllib2 from M2Crypto import BIO from M2Crypto import EVP from M2Crypto import RSA from M2Crypto import X509 import psutil from google.protobuf import message as proto2_message import logging from grr.client import actions from grr.client import client_stats from grr.client import client_utils from grr.lib import communicator from grr.lib import config_lib from grr.lib import flags from grr.lib import queues from grr.lib import rdfvalue from grr.lib import registry from grr.lib import stats from grr.lib import type_info from grr.lib import utils # This determines after how many consecutive errors # GRR will retry all known proxies. PROXY_SCAN_ERROR_LIMIT = 10 class CommsInit(registry.InitHook): pre = ["StatsInit"] def RunOnce(self): # Counters used here stats.STATS.RegisterGaugeMetric("grr_client_last_stats_sent_time", long) stats.STATS.RegisterCounterMetric("grr_client_received_bytes") stats.STATS.RegisterCounterMetric("grr_client_received_messages") stats.STATS.RegisterCounterMetric("grr_client_slave_restarts") stats.STATS.RegisterCounterMetric("grr_client_sent_bytes") stats.STATS.RegisterCounterMetric("grr_client_sent_messages") class Status(object): """An abstraction to encapsulate results of the HTTP Post.""" # Number of messages received received_count = 0 # Number of messages sent to server. sent_count = 0 sent_len = 0 # Messages sent by priority. sent = {} require_fastpoll = False # Server status code (200 is OK) code = 200 def __init__(self, **kwargs): self.__dict__.update(kwargs) class GRRClientWorker(object): """The main GRR Client worker. This provides access to the GRR framework to plugins and other code. The client worker is the main thread in the client which processes requests from the server. """ stats_collector = None IDLE_THRESHOLD = 0.3 sent_bytes_per_flow = {} # Client sends stats notifications at least every 50 minutes. STATS_MAX_SEND_INTERVAL = rdfvalue.Duration("50m") # Client sends stats notifications at most every 60 seconds. STATS_MIN_SEND_INTERVAL = rdfvalue.Duration("60s") def __init__(self): """Create a new GRRClientWorker.""" super(GRRClientWorker, self).__init__() # Queue of messages from the server to be processed. self._in_queue = [] # Queue of messages to be sent to the server. self._out_queue = [] # A tally of the total byte count of messages self._out_queue_size = 0 self._is_active = False # If True, ClientStats will be forcibly sent to server during next # CheckStats() call, if less than STATS_MIN_SEND_INTERVAL time has passed # since last stats notification was sent. self._send_stats_on_check = False # Last time when we've sent stats back to the server. self.last_stats_sent_time = None self.proc = psutil.Process(os.getpid()) # We store suspended actions in this dict. We can retrieve the suspended # client action from here if needed. self.suspended_actions = {} # Use this to control the nanny transaction log. self.nanny_controller = client_utils.NannyController() self.nanny_controller.StartNanny() if not GRRClientWorker.stats_collector: GRRClientWorker.stats_collector = client_stats.ClientStatsCollector(self) GRRClientWorker.stats_collector.start() self.lock = threading.RLock() def Sleep(self, timeout): """Sleeps the calling thread with heartbeat.""" self.nanny_controller.Heartbeat() time.sleep(timeout - int(timeout)) # Split a long sleep interval into 1 second intervals so we can heartbeat. for _ in range(int(timeout)): time.sleep(1) self.nanny_controller.Heartbeat() def ClientMachineIsIdle(self): return psutil.cpu_percent(0.05) <= 100 * self.IDLE_THRESHOLD def __del__(self): self.nanny_controller.StopNanny() def Drain(self, max_size=1024): """Return a GrrQueue message list from the queue, draining it. This is used to get the messages going _TO_ the server when the client connects. Args: max_size: The size of the returned protobuf will be at most one message length over this size. Returns: A MessageList protobuf """ queue = rdfvalue.MessageList() length = 0 self._out_queue.sort(key=lambda msg: msg[0]) # Front pops are quadratic so we reverse the queue. self._out_queue.reverse() # Use implicit True/False evaluation instead of len (WTF) while self._out_queue and length < max_size: message = self._out_queue.pop()[1] queue.job.Append(message) stats.STATS.IncrementCounter("grr_client_sent_messages") # Maintain the output queue tally length += len(message.args) self._out_queue_size -= len(message.args) # Restore the old order. self._out_queue.reverse() return queue def SendReply(self, rdf_value=None, request_id=None, response_id=None, priority=None, session_id="W:0", message_type=None, name=None, require_fastpoll=None, ttl=None, blocking=True, task_id=None): """Send the protobuf to the server. Args: rdf_value: The RDFvalue to return. request_id: The id of the request this is a response to. response_id: The id of this response. priority: The priority of this message, used to jump the scheduling queue. session_id: The session id of the flow. message_type: The contents of this message, MESSAGE, STATUS, ITERATOR or RDF_VALUE. name: The name of the client action that sends this response. require_fastpoll: If set, this will set the client to fastpoll mode after sending this message. ttl: The time to live of this message. blocking: If the output queue is full, block until there is space. task_id: The task ID that the request was queued at. We send this back to the server so it can de-queue the request. Raises: RuntimeError: An object other than an RDFValue was passed for sending. """ if not isinstance(rdf_value, rdfvalue.RDFValue): raise RuntimeError("Sending objects other than RDFValues not supported.") message = rdfvalue.GrrMessage( session_id=session_id, task_id=task_id, name=name, response_id=response_id, request_id=request_id, priority=priority, require_fastpoll=require_fastpoll, ttl=ttl, type=message_type) if rdf_value: message.payload = rdf_value serialized_message = message.SerializeToString() self.ChargeBytesToSession(session_id, len(serialized_message)) if message.type == rdfvalue.GrrMessage.Type.STATUS: rdf_value.network_bytes_sent = self.sent_bytes_per_flow[session_id] del self.sent_bytes_per_flow[session_id] message.args = rdf_value.SerializeToString() try: self.QueueResponse(message, priority=message.priority, blocking=blocking) except Queue.Full: # In the case of a non blocking send, we reraise the exception to notify # the caller that something went wrong. if not blocking: raise # There is nothing we can do about it here - we just lose the message and # keep going. logging.info("Queue is full, dropping messages.") @utils.Synchronized def ChargeBytesToSession(self, session_id, length, limit=0): self.sent_bytes_per_flow.setdefault(session_id, 0) self.sent_bytes_per_flow[session_id] += length # Check after incrementing so that sent_bytes_per_flow goes over the limit # even though we don't send those bytes. This makes sure flow_runner will # die on the flow. if limit and (self.sent_bytes_per_flow[session_id] > limit): self.SendClientAlert("Network limit exceeded.") raise actions.NetworkBytesExceededError( "Action exceeded network send limit.") def QueueResponse(self, message, priority=rdfvalue.GrrMessage.Priority.MEDIUM_PRIORITY, blocking=True): """Push the Serialized Message on the output queue.""" # The simple queue has no size restrictions so we never block and ignore # this parameter. _ = blocking self._out_queue.append((-1 * priority, message)) # Maintain the tally of the output queue size. We estimate the size of the # message by only considering the args member. This is usually close enough # estimate to the overall size and avoids us un-necessarily serializing # here. self._out_queue_size += len(message.args) def HandleMessage(self, message): """Entry point for processing jobs. Args: message: The GrrMessage that was delivered from the server. """ self._is_active = True try: # Write the message to the transaction log. self.nanny_controller.WriteTransactionLog(message) # Try to retrieve a suspended action from the client worker. try: suspended_action_id = message.payload.iterator.suspended_action action = self.suspended_actions[suspended_action_id] except (AttributeError, KeyError): # Otherwise make a new action instance. action_cls = actions.ActionPlugin.classes.get( message.name, actions.ActionPlugin) action = action_cls(grr_worker=self) # Heartbeat so we have the full period to work on this message. action.Progress() action.Execute(message) # If we get here without exception, we can remove the transaction. self.nanny_controller.CleanTransactionLog() finally: self._is_active = False # We want to send ClientStats when client action is complete. self._send_stats_on_check = True def QueueMessages(self, messages): """Queue a message from the server for processing. We maintain all the incoming messages in a queue. These messages are consumed until the outgoing queue fills to the allowable level. This mechanism allows us to throttle the server messages and limit the size of the outgoing queue on the client. Note that we can only limit processing of single request messages so if a single request message generates huge amounts of response messages we will still overflow the output queue. Therefore actions must be written in such a way that each request generates a limited and known maximum number and size of responses. (e.g. do not write a single client action to fetch the entire disk). Args: messages: List of parsed protobuf arriving from the server. """ # Push all the messages to our input queue for message in messages: self._in_queue.append(message) stats.STATS.IncrementCounter("grr_client_received_messages") # As long as our output queue has some room we can process some # input messages: while self._in_queue and ( self._out_queue_size < config_lib.CONFIG["Client.max_out_queue"]): message = self._in_queue.pop(0) try: self.HandleMessage(message) # Catch any errors and keep going here except Exception as e: # pylint: disable=broad-except self.SendReply( rdfvalue.GrrStatus( status=rdfvalue.GrrStatus.ReturnedStatus.GENERIC_ERROR, error_message=utils.SmartUnicode(e)), request_id=message.request_id, response_id=message.response_id, session_id=message.session_id, task_id=message.task_id, message_type=rdfvalue.GrrMessage.Type.STATUS) if flags.FLAGS.debug: pdb.post_mortem() def MemoryExceeded(self): """Returns True if our memory footprint is too large.""" rss_size, _ = self.proc.memory_info() return rss_size / 1024 / 1024 > config_lib.CONFIG["Client.rss_max"] def InQueueSize(self): """Returns the number of protobufs ready to be sent in the queue.""" return len(self._in_queue) def OutQueueSize(self): """Returns the total size of messages ready to be sent.""" return len(self._out_queue) def IsActive(self): """Returns True if worker is currently handling a message.""" return self._is_active def CheckStats(self): """Checks if the last transmission of client stats is too long ago.""" if self.last_stats_sent_time is None: self.last_stats_sent_time = rdfvalue.RDFDatetime().Now() stats.STATS.SetGaugeValue("grr_client_last_stats_sent_time", self.last_stats_sent_time.AsSecondsFromEpoch()) time_since_last_check = (rdfvalue.RDFDatetime().Now() - self.last_stats_sent_time) # No matter what, we don't want to send stats more often than # once per STATS_MIN_SEND_INTERVAL. if time_since_last_check < self.STATS_MIN_SEND_INTERVAL: return if (time_since_last_check > self.STATS_MAX_SEND_INTERVAL or self._is_active or self._send_stats_on_check): self._send_stats_on_check = False logging.info("Sending back client statistics to the server.") action_cls = actions.ActionPlugin.classes.get( "GetClientStatsAuto", actions.ActionPlugin) action = action_cls(grr_worker=self) action.Run(rdfvalue.GetClientStatsRequest( start_time=self.last_stats_sent_time)) self.last_stats_sent_time = rdfvalue.RDFDatetime().Now() stats.STATS.SetGaugeValue("grr_client_last_stats_sent_time", self.last_stats_sent_time.AsSecondsFromEpoch()) def SendNannyMessage(self): msg = self.nanny_controller.GetNannyMessage() if msg: self.SendReply( rdfvalue.DataBlob(string=msg), session_id=rdfvalue.FlowSessionID(flow_name="NannyMessage"), priority=rdfvalue.GrrMessage.Priority.LOW_PRIORITY, require_fastpoll=False) self.nanny_controller.ClearNannyMessage() def SendClientAlert(self, msg): self.SendReply( rdfvalue.DataBlob(string=msg), session_id=rdfvalue.FlowSessionID(flow_name="ClientAlert"), priority=rdfvalue.GrrMessage.Priority.LOW_PRIORITY, require_fastpoll=False) class SizeQueue(object): """A Queue which limits the total size of its elements. The standard Queue implementations uses the total number of elements to block on. In the client we want to limit the total memory footprint, hence we need to use the total size as a measure of how full the queue is. TODO(user): this class needs some attention to ensure it is thread safe. """ total_size = 0 def __init__(self, maxsize=1024, nanny=None): self.lock = threading.RLock() self.queue = [] self._reversed = [] self.total_size = 0 self.maxsize = maxsize self.nanny = nanny def Put(self, item, priority=rdfvalue.GrrMessage.Priority.MEDIUM_PRIORITY, block=True, timeout=1000): """Put an item on the queue, blocking if it is too full. This is a slightly modified Queue.put method which blocks when the queue contains more than the threshold. Args: item: The item to put - must have a __len__() method. priority: The priority of this message. block: If True we block indefinitely. timeout: Maximum time we spend waiting on the queue (1 sec resolution). Raises: Queue.Full: if the queue is full and block is False, or timeout is exceeded. """ # We only queue already serialized objects so we know how large they are. if isinstance(item, rdfvalue.RDFValue): item = item.SerializeToString() if priority >= rdfvalue.GrrMessage.Priority.HIGH_PRIORITY: pass # If high priority is set we dont care about the size of the queue. elif not block: if self.total_size >= self.maxsize: raise Queue.Full else: count = 0 # Wait until the queue has more space. We do not hold the lock here to # ensure that the posting thread can drain this queue while we block here. while self.total_size >= self.maxsize: time.sleep(1) self.nanny.Heartbeat() count += 1 if timeout and count > timeout: raise Queue.Full with self.lock: self.queue.append((-1 * priority, item)) self.total_size += len(item) def Get(self): """Retrieves the items from the queue.""" with self.lock: if self._reversed: # We have leftovers from a partial Get(). self._reversed.reverse() self.queue = self._reversed + self.queue self.queue.sort(key=lambda msg: msg[0]) # by priority only. self.queue.reverse() self._reversed, self.queue = self.queue, [] while self._reversed: item = self._reversed.pop()[1] self.total_size -= len(item) yield item def Size(self): return self.total_size def Full(self): return self.total_size >= self.maxsize class GRRThreadedWorker(GRRClientWorker, threading.Thread): """This client worker runs the main loop in another thread. The client which uses this worker is not blocked while queuing messages to be worked on. There is only a single working thread though. The overall effect is that the HTTP client is not blocked waiting for actions to be executed, and at the same time, the client working thread is not blocked waiting on network latency. """ def __init__(self): super(GRRThreadedWorker, self).__init__() # This queue should never hit its maximum since the server will throttle # messages before this. self._in_queue = utils.HeartbeatQueue( callback=self.nanny_controller.Heartbeat, maxsize=1024) # The size of the output queue controls the worker thread. Once this queue # is too large, the worker thread will block until the queue is drained. self._out_queue = SizeQueue( maxsize=config_lib.CONFIG["Client.max_out_queue"], nanny=self.nanny_controller) self.daemon = True # Start our working thread. self.start() def Sleep(self, timeout): """Sleeps the calling thread with heartbeat.""" self.nanny_controller.Heartbeat() time.sleep(timeout - int(timeout)) # Split a long sleep interval into 1 second intervals so we can heartbeat. for _ in range(int(timeout)): time.sleep(1) # If the output queue is full, we are ready to do a post - no # point in waiting. if self._out_queue.Full(): return self.nanny_controller.Heartbeat() def Drain(self, max_size=1024): """Return a GrrQueue message list from the queue, draining it. This is used to get the messages going _TO_ the server when the client connects. Args: max_size: The size (in bytes) of the returned protobuf will be at most one message length over this size. Returns: A MessageList protobuf """ queue = rdfvalue.MessageList() length = 0 for message in self._out_queue.Get(): queue.job.Append(message) stats.STATS.IncrementCounter("grr_client_sent_messages") length += len(message) if length > max_size: break return queue def QueueResponse(self, message, priority=rdfvalue.GrrMessage.Priority.MEDIUM_PRIORITY, blocking=True): """Push the Serialized Message on the output queue.""" self._out_queue.Put(message, priority=priority, block=blocking) def QueueMessages(self, messages): """Push the message to the input queue.""" # Push all the messages to our input queue for message in messages: self._in_queue.put(message, block=True) stats.STATS.IncrementCounter("grr_client_received_messages") def InQueueSize(self): """Returns the number of protobufs ready to be sent in the queue.""" return self._in_queue.qsize() def OutQueueSize(self): """Returns the total size of messages ready to be sent.""" return self._out_queue.Size() def __del__(self): # This signals our worker thread to quit. self._in_queue.put(None, block=True) self.nanny_controller.StopNanny() def OnStartup(self): """A handler that is called on client startup.""" # We read the transaction log and fail any requests that are in it. If there # is anything in the transaction log we assume its there because we crashed # last time and let the server know. last_request = self.nanny_controller.GetTransactionLog() if last_request: status = rdfvalue.GrrStatus( status=rdfvalue.GrrStatus.ReturnedStatus.CLIENT_KILLED, error_message="Client killed during transaction") nanny_status = self.nanny_controller.GetNannyStatus() if nanny_status: status.nanny_status = nanny_status self.SendReply(status, request_id=last_request.request_id, response_id=1, session_id=last_request.session_id, message_type=rdfvalue.GrrMessage.Type.STATUS) self.nanny_controller.CleanTransactionLog() # Inform the server that we started. action_cls = actions.ActionPlugin.classes.get( "SendStartupInfo", actions.ActionPlugin) action = action_cls(grr_worker=self) action.Run(None, ttl=1) def run(self): """Main thread for processing messages.""" self.OnStartup() # As long as our output queue has some room we can process some # input messages: while True: message = self._in_queue.get() # A message of None is our terminal message. if message is None: break try: self.HandleMessage(message) # Catch any errors and keep going here except Exception as e: # pylint: disable=broad-except logging.warn("%s", e) self.SendReply( rdfvalue.GrrStatus( status=rdfvalue.GrrStatus.ReturnedStatus.GENERIC_ERROR, error_message=utils.SmartUnicode(e)), request_id=message.request_id, response_id=message.response_id, session_id=message.session_id, task_id=message.task_id, message_type=rdfvalue.GrrMessage.Type.STATUS) if flags.FLAGS.debug: pdb.post_mortem() class GRRHTTPClient(object): """A class which abstracts away HTTP communications. To create a new GRR HTTP client, intantiate this class and generate its Run() method. The HTTP client starts up by loading a communicator which will read the client's public key (or create a new random key). Since the client ID is based on the key (its a hash of the public key), the communicator controls the client name. The client worker is then created - this will be the main thread for executing server messages. The HTTP engine simply reads pending messages from the client worker queues and makes POST requests to the server. The POST request may return the following error conditions: - A successful POST is signified by a status of 200: The client worker is given any requests the server has sent. - A status code of 406 means that the server is unable to communicate with the client. The client will then prepare an enrollment request CSR and send that as a high priority. Enrollment requests are throttled to a maximum of one every 10 minutes. - A status code of 500 is an error, the messages are re-queued and the client waits and retried to send them later. """ def __init__(self, ca_cert=None, worker=None, private_key=None): """Constructor. Args: ca_cert: String representation of a CA certificate to use for checking server certificate. worker: The client worker class to use. Defaults to GRRThreadedWorker(). private_key: The private key for this client. Defaults to config Client.private_key. """ self.ca_cert = ca_cert if private_key is None: private_key = config_lib.CONFIG.Get("Client.private_key", default=None) self.communicator = ClientCommunicator(private_key=private_key) self.active_server_url = None self.consecutive_connection_errors = 0 # The time we last sent an enrollment request. self.last_enrollment_time = 0 # The time we last checked with the foreman. self.last_foreman_check = 0 # The client worker does all the real work here. if worker: self.client_worker = worker() else: self.client_worker = GRRThreadedWorker() # Start off with a maximum polling interval self.sleep_time = config_lib.CONFIG["Client.poll_max"] def GetServerUrl(self): if not self.active_server_url: if not self.EstablishConnection(): return "" return self.active_server_url def EstablishConnection(self): """Finds a connection to the server and initializes the client. This method tries all pairs of location urls and known proxies until it finds one that works. It does so by downloading the server.pem from the GRR server and verifies it directly. Note that this also refreshes the server certificate. Returns: A boolean indicating success. Side-effect: On success we set self.active_server_url, which is used by other methods to check if we have made a successful connection in the past. """ # This gets proxies from the platform specific proxy settings. proxies = client_utils.FindProxies() # Also try to connect directly if all proxies fail. proxies.append("") # Also try all proxies configured in the config system. proxies.extend(config_lib.CONFIG["Client.proxy_servers"]) for server_url in config_lib.CONFIG["Client.control_urls"]: for proxy in proxies: try: proxydict = {} if proxy: proxydict["http"] = proxy proxy_support = urllib2.ProxyHandler(proxydict) opener = urllib2.build_opener(proxy_support) urllib2.install_opener(opener) cert_url = "/".join((posixpath.dirname(server_url), "server.pem")) request = urllib2.Request(cert_url, None, {"Cache-Control": "no-cache"}) handle = urllib2.urlopen(request, timeout=10) server_pem = handle.read() if "BEGIN CERTIFICATE" in server_pem: # Now we know that this proxy is working. We still have # to verify the certificate. self.communicator.LoadServerCertificate( server_certificate=server_pem, ca_certificate=self.ca_cert) # If we reach this point, the server can be reached and the # certificate is valid. self.server_certificate = server_pem self.active_server_url = server_url handle.close() return True except urllib2.URLError: pass except Exception as e: # pylint: disable=broad-except logging.info("Unable to verify server certificate at %s: %s", cert_url, e) # No connection is possible at all. logging.info("Could not connect to GRR servers %s, directly or through " "these proxies: %s.", config_lib.CONFIG["Client.control_urls"], proxies) return False def MakeRequest(self, data, status): """Make a HTTP Post request and return the raw results.""" status.sent_len = len(data) stats.STATS.IncrementCounter("grr_client_sent_bytes", len(data)) return_msg = "" try: # Now send the request using POST start = time.time() url = "%s?api=%s" % (self.GetServerUrl(), config_lib.CONFIG["Network.api"]) req = urllib2.Request(utils.SmartStr(url), data, {"Content-Type": "binary/octet-stream"}) handle = urllib2.urlopen(req) data = handle.read() logging.debug("Request took %s Seconds", time.time() - start) self.consecutive_connection_errors = 0 stats.STATS.IncrementCounter("grr_client_received_bytes", len(data)) return data except urllib2.HTTPError as e: status.code = e.code # Server can not talk with us - re-enroll. if e.code == 406: self.InitiateEnrolment(status) return_msg = "" else: self.consecutive_connection_errors += 1 if self.consecutive_connection_errors % PROXY_SCAN_ERROR_LIMIT == 0: # Reset the active connection, this will trigger a reconnect attempt. self.active_server_url = None return_msg = str(e) except urllib2.URLError as e: status.code = 500 self.consecutive_connection_errors += 1 if self.consecutive_connection_errors % PROXY_SCAN_ERROR_LIMIT == 0: # Reset the active connection, this will trigger a reconnect attempt. self.active_server_url = None return_msg = str(e) # Error path: status.sent_count = 0 return return_msg def RunOnce(self): """Makes a single request to the GRR server. Returns: A Status() object indicating how the last POST went. """ try: status = Status() # Here we only drain messages if we were able to connect to the server in # the last poll request. Otherwise we just wait until the connection comes # back so we don't expire our messages too fast. if self.consecutive_connection_errors == 0: # Grab some messages to send message_list = self.client_worker.Drain( max_size=config_lib.CONFIG["Client.max_post_size"]) else: message_list = rdfvalue.MessageList() sent_count = 0 sent = {} require_fastpoll = False for message in message_list.job: sent_count += 1 require_fastpoll |= message.require_fastpoll sent.setdefault(message.priority, 0) sent[message.priority] += 1 status = Status(sent_count=sent_count, sent=sent, require_fastpoll=require_fastpoll) # Make new encrypted ClientCommunication rdfvalue. payload = rdfvalue.ClientCommunication() # If our memory footprint is too large, we advertise that our input queue # is full. This will prevent the server from sending us any messages, and # hopefully allow us to work down our memory usage, by processing any # outstanding messages. if self.client_worker.MemoryExceeded(): logging.info("Memory exceeded, will not retrieve jobs.") payload.queue_size = 1000000 else: # Let the server know how many messages are currently queued in # the input queue. payload.queue_size = self.client_worker.InQueueSize() nonce = self.communicator.EncodeMessages(message_list, payload) response = self.MakeRequest(payload.SerializeToString(), status) if status.code != 200: # We don't print response here since it should be encrypted and will # cause ascii conversion errors. logging.info("%s: Could not connect to server at %s, status %s", self.communicator.common_name, self.GetServerUrl(), status.code) # Reschedule the tasks back on the queue so they get retried next time. messages = list(message_list.job) for message in messages: message.priority = rdfvalue.GrrMessage.Priority.HIGH_PRIORITY message.require_fastpoll = False message.ttl -= 1 if message.ttl > 0: # Schedule with high priority to make it jump the queue. self.client_worker.QueueResponse( message, rdfvalue.GrrMessage.Priority.HIGH_PRIORITY + 1) else: logging.info("Dropped message due to retransmissions.") return status if not response: return status try: tmp = self.communicator.DecryptMessage(response) (messages, source, server_nonce) = tmp if server_nonce != nonce: logging.info("Nonce not matched.") status.code = 500 return status except proto2_message.DecodeError: logging.info("Protobuf decode error. Bad URL or auth.") status.code = 500 return status if source != self.communicator.server_name: logging.info("Received a message not from the server " "%s, expected %s.", source, self.communicator.server_name) status.code = 500 return status status.received_count = len(messages) # If we're not going to fastpoll based on outbound messages, check to see # if any inbound messages want us to fastpoll. This means we drop to # fastpoll immediately on a new request rather than waiting for the next # beacon to report results. if not status.require_fastpoll: for message in messages: if message.require_fastpoll: status.require_fastpoll = True break # Process all messages. Messages can be processed by clients in # any order since clients do not have state. self.client_worker.QueueMessages(messages) except Exception: # pylint: disable=broad-except # Catch everything, yes, this is terrible but necessary logging.warn("Uncaught exception caught: %s", traceback.format_exc()) if status: status.code = 500 if flags.FLAGS.debug: pdb.post_mortem() return status def SendForemanRequest(self): self.client_worker.SendReply( rdfvalue.DataBlob(), session_id=rdfvalue.FlowSessionID(flow_name="Foreman"), priority=rdfvalue.GrrMessage.Priority.LOW_PRIORITY, require_fastpoll=False) def Run(self): """A Generator which makes a single request to the GRR server. Callers should generate this when they wish to make a connection to the server. It is up to the caller to sleep between calls in order to enforce the required network and CPU utilization policies. Raises: RuntimeError: Too many connection errors have been encountered. Yields: A Status() object indicating how the last POST went. """ while True: self.consecutive_connection_errors = 0 while self.active_server_url is None: if self.EstablishConnection(): # Everything went as expected - we don't need to return to # the main loop (which would mean sleeping for a poll_time). break else: # If we can't reconnect to the server for a long time, we restart # to reset our state. In some very rare cases, the urrlib can get # confused and we need to reset it before we can start talking to # the server again. self.consecutive_connection_errors += 1 limit = config_lib.CONFIG["Client.connection_error_limit"] if self.consecutive_connection_errors > limit: raise RuntimeError("Too many connection errors, exiting.") # Constantly retrying will not work, we back off a bit. time.sleep(60) yield Status() # Check if there is a message from the nanny to be sent. self.client_worker.SendNannyMessage() now = time.time() # Check with the foreman if we need to if (now > self.last_foreman_check + config_lib.CONFIG["Client.foreman_check_frequency"]): # We must not queue messages from the comms thread with blocking=True # or we might deadlock. If the output queue is full, we can't accept # more work from the foreman anyways so it's ok to drop the message. try: self.client_worker.SendReply( rdfvalue.DataBlob(), session_id=rdfvalue.FlowSessionID(flow_name="Foreman"), priority=rdfvalue.GrrMessage.Priority.LOW_PRIORITY, require_fastpoll=False, blocking=False) self.last_foreman_check = now except Queue.Full: pass status = self.RunOnce() # We suicide if our memory is exceeded, and there is no more work to do # right now. Our death should not result in loss of messages since we are # not holding any requests in our input queues. if (self.client_worker.MemoryExceeded() and not self.client_worker.IsActive() and self.client_worker.InQueueSize() == 0 and self.client_worker.OutQueueSize() == 0): logging.warning("Memory exceeded - exiting.") self.client_worker.SendClientAlert("Memory limit exceeded, exiting.") # Make sure this will return True so we don't get more work. # pylint: disable=g-bad-name self.client_worker.MemoryExceeded = lambda: True # pylint: enable=g-bad-name # Now send back the client message. self.RunOnce() # And done for now. sys.exit(-1) self.Wait(status) yield status def Wait(self, status): """This function implements the backoff algorithm. We sleep for the required amount of time based on the status of the last request. Args: status: The status of the last request. """ if status.code == 500: # In this case, the server just became unavailable. We have been able # to make connections before but now we can't anymore for some reason. # We want to wait at least some time before retrying in case the frontend # served a 500 error because it is overloaded already. error_sleep_time = max(config_lib.CONFIG["Client.error_poll_min"], self.sleep_time) logging.debug("Could not reach server. Sleeping for %s", error_sleep_time) self.Sleep(error_sleep_time, heartbeat=False) return # If we communicated this time we want to continue aggressively if status.require_fastpoll > 0: self.sleep_time = config_lib.CONFIG["Client.poll_min"] cn = self.communicator.common_name logging.debug("%s: Sending %s(%s), Received %s messages. Sleeping for %s", cn, status.sent_count, status.sent_len, status.received_count, self.sleep_time) self.Sleep(self.sleep_time, heartbeat=False) # Back off slowly at first and fast if no answer. self.sleep_time = min( config_lib.CONFIG["Client.poll_max"], max(config_lib.CONFIG["Client.poll_min"], self.sleep_time) * config_lib.CONFIG["Client.poll_slew"]) def InitiateEnrolment(self, status): """Initiate the enrollment process. We do not sent more than one request every 10 minutes. Args: status: The http status object, used to set fastpoll mode if this is the first enrollment request sent since restart. """ now = time.time() if now > self.last_enrollment_time + 10 * 60: if not self.last_enrollment_time: # This is the first enrolment request - we should enter fastpoll mode. status.require_fastpoll = True self.last_enrollment_time = now # Send registration request: self.client_worker.SendReply( rdfvalue.Certificate(type=rdfvalue.Certificate.Type.CSR, pem=self.communicator.GetCSR()), session_id=rdfvalue.SessionID( queue=queues.ENROLLMENT, flow_name="Enrol")) def Sleep(self, timeout, heartbeat=False): if not heartbeat: time.sleep(timeout) else: self.client_worker.Sleep(timeout) class ClientCommunicator(communicator.Communicator): """A communicator implementation for clients. This extends the generic communicator to include verification of server side certificates. """ BITS = 1024 def _ParseRSAKey(self, rsa): """Use the RSA private key to initialize our parameters. We set our client name as the hash of the RSA private key. Args: rsa: An RSA key pair. """ # Our CN will be the first 64 bits of the hash of the public key. public_key = rsa.pub()[1] self.common_name = rdfvalue.ClientURN("C.%s" % ( hashlib.sha256(public_key).digest()[:8].encode("hex"))) def _LoadOurCertificate(self): """Loads an RSA key from the certificate. If no certificate is found, or it is invalid, we make a new random RSA key, and store it as our certificate. Returns: An RSA key - either from the certificate or a new random key. """ if self.private_key: try: # This is our private key - make sure it has no password set. self.private_key.Validate() rsa = self.private_key.GetPrivateKey() self._ParseRSAKey(rsa) logging.info("Starting client %s", self.common_name) return rsa except type_info.TypeValueError: pass # We either have an invalid key or no key. We just generate a new one. # 65537 is the standard value for e rsa = RSA.gen_key(self.BITS, 65537, lambda: None) self._ParseRSAKey(rsa) logging.info("Client pending enrolment %s", self.common_name) # Make new keys pk = EVP.PKey() pk.assign_rsa(rsa) # Save the keys self.SavePrivateKey(pk) return rsa def GetCSR(self): """Return our CSR in pem format.""" csr = X509.Request() pk = EVP.PKey() rsa = self._LoadOurCertificate() pk.assign_rsa(rsa) csr.set_pubkey(pk) name = csr.get_subject() name.CN = str(self.common_name) csr.sign(pk, "sha1") return csr.as_pem() def SavePrivateKey(self, pkey): """Store the new private key on disk.""" bio = BIO.MemoryBuffer() pkey.save_key_bio(bio, cipher=None) self.private_key = rdfvalue.PEMPrivateKey(bio.read_all()) config_lib.CONFIG.Set("Client.private_key", self.private_key) config_lib.CONFIG.Write() def LoadServerCertificate(self, server_certificate=None, ca_certificate=None): """Loads and verifies the server certificate.""" try: server_cert = X509.load_cert_string(str(server_certificate)) ca_cert = X509.load_cert_string(str(ca_certificate)) # Check that the server certificate verifies if server_cert.verify(ca_cert.get_pubkey()) != 1: self.server_name = None raise IOError("Server cert is invalid.") # Make sure that the serial number is higher. server_cert_serial = server_cert.get_serial_number() if server_cert_serial < config_lib.CONFIG["Client.server_serial_number"]: # We can not accept this serial number... raise IOError("Server cert is too old.") elif server_cert_serial > config_lib.CONFIG[ "Client.server_serial_number"]: logging.info("Server serial number updated to %s", server_cert_serial) config_lib.CONFIG.Set("Client.server_serial_number", server_cert_serial) # Save the new data to the config file. config_lib.CONFIG.Write() except X509.X509Error: raise IOError("Server cert is invalid.") self.server_name = self.pub_key_cache.GetCNFromCert(server_cert) self.server_certificate = server_certificate self.ca_certificate = ca_certificate # We need to store the serialised version of the public key due # to M2Crypto memory referencing bugs self.pub_key_cache.Put( self.server_name, self.pub_key_cache.PubKeyFromCert(server_cert)) def EncodeMessages(self, message_list, result, **kwargs): # Force the right API to be used kwargs["api_version"] = config_lib.CONFIG["Network.api"] return super(ClientCommunicator, self).EncodeMessages( message_list, result, **kwargs)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 2765, 1021, 10022, 314, 598, 13381, 6810, 29585, 14, 199, 199, 2925, 787, 315, 1973, 15, 9203, 707, 63, 396, 14, 647, 199, 624, 421, 199, 646, 8337, 199, 646, 747, 199, 199, 646, 10543, 199, 646, 15454, 199, 646, 10703, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 646, 5190, 199, 646, 4011, 18, 4388, 199, 504, 603, 18, 17134, 492, 699, 2090, 199, 504, 603, 18, 17134, 492, 662, 14159, 199, 504, 603, 18, 17134, 492, 18471, 199, 504, 603, 18, 17134, 492, 1323, 6576, 199, 646, 22214, 199, 199, 504, 6233, 14, 7204, 492, 1245, 465, 4104, 18, 63, 1188, 199, 199, 646, 2050, 199, 199, 504, 31118, 14, 1258, 492, 5445, 199, 504, 31118, 14, 1258, 492, 1890, 63, 3200, 199, 504, 31118, 14, 1258, 492, 1890, 63, 1208, 199, 504, 31118, 14, 773, 492, 13882, 707, 199, 504, 31118, 14, 773, 492, 1101, 63, 773, 199, 504, 31118, 14, 773, 492, 3285, 199, 504, 31118, 14, 773, 492, 21366, 199, 504, 31118, 14, 773, 492, 18148, 585, 199, 504, 31118, 14, 773, 492, 7086, 199, 504, 31118, 14, 773, 492, 5020, 199, 504, 31118, 14, 773, 492, 730, 63, 815, 199, 504, 31118, 14, 773, 492, 3778, 421, 199, 3, 961, 16756, 2410, 4212, 5002, 23376, 2552, 199, 3, 598, 13381, 911, 7269, 1006, 6040, 14942, 14, 199, 20026, 63, 24078, 63, 3170, 63, 13387, 275, 1616, 421, 199, 533, 7046, 83, 9346, 8, 5189, 14, 9346, 8481, 304, 819, 876, 275, 2097, 8257, 9346, 937, 819, 347, 3378, 25690, 8, 277, 304, 272, 327, 1849, 324, 878, 1202, 2348, 272, 5020, 14, 19202, 14, 7099, 39, 30949, 11119, 480, 2587, 82, 63, 1258, 63, 2019, 63, 3200, 63, 1150, 63, 521, 401, 1846, 9, 272, 5020, 14, 19202, 14, 7099, 11348, 11119, 480, 2587, 82, 63, 1258, 63, 9226, 63, 2394, 531, 272, 5020, 14, 19202, 14, 7099, 11348, 11119, 480, 2587, 82, 63, 1258, 63, 9226, 63, 3431, 531, 272, 5020, 14, 19202, 14, 7099, 11348, 11119, 480, 2587, 82, 63, 1258, 63, 12384, 63, 10506, 83, 531, 272, 5020, 14, 19202, 14, 7099, 11348, 11119, 480, 2587, 82, 63, 1258, 63, 1150, 63, 2394, 531, 272, 5020, 14, 19202, 14, 7099, 11348, 11119, 480, 2587, 82, 63, 1258, 63, 1150, 63, 3431, 531, 421, 199, 533, 9795, 8, 785, 304, 523, 408, 2493, 2236, 29639, 370, 22667, 5434, 2058, 402, 314, 3101, 7711, 1041, 523, 327, 4860, 402, 3788, 3086, 523, 3086, 63, 835, 275, 378, 819, 327, 4860, 402, 3788, 4847, 370, 1654, 14, 523, 4847, 63, 835, 275, 378, 523, 4847, 63, 552, 275, 378, 523, 327, 27377, 4847, 701, 7464, 14, 523, 4847, 275, 1052, 819, 4409, 63, 7015, 6843, 275, 756, 819, 327, 7146, 2004, 1233, 334, 1840, 365, 9949, 9, 523, 1233, 275, 1926, 819, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 272, 291, 855, 807, 4343, 873, 8, 958, 9, 421, 199, 533, 598, 13381, 3041, 12678, 8, 785, 304, 523, 408, 1918, 2446, 598, 13381, 6810, 7239, 14, 819, 961, 6571, 2879, 370, 314, 598, 13381, 10059, 370, 8963, 436, 1163, 1233, 14, 819, 710, 1890, 7239, 365, 314, 2446, 2462, 315, 314, 1890, 1314, 10358, 4145, 523, 687, 314, 1654, 14, 523, 408, 819, 5020, 63, 10946, 275, 488, 819, 23240, 63, 19307, 275, 378, 14, 19, 819, 4847, 63, 2394, 63, 529, 63, 1659, 275, 1052, 819, 327, 6810, 16178, 5020, 13116, 737, 5210, 4036, 5238, 9395, 14, 523, 13146, 51, 63, 4283, 63, 20469, 63, 17359, 275, 18148, 585, 14, 13283, 480, 1400, 77, 531, 819, 327, 6810, 16178, 5020, 13116, 737, 4750, 4036, 5212, 4696, 14, 523, 13146, 51, 63, 4896, 63, 20469, 63, 17359, 275, 18148, 585, 14, 13283, 480, 2259, 83, 531, 819, 347, 636, 826, 721, 277, 304, 272, 408, 2499, 282, 892, 598, 13381, 3041, 12678, 1041, 272, 1613, 8, 3975, 50, 3041, 12678, 12, 291, 2843, 826, 4533, 339, 327, 10703, 402, 3788, 687, 314, 1654, 370, 506, 7686, 14, 272, 291, 423, 262, 63, 1825, 275, 942, 339, 327, 10703, 402, 3788, 370, 506, 4847, 370, 314, 1654, 14, 272, 291, 423, 548, 63, 1825, 275, 942, 339, 327, 437, 307, 1183, 402, 314, 3141, 3696, 2338, 402, 3788, 272, 291, 423, 548, 63, 1825, 63, 890, 275, 378, 339, 291, 423, 374, 63, 2682, 275, 756, 339, 327, 982, 715, 12, 6810, 8257, 911, 506, 367, 559, 66, 590, 4847, 370, 1654, 5309, 2163, 272, 327, 2670, 8257, 342, 1240, 12, 340, 6656, 2419, 13146, 51, 63, 4896, 63, 20469, 63, 17359, 900, 965, 3032, 272, 327, 3967, 2061, 5020, 6955, 1990, 4847, 14, 272, 291, 423, 2254, 63, 3200, 63, 265, 63, 1074, 275, 756, 339, 327, 15237, 900, 1380, 781, 9064, 4847, 5020, 1771, 370, 314, 1654, 14, 272, 291, 14, 2019, 63, 3200, 63, 1150, 63, 521, 275, 488, 339, 291, 14, 4687, 275, 22214, 14, 3498, 8, 736, 14, 17829, 1012, 339, 327, 2136, 3877, 308, 18559, 5445, 315, 642, 1211, 14, 2136, 883, 8044, 314, 308, 18559, 272, 327, 1890, 1595, 687, 2348, 340, 4346, 14, 272, 291, 14, 83, 18559, 63, 3723, 275, 1052, 339, 327, 3645, 642, 370, 3304, 314, 302, 1189, 89, 6008, 943, 14, 272, 291, 14, 78, 1189, 89, 63, 5538, 275, 1890, 63, 1208, 14, 46, 1189, 89, 7506, 342, 272, 291, 14, 78, 1189, 89, 63, 5538, 14, 3162, 46, 1189, 89, 342, 272, 340, 440, 598, 13381, 3041, 12678, 14, 3200, 63, 10946, 26, 489, 598, 13381, 3041, 12678, 14, 3200, 63, 10946, 275, 1890, 63, 3200, 14, 3041, 8257, 12852, 8, 277, 9, 489, 598, 13381, 3041, 12678, 14, 3200, 63, 10946, 14, 928, 342, 339, 291, 14, 831, 275, 5796, 14, 30550, 342, 819, 347, 428, 3614, 8, 277, 12, 2653, 304, 272, 408, 51, 274, 8277, 314, 6358, 2462, 543, 32015, 1041, 272, 291, 14, 78, 1189, 89, 63, 5538, 14, 1966, 16145, 342, 272, 900, 14, 4532, 8, 2593, 446, 1109, 8, 2593, 430, 339, 327, 11740, 282, 1846, 9435, 6252, 1901, 413, 3499, 15802, 880, 781, 883 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 624, 2765, 1021, 10022, 314, 598, 13381, 6810, 29585, 14, 199, 199, 2925, 787, 315, 1973, 15, 9203, 707, 63, 396, 14, 647, 199, 624, 421, 199, 646, 8337, 199, 646, 747, 199, 199, 646, 10543, 199, 646, 15454, 199, 646, 10703, 199, 646, 984, 199, 646, 5796, 199, 646, 900, 199, 646, 5190, 199, 646, 4011, 18, 4388, 199, 504, 603, 18, 17134, 492, 699, 2090, 199, 504, 603, 18, 17134, 492, 662, 14159, 199, 504, 603, 18, 17134, 492, 18471, 199, 504, 603, 18, 17134, 492, 1323, 6576, 199, 646, 22214, 199, 199, 504, 6233, 14, 7204, 492, 1245, 465, 4104, 18, 63, 1188, 199, 199, 646, 2050, 199, 199, 504, 31118, 14, 1258, 492, 5445, 199, 504, 31118, 14, 1258, 492, 1890, 63, 3200, 199, 504, 31118, 14, 1258, 492, 1890, 63, 1208, 199, 504, 31118, 14, 773, 492, 13882, 707, 199, 504, 31118, 14, 773, 492, 1101, 63, 773, 199, 504, 31118, 14, 773, 492, 3285, 199, 504, 31118, 14, 773, 492, 21366, 199, 504, 31118, 14, 773, 492, 18148, 585, 199, 504, 31118, 14, 773, 492, 7086, 199, 504, 31118, 14, 773, 492, 5020, 199, 504, 31118, 14, 773, 492, 730, 63, 815, 199, 504, 31118, 14, 773, 492, 3778, 421, 199, 3, 961, 16756, 2410, 4212, 5002, 23376, 2552, 199, 3, 598, 13381, 911, 7269, 1006, 6040, 14942, 14, 199, 20026, 63, 24078, 63, 3170, 63, 13387, 275, 1616, 421, 199, 533, 7046, 83, 9346, 8, 5189, 14, 9346, 8481, 304, 819, 876, 275, 2097, 8257, 9346, 937, 819, 347, 3378, 25690, 8, 277, 304, 272, 327, 1849, 324, 878, 1202, 2348, 272, 5020, 14, 19202, 14, 7099, 39, 30949, 11119, 480, 2587, 82, 63, 1258, 63, 2019, 63, 3200, 63, 1150, 63, 521, 401, 1846, 9, 272, 5020, 14, 19202, 14, 7099, 11348, 11119, 480, 2587, 82, 63, 1258, 63, 9226, 63, 2394, 531, 272, 5020, 14, 19202, 14, 7099, 11348, 11119, 480, 2587, 82, 63, 1258, 63, 9226, 63, 3431, 531, 272, 5020, 14, 19202, 14, 7099, 11348, 11119, 480, 2587, 82, 63, 1258, 63, 12384, 63, 10506, 83, 531, 272, 5020, 14, 19202, 14, 7099, 11348, 11119, 480, 2587, 82, 63, 1258, 63, 1150, 63, 2394, 531, 272, 5020, 14, 19202, 14, 7099, 11348, 11119, 480, 2587, 82, 63, 1258, 63, 1150, 63, 3431, 531, 421, 199, 533, 9795, 8, 785, 304, 523, 408, 2493, 2236, 29639, 370, 22667, 5434, 2058, 402, 314, 3101, 7711, 1041, 523, 327, 4860, 402, 3788, 3086, 523, 3086, 63, 835, 275, 378, 819, 327, 4860, 402, 3788, 4847, 370, 1654, 14, 523, 4847, 63, 835, 275, 378, 523, 4847, 63, 552, 275, 378, 523, 327, 27377, 4847, 701, 7464, 14, 523, 4847, 275, 1052, 819, 4409, 63, 7015, 6843, 275, 756, 819, 327, 7146, 2004, 1233, 334, 1840, 365, 9949, 9, 523, 1233, 275, 1926, 819, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 272, 291, 855, 807, 4343, 873, 8, 958, 9, 421, 199, 533, 598, 13381, 3041, 12678, 8, 785, 304, 523, 408, 1918, 2446, 598, 13381, 6810, 7239, 14, 819, 961, 6571, 2879, 370, 314, 598, 13381, 10059, 370, 8963, 436, 1163, 1233, 14, 819, 710, 1890, 7239, 365, 314, 2446, 2462, 315, 314, 1890, 1314, 10358, 4145, 523, 687, 314, 1654, 14, 523, 408, 819, 5020, 63, 10946, 275, 488, 819, 23240, 63, 19307, 275, 378, 14, 19, 819, 4847, 63, 2394, 63, 529, 63, 1659, 275, 1052, 819, 327, 6810, 16178, 5020, 13116, 737, 5210, 4036, 5238, 9395, 14, 523, 13146, 51, 63, 4283, 63, 20469, 63, 17359, 275, 18148, 585, 14, 13283, 480, 1400, 77, 531, 819, 327, 6810, 16178, 5020, 13116, 737, 4750, 4036, 5212, 4696, 14, 523, 13146, 51, 63, 4896, 63, 20469, 63, 17359, 275, 18148, 585, 14, 13283, 480, 2259, 83, 531, 819, 347, 636, 826, 721, 277, 304, 272, 408, 2499, 282, 892, 598, 13381, 3041, 12678, 1041, 272, 1613, 8, 3975, 50, 3041, 12678, 12, 291, 2843, 826, 4533, 339, 327, 10703, 402, 3788, 687, 314, 1654, 370, 506, 7686, 14, 272, 291, 423, 262, 63, 1825, 275, 942, 339, 327, 10703, 402, 3788, 370, 506, 4847, 370, 314, 1654, 14, 272, 291, 423, 548, 63, 1825, 275, 942, 339, 327, 437, 307, 1183, 402, 314, 3141, 3696, 2338, 402, 3788, 272, 291, 423, 548, 63, 1825, 63, 890, 275, 378, 339, 291, 423, 374, 63, 2682, 275, 756, 339, 327, 982, 715, 12, 6810, 8257, 911, 506, 367, 559, 66, 590, 4847, 370, 1654, 5309, 2163, 272, 327, 2670, 8257, 342, 1240, 12, 340, 6656, 2419, 13146, 51, 63, 4896, 63, 20469, 63, 17359, 900, 965, 3032, 272, 327, 3967, 2061, 5020, 6955, 1990, 4847, 14, 272, 291, 423, 2254, 63, 3200, 63, 265, 63, 1074, 275, 756, 339, 327, 15237, 900, 1380, 781, 9064, 4847, 5020, 1771, 370, 314, 1654, 14, 272, 291, 14, 2019, 63, 3200, 63, 1150, 63, 521, 275, 488, 339, 291, 14, 4687, 275, 22214, 14, 3498, 8, 736, 14, 17829, 1012, 339, 327, 2136, 3877, 308, 18559, 5445, 315, 642, 1211, 14, 2136, 883, 8044, 314, 308, 18559, 272, 327, 1890, 1595, 687, 2348, 340, 4346, 14, 272, 291, 14, 83, 18559, 63, 3723, 275, 1052, 339, 327, 3645, 642, 370, 3304, 314, 302, 1189, 89, 6008, 943, 14, 272, 291, 14, 78, 1189, 89, 63, 5538, 275, 1890, 63, 1208, 14, 46, 1189, 89, 7506, 342, 272, 291, 14, 78, 1189, 89, 63, 5538, 14, 3162, 46, 1189, 89, 342, 272, 340, 440, 598, 13381, 3041, 12678, 14, 3200, 63, 10946, 26, 489, 598, 13381, 3041, 12678, 14, 3200, 63, 10946, 275, 1890, 63, 3200, 14, 3041, 8257, 12852, 8, 277, 9, 489, 598, 13381, 3041, 12678, 14, 3200, 63, 10946, 14, 928, 342, 339, 291, 14, 831, 275, 5796, 14, 30550, 342, 819, 347, 428, 3614, 8, 277, 12, 2653, 304, 272, 408, 51, 274, 8277, 314,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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 ]
fanglinfang/myuw
myuw/migrations/0002_auto__add_unique_usernotices_notice_hash_user__add_field_categorylinks.py
1
6154
# -*- 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): # Eh, I'm not so worried about tracking user notices that this is a problem db.clear_table(u'myuw_mobile_usernotices') # Adding unique constraint on 'UserNotices', fields ['notice_hash', 'user'] db.create_unique(u'myuw_mobile_usernotices', ['notice_hash', 'user_id']) # Adding field 'CategoryLinks.new_tab' db.add_column(u'myuw_mobile_categorylinks', 'new_tab', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) def backwards(self, orm): # Removing unique constraint on 'UserNotices', fields ['notice_hash', 'user'] db.delete_unique(u'myuw_mobile_usernotices', ['notice_hash', 'user_id']) # Deleting field 'CategoryLinks.new_tab' db.delete_column(u'myuw_mobile_categorylinks', 'new_tab') models = { u'myuw.building': { 'Meta': {'object_name': 'Building'}, 'code': ('django.db.models.fields.CharField', [], {'max_length': '6', 'db_index': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'latititude': ('django.db.models.fields.CharField', [], {'max_length': '40'}), 'longitude': ('django.db.models.fields.CharField', [], {'max_length': '40'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}) }, u'myuw.categorylinks': { 'Meta': {'object_name': 'CategoryLinks'}, 'campus': ('django.db.models.fields.CharField', [], {'max_length': '8', 'null': 'True'}), 'category_id': ('django.db.models.fields.CharField', [], {'max_length': '80'}), 'category_name': ('django.db.models.fields.CharField', [], {'max_length': '80'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'new_tab': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'sub_category': ('django.db.models.fields.CharField', [], {'max_length': '80'}), 'title': ('django.db.models.fields.CharField', [], {'max_length': '150'}), 'url': ('django.db.models.fields.CharField', [], {'max_length': '150'}) }, u'myuw.coursecolor': { 'Meta': {'object_name': 'CourseColor'}, 'color_id': ('django.db.models.fields.PositiveIntegerField', [], {}), 'course_number': ('django.db.models.fields.CharField', [], {'max_length': '3'}), 'curriculum_abbr': ('django.db.models.fields.CharField', [], {'max_length': '10'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {}), 'quarter': ('django.db.models.fields.CharField', [], {'max_length': '10', 'db_index': 'True'}), 'regid': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_index': 'True'}), 'section_id': ('django.db.models.fields.CharField', [], {'max_length': '2'}), 'year': ('django.db.models.fields.PositiveSmallIntegerField', [], {'db_index': 'True'}) }, u'myuw.studentaccountsbalances': { 'Meta': {'object_name': 'StudentAccountsBalances'}, 'asof_datetime': ('django.db.models.fields.DateTimeField', [], {}), 'employee_id': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '10', 'null': 'True', 'blank': 'True'}), 'husky_card': ('django.db.models.fields.DecimalField', [], {'default': '0.0', 'max_digits': '6', 'decimal_places': '2'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_am': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'residence_hall_dining': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '7', 'decimal_places': '2', 'blank': 'True'}), 'student_number': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '10', 'db_index': 'True'}) }, u'myuw.tuitiondate': { 'Meta': {'object_name': 'TuitionDate'}, 'date': ('django.db.models.fields.DateField', [], {}), 'date_stored': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['myuw.User']", 'unique': 'True', 'on_delete': 'models.PROTECT'}) }, u'myuw.user': { 'Meta': {'object_name': 'User'}, u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'last_visit': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2014, 9, 15, 0, 0)'}), 'uwnetid': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '16'}), 'uwregid': ('django.db.models.fields.CharField', [], {'max_length': '32', 'unique': 'True', 'null': 'True', 'db_index': 'True'}) }, u'myuw.usernotices': { 'Meta': {'unique_together': "(('notice_hash', 'user'),)", 'object_name': 'UserNotices'}, 'first_viewed': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_read': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'marked_read': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'notice_hash': ('django.db.models.fields.CharField', [], {'max_length': '32'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['myuw.User']", 'on_delete': 'models.PROTECT'}) } } complete_apps = ['myuw']
apache-2.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, 662, 72, 12, 473, 6704, 440, 880, 1319, 18906, 3595, 15161, 922, 949, 7724, 626, 642, 365, 282, 5160, 267, 1592, 14, 3584, 63, 1224, 8, 85, 6704, 16366, 87, 63, 11375, 63, 751, 889, 7724, 358, 267, 327, 12934, 3747, 5828, 641, 283, 1899, 1944, 7724, 297, 1504, 788, 20556, 63, 2227, 297, 283, 751, 418, 267, 1592, 14, 981, 63, 3235, 8, 85, 6704, 16366, 87, 63, 11375, 63, 751, 889, 7724, 297, 788, 20556, 63, 2227, 297, 283, 751, 63, 344, 1105, 398, 327, 12934, 901, 283, 7841, 16974, 14, 1222, 63, 2902, 7, 267, 1592, 14, 525, 63, 2301, 8, 85, 6704, 16366, 87, 63, 11375, 63, 3710, 4614, 297, 283, 1222, 63, 2902, 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, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 29343, 3747, 5828, 641, 283, 1899, 1944, 7724, 297, 1504, 788, 20556, 63, 2227, 297, 283, 751, 418, 267, 1592, 14, 1807, 63, 3235, 8, 85, 6704, 16366, 87, 63, 11375, 63, 751, 889, 7724, 297, 788, 20556, 63, 2227, 297, 283, 751, 63, 344, 1105, 398, 327, 15920, 901, 283, 7841, 16974, 14, 1222, 63, 2902, 7, 267, 1592, 14, 1807, 63, 2301, 8, 85, 6704, 16366, 87, 63, 11375, 63, 3710, 4614, 297, 283, 1222, 63, 2902, 358, 2378, 1709, 275, 469, 267, 399, 6704, 16366, 87, 14, 17952, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 16461, 2267, 288, 283, 600, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 22, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 416, 280, 7951, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2167, 1604, 288, 283, 13803, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2167, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1840, 3071, 267, 1660, 267, 399, 6704, 16366, 87, 14, 3710, 4614, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 7841, 16974, 2267, 288, 283, 20290, 527, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 24, 297, 283, 2307, 356, 283, 549, 1604, 288, 283, 3710, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 3710, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1257, 1604, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1222, 63, 2902, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 954, 63, 3710, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 1213, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 8251, 1604, 288, 283, 633, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 8251, 3071, 267, 1660, 267, 399, 6704, 16366, 87, 14, 1972, 2326, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 6979, 4117, 2267, 288, 283, 2326, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 8613, 288, 283, 1972, 63, 1955, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 19, 1604, 288, 283, 895, 1567, 348, 453, 63, 20787, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 709, 1604, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 8613, 288, 283, 25985, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 709, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 1135, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 708, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 2792, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 18, 1604, 288, 283, 3403, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 25197, 297, 990, 791, 697, 63, 1080, 356, 283, 549, 3071, 267, 1660, 267, 399, 6704, 16366, 87, 14, 5500, 8370, 7358, 83, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 18086, 30682, 13129, 13236, 2267, 288, 283, 305, 1618, 63, 2083, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 8613, 288, 283, 10103, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 697, 63, 1080, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 709, 297, 283, 2307, 356, 283, 549, 297, 283, 2500, 356, 283, 549 ]
[ 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, 662, 72, 12, 473, 6704, 440, 880, 1319, 18906, 3595, 15161, 922, 949, 7724, 626, 642, 365, 282, 5160, 267, 1592, 14, 3584, 63, 1224, 8, 85, 6704, 16366, 87, 63, 11375, 63, 751, 889, 7724, 358, 267, 327, 12934, 3747, 5828, 641, 283, 1899, 1944, 7724, 297, 1504, 788, 20556, 63, 2227, 297, 283, 751, 418, 267, 1592, 14, 981, 63, 3235, 8, 85, 6704, 16366, 87, 63, 11375, 63, 751, 889, 7724, 297, 788, 20556, 63, 2227, 297, 283, 751, 63, 344, 1105, 398, 327, 12934, 901, 283, 7841, 16974, 14, 1222, 63, 2902, 7, 267, 1592, 14, 525, 63, 2301, 8, 85, 6704, 16366, 87, 63, 11375, 63, 3710, 4614, 297, 283, 1222, 63, 2902, 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, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 29343, 3747, 5828, 641, 283, 1899, 1944, 7724, 297, 1504, 788, 20556, 63, 2227, 297, 283, 751, 418, 267, 1592, 14, 1807, 63, 3235, 8, 85, 6704, 16366, 87, 63, 11375, 63, 751, 889, 7724, 297, 788, 20556, 63, 2227, 297, 283, 751, 63, 344, 1105, 398, 327, 15920, 901, 283, 7841, 16974, 14, 1222, 63, 2902, 7, 267, 1592, 14, 1807, 63, 2301, 8, 85, 6704, 16366, 87, 63, 11375, 63, 3710, 4614, 297, 283, 1222, 63, 2902, 358, 2378, 1709, 275, 469, 267, 399, 6704, 16366, 87, 14, 17952, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 16461, 2267, 288, 283, 600, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 22, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 416, 280, 7951, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2167, 1604, 288, 283, 13803, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 2167, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1840, 3071, 267, 1660, 267, 399, 6704, 16366, 87, 14, 3710, 4614, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 7841, 16974, 2267, 288, 283, 20290, 527, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 24, 297, 283, 2307, 356, 283, 549, 1604, 288, 283, 3710, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 3710, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1257, 1604, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 1222, 63, 2902, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 954, 63, 3710, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 1213, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 8251, 1604, 288, 283, 633, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 8251, 3071, 267, 1660, 267, 399, 6704, 16366, 87, 14, 1972, 2326, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 6979, 4117, 2267, 288, 283, 2326, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 8591, 297, 990, 8613, 288, 283, 1972, 63, 1955, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 19, 1604, 288, 283, 895, 1567, 348, 453, 63, 20787, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 709, 1604, 288, 399, 7, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 8613, 288, 283, 25985, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 709, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 1135, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 708, 297, 283, 697, 63, 1080, 356, 283, 549, 1604, 288, 283, 2792, 63, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 18, 1604, 288, 283, 3403, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 25197, 297, 990, 791, 697, 63, 1080, 356, 283, 549, 3071, 267, 1660, 267, 399, 6704, 16366, 87, 14, 5500, 8370, 7358, 83, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 18086, 30682, 13129, 13236, 2267, 288, 283, 305, 1618, 63, 2083, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 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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 ]
bpshetty/erpnext
erpnext/patches/v5_8/tax_rule.py
65
1087
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals import frappe def execute(): frappe.reload_doc("accounts", "doctype", "tax_rule") customers = frappe.db.sql("""select name, default_taxes_and_charges from tabCustomer where ifnull(default_taxes_and_charges, '') != '' """, as_dict=1) for d in customers: if not frappe.db.sql("select name from `tabTax Rule` where customer=%s", d.name): tr = frappe.new_doc("Tax Rule") tr.tax_type = "Sales" tr.customer = d.name tr.sales_tax_template = d.default_taxes_and_charges tr.save() suppliers = frappe.db.sql("""select name, default_taxes_and_charges from tabSupplier where ifnull(default_taxes_and_charges, '') != '' """, as_dict=1) for d in suppliers: if not frappe.db.sql("select name from `tabTax Rule` where supplier=%s", d.name): tr = frappe.new_doc("Tax Rule") tr.tax_type = "Purchase" tr.supplier = d.name tr.purchase_tax_template = d.default_taxes_and_charges tr.save()
gpl-3.0
[ 3, 1898, 334, 67, 9, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 199, 318, 5341, 837, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 5530, 63, 2200, 531, 421, 198, 67, 28078, 275, 6950, 14, 697, 14, 3009, 4852, 2416, 536, 12, 849, 63, 22272, 63, 460, 63, 1560, 3389, 687, 5174, 17025, 2382, 507, 198, 692, 2307, 8, 885, 63, 22272, 63, 460, 63, 1560, 3389, 12, 4074, 1137, 2125, 10327, 465, 63, 807, 29, 17, 9, 421, 198, 509, 366, 315, 286, 28078, 26, 507, 198, 692, 440, 6950, 14, 697, 14, 3009, 480, 2416, 536, 687, 658, 2902, 26019, 11949, 64, 2382, 15229, 2458, 83, 401, 366, 14, 354, 304, 686, 198, 454, 275, 6950, 14, 1222, 63, 1301, 480, 26019, 11949, 531, 686, 198, 454, 14, 5530, 63, 466, 275, 298, 18220, 2, 686, 198, 454, 14, 10178, 275, 366, 14, 354, 686, 198, 454, 14, 16175, 63, 5530, 63, 1160, 275, 366, 14, 885, 63, 22272, 63, 460, 63, 1560, 3389, 686, 198, 454, 14, 2117, 342, 4388, 198, 8621, 14035, 275, 6950, 14, 697, 14, 3009, 4852, 2416, 536, 12, 849, 63, 22272, 63, 460, 63, 1560, 3389, 687, 5174, 30080, 2382, 507, 198, 692, 2307, 8, 885, 63, 22272, 63, 460, 63, 1560, 3389, 12, 4074, 1137, 2125, 10327, 465, 63, 807, 29, 17, 9, 421, 198, 509, 366, 315, 4973, 14035, 26, 507, 198, 692, 440, 6950, 14, 697, 14, 3009, 480, 2416, 536, 687, 658, 2902, 26019, 11949, 64, 2382, 23700, 2458, 83, 401, 366, 14, 354, 304, 686, 198, 454, 275, 6950, 14, 1222, 63, 1301, 480, 26019, 11949, 531, 686, 198, 454, 14, 5530, 63, 466, 275, 298, 20486, 2, 686, 198, 454, 14, 17294, 275, 366, 14, 354, 686, 198, 454, 14, 9533, 63, 5530, 63, 1160, 275, 366, 14, 885, 63, 22272, 63, 460, 63, 1560, 3389, 686, 198, 454, 14, 2117, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6171, 12, 6001, 8144, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 6950, 199, 199, 318, 5341, 837, 199, 198, 9098, 14, 9233, 63, 1301, 480, 8370, 401, 298, 6356, 401, 298, 5530, 63, 2200, 531, 421, 198, 67, 28078, 275, 6950, 14, 697, 14, 3009, 4852, 2416, 536, 12, 849, 63, 22272, 63, 460, 63, 1560, 3389, 687, 5174, 17025, 2382, 507, 198, 692, 2307, 8, 885, 63, 22272, 63, 460, 63, 1560, 3389, 12, 4074, 1137, 2125, 10327, 465, 63, 807, 29, 17, 9, 421, 198, 509, 366, 315, 286, 28078, 26, 507, 198, 692, 440, 6950, 14, 697, 14, 3009, 480, 2416, 536, 687, 658, 2902, 26019, 11949, 64, 2382, 15229, 2458, 83, 401, 366, 14, 354, 304, 686, 198, 454, 275, 6950, 14, 1222, 63, 1301, 480, 26019, 11949, 531, 686, 198, 454, 14, 5530, 63, 466, 275, 298, 18220, 2, 686, 198, 454, 14, 10178, 275, 366, 14, 354, 686, 198, 454, 14, 16175, 63, 5530, 63, 1160, 275, 366, 14, 885, 63, 22272, 63, 460, 63, 1560, 3389, 686, 198, 454, 14, 2117, 342, 4388, 198, 8621, 14035, 275, 6950, 14, 697, 14, 3009, 4852, 2416, 536, 12, 849, 63, 22272, 63, 460, 63, 1560, 3389, 687, 5174, 30080, 2382, 507, 198, 692, 2307, 8, 885, 63, 22272, 63, 460, 63, 1560, 3389, 12, 4074, 1137, 2125, 10327, 465, 63, 807, 29, 17, 9, 421, 198, 509, 366, 315, 4973, 14035, 26, 507, 198, 692, 440, 6950, 14, 697, 14, 3009, 480, 2416, 536, 687, 658, 2902, 26019, 11949, 64, 2382, 23700, 2458, 83, 401, 366, 14, 354, 304, 686, 198, 454, 275, 6950, 14, 1222, 63, 1301, 480, 26019, 11949, 531, 686, 198, 454, 14, 5530, 63, 466, 275, 298, 20486, 2, 686, 198, 454, 14, 17294, 275, 366, 14, 354, 686, 198, 454, 14, 9533, 63, 5530, 63, 1160, 275, 366, 14, 885, 63, 22272, 63, 460, 63, 1560, 3389, 686, 198, 454, 14, 2117, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
apanju/GMIO_Odoo
addons/mrp/report/__init__.py
378
1122
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import price import workcenter_load import bom_structure import mrp_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 8033, 199, 646, 1736, 4218, 63, 912, 199, 646, 17190, 63, 6976, 199, 646, 333, 4599, 63, 3070, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 8033, 199, 646, 1736, 4218, 63, 912, 199, 646, 17190, 63, 6976, 199, 646, 333, 4599, 63, 3070, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jspraul/bite-project
deps/gdata-python-client/src/gdata/health/__init__.py
263
7090
#!/usr/bin/python # # Copyright 2009 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Contains extensions to Atom objects used with Google Health.""" __author__ = 'api.eric@google.com (Eric Bidelman)' import atom import gdata CCR_NAMESPACE = 'urn:astm-org:CCR' METADATA_NAMESPACE = 'http://schemas.google.com/health/metadata' class Ccr(atom.AtomBase): """Represents a Google Health <ContinuityOfCareRecord>.""" _tag = 'ContinuityOfCareRecord' _namespace = CCR_NAMESPACE _children = atom.AtomBase._children.copy() def __init__(self, extension_elements=None, extension_attributes=None, text=None): atom.AtomBase.__init__(self, extension_elements=extension_elements, extension_attributes=extension_attributes, text=text) def GetAlerts(self): """Helper for extracting Alert/Allergy data from the CCR. Returns: A list of ExtensionElements (one for each allergy found) or None if no allergies where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Alerts')[0].FindChildren('Alert') except: return None def GetAllergies(self): """Alias for GetAlerts().""" return self.GetAlerts() def GetProblems(self): """Helper for extracting Problem/Condition data from the CCR. Returns: A list of ExtensionElements (one for each problem found) or None if no problems where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Problems')[0].FindChildren('Problem') except: return None def GetConditions(self): """Alias for GetProblems().""" return self.GetProblems() def GetProcedures(self): """Helper for extracting Procedure data from the CCR. Returns: A list of ExtensionElements (one for each procedure found) or None if no procedures where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Procedures')[0].FindChildren('Procedure') except: return None def GetImmunizations(self): """Helper for extracting Immunization data from the CCR. Returns: A list of ExtensionElements (one for each immunization found) or None if no immunizations where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Immunizations')[0].FindChildren('Immunization') except: return None def GetMedications(self): """Helper for extracting Medication data from the CCR. Returns: A list of ExtensionElements (one for each medication found) or None if no medications where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Medications')[0].FindChildren('Medication') except: return None def GetResults(self): """Helper for extracting Results/Labresults data from the CCR. Returns: A list of ExtensionElements (one for each result found) or None if no results where found in this CCR. """ try: body = self.FindExtensions('Body')[0] return body.FindChildren('Results')[0].FindChildren('Result') except: return None class ProfileEntry(gdata.GDataEntry): """The Google Health version of an Atom Entry.""" _tag = gdata.GDataEntry._tag _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataEntry._children.copy() _attributes = gdata.GDataEntry._attributes.copy() _children['{%s}ContinuityOfCareRecord' % CCR_NAMESPACE] = ('ccr', Ccr) def __init__(self, ccr=None, author=None, category=None, content=None, atom_id=None, link=None, published=None, title=None, updated=None, text=None, extension_elements=None, extension_attributes=None): self.ccr = ccr gdata.GDataEntry.__init__( self, author=author, category=category, content=content, atom_id=atom_id, link=link, published=published, title=title, updated=updated, extension_elements=extension_elements, extension_attributes=extension_attributes, text=text) class ProfileFeed(gdata.GDataFeed): """A feed containing a list of Google Health profile entries.""" _tag = gdata.GDataFeed._tag _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataFeed._children.copy() _attributes = gdata.GDataFeed._attributes.copy() _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [ProfileEntry]) class ProfileListEntry(gdata.GDataEntry): """The Atom Entry in the Google Health profile list feed.""" _tag = gdata.GDataEntry._tag _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataEntry._children.copy() _attributes = gdata.GDataEntry._attributes.copy() def GetProfileId(self): return self.content.text def GetProfileName(self): return self.title.text class ProfileListFeed(gdata.GDataFeed): """A feed containing a list of Google Health profile list entries.""" _tag = gdata.GDataFeed._tag _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataFeed._children.copy() _attributes = gdata.GDataFeed._attributes.copy() _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [ProfileListEntry]) def ProfileEntryFromString(xml_string): """Converts an XML string into a ProfileEntry object. Args: xml_string: string The XML describing a Health profile feed entry. Returns: A ProfileEntry object corresponding to the given XML. """ return atom.CreateClassFromXMLString(ProfileEntry, xml_string) def ProfileListEntryFromString(xml_string): """Converts an XML string into a ProfileListEntry object. Args: xml_string: string The XML describing a Health profile list feed entry. Returns: A ProfileListEntry object corresponding to the given XML. """ return atom.CreateClassFromXMLString(ProfileListEntry, xml_string) def ProfileFeedFromString(xml_string): """Converts an XML string into a ProfileFeed object. Args: xml_string: string The XML describing a ProfileFeed feed. Returns: A ProfileFeed object corresponding to the given XML. """ return atom.CreateClassFromXMLString(ProfileFeed, xml_string) def ProfileListFeedFromString(xml_string): """Converts an XML string into a ProfileListFeed object. Args: xml_string: string The XML describing a ProfileListFeed feed. Returns: A ProfileListFeed object corresponding to the given XML. """ return atom.CreateClassFromXMLString(ProfileListFeed, xml_string)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 8937, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 6906, 5478, 370, 18840, 2251, 1202, 543, 4475, 5311, 6130, 1041, 199, 199, 363, 2502, 363, 275, 283, 1246, 14, 281, 530, 32, 3098, 14, 957, 334, 37, 1567, 31012, 2264, 1237, 3171, 199, 199, 646, 6222, 199, 646, 11006, 421, 199, 2571, 50, 63, 13001, 275, 283, 349, 26, 1810, 77, 13, 1308, 26, 2571, 50, 7, 199, 8314, 63, 13001, 275, 283, 1014, 921, 9482, 14, 3098, 14, 957, 15, 9665, 15, 2343, 7, 421, 199, 533, 445, 1556, 8, 4188, 14, 12097, 1563, 304, 523, 408, 18089, 282, 4475, 5311, 6130, 665, 24593, 24180, 3466, 35, 1530, 5433, 30, 1041, 819, 485, 1450, 275, 283, 24593, 24180, 3466, 35, 1530, 5433, 7, 523, 485, 3251, 275, 445, 2944, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 819, 347, 636, 826, 721, 277, 12, 3329, 63, 5527, 29, 403, 12, 2049, 3329, 63, 2987, 29, 403, 12, 1318, 29, 403, 304, 272, 6222, 14, 12097, 1563, 855, 826, 721, 277, 12, 3329, 63, 5527, 29, 3435, 63, 5527, 12, 2574, 3329, 63, 2987, 29, 3435, 63, 2987, 12, 1318, 29, 505, 9, 819, 347, 2372, 33, 16676, 8, 277, 304, 272, 408, 4433, 367, 30137, 25762, 15, 2439, 1435, 4312, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 741, 1435, 4312, 1911, 9, 503, 488, 340, 489, 949, 741, 1435, 28152, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 33, 16676, 5832, 16, 1055, 6591, 7139, 360, 18758, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 2439, 1435, 28152, 8, 277, 304, 272, 408, 14149, 367, 2372, 33, 16676, 20693, 272, 372, 291, 14, 1002, 33, 16676, 342, 819, 347, 2372, 919, 7561, 8, 277, 304, 272, 408, 4433, 367, 30137, 20980, 15, 9558, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 5160, 1911, 9, 503, 488, 340, 489, 949, 8826, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 919, 7561, 5832, 16, 1055, 6591, 7139, 360, 16467, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 23107, 8, 277, 304, 272, 408, 14149, 367, 2372, 919, 7561, 20693, 272, 372, 291, 14, 1002, 919, 7561, 342, 819, 347, 2372, 919, 6867, 1482, 8, 277, 304, 272, 408, 4433, 367, 30137, 2165, 12194, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 17782, 1911, 9, 503, 488, 340, 489, 949, 557, 6867, 1482, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 919, 6867, 1482, 5832, 16, 1055, 6591, 7139, 360, 919, 12194, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 27564, 324, 12270, 8, 277, 304, 272, 408, 4433, 367, 30137, 473, 596, 324, 2072, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 25531, 324, 2072, 1911, 9, 503, 488, 340, 489, 949, 25531, 324, 12270, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 27564, 324, 12270, 5832, 16, 1055, 6591, 7139, 360, 27564, 324, 2072, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 1352, 21171, 83, 8, 277, 304, 272, 408, 4433, 367, 30137, 3194, 21171, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 562, 21171, 1911, 9, 503, 488, 340, 489, 949, 562, 21171, 83, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 1352, 21171, 83, 5832, 16, 1055, 6591, 7139, 360, 1352, 21171, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 6579, 8, 277, 304, 272, 408, 4433, 367, 30137, 24288, 15, 22511, 2604, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 754, 1911, 9, 503, 488, 340, 489, 949, 2058, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 6579, 5832, 16, 1055, 6591, 7139, 360, 2889, 358, 272, 871, 26, 489, 372, 488, 421, 199, 533, 14386, 3900, 8, 15275, 14, 27413, 3900, 304, 523, 408, 1918, 4475, 5311, 6130, 1015, 402, 376, 18840, 11855, 1041, 819, 485, 1450, 275, 11006, 14, 27413, 3900, 423, 1450, 523, 485, 3251, 275, 6222, 14, 22479, 63, 13001, 523, 485, 3223, 275, 11006, 14, 27413, 3900, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 11006, 14, 27413, 3900 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 8937, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 6906, 5478, 370, 18840, 2251, 1202, 543, 4475, 5311, 6130, 1041, 199, 199, 363, 2502, 363, 275, 283, 1246, 14, 281, 530, 32, 3098, 14, 957, 334, 37, 1567, 31012, 2264, 1237, 3171, 199, 199, 646, 6222, 199, 646, 11006, 421, 199, 2571, 50, 63, 13001, 275, 283, 349, 26, 1810, 77, 13, 1308, 26, 2571, 50, 7, 199, 8314, 63, 13001, 275, 283, 1014, 921, 9482, 14, 3098, 14, 957, 15, 9665, 15, 2343, 7, 421, 199, 533, 445, 1556, 8, 4188, 14, 12097, 1563, 304, 523, 408, 18089, 282, 4475, 5311, 6130, 665, 24593, 24180, 3466, 35, 1530, 5433, 30, 1041, 819, 485, 1450, 275, 283, 24593, 24180, 3466, 35, 1530, 5433, 7, 523, 485, 3251, 275, 445, 2944, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 819, 347, 636, 826, 721, 277, 12, 3329, 63, 5527, 29, 403, 12, 2049, 3329, 63, 2987, 29, 403, 12, 1318, 29, 403, 304, 272, 6222, 14, 12097, 1563, 855, 826, 721, 277, 12, 3329, 63, 5527, 29, 3435, 63, 5527, 12, 2574, 3329, 63, 2987, 29, 3435, 63, 2987, 12, 1318, 29, 505, 9, 819, 347, 2372, 33, 16676, 8, 277, 304, 272, 408, 4433, 367, 30137, 25762, 15, 2439, 1435, 4312, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 741, 1435, 4312, 1911, 9, 503, 488, 340, 489, 949, 741, 1435, 28152, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 33, 16676, 5832, 16, 1055, 6591, 7139, 360, 18758, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 2439, 1435, 28152, 8, 277, 304, 272, 408, 14149, 367, 2372, 33, 16676, 20693, 272, 372, 291, 14, 1002, 33, 16676, 342, 819, 347, 2372, 919, 7561, 8, 277, 304, 272, 408, 4433, 367, 30137, 20980, 15, 9558, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 5160, 1911, 9, 503, 488, 340, 489, 949, 8826, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 919, 7561, 5832, 16, 1055, 6591, 7139, 360, 16467, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 23107, 8, 277, 304, 272, 408, 14149, 367, 2372, 919, 7561, 20693, 272, 372, 291, 14, 1002, 919, 7561, 342, 819, 347, 2372, 919, 6867, 1482, 8, 277, 304, 272, 408, 4433, 367, 30137, 2165, 12194, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 17782, 1911, 9, 503, 488, 340, 489, 949, 557, 6867, 1482, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 919, 6867, 1482, 5832, 16, 1055, 6591, 7139, 360, 919, 12194, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 27564, 324, 12270, 8, 277, 304, 272, 408, 4433, 367, 30137, 473, 596, 324, 2072, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 25531, 324, 2072, 1911, 9, 503, 488, 340, 489, 949, 25531, 324, 12270, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 27564, 324, 12270, 5832, 16, 1055, 6591, 7139, 360, 27564, 324, 2072, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 1352, 21171, 83, 8, 277, 304, 272, 408, 4433, 367, 30137, 3194, 21171, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 562, 21171, 1911, 9, 503, 488, 340, 489, 949, 562, 21171, 83, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 1352, 21171, 83, 5832, 16, 1055, 6591, 7139, 360, 1352, 21171, 358, 272, 871, 26, 489, 372, 488, 819, 347, 2372, 6579, 8, 277, 304, 272, 408, 4433, 367, 30137, 24288, 15, 22511, 2604, 666, 687, 314, 445, 2944, 14, 339, 1803, 26, 489, 437, 769, 402, 13282, 6255, 334, 368, 367, 1924, 754, 1911, 9, 503, 488, 340, 489, 949, 2058, 2382, 1911, 315, 642, 445, 2944, 14, 272, 408, 272, 862, 26, 489, 2396, 275, 291, 14, 6591, 10597, 360, 8173, 5832, 16, 61, 489, 372, 2396, 14, 6591, 7139, 360, 6579, 5832, 16, 1055, 6591, 7139, 360, 2889, 358, 272, 871, 26, 489, 372, 488, 421, 199, 533, 14386, 3900, 8, 15275, 14, 27413, 3900, 304, 523, 408, 1918, 4475, 5311, 6130, 1015, 402, 376, 18840, 11855, 1041, 819, 485, 1450, 275, 11006, 14, 27413, 3900, 423, 1450, 523, 485, 3251, 275, 6222, 14, 22479, 63, 13001, 523, 485, 3223, 275, 11006, 14, 27413, 3900, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 11006, 14, 27413, 3900, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jainaman224/zenodo
tests/unit/records/test_records_templates.py
8
2697
# -*- coding: utf-8 -*- # # This file is part of Zenodo. # Copyright (C) 2016 CERN. # # Zenodo 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. # # Zenodo 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 Zenodo; if not, write to the # Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307, USA. # # In applying this license, CERN does not # waive the privileges and immunities granted to it by virtue of its status # as an Intergovernmental Organization or submit itself to any jurisdiction. """Template test.""" from __future__ import absolute_import, print_function from flask import url_for from lxml import html def test_header_links_exists(app, record_with_files_creation): """Validate that link tags to files exists in document header.""" (pid, record, record_url) = record_with_files_creation base_url = url_for('invenio_records_ui.recid_files', pid_value=pid.pid_value, filename='Test.pdf') with app.test_client() as client: res = client.get(record_url) assert res.status_code == 200 tree = html.fromstring(res.data) for l in tree.xpath('//link[@rel="alternate"]'): if l.get('href').endswith(base_url): return assert False, "<link> tags to files not found in record page." def test_header_pdf_metahighwire_empty(app, db, record_with_bucket): """Check that the meta tag for highwire is not existing without PDF.""" (pid, record) = record_with_bucket with app.test_client() as client: res = client.get(url_for('invenio_records_ui.recid', pid_value=pid.pid_value)) assert res.status_code == 200 tree = html.fromstring(res.data) assert len(tree.xpath('//meta[@name="citation_pdf_url"]')) == 0 def test_header_pdf_exits_metahighwire(app, record_with_files_creation): """Check that the meta tag for highwire is exists when a PDF file.""" (pid, record, record_url) = record_with_files_creation with app.test_client() as client: res = client.get(record_url) assert res.status_code == 200 tree = html.fromstring(res.data) assert len(tree.xpath('//meta[@name="citation_pdf_url"]')) == 1
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 3107, 287, 19657, 14, 199, 3, 1898, 334, 35, 9, 7800, 24354, 14, 199, 3, 199, 3, 3107, 287, 19657, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 199, 3, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 3107, 287, 19657, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 199, 3, 2997, 12, 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, 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, 3107, 287, 19657, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 199, 3, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 3, 199, 3, 1010, 18876, 642, 4190, 12, 24354, 1630, 440, 199, 3, 14442, 1912, 314, 20001, 436, 25531, 22047, 10009, 370, 652, 701, 12043, 310, 402, 2399, 2004, 199, 3, 465, 376, 6551, 71, 27639, 279, 18863, 503, 11482, 6337, 370, 1263, 1335, 17656, 26382, 14, 199, 199, 624, 4231, 511, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 504, 7209, 492, 1166, 63, 509, 199, 504, 14490, 492, 3517, 421, 199, 318, 511, 63, 1291, 63, 4614, 63, 2444, 8, 571, 12, 2777, 63, 1045, 63, 1725, 63, 8782, 304, 272, 408, 12584, 626, 2142, 3762, 370, 1584, 3495, 315, 2213, 1406, 1041, 272, 334, 3150, 12, 2777, 12, 2777, 63, 633, 9, 275, 2777, 63, 1045, 63, 1725, 63, 8782, 339, 1300, 63, 633, 275, 1166, 63, 509, 360, 30628, 63, 6502, 63, 1907, 14, 17532, 63, 1725, 297, 2432, 4422, 63, 585, 29, 3150, 14, 3150, 63, 585, 12, 1788, 534, 774, 14, 5607, 358, 339, 543, 1145, 14, 396, 63, 1258, 342, 465, 1890, 26, 267, 522, 275, 1890, 14, 362, 8, 3059, 63, 633, 9, 398, 702, 522, 14, 1205, 63, 600, 508, 1926, 267, 3123, 275, 3517, 14, 13521, 8, 470, 14, 576, 9, 267, 367, 634, 315, 3123, 14, 8006, 15079, 1073, 14251, 3369, 628, 17170, 937, 735, 288, 340, 634, 14, 362, 360, 6399, 1959, 4130, 8, 1095, 63, 633, 304, 355, 372, 272, 702, 756, 12, 3886, 1073, 30, 3762, 370, 1584, 440, 1911, 315, 2777, 2034, 2122, 421, 199, 318, 511, 63, 1291, 63, 5607, 63, 2024, 6260, 11239, 63, 1667, 8, 571, 12, 1592, 12, 2777, 63, 1045, 63, 4623, 304, 272, 408, 1799, 626, 314, 3404, 1947, 367, 4721, 11239, 365, 440, 3411, 1928, 15537, 1041, 272, 334, 3150, 12, 2777, 9, 275, 2777, 63, 1045, 63, 4623, 272, 543, 1145, 14, 396, 63, 1258, 342, 465, 1890, 26, 267, 522, 275, 1890, 14, 362, 8, 633, 63, 509, 360, 30628, 63, 6502, 63, 1907, 14, 17532, 297, 639, 4422, 63, 585, 29, 3150, 14, 3150, 63, 585, 430, 267, 702, 522, 14, 1205, 63, 600, 508, 1926, 267, 3123, 275, 3517, 14, 13521, 8, 470, 14, 576, 9, 267, 702, 822, 8, 2350, 14, 8006, 15079, 2024, 14251, 354, 628, 6210, 63, 5607, 63, 633, 937, 1333, 508, 378, 421, 199, 318, 511, 63, 1291, 63, 5607, 63, 476, 1405, 63, 2024, 6260, 11239, 8, 571, 12, 2777, 63, 1045, 63, 1725, 63, 8782, 304, 272, 408, 1799, 626, 314, 3404, 1947, 367, 4721, 11239, 365, 3495, 1380, 282, 15537, 570, 1041, 272, 334, 3150, 12, 2777, 12, 2777, 63, 633, 9, 275, 2777, 63, 1045, 63, 1725, 63, 8782, 339, 543, 1145, 14, 396, 63, 1258, 342, 465, 1890, 26, 267, 522, 275, 1890, 14, 362, 8, 3059, 63, 633, 9, 267, 702, 522, 14, 1205, 63, 600, 508, 1926, 267, 3123, 275, 3517, 14, 13521, 8, 470, 14, 576, 9, 267, 702, 822, 8, 2350, 14, 8006, 15079, 2024, 14251, 354, 628, 6210, 63, 5607, 63, 633, 937, 1333, 508, 413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 3107, 287, 19657, 14, 199, 3, 1898, 334, 35, 9, 7800, 24354, 14, 199, 3, 199, 3, 3107, 287, 19657, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 199, 3, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 3107, 287, 19657, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 199, 3, 2997, 12, 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, 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, 3107, 287, 19657, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 199, 3, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 3, 199, 3, 1010, 18876, 642, 4190, 12, 24354, 1630, 440, 199, 3, 14442, 1912, 314, 20001, 436, 25531, 22047, 10009, 370, 652, 701, 12043, 310, 402, 2399, 2004, 199, 3, 465, 376, 6551, 71, 27639, 279, 18863, 503, 11482, 6337, 370, 1263, 1335, 17656, 26382, 14, 199, 199, 624, 4231, 511, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 504, 7209, 492, 1166, 63, 509, 199, 504, 14490, 492, 3517, 421, 199, 318, 511, 63, 1291, 63, 4614, 63, 2444, 8, 571, 12, 2777, 63, 1045, 63, 1725, 63, 8782, 304, 272, 408, 12584, 626, 2142, 3762, 370, 1584, 3495, 315, 2213, 1406, 1041, 272, 334, 3150, 12, 2777, 12, 2777, 63, 633, 9, 275, 2777, 63, 1045, 63, 1725, 63, 8782, 339, 1300, 63, 633, 275, 1166, 63, 509, 360, 30628, 63, 6502, 63, 1907, 14, 17532, 63, 1725, 297, 2432, 4422, 63, 585, 29, 3150, 14, 3150, 63, 585, 12, 1788, 534, 774, 14, 5607, 358, 339, 543, 1145, 14, 396, 63, 1258, 342, 465, 1890, 26, 267, 522, 275, 1890, 14, 362, 8, 3059, 63, 633, 9, 398, 702, 522, 14, 1205, 63, 600, 508, 1926, 267, 3123, 275, 3517, 14, 13521, 8, 470, 14, 576, 9, 267, 367, 634, 315, 3123, 14, 8006, 15079, 1073, 14251, 3369, 628, 17170, 937, 735, 288, 340, 634, 14, 362, 360, 6399, 1959, 4130, 8, 1095, 63, 633, 304, 355, 372, 272, 702, 756, 12, 3886, 1073, 30, 3762, 370, 1584, 440, 1911, 315, 2777, 2034, 2122, 421, 199, 318, 511, 63, 1291, 63, 5607, 63, 2024, 6260, 11239, 63, 1667, 8, 571, 12, 1592, 12, 2777, 63, 1045, 63, 4623, 304, 272, 408, 1799, 626, 314, 3404, 1947, 367, 4721, 11239, 365, 440, 3411, 1928, 15537, 1041, 272, 334, 3150, 12, 2777, 9, 275, 2777, 63, 1045, 63, 4623, 272, 543, 1145, 14, 396, 63, 1258, 342, 465, 1890, 26, 267, 522, 275, 1890, 14, 362, 8, 633, 63, 509, 360, 30628, 63, 6502, 63, 1907, 14, 17532, 297, 639, 4422, 63, 585, 29, 3150, 14, 3150, 63, 585, 430, 267, 702, 522, 14, 1205, 63, 600, 508, 1926, 267, 3123, 275, 3517, 14, 13521, 8, 470, 14, 576, 9, 267, 702, 822, 8, 2350, 14, 8006, 15079, 2024, 14251, 354, 628, 6210, 63, 5607, 63, 633, 937, 1333, 508, 378, 421, 199, 318, 511, 63, 1291, 63, 5607, 63, 476, 1405, 63, 2024, 6260, 11239, 8, 571, 12, 2777, 63, 1045, 63, 1725, 63, 8782, 304, 272, 408, 1799, 626, 314, 3404, 1947, 367, 4721, 11239, 365, 3495, 1380, 282, 15537, 570, 1041, 272, 334, 3150, 12, 2777, 12, 2777, 63, 633, 9, 275, 2777, 63, 1045, 63, 1725, 63, 8782, 339, 543, 1145, 14, 396, 63, 1258, 342, 465, 1890, 26, 267, 522, 275, 1890, 14, 362, 8, 3059, 63, 633, 9, 267, 702, 522, 14, 1205, 63, 600, 508, 1926, 267, 3123, 275, 3517, 14, 13521, 8, 470, 14, 576, 9, 267, 702, 822, 8, 2350, 14, 8006, 15079, 2024, 14251, 354, 628, 6210, 63, 5607, 63, 633, 937, 1333, 508, 413, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jn2840/bitcoin
share/qt/extract_strings_qt.py
1
1875
#!/usr/bin/python ''' Extract _("...") strings for translation and convert to Qt4 stringdefs so that they can be picked up by Qt linguist. ''' from subprocess import Popen, PIPE import glob import operator import os import sys OUT_CPP="qt/bitcoinstrings.cpp" EMPTY=['""'] def parse_po(text): """ Parse 'po' format produced by xgettext. Return a list of (msgid,msgstr) tuples. """ messages = [] msgid = [] msgstr = [] in_msgid = False in_msgstr = False for line in text.split('\n'): line = line.rstrip('\r') if line.startswith('msgid '): if in_msgstr: messages.append((msgid, msgstr)) in_msgstr = False # message start in_msgid = True msgid = [line[6:]] elif line.startswith('msgstr '): in_msgid = False in_msgstr = True msgstr = [line[7:]] elif line.startswith('"'): if in_msgid: msgid.append(line) if in_msgstr: msgstr.append(line) if in_msgstr: messages.append((msgid, msgstr)) return messages files = sys.argv[1:] # xgettext -n --keyword=_ $FILES XGETTEXT=os.getenv('XGETTEXT', 'xgettext') child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE) (out, err) = child.communicate() messages = parse_po(out) f = open(OUT_CPP, 'w') f.write(""" #include <QtGlobal> // Automatically generated by extract_strings.py #ifdef __GNUC__ #define UNUSED __attribute__((unused)) #else #define UNUSED #endif """) f.write('static const char UNUSED *bitcoin_strings[] = {\n') messages.sort(key=operator.itemgetter(0)) for (msgid, msgstr) in messages: if msgid != EMPTY: f.write('QT_TRANSLATE_NOOP("beardcoin-core", %s),\n' % ('\n'.join(msgid))) f.write('};\n') f.close()
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 2344, 199, 12147, 3824, 12594, 3326, 367, 7761, 436, 3957, 370, 3959, 20, 1059, 8710, 880, 626, 199, 29002, 883, 506, 29438, 1536, 701, 3959, 634, 14659, 631, 14, 199, 2344, 199, 504, 3873, 492, 13995, 12, 22773, 199, 646, 5739, 199, 646, 4182, 199, 646, 747, 199, 646, 984, 199, 199, 1877, 63, 14533, 628, 8440, 15, 22816, 5465, 14, 5910, 2, 199, 13993, 2968, 341, 418, 199, 199, 318, 2198, 63, 555, 8, 505, 304, 272, 408, 272, 6077, 283, 555, 7, 1475, 13584, 701, 671, 5152, 14, 272, 1432, 282, 769, 402, 334, 15245, 12, 23367, 9, 6346, 14, 272, 408, 272, 3788, 275, 942, 272, 17879, 275, 942, 272, 1499, 495, 275, 942, 272, 315, 63, 15245, 275, 756, 272, 315, 63, 23367, 275, 756, 339, 367, 1004, 315, 1318, 14, 1294, 2258, 78, 735, 267, 1004, 275, 1004, 14, 6735, 2258, 82, 358, 267, 340, 1004, 14, 2460, 360, 15245, 18927, 288, 340, 315, 63, 23367, 26, 355, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 355, 315, 63, 23367, 275, 756, 288, 327, 1245, 1343, 288, 315, 63, 15245, 275, 715, 7846, 17879, 275, 359, 604, 59, 22, 21316, 267, 916, 1004, 14, 2460, 360, 23367, 18927, 288, 315, 63, 15245, 275, 756, 288, 315, 63, 23367, 275, 715, 288, 1499, 495, 275, 359, 604, 59, 23, 21316, 267, 916, 1004, 14, 2460, 14088, 735, 288, 340, 315, 63, 15245, 26, 355, 17879, 14, 740, 8, 604, 9, 288, 340, 315, 63, 23367, 26, 355, 1499, 495, 14, 740, 8, 604, 9, 339, 340, 315, 63, 23367, 26, 267, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 339, 372, 3788, 199, 199, 1725, 275, 984, 14, 3020, 59, 17, 2938, 199, 199, 3, 671, 5152, 446, 78, 1553, 6691, 3699, 2672, 9472, 199, 56, 2970, 3876, 29, 736, 14, 12959, 360, 56, 2970, 3876, 297, 283, 88, 5152, 358, 199, 1739, 275, 13995, 779, 56, 2970, 3876, 2584, 306, 1199, 4022, 21810, 78, 28280, 6691, 3699, 418, 435, 1584, 12, 3839, 29, 6089, 9, 199, 8, 548, 12, 2329, 9, 275, 1982, 14, 10664, 342, 199, 199, 3431, 275, 2198, 63, 555, 8, 548, 9, 9948, 199, 70, 275, 1551, 8, 1877, 63, 14533, 12, 283, 87, 358, 199, 70, 14, 952, 4852, 199, 199, 3, 2613, 665, 4238, 7025, 30, 199, 199, 501, 9195, 17174, 4046, 701, 5536, 63, 5465, 14, 647, 199, 3, 27737, 636, 17732, 35, 363, 199, 3, 4640, 738, 27726, 636, 3215, 721, 8, 8618, 430, 199, 3, 2836, 199, 3, 4640, 738, 27726, 199, 3, 13739, 199, 6141, 199, 70, 14, 952, 360, 1986, 950, 1495, 738, 27726, 627, 22816, 63, 5465, 8607, 275, 9459, 78, 358, 199, 3431, 14, 3191, 8, 498, 29, 3856, 14, 20832, 8, 16, 430, 199, 509, 334, 15245, 12, 1499, 495, 9, 315, 3788, 26, 272, 340, 17879, 1137, 16589, 26, 267, 289, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 15283, 9061, 13, 1018, 401, 450, 83, 26323, 78, 7, 450, 17485, 78, 1370, 904, 8, 15245, 1724, 199, 70, 14, 952, 360, 16055, 78, 358, 199, 70, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 2344, 199, 12147, 3824, 12594, 3326, 367, 7761, 436, 3957, 370, 3959, 20, 1059, 8710, 880, 626, 199, 29002, 883, 506, 29438, 1536, 701, 3959, 634, 14659, 631, 14, 199, 2344, 199, 504, 3873, 492, 13995, 12, 22773, 199, 646, 5739, 199, 646, 4182, 199, 646, 747, 199, 646, 984, 199, 199, 1877, 63, 14533, 628, 8440, 15, 22816, 5465, 14, 5910, 2, 199, 13993, 2968, 341, 418, 199, 199, 318, 2198, 63, 555, 8, 505, 304, 272, 408, 272, 6077, 283, 555, 7, 1475, 13584, 701, 671, 5152, 14, 272, 1432, 282, 769, 402, 334, 15245, 12, 23367, 9, 6346, 14, 272, 408, 272, 3788, 275, 942, 272, 17879, 275, 942, 272, 1499, 495, 275, 942, 272, 315, 63, 15245, 275, 756, 272, 315, 63, 23367, 275, 756, 339, 367, 1004, 315, 1318, 14, 1294, 2258, 78, 735, 267, 1004, 275, 1004, 14, 6735, 2258, 82, 358, 267, 340, 1004, 14, 2460, 360, 15245, 18927, 288, 340, 315, 63, 23367, 26, 355, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 355, 315, 63, 23367, 275, 756, 288, 327, 1245, 1343, 288, 315, 63, 15245, 275, 715, 7846, 17879, 275, 359, 604, 59, 22, 21316, 267, 916, 1004, 14, 2460, 360, 23367, 18927, 288, 315, 63, 15245, 275, 756, 288, 315, 63, 23367, 275, 715, 288, 1499, 495, 275, 359, 604, 59, 23, 21316, 267, 916, 1004, 14, 2460, 14088, 735, 288, 340, 315, 63, 15245, 26, 355, 17879, 14, 740, 8, 604, 9, 288, 340, 315, 63, 23367, 26, 355, 1499, 495, 14, 740, 8, 604, 9, 339, 340, 315, 63, 23367, 26, 267, 3788, 14, 740, 1332, 15245, 12, 1499, 495, 430, 339, 372, 3788, 199, 199, 1725, 275, 984, 14, 3020, 59, 17, 2938, 199, 199, 3, 671, 5152, 446, 78, 1553, 6691, 3699, 2672, 9472, 199, 56, 2970, 3876, 29, 736, 14, 12959, 360, 56, 2970, 3876, 297, 283, 88, 5152, 358, 199, 1739, 275, 13995, 779, 56, 2970, 3876, 2584, 306, 1199, 4022, 21810, 78, 28280, 6691, 3699, 418, 435, 1584, 12, 3839, 29, 6089, 9, 199, 8, 548, 12, 2329, 9, 275, 1982, 14, 10664, 342, 199, 199, 3431, 275, 2198, 63, 555, 8, 548, 9, 9948, 199, 70, 275, 1551, 8, 1877, 63, 14533, 12, 283, 87, 358, 199, 70, 14, 952, 4852, 199, 199, 3, 2613, 665, 4238, 7025, 30, 199, 199, 501, 9195, 17174, 4046, 701, 5536, 63, 5465, 14, 647, 199, 3, 27737, 636, 17732, 35, 363, 199, 3, 4640, 738, 27726, 636, 3215, 721, 8, 8618, 430, 199, 3, 2836, 199, 3, 4640, 738, 27726, 199, 3, 13739, 199, 6141, 199, 70, 14, 952, 360, 1986, 950, 1495, 738, 27726, 627, 22816, 63, 5465, 8607, 275, 9459, 78, 358, 199, 3431, 14, 3191, 8, 498, 29, 3856, 14, 20832, 8, 16, 430, 199, 509, 334, 15245, 12, 1499, 495, 9, 315, 3788, 26, 272, 340, 17879, 1137, 16589, 26, 267, 289, 14, 952, 360, 19229, 63, 26376, 1951, 63, 2826, 1938, 480, 15283, 9061, 13, 1018, 401, 450, 83, 26323, 78, 7, 450, 17485, 78, 1370, 904, 8, 15245, 1724, 199, 70, 14, 952, 360, 16055, 78, 358, 199, 70, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
anthonyfok/frescobaldi
frescobaldi_app/logtool/__init__.py
1
3820
# This file is part of the Frescobaldi project, http://www.frescobaldi.org/ # # Copyright (c) 2008 - 2014 by Wilbert Berendsen # # 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 St, Fifth Floor, Boston, MA 02110-1301 USA # See http://www.gnu.org/licenses/ for more information. """ The log dockwindow. """ from PyQt5.QtCore import QSettings, Qt from PyQt5.QtGui import QKeySequence from PyQt5.QtWidgets import QAction import actioncollection import actioncollectionmanager import app import panel class LogTool(panel.Panel): """A dockwidget showing the log of running Jobs.""" def __init__(self, mainwindow): super(LogTool, self).__init__(mainwindow) self.hide() self.toggleViewAction().setShortcut(QKeySequence("Meta+Alt+L")) ac = self.actionCollection = Actions() ac.log_next_error.triggered.connect(self.slotNextError) ac.log_previous_error.triggered.connect(self.slotPreviousError) actioncollectionmanager.manager(mainwindow).addActionCollection(ac) mainwindow.addDockWidget(Qt.BottomDockWidgetArea, self) app.jobStarted.connect(self.slotJobStarted) app.jobFinished.connect(self.slotJobFinished) def translateUI(self): self.setWindowTitle(_("LilyPond Log")) self.toggleViewAction().setText(_("LilyPond &Log")) def createWidget(self): from . import logwidget return logwidget.LogWidget(self) def slotJobStarted(self, doc, job): """Called whenever job starts, decides whether to follow it and show the log.""" import jobattributes jattrs = jobattributes.get(job) if doc == self.mainwindow().currentDocument() or self.mainwindow() == jattrs.mainwindow: self.widget().switchDocument(doc) if not jattrs.hidden and QSettings().value("log/show_on_start", True, bool): self.show() def slotJobFinished(self, document, job, success): import jobattributes if (not success and not job.is_aborted() and not jobattributes.get(job).hidden and document == self.mainwindow().currentDocument()): self.show() def slotNextError(self): """Jumps to the position pointed to by the next error message.""" self.activate() self.widget().gotoError(1) def slotPreviousError(self): """Jumps to the position pointed to by the next error message.""" self.activate() self.widget().gotoError(-1) class Actions(actioncollection.ActionCollection): name = "logtool" def createActions(self, parent=None): self.log_next_error = QAction(parent) self.log_previous_error = QAction(parent) self.log_next_error.setShortcut(QKeySequence("Ctrl+E")) self.log_previous_error.setShortcut(QKeySequence("Ctrl+Shift+E")) def translateUI(self): self.log_next_error.setText(_("Next Error Message")) self.log_previous_error.setText(_("Previous Error Message")) # log errors by initializing Errors instance @app.jobStarted.connect def _log_errors(document): from . import errors errors.errors(document)
gpl-2.0
[ 3, 961, 570, 365, 1777, 402, 314, 481, 470, 331, 4982, 328, 2199, 12, 1455, 921, 1544, 14, 70, 470, 331, 4982, 328, 14, 1308, 15, 199, 3, 199, 3, 1898, 334, 67, 9, 9079, 446, 6927, 701, 644, 382, 12504, 6423, 16479, 2464, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 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, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 1666, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 367, 1655, 2556, 14, 199, 199, 624, 199, 1918, 943, 366, 766, 3806, 14, 199, 624, 421, 199, 504, 14084, 21, 14, 10901, 492, 1413, 5268, 12, 3959, 199, 504, 14084, 21, 14, 10604, 492, 1413, 1197, 5826, 199, 504, 14084, 21, 14, 29081, 492, 1413, 3310, 199, 199, 646, 1595, 3627, 199, 646, 1595, 3627, 2609, 199, 646, 1145, 199, 646, 12748, 421, 199, 533, 5297, 5157, 8, 7885, 14, 10185, 304, 272, 408, 33, 366, 766, 3440, 21207, 314, 943, 402, 3879, 7135, 1533, 1041, 272, 347, 636, 826, 721, 277, 12, 2446, 3806, 304, 267, 1613, 8, 2445, 5157, 12, 291, 2843, 826, 721, 973, 3806, 9, 267, 291, 14, 8191, 342, 267, 291, 14, 13396, 2768, 3310, 1252, 409, 28301, 8, 49, 1197, 5826, 480, 3396, 11, 16985, 11, 44, 2237, 267, 1066, 275, 291, 14, 1287, 7768, 275, 24367, 342, 267, 1066, 14, 793, 63, 2184, 63, 705, 14, 21142, 14, 2242, 8, 277, 14, 7998, 5765, 547, 9, 267, 1066, 14, 793, 63, 6352, 63, 705, 14, 21142, 14, 2242, 8, 277, 14, 7998, 18021, 547, 9, 267, 1595, 3627, 2609, 14, 2609, 8, 973, 3806, 680, 19006, 7768, 8, 645, 9, 267, 2446, 3806, 14, 525, 28804, 3339, 8, 4238, 14, 22886, 28804, 3339, 11043, 12, 291, 9, 267, 1145, 14, 2423, 21031, 14, 2242, 8, 277, 14, 7998, 6694, 21031, 9, 267, 1145, 14, 2423, 13430, 14, 2242, 8, 277, 14, 7998, 6694, 13430, 9, 2286, 347, 9028, 6379, 8, 277, 304, 267, 291, 14, 30601, 6115, 44, 3444, 48, 7835, 5297, 2237, 267, 291, 14, 13396, 2768, 3310, 1252, 8341, 6115, 44, 3444, 48, 7835, 1253, 2445, 2237, 5493, 347, 1218, 3339, 8, 277, 304, 267, 687, 1275, 492, 943, 3440, 267, 372, 943, 3440, 14, 2445, 3339, 8, 277, 9, 2286, 347, 9348, 6694, 21031, 8, 277, 12, 1382, 12, 3906, 304, 267, 408, 10474, 18119, 3906, 9174, 12, 12985, 3424, 3775, 370, 2035, 652, 436, 2498, 314, 943, 1041, 267, 492, 3906, 2987, 267, 1335, 3288, 275, 3906, 2987, 14, 362, 8, 2423, 9, 267, 340, 1382, 508, 291, 14, 973, 3806, 1252, 1818, 5564, 342, 503, 291, 14, 973, 3806, 342, 508, 1335, 3288, 14, 973, 3806, 26, 288, 291, 14, 3440, 1252, 5656, 5564, 8, 1301, 9, 288, 340, 440, 1335, 3288, 14, 5642, 436, 1413, 5268, 1252, 585, 480, 793, 15, 2384, 63, 265, 63, 928, 401, 715, 12, 2155, 304, 355, 291, 14, 2384, 342, 339, 347, 9348, 6694, 13430, 8, 277, 12, 2213, 12, 3906, 12, 3182, 304, 267, 492, 3906, 2987, 267, 340, 334, 1397, 3182, 436, 440, 3906, 14, 374, 63, 371, 1376, 342, 355, 436, 440, 3906, 2987, 14, 362, 8, 2423, 680, 5642, 355, 436, 2213, 508, 291, 14, 973, 3806, 1252, 1818, 5564, 5109, 288, 291, 14, 2384, 342, 2286, 347, 9348, 5765, 547, 8, 277, 304, 267, 408, 42, 1220, 83, 370, 314, 3421, 32031, 370, 701, 314, 2163, 1125, 1245, 1041, 267, 291, 14, 8222, 342, 267, 291, 14, 3440, 1252, 14867, 547, 8, 17, 9, 2286, 347, 9348, 18021, 547, 8, 277, 304, 267, 408, 42, 1220, 83, 370, 314, 3421, 32031, 370, 701, 314, 2163, 1125, 1245, 1041, 267, 291, 14, 8222, 342, 267, 291, 14, 3440, 1252, 14867, 547, 2801, 17, 9, 27844, 199, 533, 24367, 8, 1287, 3627, 14, 3310, 7768, 304, 272, 536, 275, 298, 793, 3557, 2, 272, 347, 1218, 9303, 8, 277, 12, 1676, 29, 403, 304, 267, 291, 14, 793, 63, 2184, 63, 705, 275, 1413, 3310, 8, 1708, 9, 267, 291, 14, 793, 63, 6352, 63, 705, 275, 1413, 3310, 8, 1708, 9, 2728, 291, 14, 793, 63, 2184, 63, 705, 14, 409, 28301, 8, 49, 1197, 5826, 480, 9778, 11, 37, 2237, 267, 291, 14, 793, 63, 6352, 63, 705, 14, 409, 28301, 8, 49, 1197, 5826, 480, 9778, 11, 14379, 11, 37, 2237, 5493, 347, 9028, 6379, 8, 277, 304, 267, 291, 14, 793, 63, 2184, 63, 705, 14, 8341, 6115, 5765, 4520, 6430, 2237, 267, 291, 14, 793, 63, 6352, 63, 705, 14, 8341, 6115, 18021, 4520, 6430, 2237, 421, 199, 3, 943, 2552, 701, 29141, 20456, 1256, 199, 32, 571, 14, 2423, 21031, 14, 2242, 199, 318, 485, 793, 63, 2550, 8, 3554, 304, 272, 687, 1275, 492, 2552, 272, 2552, 14, 2550, 8, 3554, 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 ]
[ 961, 570, 365, 1777, 402, 314, 481, 470, 331, 4982, 328, 2199, 12, 1455, 921, 1544, 14, 70, 470, 331, 4982, 328, 14, 1308, 15, 199, 3, 199, 3, 1898, 334, 67, 9, 9079, 446, 6927, 701, 644, 382, 12504, 6423, 16479, 2464, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 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, 8026, 11236, 1933, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 1666, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 367, 1655, 2556, 14, 199, 199, 624, 199, 1918, 943, 366, 766, 3806, 14, 199, 624, 421, 199, 504, 14084, 21, 14, 10901, 492, 1413, 5268, 12, 3959, 199, 504, 14084, 21, 14, 10604, 492, 1413, 1197, 5826, 199, 504, 14084, 21, 14, 29081, 492, 1413, 3310, 199, 199, 646, 1595, 3627, 199, 646, 1595, 3627, 2609, 199, 646, 1145, 199, 646, 12748, 421, 199, 533, 5297, 5157, 8, 7885, 14, 10185, 304, 272, 408, 33, 366, 766, 3440, 21207, 314, 943, 402, 3879, 7135, 1533, 1041, 272, 347, 636, 826, 721, 277, 12, 2446, 3806, 304, 267, 1613, 8, 2445, 5157, 12, 291, 2843, 826, 721, 973, 3806, 9, 267, 291, 14, 8191, 342, 267, 291, 14, 13396, 2768, 3310, 1252, 409, 28301, 8, 49, 1197, 5826, 480, 3396, 11, 16985, 11, 44, 2237, 267, 1066, 275, 291, 14, 1287, 7768, 275, 24367, 342, 267, 1066, 14, 793, 63, 2184, 63, 705, 14, 21142, 14, 2242, 8, 277, 14, 7998, 5765, 547, 9, 267, 1066, 14, 793, 63, 6352, 63, 705, 14, 21142, 14, 2242, 8, 277, 14, 7998, 18021, 547, 9, 267, 1595, 3627, 2609, 14, 2609, 8, 973, 3806, 680, 19006, 7768, 8, 645, 9, 267, 2446, 3806, 14, 525, 28804, 3339, 8, 4238, 14, 22886, 28804, 3339, 11043, 12, 291, 9, 267, 1145, 14, 2423, 21031, 14, 2242, 8, 277, 14, 7998, 6694, 21031, 9, 267, 1145, 14, 2423, 13430, 14, 2242, 8, 277, 14, 7998, 6694, 13430, 9, 2286, 347, 9028, 6379, 8, 277, 304, 267, 291, 14, 30601, 6115, 44, 3444, 48, 7835, 5297, 2237, 267, 291, 14, 13396, 2768, 3310, 1252, 8341, 6115, 44, 3444, 48, 7835, 1253, 2445, 2237, 5493, 347, 1218, 3339, 8, 277, 304, 267, 687, 1275, 492, 943, 3440, 267, 372, 943, 3440, 14, 2445, 3339, 8, 277, 9, 2286, 347, 9348, 6694, 21031, 8, 277, 12, 1382, 12, 3906, 304, 267, 408, 10474, 18119, 3906, 9174, 12, 12985, 3424, 3775, 370, 2035, 652, 436, 2498, 314, 943, 1041, 267, 492, 3906, 2987, 267, 1335, 3288, 275, 3906, 2987, 14, 362, 8, 2423, 9, 267, 340, 1382, 508, 291, 14, 973, 3806, 1252, 1818, 5564, 342, 503, 291, 14, 973, 3806, 342, 508, 1335, 3288, 14, 973, 3806, 26, 288, 291, 14, 3440, 1252, 5656, 5564, 8, 1301, 9, 288, 340, 440, 1335, 3288, 14, 5642, 436, 1413, 5268, 1252, 585, 480, 793, 15, 2384, 63, 265, 63, 928, 401, 715, 12, 2155, 304, 355, 291, 14, 2384, 342, 339, 347, 9348, 6694, 13430, 8, 277, 12, 2213, 12, 3906, 12, 3182, 304, 267, 492, 3906, 2987, 267, 340, 334, 1397, 3182, 436, 440, 3906, 14, 374, 63, 371, 1376, 342, 355, 436, 440, 3906, 2987, 14, 362, 8, 2423, 680, 5642, 355, 436, 2213, 508, 291, 14, 973, 3806, 1252, 1818, 5564, 5109, 288, 291, 14, 2384, 342, 2286, 347, 9348, 5765, 547, 8, 277, 304, 267, 408, 42, 1220, 83, 370, 314, 3421, 32031, 370, 701, 314, 2163, 1125, 1245, 1041, 267, 291, 14, 8222, 342, 267, 291, 14, 3440, 1252, 14867, 547, 8, 17, 9, 2286, 347, 9348, 18021, 547, 8, 277, 304, 267, 408, 42, 1220, 83, 370, 314, 3421, 32031, 370, 701, 314, 2163, 1125, 1245, 1041, 267, 291, 14, 8222, 342, 267, 291, 14, 3440, 1252, 14867, 547, 2801, 17, 9, 27844, 199, 533, 24367, 8, 1287, 3627, 14, 3310, 7768, 304, 272, 536, 275, 298, 793, 3557, 2, 272, 347, 1218, 9303, 8, 277, 12, 1676, 29, 403, 304, 267, 291, 14, 793, 63, 2184, 63, 705, 275, 1413, 3310, 8, 1708, 9, 267, 291, 14, 793, 63, 6352, 63, 705, 275, 1413, 3310, 8, 1708, 9, 2728, 291, 14, 793, 63, 2184, 63, 705, 14, 409, 28301, 8, 49, 1197, 5826, 480, 9778, 11, 37, 2237, 267, 291, 14, 793, 63, 6352, 63, 705, 14, 409, 28301, 8, 49, 1197, 5826, 480, 9778, 11, 14379, 11, 37, 2237, 5493, 347, 9028, 6379, 8, 277, 304, 267, 291, 14, 793, 63, 2184, 63, 705, 14, 8341, 6115, 5765, 4520, 6430, 2237, 267, 291, 14, 793, 63, 6352, 63, 705, 14, 8341, 6115, 18021, 4520, 6430, 2237, 421, 199, 3, 943, 2552, 701, 29141, 20456, 1256, 199, 32, 571, 14, 2423, 21031, 14, 2242, 199, 318, 485, 793, 63, 2550, 8, 3554, 304, 272, 687, 1275, 492, 2552, 272, 2552, 14, 2550, 8, 3554, 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, 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 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
grnet/synnefo
snf-astakos-app/astakos/im/migrations/old/0057_auto__del_field_resource_allow_in_projects__add_field_resource_ui_visi.py
10
25856
# -*- 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): db.rename_column('im_resource', 'allow_in_projects', 'ui_visible') # Adding field 'Resource.api_visible' db.add_column('im_resource', 'api_visible', self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False) def backwards(self, orm): db.rename_column('im_resource', 'ui_visible', 'allow_in_projects') # Deleting field 'Resource.api_visible' db.delete_column('im_resource', 'api_visible') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'im.additionalmail': { 'Meta': {'object_name': 'AdditionalMail'}, 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']"}) }, 'im.approvalterms': { 'Meta': {'object_name': 'ApprovalTerms'}, 'date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'location': ('django.db.models.fields.CharField', [], {'max_length': '255'}) }, 'im.astakosuser': { 'Meta': {'object_name': 'AstakosUser', '_ormbases': ['auth.User']}, 'accepted_email': ('django.db.models.fields.EmailField', [], {'default': 'None', 'max_length': '75', 'null': 'True', 'blank': 'True'}), 'accepted_policy': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True', 'blank': 'True'}), 'activation_sent': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'affiliation': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'auth_token': ('django.db.models.fields.CharField', [], {'max_length': '64', 'unique': 'True', 'null': 'True', 'blank': 'True'}), 'auth_token_created': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'auth_token_expires': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'date_signed_terms': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'deactivated_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'deactivated_reason': ('django.db.models.fields.TextField', [], {'default': 'None', 'null': 'True'}), 'disturbed_quota': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), 'email_verified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'has_credits': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'has_signed_terms': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'invitations': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'is_rejected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_verified': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'level': ('django.db.models.fields.IntegerField', [], {'default': '4'}), 'moderated': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'moderated_at': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'moderated_data': ('django.db.models.fields.TextField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'policy': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['im.Resource']", 'null': 'True', 'through': "orm['im.AstakosUserQuota']", 'symmetrical': 'False'}), 'rejected_reason': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'updated': ('django.db.models.fields.DateTimeField', [], {}), 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}), 'uuid': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}), 'verification_code': ('django.db.models.fields.CharField', [], {'max_length': '255', 'unique': 'True', 'null': 'True'}), 'verified_at': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}) }, 'im.astakosuserauthprovider': { 'Meta': {'ordering': "('module', 'created')", 'unique_together': "(('identifier', 'module', 'user'),)", 'object_name': 'AstakosUserAuthProvider'}, 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'affiliation': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True', 'blank': 'True'}), 'auth_backend': ('django.db.models.fields.CharField', [], {'default': "'astakos'", 'max_length': '255'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'identifier': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'info_data': ('django.db.models.fields.TextField', [], {'default': "''", 'null': 'True', 'blank': 'True'}), 'module': ('django.db.models.fields.CharField', [], {'default': "'local'", 'max_length': '255'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'auth_providers'", 'to': "orm['im.AstakosUser']"}) }, 'im.astakosuserquota': { 'Meta': {'unique_together': "(('resource', 'user'),)", 'object_name': 'AstakosUserQuota'}, 'capacity': ('django.db.models.fields.BigIntegerField', [], {}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'resource': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Resource']"}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']"}) }, 'im.authproviderpolicyprofile': { 'Meta': {'ordering': "['priority']", 'object_name': 'AuthProviderPolicyProfile'}, 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'authpolicy_profiles'", 'symmetrical': 'False', 'to': "orm['auth.Group']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_exclusive': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'policy_add': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'policy_automoderate': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'policy_create': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'policy_limit': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True'}), 'policy_login': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'policy_remove': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'policy_required': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'policy_switch': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}), 'priority': ('django.db.models.fields.IntegerField', [], {'default': '1'}), 'provider': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'users': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'authpolicy_profiles'", 'symmetrical': 'False', 'to': "orm['im.AstakosUser']"}) }, 'im.chain': { 'Meta': {'object_name': 'Chain'}, 'chain': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, 'im.component': { 'Meta': {'object_name': 'Component'}, 'auth_token': ('django.db.models.fields.CharField', [], {'max_length': '64', 'unique': 'True', 'null': 'True', 'blank': 'True'}), 'auth_token_created': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'auth_token_expires': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}), 'base_url': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'}), 'url': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True'}) }, 'im.emailchange': { 'Meta': {'object_name': 'EmailChange'}, 'activation_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '40', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'new_email_address': ('django.db.models.fields.EmailField', [], {'max_length': '75'}), 'requested_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'emailchanges'", 'unique': 'True', 'to': "orm['im.AstakosUser']"}) }, 'im.endpoint': { 'Meta': {'object_name': 'Endpoint'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'service': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'endpoints'", 'to': "orm['im.Service']"}) }, 'im.endpointdata': { 'Meta': {'unique_together': "(('endpoint', 'key'),)", 'object_name': 'EndpointData'}, 'endpoint': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'data'", 'to': "orm['im.Endpoint']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'key': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'value': ('django.db.models.fields.CharField', [], {'max_length': '1024'}) }, 'im.invitation': { 'Meta': {'object_name': 'Invitation'}, 'code': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True'}), 'consumed': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'inviter': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'invitations_sent'", 'null': 'True', 'to': "orm['im.AstakosUser']"}), 'is_consumed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'realname': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) }, 'im.pendingthirdpartyuser': { 'Meta': {'unique_together': "(('provider', 'third_party_identifier'),)", 'object_name': 'PendingThirdPartyUser'}, 'affiliation': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'info': ('django.db.models.fields.TextField', [], {'default': "''", 'null': 'True', 'blank': 'True'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), 'provider': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), 'third_party_identifier': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'token': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'im.project': { 'Meta': {'object_name': 'Project'}, 'application': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'project'", 'unique': 'True', 'to': "orm['im.ProjectApplication']"}), 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.BigIntegerField', [], {'primary_key': 'True', 'db_column': "'id'"}), 'members': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['im.AstakosUser']", 'through': "orm['im.ProjectMembership']", 'symmetrical': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '80', 'unique': 'True', 'null': 'True', 'db_index': 'True'}), 'state': ('django.db.models.fields.IntegerField', [], {'default': '1', 'db_index': 'True'}) }, 'im.projectapplication': { 'Meta': {'unique_together': "(('chain', 'id'),)", 'object_name': 'ProjectApplication'}, 'applicant': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'projects_applied'", 'to': "orm['im.AstakosUser']"}), 'chain': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'chained_apps'", 'db_column': "'chain'", 'to': "orm['im.Project']"}), 'comments': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'end_date': ('django.db.models.fields.DateTimeField', [], {}), 'homepage': ('django.db.models.fields.URLField', [], {'max_length': '255', 'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'issue_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'limit_on_members_number': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}), 'member_join_policy': ('django.db.models.fields.IntegerField', [], {}), 'member_leave_policy': ('django.db.models.fields.IntegerField', [], {}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '80'}), 'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'projects_owned'", 'to': "orm['im.AstakosUser']"}), 'resource_grants': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['im.Resource']", 'null': 'True', 'through': "orm['im.ProjectResourceGrant']", 'blank': 'True'}), 'response': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'response_actor': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'responded_apps'", 'null': 'True', 'to': "orm['im.AstakosUser']"}), 'response_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'start_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'state': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}), 'waive_actor': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'waived_apps'", 'null': 'True', 'to': "orm['im.AstakosUser']"}), 'waive_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'waive_reason': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) }, 'im.projectlock': { 'Meta': {'object_name': 'ProjectLock'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, 'im.projectlog': { 'Meta': {'object_name': 'ProjectLog'}, 'actor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']", 'null': 'True'}), 'comments': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'date': ('django.db.models.fields.DateTimeField', [], {}), 'from_state': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'project': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'log'", 'to': "orm['im.Project']"}), 'reason': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'to_state': ('django.db.models.fields.IntegerField', [], {}) }, 'im.projectmembership': { 'Meta': {'unique_together': "(('person', 'project'),)", 'object_name': 'ProjectMembership'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'person': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']"}), 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Project']"}), 'state': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}) }, 'im.projectmembershiplog': { 'Meta': {'object_name': 'ProjectMembershipLog'}, 'actor': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']", 'null': 'True'}), 'comments': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'date': ('django.db.models.fields.DateTimeField', [], {}), 'from_state': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'membership': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'log'", 'to': "orm['im.ProjectMembership']"}), 'reason': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'to_state': ('django.db.models.fields.IntegerField', [], {}) }, 'im.projectresourcegrant': { 'Meta': {'unique_together': "(('resource', 'project_application'),)", 'object_name': 'ProjectResourceGrant'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'member_capacity': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}), 'project_application': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.ProjectApplication']", 'null': 'True'}), 'project_capacity': ('django.db.models.fields.BigIntegerField', [], {'null': 'True'}), 'resource': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Resource']"}) }, 'im.resource': { 'Meta': {'object_name': 'Resource'}, 'api_visible': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'desc': ('django.db.models.fields.TextField', [], {'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'service_origin': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'service_type': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'ui_visible': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'unit': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), 'uplimit': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}) }, 'im.service': { 'Meta': {'object_name': 'Service'}, 'component': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Component']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'type': ('django.db.models.fields.CharField', [], {'max_length': '255'}) }, 'im.sessioncatalog': { 'Meta': {'object_name': 'SessionCatalog'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'session_key': ('django.db.models.fields.CharField', [], {'max_length': '40'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'sessions'", 'null': 'True', 'to': "orm['im.AstakosUser']"}) }, 'im.usersetting': { 'Meta': {'unique_together': "(('user', 'setting'),)", 'object_name': 'UserSetting'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'setting': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']"}), 'value': ('django.db.models.fields.IntegerField', [], {}) } } complete_apps = ['im']
gpl-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, 1592, 14, 8165, 63, 2301, 360, 1017, 63, 1927, 297, 283, 3306, 63, 262, 63, 6776, 297, 283, 1907, 63, 6604, 358, 398, 327, 12934, 901, 283, 4031, 14, 1246, 63, 6604, 7, 267, 1592, 14, 525, 63, 2301, 360, 1017, 63, 1927, 297, 283, 1246, 63, 6604, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 1592, 14, 8165, 63, 2301, 360, 1017, 63, 1927, 297, 283, 1907, 63, 6604, 297, 283, 3306, 63, 262, 63, 6776, 358, 398, 327, 15920, 901, 283, 4031, 14, 1246, 63, 6604, 7, 267, 1592, 14, 1807, 63, 2301, 360, 1017, 63, 1927, 297, 283, 1246, 63, 6604, 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, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 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, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 3071, 267, 1660, 267, 283, 1017, 14, 8460, 1198, 356, 469, 288, 283, 3396, 356 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 1592, 14, 8165, 63, 2301, 360, 1017, 63, 1927, 297, 283, 3306, 63, 262, 63, 6776, 297, 283, 1907, 63, 6604, 358, 398, 327, 12934, 901, 283, 4031, 14, 1246, 63, 6604, 7, 267, 1592, 14, 525, 63, 2301, 360, 1017, 63, 1927, 297, 283, 1246, 63, 6604, 297, 1993, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 549, 395, 1993, 4215, 63, 885, 29, 797, 9, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 1592, 14, 8165, 63, 2301, 360, 1017, 63, 1927, 297, 283, 1907, 63, 6604, 297, 283, 3306, 63, 262, 63, 6776, 358, 398, 327, 15920, 901, 283, 4031, 14, 1246, 63, 6604, 7, 267, 1592, 14, 1807, 63, 2301, 360, 1017, 63, 1927, 297, 283, 1246, 63, 6604, 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, 10778, 14, 20735, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 354, 21099, 283, 3235, 63, 6314, 356, 9510, 571, 63, 1302, 297, 283, 1238, 9878, 283, 785, 63, 354, 356, 283, 11282, 297, 283, 697, 63, 1224, 356, 3546, 1176, 63, 1317, 63, 466, 15208, 288, 283, 571, 63, 1302, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 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, 1238, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 3071, 267, 1660, 267, 283, 1017, 14, 8460, 1198, 356, 469, 288, 283, 3396, 356, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
joshgeller/PyPardot
pypardot/objects/opportunities.py
1
3806
class Opportunities(object): """ A class to query and use Pardot opportunities. Opportunity field reference: http://developer.pardot.com/kb/api-version-3/object-field-references/#opportunity """ def __init__(self, client): self.client = client def query(self, **kwargs): """ Returns the opportunities matching the specified criteria parameters. Supported search criteria: http://developer.pardot.com/kb/api-version-3/opportunities/#supported-search-criteria """ response = self._get(path='/do/query', params=kwargs) # Ensure result['opportunity'] is a list, no matter what. result = response.get('result') if result['total_results'] == 0: result['opportunity'] = [] elif result['total_results'] == 1: result['opportunity'] = [result['opportunity']] return result def create_by_email(self, prospect_email=None, name=None, value=None, probability=None, **kwargs): """ Creates a new opportunity using the specified data. <prospect_email> must correspond to an existing prospect. """ kwargs.update({'name': name, 'value': value, 'probability': probability}) response = self._post( path='/do/create/prospect_email/{prospect_email}'.format(prospect_email=prospect_email), params=kwargs) return response def create_by_id(self, prospect_id=None, name=None, value=None, probability=None, **kwargs): """ Creates a new opportunity using the specified data. <prospect_id> must correspond to an existing prospect. """ kwargs.update({'name': name, 'value': value, 'probability': probability}) response = self._post( path='/do/create/prospect_id/{prospect_id}'.format(prospect_id=prospect_id), params=kwargs) return response def read(self, id=None): """ Returns the data for the opportunity specified by <id>, including campaign assignment and associated visitor activities. <id> is the Pardot ID for the target opportunity. """ response = self._post(path='/do/read/id/{id}'.format(id=id)) return response def update(self, id=None): """ Updates the provided data for the opportunity specified by <id>. <id> is the Pardot ID for the target opportunity. Fields that are not updated by the request remain unchanged. Returns an updated version of the opportunity. """ response = self._post(path='/do/update/id/{id}'.format(id=id)) return response def delete(self, id=None): """ Deletes the opportunity specified by <id>. <id> is the Pardot ID for the target opportunity. Returns no response on success. """ response = self._post(path='/do/delete/id/{id}'.format(id=id)) return response def undelete(self, id=None): """ Un-deletes the opportunity specified by <id>. <id> is the Pardot ID for the target opportunity. Returns no response on success. """ response = self._post(path='/do/undelete/id/{id}'.format(id=id)) return response def _get(self, object_name='opportunity', path=None, params=None): """GET requests for the Opportunity object.""" if params is None: params = {} response = self.client.get(object_name=object_name, path=path, params=params) return response def _post(self, object_name='opportunity', path=None, params=None): """POST requests for the Opportunity object.""" if params is None: params = {} response = self.client.post(object_name=object_name, path=path, params=params) return response
mit
[ 533, 9319, 719, 22047, 8, 785, 304, 272, 408, 272, 437, 1021, 370, 1827, 436, 675, 510, 1005, 357, 1687, 719, 22047, 14, 272, 9319, 19145, 901, 3659, 26, 1455, 921, 11071, 14, 462, 3287, 14, 957, 15, 7862, 15, 1246, 13, 1023, 13, 19, 15, 785, 13, 698, 13, 12635, 12645, 31389, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1890, 304, 267, 291, 14, 1258, 275, 1890, 339, 347, 1827, 8, 277, 12, 1011, 958, 304, 267, 408, 267, 1803, 314, 1687, 719, 22047, 4877, 314, 2013, 15647, 2633, 14, 267, 26167, 2754, 15647, 26, 1455, 921, 11071, 14, 462, 3287, 14, 957, 15, 7862, 15, 1246, 13, 1023, 13, 19, 15, 411, 719, 22047, 12645, 4946, 13, 1733, 13, 20525, 267, 408, 267, 1177, 275, 291, 423, 362, 8, 515, 8805, 1117, 15, 1131, 297, 1862, 29, 958, 9, 398, 327, 7523, 754, 459, 31389, 418, 365, 282, 769, 12, 949, 17247, 4052, 14, 267, 754, 275, 1177, 14, 362, 360, 1099, 358, 267, 340, 754, 459, 2923, 63, 2604, 418, 508, 378, 26, 288, 754, 459, 31389, 418, 275, 942, 267, 916, 754, 459, 2923, 63, 2604, 418, 508, 413, 26, 288, 754, 459, 31389, 418, 275, 359, 1099, 459, 31389, 6538, 398, 372, 754, 339, 347, 1218, 63, 991, 63, 2123, 8, 277, 12, 557, 20865, 63, 2123, 29, 403, 12, 536, 29, 403, 12, 574, 29, 403, 12, 12224, 29, 403, 12, 1011, 958, 304, 267, 408, 267, 10560, 282, 892, 30914, 1808, 314, 2013, 666, 14, 665, 496, 20865, 63, 2123, 30, 1471, 17118, 370, 376, 3411, 557, 20865, 14, 267, 408, 267, 2074, 14, 873, 3252, 354, 356, 536, 12, 283, 585, 356, 574, 12, 283, 17210, 356, 12224, 1552, 267, 1177, 275, 291, 423, 1932, 8, 288, 931, 8805, 1117, 15, 981, 15, 496, 20865, 63, 2123, 5321, 496, 20865, 63, 2123, 5285, 908, 8, 496, 20865, 63, 2123, 29, 496, 20865, 63, 2123, 395, 288, 1862, 29, 958, 9, 267, 372, 1177, 339, 347, 1218, 63, 991, 63, 344, 8, 277, 12, 557, 20865, 63, 344, 29, 403, 12, 536, 29, 403, 12, 574, 29, 403, 12, 12224, 29, 403, 12, 1011, 958, 304, 267, 408, 267, 10560, 282, 892, 30914, 1808, 314, 2013, 666, 14, 665, 496, 20865, 63, 344, 30, 1471, 17118, 370, 376, 3411, 557, 20865, 14, 267, 408, 267, 2074, 14, 873, 3252, 354, 356, 536, 12, 283, 585, 356, 574, 12, 283, 17210, 356, 12224, 1552, 267, 1177, 275, 291, 423, 1932, 8, 288, 931, 8805, 1117, 15, 981, 15, 496, 20865, 63, 344, 5321, 496, 20865, 63, 344, 5285, 908, 8, 496, 20865, 63, 344, 29, 496, 20865, 63, 344, 395, 288, 1862, 29, 958, 9, 267, 372, 1177, 339, 347, 1586, 8, 277, 12, 1305, 29, 403, 304, 267, 408, 267, 1803, 314, 666, 367, 314, 30914, 2013, 701, 665, 344, 6244, 5893, 22166, 9801, 436, 4568, 18040, 267, 30744, 14, 665, 344, 30, 365, 314, 510, 1005, 357, 2870, 367, 314, 1347, 30914, 14, 267, 408, 267, 1177, 275, 291, 423, 1932, 8, 515, 8805, 1117, 15, 739, 15, 344, 5321, 344, 5285, 908, 8, 344, 29, 344, 430, 267, 372, 1177, 339, 347, 1678, 8, 277, 12, 1305, 29, 403, 304, 267, 408, 267, 24663, 314, 2741, 666, 367, 314, 30914, 2013, 701, 665, 344, 10827, 665, 344, 30, 365, 314, 510, 1005, 357, 2870, 367, 314, 1347, 267, 30914, 14, 16424, 626, 787, 440, 4588, 701, 314, 1056, 5706, 14874, 14, 1803, 376, 4588, 1015, 402, 314, 267, 30914, 14, 267, 408, 267, 1177, 275, 291, 423, 1932, 8, 515, 8805, 1117, 15, 873, 15, 344, 5321, 344, 5285, 908, 8, 344, 29, 344, 430, 267, 372, 1177, 339, 347, 3145, 8, 277, 12, 1305, 29, 403, 304, 267, 408, 267, 28382, 314, 30914, 2013, 701, 665, 344, 10827, 665, 344, 30, 365, 314, 510, 1005, 357, 2870, 367, 314, 1347, 30914, 14, 1803, 949, 1177, 267, 641, 3182, 14, 267, 408, 267, 1177, 275, 291, 423, 1932, 8, 515, 8805, 1117, 15, 1807, 15, 344, 5321, 344, 5285, 908, 8, 344, 29, 344, 430, 267, 372, 1177, 339, 347, 625, 1807, 8, 277, 12, 1305, 29, 403, 304, 267, 408, 267, 1910, 13, 26289, 314, 30914, 2013, 701, 665, 344, 10827, 665, 344, 30, 365, 314, 510, 1005, 357, 2870, 367, 314, 1347, 30914, 14, 1803, 949, 267, 1177, 641, 3182, 14, 267, 408, 267, 1177, 275, 291, 423, 1932, 8, 515, 8805, 1117, 15, 324, 1807, 15, 344, 5321, 344, 5285, 908, 8, 344, 29, 344, 430, 267, 372, 1177, 339, 347, 485, 362, 8, 277, 12, 909, 63, 354, 534, 31389, 297, 931, 29, 403, 12, 1862, 29, 403, 304, 267, 408, 2970, 4145, 367, 314, 9319, 19145, 909, 1041, 267, 340, 1862, 365, 488, 26, 288, 1862, 275, 1052, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 785, 63, 354, 29, 785, 63, 354, 12, 931, 29, 515, 12, 1862, 29, 1162, 9, 267, 372, 1177, 339, 347, 485, 1932, 8, 277, 12, 909, 63, 354, 534, 31389, 297, 931, 29, 403, 12, 1862, 29, 403, 304, 267, 408, 4030, 4145, 367, 314, 9319, 19145, 909, 1041, 267, 340, 1862, 365, 488, 26, 288, 1862, 275, 1052, 267, 1177, 275, 291, 14, 1258, 14, 1932, 8, 785, 63, 354, 29, 785, 63, 354, 12, 931, 29, 515, 12, 1862, 29, 1162, 9, 267, 372, 1177, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 9319, 719, 22047, 8, 785, 304, 272, 408, 272, 437, 1021, 370, 1827, 436, 675, 510, 1005, 357, 1687, 719, 22047, 14, 272, 9319, 19145, 901, 3659, 26, 1455, 921, 11071, 14, 462, 3287, 14, 957, 15, 7862, 15, 1246, 13, 1023, 13, 19, 15, 785, 13, 698, 13, 12635, 12645, 31389, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1890, 304, 267, 291, 14, 1258, 275, 1890, 339, 347, 1827, 8, 277, 12, 1011, 958, 304, 267, 408, 267, 1803, 314, 1687, 719, 22047, 4877, 314, 2013, 15647, 2633, 14, 267, 26167, 2754, 15647, 26, 1455, 921, 11071, 14, 462, 3287, 14, 957, 15, 7862, 15, 1246, 13, 1023, 13, 19, 15, 411, 719, 22047, 12645, 4946, 13, 1733, 13, 20525, 267, 408, 267, 1177, 275, 291, 423, 362, 8, 515, 8805, 1117, 15, 1131, 297, 1862, 29, 958, 9, 398, 327, 7523, 754, 459, 31389, 418, 365, 282, 769, 12, 949, 17247, 4052, 14, 267, 754, 275, 1177, 14, 362, 360, 1099, 358, 267, 340, 754, 459, 2923, 63, 2604, 418, 508, 378, 26, 288, 754, 459, 31389, 418, 275, 942, 267, 916, 754, 459, 2923, 63, 2604, 418, 508, 413, 26, 288, 754, 459, 31389, 418, 275, 359, 1099, 459, 31389, 6538, 398, 372, 754, 339, 347, 1218, 63, 991, 63, 2123, 8, 277, 12, 557, 20865, 63, 2123, 29, 403, 12, 536, 29, 403, 12, 574, 29, 403, 12, 12224, 29, 403, 12, 1011, 958, 304, 267, 408, 267, 10560, 282, 892, 30914, 1808, 314, 2013, 666, 14, 665, 496, 20865, 63, 2123, 30, 1471, 17118, 370, 376, 3411, 557, 20865, 14, 267, 408, 267, 2074, 14, 873, 3252, 354, 356, 536, 12, 283, 585, 356, 574, 12, 283, 17210, 356, 12224, 1552, 267, 1177, 275, 291, 423, 1932, 8, 288, 931, 8805, 1117, 15, 981, 15, 496, 20865, 63, 2123, 5321, 496, 20865, 63, 2123, 5285, 908, 8, 496, 20865, 63, 2123, 29, 496, 20865, 63, 2123, 395, 288, 1862, 29, 958, 9, 267, 372, 1177, 339, 347, 1218, 63, 991, 63, 344, 8, 277, 12, 557, 20865, 63, 344, 29, 403, 12, 536, 29, 403, 12, 574, 29, 403, 12, 12224, 29, 403, 12, 1011, 958, 304, 267, 408, 267, 10560, 282, 892, 30914, 1808, 314, 2013, 666, 14, 665, 496, 20865, 63, 344, 30, 1471, 17118, 370, 376, 3411, 557, 20865, 14, 267, 408, 267, 2074, 14, 873, 3252, 354, 356, 536, 12, 283, 585, 356, 574, 12, 283, 17210, 356, 12224, 1552, 267, 1177, 275, 291, 423, 1932, 8, 288, 931, 8805, 1117, 15, 981, 15, 496, 20865, 63, 344, 5321, 496, 20865, 63, 344, 5285, 908, 8, 496, 20865, 63, 344, 29, 496, 20865, 63, 344, 395, 288, 1862, 29, 958, 9, 267, 372, 1177, 339, 347, 1586, 8, 277, 12, 1305, 29, 403, 304, 267, 408, 267, 1803, 314, 666, 367, 314, 30914, 2013, 701, 665, 344, 6244, 5893, 22166, 9801, 436, 4568, 18040, 267, 30744, 14, 665, 344, 30, 365, 314, 510, 1005, 357, 2870, 367, 314, 1347, 30914, 14, 267, 408, 267, 1177, 275, 291, 423, 1932, 8, 515, 8805, 1117, 15, 739, 15, 344, 5321, 344, 5285, 908, 8, 344, 29, 344, 430, 267, 372, 1177, 339, 347, 1678, 8, 277, 12, 1305, 29, 403, 304, 267, 408, 267, 24663, 314, 2741, 666, 367, 314, 30914, 2013, 701, 665, 344, 10827, 665, 344, 30, 365, 314, 510, 1005, 357, 2870, 367, 314, 1347, 267, 30914, 14, 16424, 626, 787, 440, 4588, 701, 314, 1056, 5706, 14874, 14, 1803, 376, 4588, 1015, 402, 314, 267, 30914, 14, 267, 408, 267, 1177, 275, 291, 423, 1932, 8, 515, 8805, 1117, 15, 873, 15, 344, 5321, 344, 5285, 908, 8, 344, 29, 344, 430, 267, 372, 1177, 339, 347, 3145, 8, 277, 12, 1305, 29, 403, 304, 267, 408, 267, 28382, 314, 30914, 2013, 701, 665, 344, 10827, 665, 344, 30, 365, 314, 510, 1005, 357, 2870, 367, 314, 1347, 30914, 14, 1803, 949, 1177, 267, 641, 3182, 14, 267, 408, 267, 1177, 275, 291, 423, 1932, 8, 515, 8805, 1117, 15, 1807, 15, 344, 5321, 344, 5285, 908, 8, 344, 29, 344, 430, 267, 372, 1177, 339, 347, 625, 1807, 8, 277, 12, 1305, 29, 403, 304, 267, 408, 267, 1910, 13, 26289, 314, 30914, 2013, 701, 665, 344, 10827, 665, 344, 30, 365, 314, 510, 1005, 357, 2870, 367, 314, 1347, 30914, 14, 1803, 949, 267, 1177, 641, 3182, 14, 267, 408, 267, 1177, 275, 291, 423, 1932, 8, 515, 8805, 1117, 15, 324, 1807, 15, 344, 5321, 344, 5285, 908, 8, 344, 29, 344, 430, 267, 372, 1177, 339, 347, 485, 362, 8, 277, 12, 909, 63, 354, 534, 31389, 297, 931, 29, 403, 12, 1862, 29, 403, 304, 267, 408, 2970, 4145, 367, 314, 9319, 19145, 909, 1041, 267, 340, 1862, 365, 488, 26, 288, 1862, 275, 1052, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 785, 63, 354, 29, 785, 63, 354, 12, 931, 29, 515, 12, 1862, 29, 1162, 9, 267, 372, 1177, 339, 347, 485, 1932, 8, 277, 12, 909, 63, 354, 534, 31389, 297, 931, 29, 403, 12, 1862, 29, 403, 304, 267, 408, 4030, 4145, 367, 314, 9319, 19145, 909, 1041, 267, 340, 1862, 365, 488, 26, 288, 1862, 275, 1052, 267, 1177, 275, 291, 14, 1258, 14, 1932, 8, 785, 63, 354, 29, 785, 63, 354, 12, 931, 29, 515, 12, 1862, 29, 1162, 9, 267, 372, 1177, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
dmsimard/ansible
lib/ansible/plugins/lookup/first_found.py
1
7109
# (c) 2013, seth vidal <skvidal@fedoraproject.org> red hat, inc # (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 DOCUMENTATION = """ name: first_found author: Seth Vidal (!UNKNOWN) <skvidal@fedoraproject.org> version_added: historical short_description: return first file found from list description: - this lookup checks a list of files and paths and returns the full path to the first combination found. - As all lookups, when fed relative paths it will try use the current task's location first and go up the chain to the containing role/play/include/etc's location. - The list of files has precedence over the paths searched. i.e, A task in a role has a 'file1' in the play's relative path, this will be used, 'file2' in role's relative path will not. - Either a list of files C(_terms) or a key `files` with a list of files is required for this plugin to operate. notes: - This lookup can be used in 'dual mode', either passing a list of file names or a dictionary that has C(files) and C(paths). options: _terms: description: list of file names files: description: list of file names type: list default: [] paths: description: list of paths in which to look for the files type: list default: [] skip: type: boolean default: False description: Return an empty list if no file is found, instead of an error. """ EXAMPLES = """ - name: show first existing file or ignore if none do debug: msg={{lookup('first_found', findme, errors='ignore')}} vars: findme: - "/path/to/foo.txt" - "bar.txt" # will be looked in files/ dir relative to role and/or play - "/path/to/biz.txt" - name: | include tasks only if files exist. Note the use of query() to return a blank list for the loop if no files are found. import_tasks: '{{ item }}' vars: params: files: - path/tasks.yaml - path/other_tasks.yaml loop: "{{ query('first_found', params, errors='ignore') }}" - name: | copy first existing file found to /some/file, looking in relative directories from where the task is defined and including any play objects that contain it copy: src={{lookup('first_found', findme)}} dest=/some/file vars: findme: - foo - "{{inventory_hostname}}" - bar - name: same copy but specific paths copy: src={{lookup('first_found', params)}} dest=/some/file vars: params: files: - foo - "{{inventory_hostname}}" - bar paths: - /tmp/production - /tmp/staging - name: INTERFACES | Create Ansible header for /etc/network/interfaces template: src: "{{ lookup('first_found', findme)}}" dest: "/etc/foo.conf" vars: findme: - "{{ ansible_virtualization_type }}_foo.conf" - "default_foo.conf" - name: read vars from first file found, use 'vars/' relative subdir include_vars: "{{lookup('first_found', params)}}" vars: params: files: - '{{ansible_distribution}}.yml' - '{{ansible_os_family}}.yml' - default.yml paths: - 'vars' """ RETURN = """ _raw: description: - path to file found type: list elements: path """ import os from jinja2.exceptions import UndefinedError from ansible.errors import AnsibleLookupError, AnsibleUndefinedVariable from ansible.module_utils.common._collections_compat import Mapping, Sequence from ansible.module_utils.six import string_types from ansible.plugins.lookup import LookupBase def _split_on(terms, spliters=','): # TODO: fix as it does not allow spaces in names termlist = [] if isinstance(terms, string_types): for spliter in spliters: terms = terms.replace(spliter, ' ') termlist = terms.split(' ') else: # added since options will already listify for t in terms: termlist.extend(_split_on(t, spliters)) return termlist class LookupModule(LookupBase): def _process_terms(self, terms, variables, kwargs): total_search = [] skip = False # can use a dict instead of list item to pass inline config for term in terms: if isinstance(term, Mapping): self.set_options(var_options=variables, direct=term) elif isinstance(term, string_types): self.set_options(var_options=variables, direct=kwargs) elif isinstance(term, Sequence): partial, skip = self._process_terms(term, variables, kwargs) total_search.extend(partial) continue else: raise AnsibleLookupError("Invalid term supplied, can handle string, mapping or list of strings but got: %s for %s" % (type(term), term)) files = self.get_option('files') paths = self.get_option('paths') # NOTE: this is used as 'global' but can be set many times?!?!? skip = self.get_option('skip') # magic extra spliting to create lists filelist = _split_on(files, ',;') pathlist = _split_on(paths, ',:;') # create search structure if pathlist: for path in pathlist: for fn in filelist: f = os.path.join(path, fn) total_search.append(f) elif filelist: # NOTE: this seems wrong, should be 'extend' as any option/entry can clobber all total_search = filelist else: total_search.append(term) return total_search, skip def run(self, terms, variables, **kwargs): total_search, skip = self._process_terms(terms, variables, kwargs) # NOTE: during refactor noticed that the 'using a dict' as term # is designed to only work with 'one' otherwise inconsistencies will appear. # see other notes below. # actually search subdir = getattr(self, '_subdir', 'files') path = None for fn in total_search: try: fn = self._templar.template(fn) except (AnsibleUndefinedVariable, UndefinedError): continue # get subdir if set by task executor, default to files otherwise path = self.find_file_in_search_path(variables, subdir, fn, ignore_missing=True) # exit if we find one! if path is not None: return [path] # if we get here, no file was found if skip: # NOTE: global skip wont matter, only last 'skip' value in dict term return [] raise AnsibleLookupError("No file was found when using first_found. Use errors='ignore' to allow this task to be skipped if no files are found")
gpl-3.0
[ 3, 334, 67, 9, 6171, 12, 542, 273, 27767, 279, 665, 1339, 5017, 279, 32, 15800, 269, 30204, 963, 14, 1308, 30, 8992, 394, 292, 12, 12864, 199, 3, 334, 67, 9, 9708, 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, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 8948, 275, 408, 272, 536, 26, 1642, 63, 4214, 272, 4132, 26, 3240, 273, 812, 344, 279, 19452, 11588, 9, 665, 1339, 5017, 279, 32, 15800, 269, 30204, 963, 14, 1308, 30, 272, 1015, 63, 3270, 26, 32530, 272, 3974, 63, 1802, 26, 372, 1642, 570, 1911, 687, 769, 272, 1369, 26, 489, 446, 642, 4237, 5920, 282, 769, 402, 1584, 436, 3792, 436, 2529, 314, 2615, 931, 370, 314, 1642, 14665, 1911, 14, 489, 446, 3709, 1006, 16807, 12, 1380, 23036, 3847, 3792, 652, 911, 862, 675, 314, 1453, 2120, 1159, 2909, 1642, 436, 2621, 1536, 314, 6036, 267, 370, 314, 3035, 4719, 15, 2802, 15, 2613, 15, 6839, 1159, 2909, 14, 489, 446, 710, 769, 402, 1584, 965, 13823, 1806, 314, 3792, 17543, 14, 267, 284, 14, 69, 12, 437, 2120, 315, 282, 221, 4719, 965, 282, 283, 493, 17, 7, 315, 314, 5232, 1159, 3847, 931, 12, 642, 911, 506, 1202, 12, 283, 493, 18, 7, 315, 4719, 1159, 3847, 931, 911, 440, 14, 489, 446, 13083, 282, 769, 402, 1584, 445, 1547, 9187, 9, 503, 282, 790, 658, 1725, 64, 543, 282, 769, 402, 1584, 365, 1415, 367, 642, 3589, 370, 19218, 14, 272, 12681, 26, 489, 446, 961, 4237, 883, 506, 1202, 315, 283, 17962, 818, 297, 1902, 9476, 282, 769, 402, 570, 1561, 503, 282, 2600, 626, 965, 445, 8, 1725, 9, 436, 445, 8, 3771, 680, 272, 1511, 26, 489, 485, 9187, 26, 267, 1369, 26, 769, 402, 570, 1561, 489, 1584, 26, 267, 1369, 26, 769, 402, 570, 1561, 267, 730, 26, 769, 267, 849, 26, 942, 489, 3792, 26, 267, 1369, 26, 769, 402, 3792, 315, 1314, 370, 3648, 367, 314, 1584, 267, 730, 26, 769, 267, 849, 26, 942, 489, 3372, 26, 267, 730, 26, 5046, 267, 849, 26, 756, 267, 1369, 26, 1432, 376, 2701, 769, 340, 949, 570, 365, 1911, 12, 3140, 402, 376, 1125, 14, 199, 624, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 2498, 1642, 3411, 570, 503, 3686, 340, 7179, 886, 523, 3105, 26, 1499, 3126, 91, 3892, 360, 2246, 63, 4214, 297, 2342, 278, 12, 2552, 534, 4247, 358, 4863, 523, 6802, 26, 272, 2342, 278, 26, 489, 446, 3286, 515, 15, 475, 15, 1421, 14, 2424, 2, 489, 446, 298, 1700, 14, 2424, 2, 221, 327, 911, 506, 21182, 315, 1584, 15, 2935, 3847, 370, 4719, 436, 15, 269, 5232, 489, 446, 3286, 515, 15, 475, 15, 66, 565, 14, 2424, 2, 199, 199, 13, 536, 26, 1204, 267, 2387, 6527, 1454, 340, 1584, 2187, 14, 221, 3390, 314, 675, 402, 1827, 342, 370, 372, 267, 282, 4596, 769, 367, 314, 4438, 340, 949, 1584, 787, 1911, 14, 523, 492, 63, 5054, 26, 11400, 1242, 16339, 523, 6802, 26, 272, 1862, 26, 489, 1584, 26, 267, 446, 931, 15, 5054, 14, 5963, 267, 446, 931, 15, 1848, 63, 5054, 14, 5963, 523, 4438, 26, 7370, 1827, 360, 2246, 63, 4214, 297, 1862, 12, 2552, 534, 4247, 358, 7820, 199, 199, 13, 536, 26, 1204, 267, 1331, 1642, 3411, 570, 1911, 370, 1182, 3972, 15, 493, 12, 267, 10023, 315, 3847, 6602, 687, 2382, 314, 2120, 365, 3247, 436, 267, 5893, 1263, 5232, 2251, 626, 1395, 652, 523, 1331, 26, 2928, 3126, 91, 3892, 360, 2246, 63, 4214, 297, 2342, 278, 9, 4863, 2053, 13043, 3972, 15, 493, 523, 6802, 26, 272, 2342, 278, 26, 489, 446, 3925, 489, 446, 7370, 7212, 63, 4269, 30618, 489, 446, 4681, 199, 199, 13, 536, 26, 2011, 1331, 1325, 2488, 3792, 523, 1331, 26, 2928, 3126, 91, 3892, 360, 2246, 63, 4214, 297, 1862, 9, 4863, 2053, 13043, 3972, 15, 493, 523, 6802, 26, 272, 1862, 26, 489, 1584, 26, 267, 446, 3925, 267, 446, 7370, 7212, 63, 4269, 30618, 267, 446, 4681, 489, 3792, 26, 267, 446, 1182, 2791, 15, 10777, 267, 446, 1182, 2791, 15, 26840, 199, 199, 13, 536, 26, 8729, 38, 21287, 1204, 2790, 2622, 1406, 367, 1182, 6839, 15, 1200, 15, 7436, 523, 1978, 26, 272, 2928, 26, 7370, 4237, 360, 2246, 63, 4214, 297, 2342, 278, 9, 30618, 272, 2053, 26, 3286, 6839, 15, 1421, 14, 2190, 2, 523, 6802, 26, 272, 2342, 278, 26, 489, 446, 7370, 3242, 63, 2065, 2072, 63, 466, 3586, 63, 1421, 14, 2190, 2, 489, 446, 298, 885, 63, 1421, 14, 2190, 2, 199, 199, 13, 536, 26, 1586, 6802, 687, 1642, 570, 1911, 12, 675, 283, 2936, 4805, 3847, 15488, 523, 2387, 63, 2936, 26, 7370, 3892, 360, 2246, 63, 4214, 297, 1862, 9, 30618, 523, 6802, 26, 272, 1862, 26, 489, 1584, 26, 267, 446, 11400, 4853, 63, 4972, 4863, 14, 11714, 7, 267, 446, 11400, 4853, 63, 736, 63, 6606, 4863, 14, 11714, 7, 267, 446, 849, 14, 11714, 489, 3792, 26, 267, 446, 283, 2936, 7, 199, 624, 199, 199, 9677, 275, 408, 523, 485, 1773, 26, 272, 1369, 26, 489, 446, 931, 370, 570, 1911, 272, 730, 26, 769, 272, 4008, 26, 931, 199, 624, 199, 646, 747, 199, 199, 504, 10321, 18, 14, 3924, 492, 25868, 547, 199, 199, 504, 3242, 14, 2550, 492, 2622, 32060, 12, 2622, 16283, 2773, 199, 504, 3242, 14, 578, 63, 1208, 14, 2330, 423, 7882, 63, 5819, 492, 12340, 12, 10975, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 1059, 63, 1313, 199, 504, 3242, 14, 5265, 14, 3892, 492, 12785, 1563, 421, 199, 318, 485, 1294, 63, 265, 8, 9187, 12, 2249, 317, 878, 4009, 735, 339, 327, 3254, 26, 5325, 465, 652, 1630, 440, 2040, 7883, 315, 1561, 272, 6707, 513, 275, 942, 272, 340, 1228, 8, 9187 ]
[ 334, 67, 9, 6171, 12, 542, 273, 27767, 279, 665, 1339, 5017, 279, 32, 15800, 269, 30204, 963, 14, 1308, 30, 8992, 394, 292, 12, 12864, 199, 3, 334, 67, 9, 9708, 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, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 8948, 275, 408, 272, 536, 26, 1642, 63, 4214, 272, 4132, 26, 3240, 273, 812, 344, 279, 19452, 11588, 9, 665, 1339, 5017, 279, 32, 15800, 269, 30204, 963, 14, 1308, 30, 272, 1015, 63, 3270, 26, 32530, 272, 3974, 63, 1802, 26, 372, 1642, 570, 1911, 687, 769, 272, 1369, 26, 489, 446, 642, 4237, 5920, 282, 769, 402, 1584, 436, 3792, 436, 2529, 314, 2615, 931, 370, 314, 1642, 14665, 1911, 14, 489, 446, 3709, 1006, 16807, 12, 1380, 23036, 3847, 3792, 652, 911, 862, 675, 314, 1453, 2120, 1159, 2909, 1642, 436, 2621, 1536, 314, 6036, 267, 370, 314, 3035, 4719, 15, 2802, 15, 2613, 15, 6839, 1159, 2909, 14, 489, 446, 710, 769, 402, 1584, 965, 13823, 1806, 314, 3792, 17543, 14, 267, 284, 14, 69, 12, 437, 2120, 315, 282, 221, 4719, 965, 282, 283, 493, 17, 7, 315, 314, 5232, 1159, 3847, 931, 12, 642, 911, 506, 1202, 12, 283, 493, 18, 7, 315, 4719, 1159, 3847, 931, 911, 440, 14, 489, 446, 13083, 282, 769, 402, 1584, 445, 1547, 9187, 9, 503, 282, 790, 658, 1725, 64, 543, 282, 769, 402, 1584, 365, 1415, 367, 642, 3589, 370, 19218, 14, 272, 12681, 26, 489, 446, 961, 4237, 883, 506, 1202, 315, 283, 17962, 818, 297, 1902, 9476, 282, 769, 402, 570, 1561, 503, 282, 2600, 626, 965, 445, 8, 1725, 9, 436, 445, 8, 3771, 680, 272, 1511, 26, 489, 485, 9187, 26, 267, 1369, 26, 769, 402, 570, 1561, 489, 1584, 26, 267, 1369, 26, 769, 402, 570, 1561, 267, 730, 26, 769, 267, 849, 26, 942, 489, 3792, 26, 267, 1369, 26, 769, 402, 3792, 315, 1314, 370, 3648, 367, 314, 1584, 267, 730, 26, 769, 267, 849, 26, 942, 489, 3372, 26, 267, 730, 26, 5046, 267, 849, 26, 756, 267, 1369, 26, 1432, 376, 2701, 769, 340, 949, 570, 365, 1911, 12, 3140, 402, 376, 1125, 14, 199, 624, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 2498, 1642, 3411, 570, 503, 3686, 340, 7179, 886, 523, 3105, 26, 1499, 3126, 91, 3892, 360, 2246, 63, 4214, 297, 2342, 278, 12, 2552, 534, 4247, 358, 4863, 523, 6802, 26, 272, 2342, 278, 26, 489, 446, 3286, 515, 15, 475, 15, 1421, 14, 2424, 2, 489, 446, 298, 1700, 14, 2424, 2, 221, 327, 911, 506, 21182, 315, 1584, 15, 2935, 3847, 370, 4719, 436, 15, 269, 5232, 489, 446, 3286, 515, 15, 475, 15, 66, 565, 14, 2424, 2, 199, 199, 13, 536, 26, 1204, 267, 2387, 6527, 1454, 340, 1584, 2187, 14, 221, 3390, 314, 675, 402, 1827, 342, 370, 372, 267, 282, 4596, 769, 367, 314, 4438, 340, 949, 1584, 787, 1911, 14, 523, 492, 63, 5054, 26, 11400, 1242, 16339, 523, 6802, 26, 272, 1862, 26, 489, 1584, 26, 267, 446, 931, 15, 5054, 14, 5963, 267, 446, 931, 15, 1848, 63, 5054, 14, 5963, 523, 4438, 26, 7370, 1827, 360, 2246, 63, 4214, 297, 1862, 12, 2552, 534, 4247, 358, 7820, 199, 199, 13, 536, 26, 1204, 267, 1331, 1642, 3411, 570, 1911, 370, 1182, 3972, 15, 493, 12, 267, 10023, 315, 3847, 6602, 687, 2382, 314, 2120, 365, 3247, 436, 267, 5893, 1263, 5232, 2251, 626, 1395, 652, 523, 1331, 26, 2928, 3126, 91, 3892, 360, 2246, 63, 4214, 297, 2342, 278, 9, 4863, 2053, 13043, 3972, 15, 493, 523, 6802, 26, 272, 2342, 278, 26, 489, 446, 3925, 489, 446, 7370, 7212, 63, 4269, 30618, 489, 446, 4681, 199, 199, 13, 536, 26, 2011, 1331, 1325, 2488, 3792, 523, 1331, 26, 2928, 3126, 91, 3892, 360, 2246, 63, 4214, 297, 1862, 9, 4863, 2053, 13043, 3972, 15, 493, 523, 6802, 26, 272, 1862, 26, 489, 1584, 26, 267, 446, 3925, 267, 446, 7370, 7212, 63, 4269, 30618, 267, 446, 4681, 489, 3792, 26, 267, 446, 1182, 2791, 15, 10777, 267, 446, 1182, 2791, 15, 26840, 199, 199, 13, 536, 26, 8729, 38, 21287, 1204, 2790, 2622, 1406, 367, 1182, 6839, 15, 1200, 15, 7436, 523, 1978, 26, 272, 2928, 26, 7370, 4237, 360, 2246, 63, 4214, 297, 2342, 278, 9, 30618, 272, 2053, 26, 3286, 6839, 15, 1421, 14, 2190, 2, 523, 6802, 26, 272, 2342, 278, 26, 489, 446, 7370, 3242, 63, 2065, 2072, 63, 466, 3586, 63, 1421, 14, 2190, 2, 489, 446, 298, 885, 63, 1421, 14, 2190, 2, 199, 199, 13, 536, 26, 1586, 6802, 687, 1642, 570, 1911, 12, 675, 283, 2936, 4805, 3847, 15488, 523, 2387, 63, 2936, 26, 7370, 3892, 360, 2246, 63, 4214, 297, 1862, 9, 30618, 523, 6802, 26, 272, 1862, 26, 489, 1584, 26, 267, 446, 11400, 4853, 63, 4972, 4863, 14, 11714, 7, 267, 446, 11400, 4853, 63, 736, 63, 6606, 4863, 14, 11714, 7, 267, 446, 849, 14, 11714, 489, 3792, 26, 267, 446, 283, 2936, 7, 199, 624, 199, 199, 9677, 275, 408, 523, 485, 1773, 26, 272, 1369, 26, 489, 446, 931, 370, 570, 1911, 272, 730, 26, 769, 272, 4008, 26, 931, 199, 624, 199, 646, 747, 199, 199, 504, 10321, 18, 14, 3924, 492, 25868, 547, 199, 199, 504, 3242, 14, 2550, 492, 2622, 32060, 12, 2622, 16283, 2773, 199, 504, 3242, 14, 578, 63, 1208, 14, 2330, 423, 7882, 63, 5819, 492, 12340, 12, 10975, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 1059, 63, 1313, 199, 504, 3242, 14, 5265, 14, 3892, 492, 12785, 1563, 421, 199, 318, 485, 1294, 63, 265, 8, 9187, 12, 2249, 317, 878, 4009, 735, 339, 327, 3254, 26, 5325, 465, 652, 1630, 440, 2040, 7883, 315, 1561, 272, 6707, 513, 275, 942, 272, 340, 1228, 8, 9187, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
chrys87/orca-beep
src/orca/speechdispatcherfactory.py
1
20607
# Copyright 2006, 2007, 2008, 2009 Brailcom, o.p.s. # # Author: Tomas Cerha <cerha@brailcom.org> # # 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., Franklin Street, Fifth Floor, # Boston MA 02110-1301 USA. # # [[[TODO: richb - Pylint is giving us a bunch of warnings along these # lines throughout this file: # # W0142:202:SpeechServer._send_command: Used * or ** magic # # So for now, we just disable these warnings in this module.]]] # # pylint: disable-msg=W0142 """Provides an Orca speech server for Speech Dispatcher backend.""" __id__ = "$Id$" __version__ = "$Revision$" __date__ = "$Date$" __author__ = "Tomas Cerha <cerha@brailcom.org>" __copyright__ = "Copyright (c) 2006-2008 Brailcom, o.p.s." __license__ = "LGPL" from gi.repository import GLib import re import time from . import chnames from . import debug from . import guilabels from . import messages from . import speechserver from . import settings from . import orca_state from . import punctuation_settings from .acss import ACSS try: import speechd except: _speechd_available = False else: _speechd_available = True try: getattr(speechd, "CallbackType") except AttributeError: _speechd_version_ok = False else: _speechd_version_ok = True PUNCTUATION = re.compile('[^\w\s]', re.UNICODE) ELLIPSIS = re.compile('(\342\200\246|(?<!\.)\.{3,4}(?=(\s|\Z)))') class SpeechServer(speechserver.SpeechServer): # See the parent class for documentation. _active_servers = {} DEFAULT_SERVER_ID = 'default' _SERVER_NAMES = {DEFAULT_SERVER_ID: guilabels.DEFAULT_SYNTHESIZER} def getFactoryName(): return guilabels.SPEECH_DISPATCHER getFactoryName = staticmethod(getFactoryName) def getSpeechServers(): servers = [] default = SpeechServer._getSpeechServer(SpeechServer.DEFAULT_SERVER_ID) if default is not None: servers.append(default) for module in default.list_output_modules(): servers.append(SpeechServer._getSpeechServer(module)) return servers getSpeechServers = staticmethod(getSpeechServers) def _getSpeechServer(cls, serverId): """Return an active server for given id. Attempt to create the server if it doesn't exist yet. Returns None when it is not possible to create the server. """ if serverId not in cls._active_servers: cls(serverId) # Don't return the instance, unless it is succesfully added # to `_active_Servers'. return cls._active_servers.get(serverId) _getSpeechServer = classmethod(_getSpeechServer) def getSpeechServer(info=None): if info is not None: thisId = info[1] else: thisId = SpeechServer.DEFAULT_SERVER_ID return SpeechServer._getSpeechServer(thisId) getSpeechServer = staticmethod(getSpeechServer) def shutdownActiveServers(): for server in list(SpeechServer._active_servers.values()): server.shutdown() shutdownActiveServers = staticmethod(shutdownActiveServers) # *** Instance methods *** def __init__(self, serverId): super(SpeechServer, self).__init__() self._id = serverId self._client = None self._current_voice_properties = {} self._acss_manipulators = ( (ACSS.RATE, self._set_rate), (ACSS.AVERAGE_PITCH, self._set_pitch), (ACSS.GAIN, self._set_volume), (ACSS.FAMILY, self._set_family), ) if not _speechd_available: msg = 'ERROR: Speech Dispatcher is not available' debug.println(debug.LEVEL_WARNING, msg, True) return if not _speechd_version_ok: msg = 'ERROR: Speech Dispatcher version 0.6.2 or later is required.' debug.println(debug.LEVEL_WARNING, msg, True) return # The following constants must be initialized in runtime since they # depend on the speechd module being available. self._PUNCTUATION_MODE_MAP = { settings.PUNCTUATION_STYLE_ALL: speechd.PunctuationMode.ALL, settings.PUNCTUATION_STYLE_MOST: speechd.PunctuationMode.SOME, settings.PUNCTUATION_STYLE_SOME: speechd.PunctuationMode.SOME, settings.PUNCTUATION_STYLE_NONE: speechd.PunctuationMode.NONE, } self._CALLBACK_TYPE_MAP = { speechd.CallbackType.BEGIN: speechserver.SayAllContext.PROGRESS, speechd.CallbackType.CANCEL: speechserver.SayAllContext.INTERRUPTED, speechd.CallbackType.END: speechserver.SayAllContext.COMPLETED, #speechd.CallbackType.INDEX_MARK:speechserver.SayAllContext.PROGRESS, } self._default_voice_name = guilabels.SPEECH_DEFAULT_VOICE % serverId try: self._init() except: debug.printException(debug.LEVEL_WARNING) msg = 'ERROR: Speech Dispatcher service failed to connect' debug.println(debug.LEVEL_WARNING, msg, True) else: SpeechServer._active_servers[serverId] = self self._lastKeyEchoTime = None def _init(self): self._client = client = speechd.SSIPClient('Orca', component=self._id) client.set_priority(speechd.Priority.MESSAGE) if self._id != self.DEFAULT_SERVER_ID: client.set_output_module(self._id) self._current_voice_properties = {} mode = self._PUNCTUATION_MODE_MAP[settings.verbalizePunctuationStyle] client.set_punctuation(mode) def updateCapitalizationStyle(self): """Updates the capitalization style used by the speech server.""" if settings.capitalizationStyle == settings.CAPITALIZATION_STYLE_ICON: style = 'icon' elif settings.capitalizationStyle == settings.CAPITALIZATION_STYLE_SPELL: style = 'spell' else: style = 'none' self._client.set_cap_let_recogn(style) def updatePunctuationLevel(self): """ Punctuation level changed, inform this speechServer. """ mode = self._PUNCTUATION_MODE_MAP[settings.verbalizePunctuationStyle] self._client.set_punctuation(mode) def _send_command(self, command, *args, **kwargs): if hasattr(speechd, 'SSIPCommunicationError'): try: return command(*args, **kwargs) except speechd.SSIPCommunicationError: msg = "SPEECH DISPATCHER: Connection lost. Trying to reconnect." debug.println(debug.LEVEL_INFO, msg, True) self.reset() return command(*args, **kwargs) except: pass else: # It is not possible tho catch the error with older SD versions. return command(*args, **kwargs) def _set_rate(self, acss_rate): rate = int(2 * max(0, min(99, acss_rate)) - 98) self._send_command(self._client.set_rate, rate) def _set_pitch(self, acss_pitch): pitch = int(20 * max(0, min(9, acss_pitch)) - 90) self._send_command(self._client.set_pitch, pitch) def _set_volume(self, acss_volume): volume = int(15 * max(0, min(9, acss_volume)) - 35) self._send_command(self._client.set_volume, volume) def _set_family(self, acss_family): familyLocale = acss_family.get(speechserver.VoiceFamily.LOCALE) if not familyLocale: import locale familyLocale, encoding = locale.getdefaultlocale() if familyLocale: lang = familyLocale.split('_')[0] if lang and len(lang) == 2: self._send_command(self._client.set_language, str(lang)) try: # This command is not available with older SD versions. set_synthesis_voice = self._client.set_synthesis_voice except AttributeError: pass else: name = acss_family.get(speechserver.VoiceFamily.NAME) if name != self._default_voice_name: self._send_command(set_synthesis_voice, name) def _debug_sd_values(self, prefix=""): if debug.debugLevel > debug.LEVEL_INFO: return try: sd_rate = self._send_command(self._client.get_rate) sd_pitch = self._send_command(self._client.get_pitch) except: sd_rate = "(exception occurred)" sd_pitch = "(exception occurred)" current = self._current_voice_properties msg = "SPEECH DISPATCHER: %sOrca rate %s, pitch %s; " \ "SD rate %s, pitch %s" % \ (prefix, self._current_voice_properties.get(ACSS.RATE), self._current_voice_properties.get(ACSS.AVERAGE_PITCH), sd_rate, sd_pitch) debug.println(debug.LEVEL_INFO, msg, True) def _apply_acss(self, acss): if acss is None: acss = settings.voices[settings.DEFAULT_VOICE] current = self._current_voice_properties for acss_property, method in self._acss_manipulators: value = acss.get(acss_property) if value is not None: if current.get(acss_property) != value: method(value) current[acss_property] = value elif acss_property == ACSS.AVERAGE_PITCH: method(5.0) current[acss_property] = 5.0 elif acss_property == ACSS.FAMILY \ and acss == settings.voices[settings.DEFAULT_VOICE]: # We need to explicitly reset (at least) the family. # See bgo#626072. # method({}) current[acss_property] = {} def __addVerbalizedPunctuation(self, oldText): """Depending upon the users verbalized punctuation setting, adjust punctuation symbols in the given text to their pronounced equivalents. The pronounced text will either replace the punctuation symbol or be inserted before it. In the latter case, this is to retain spoken prosity. Arguments: - oldText: text to be parsed for punctuation. Returns a text string with the punctuation symbols adjusted accordingly. """ spokenEllipsis = messages.SPOKEN_ELLIPSIS + " " newText = re.sub(ELLIPSIS, spokenEllipsis, oldText) symbols = set(re.findall(PUNCTUATION, newText)) for symbol in symbols: try: level, action = punctuation_settings.getPunctuationInfo(symbol) except: continue if level != punctuation_settings.LEVEL_NONE: # Speech Dispatcher should handle it. # continue charName = " %s " % chnames.getCharacterName(symbol) if action == punctuation_settings.PUNCTUATION_INSERT: charName += symbol newText = re.sub(symbol, charName, newText) if orca_state.activeScript: newText = orca_state.activeScript.utilities.adjustForDigits(newText) return newText def _speak(self, text, acss, **kwargs): if isinstance(text, ACSS): text = '' text = self.__addVerbalizedPunctuation(text) if orca_state.activeScript: text = orca_state.activeScript.\ utilities.adjustForPronunciation(text) # Replace no break space characters with plain spaces since some # synthesizers cannot handle them. See bug #591734. # text = text.replace('\u00a0', ' ') # Replace newline followed by full stop, since # this seems to crash sd, see bgo#618334. # text = text.replace('\n.', '\n') self._apply_acss(acss) self._debug_sd_values("Speaking '%s' " % text) self._send_command(self._client.speak, text, **kwargs) def _say_all(self, iterator, orca_callback): """Process another sayAll chunk. Called by the gidle thread. """ try: context, acss = next(iterator) except StopIteration: pass else: def callback(callbackType, index_mark=None): # This callback is called in Speech Dispatcher listener thread. # No subsequent Speech Dispatcher interaction is allowed here, # so we pass the calls to the gidle thread. t = self._CALLBACK_TYPE_MAP[callbackType] if t == speechserver.SayAllContext.PROGRESS: if index_mark: context.currentOffset = int(index_mark) else: context.currentOffset = context.startOffset elif t == speechserver.SayAllContext.COMPLETED: context.currentOffset = context.endOffset GLib.idle_add(orca_callback, context, t) if t == speechserver.SayAllContext.COMPLETED: GLib.idle_add(self._say_all, iterator, orca_callback) self._speak(context.utterance, acss, callback=callback, event_types=list(self._CALLBACK_TYPE_MAP.keys())) return False # to indicate, that we don't want to be called again. def _cancel(self): self._send_command(self._client.cancel) def _change_default_speech_rate(self, step, decrease=False): acss = settings.voices[settings.DEFAULT_VOICE] delta = step * (decrease and -1 or +1) try: rate = acss[ACSS.RATE] except KeyError: rate = 50 acss[ACSS.RATE] = max(0, min(99, rate + delta)) msg = 'SPEECH DISPATCHER: Rate set to %d' % rate debug.println(debug.LEVEL_INFO, msg, True) self.speak(decrease and messages.SPEECH_SLOWER \ or messages.SPEECH_FASTER, acss=acss) def _change_default_speech_pitch(self, step, decrease=False): acss = settings.voices[settings.DEFAULT_VOICE] delta = step * (decrease and -1 or +1) try: pitch = acss[ACSS.AVERAGE_PITCH] except KeyError: pitch = 5 acss[ACSS.AVERAGE_PITCH] = max(0, min(9, pitch + delta)) msg = 'SPEECH DISPATCHER: Pitch set to %d' % pitch debug.println(debug.LEVEL_INFO, msg, True) self.speak(decrease and messages.SPEECH_LOWER \ or messages.SPEECH_HIGHER, acss=acss) def _change_default_speech_volume(self, step, decrease=False): acss = settings.voices[settings.DEFAULT_VOICE] delta = step * (decrease and -1 or +1) try: volume = acss[ACSS.GAIN] except KeyError: volume = 5 acss[ACSS.GAIN] = max(0, min(9, volume + delta)) msg = 'SPEECH DISPATCHER: Volume set to %d' % volume debug.println(debug.LEVEL_INFO, msg, True) self.speak(decrease and messages.SPEECH_SOFTER \ or messages.SPEECH_LOUDER, acss=acss) def getInfo(self): return [self._SERVER_NAMES.get(self._id, self._id), self._id] def getVoiceFamilies(self): # Always offer the configured default voice with a language # set according to the current locale. from locale import getlocale, LC_MESSAGES locale = getlocale(LC_MESSAGES)[0] if locale is None or locale == 'C': lang = None dialect = None else: lang, dialect = locale.split('_') voices = ((self._default_voice_name, lang, None),) try: # This command is not available with older SD versions. list_synthesis_voices = self._client.list_synthesis_voices except AttributeError: pass else: try: voices += self._send_command(list_synthesis_voices) except: pass families = [speechserver.VoiceFamily({ \ speechserver.VoiceFamily.NAME: name, #speechserver.VoiceFamily.GENDER: speechserver.VoiceFamily.MALE, speechserver.VoiceFamily.DIALECT: dialect, speechserver.VoiceFamily.LOCALE: lang}) for name, lang, dialect in voices] return families def speak(self, text=None, acss=None, interrupt=True): #if interrupt: # self._cancel() # "We will not interrupt a key echo in progress." (Said the comment in # speech.py where these next two lines used to live. But the code here # suggests we haven't been doing anything with the lastKeyEchoTime in # years. TODO - JD: Dig into this and if it's truly useless, kill it.) if self._lastKeyEchoTime: interrupt = interrupt and (time.time() - self._lastKeyEchoTime) > 0.5 if text: self._speak(text, acss) def speakUtterances(self, utteranceList, acss=None, interrupt=True): #if interrupt: # self._cancel() for utterance in utteranceList: if utterance: self._speak(utterance, acss) def sayAll(self, utteranceIterator, progressCallback): GLib.idle_add(self._say_all, utteranceIterator, progressCallback) def speakCharacter(self, character, acss=None): self._apply_acss(acss) if character == '\n': self._send_command(self._client.sound_icon, 'end-of-line') return name = chnames.getCharacterName(character) if not name: self._send_command(self._client.char, character) return if orca_state.activeScript: name = orca_state.activeScript.\ utilities.adjustForPronunciation(name) self.speak(name, acss) def speakKeyEvent(self, event): if event.isPrintableKey() and event.event_string.isupper(): acss = settings.voices[settings.UPPERCASE_VOICE] else: acss = ACSS(settings.voices[settings.DEFAULT_VOICE]) event_string = event.getKeyName() if orca_state.activeScript: event_string = orca_state.activeScript.\ utilities.adjustForPronunciation(event_string) lockingStateString = event.getLockingStateString() event_string = "%s %s" % (event_string, lockingStateString) self.speak(event_string, acss=acss) self._lastKeyEchoTime = time.time() def increaseSpeechRate(self, step=5): self._change_default_speech_rate(step) def decreaseSpeechRate(self, step=5): self._change_default_speech_rate(step, decrease=True) def increaseSpeechPitch(self, step=0.5): self._change_default_speech_pitch(step) def decreaseSpeechPitch(self, step=0.5): self._change_default_speech_pitch(step, decrease=True) def increaseSpeechVolume(self, step=0.5): self._change_default_speech_volume(step) def decreaseSpeechVolume(self, step=0.5): self._change_default_speech_volume(step, decrease=True) def stop(self): self._cancel() def shutdown(self): self._client.close() del SpeechServer._active_servers[self._id] def reset(self, text=None, acss=None): self._client.close() self._init() def list_output_modules(self): """Return names of available output modules as a tuple of strings. This method is not a part of Orca speech API, but is used internally by the Speech Dispatcher backend. The returned tuple can be empty if the information can not be obtained (e.g. with an older Speech Dispatcher version). """ try: return self._send_command(self._client.list_output_modules) except AttributeError: return () except speechd.SSIPCommandError: return ()
lgpl-2.1
[ 3, 1898, 8315, 12, 10219, 12, 9079, 12, 8937, 32377, 382, 957, 12, 312, 14, 80, 14, 83, 14, 199, 3, 199, 3, 6529, 26, 21644, 305, 11002, 2411, 665, 2247, 2411, 32, 7828, 382, 957, 14, 1308, 30, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 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, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 11236, 14259, 12, 12066, 11844, 12, 199, 3, 8226, 4828, 221, 11315, 13, 10067, 8217, 14, 199, 199, 3, 327, 19819, 11768, 26, 30162, 66, 446, 1611, 3854, 365, 15131, 2739, 282, 22219, 402, 3598, 3180, 3520, 199, 3, 2385, 23088, 642, 570, 26, 199, 3, 199, 3, 221, 644, 29556, 26, 4999, 26, 27047, 12736, 3120, 423, 2254, 63, 1531, 26, 8051, 627, 503, 1011, 10628, 199, 3, 199, 3, 2002, 367, 3063, 12, 781, 2951, 3507, 3520, 3598, 315, 642, 859, 14, 20737, 199, 3, 199, 3, 4287, 26, 3507, 13, 1328, 29, 55, 29556, 199, 199, 624, 17473, 376, 4236, 696, 32093, 1654, 367, 428, 321, 12736, 5289, 11238, 4865, 1041, 199, 199, 363, 344, 363, 275, 7880, 1304, 17351, 199, 363, 1023, 363, 257, 275, 7880, 12714, 17351, 199, 363, 602, 363, 420, 275, 7880, 2506, 17351, 199, 363, 2502, 363, 259, 275, 298, 52, 676, 305, 11002, 2411, 665, 2247, 2411, 32, 7828, 382, 957, 14, 1308, 4335, 199, 363, 7307, 363, 275, 298, 7384, 334, 67, 9, 8315, 13, 9300, 32377, 382, 957, 12, 312, 14, 80, 14, 83, 2122, 199, 363, 1682, 363, 257, 275, 298, 44, 12006, 2, 199, 199, 504, 18895, 14, 8421, 492, 3563, 1892, 199, 646, 295, 199, 646, 900, 199, 199, 504, 1275, 492, 682, 1247, 199, 504, 1275, 492, 3105, 199, 504, 1275, 492, 8129, 382, 902, 83, 199, 504, 1275, 492, 3788, 199, 504, 1275, 492, 32093, 1000, 199, 504, 1275, 492, 2202, 199, 504, 1275, 492, 503, 696, 63, 929, 199, 504, 1275, 492, 22929, 63, 1751, 199, 504, 1275, 645, 385, 492, 6570, 2300, 199, 199, 893, 26, 272, 492, 32093, 68, 199, 2590, 26, 272, 485, 23660, 68, 63, 4561, 275, 756, 199, 2836, 26, 14821, 485, 23660, 68, 63, 4561, 275, 715, 272, 862, 26, 267, 2519, 8, 23660, 68, 12, 298, 2806, 804, 531, 272, 871, 4281, 26, 267, 485, 23660, 68, 63, 1023, 63, 745, 275, 756, 272, 587, 26, 267, 485, 23660, 68, 63, 1023, 63, 745, 275, 715, 199, 199, 48, 1734, 1028, 53, 2594, 275, 295, 14, 2014, 360, 16045, 87, 60, 83, 4300, 295, 14, 12819, 9, 199, 21677, 275, 295, 14, 2014, 360, 2961, 14519, 60, 1840, 60, 11440, 92, 2229, 11230, 4537, 2862, 23379, 19, 12, 20, 93, 2229, 2687, 60, 83, 6113, 58, 1724, 358, 199, 199, 533, 428, 321, 12736, 3120, 8, 23660, 1000, 14, 27047, 12736, 3120, 304, 272, 327, 1666, 314, 1676, 1021, 367, 3794, 14, 339, 485, 2682, 63, 5871, 275, 1052, 2286, 6186, 63, 6613, 63, 998, 275, 283, 885, 7, 272, 485, 6613, 63, 14546, 275, 469, 3472, 63, 6613, 63, 998, 26, 8129, 382, 902, 83, 14, 3472, 63, 31802, 2080, 654, 5357, 540, 93, 339, 347, 664, 2927, 985, 837, 267, 372, 8129, 382, 902, 83, 14, 14179, 25126, 63, 32550, 540, 272, 664, 2927, 985, 275, 12822, 8, 362, 2927, 985, 9, 339, 347, 664, 27047, 12736, 23637, 837, 267, 8037, 275, 942, 267, 849, 275, 428, 321, 12736, 3120, 423, 362, 27047, 12736, 3120, 8, 27047, 12736, 3120, 14, 3472, 63, 6613, 63, 998, 9, 267, 340, 849, 365, 440, 488, 26, 288, 8037, 14, 740, 8, 885, 9, 288, 367, 859, 315, 849, 14, 513, 63, 1199, 63, 3112, 837, 355, 8037, 14, 740, 8, 27047, 12736, 3120, 423, 362, 27047, 12736, 3120, 8, 578, 430, 267, 372, 8037, 272, 664, 27047, 12736, 23637, 275, 12822, 8, 362, 27047, 12736, 23637, 9, 339, 347, 485, 362, 27047, 12736, 3120, 8, 1886, 12, 1654, 1304, 304, 267, 408, 1767, 376, 4702, 1654, 367, 1627, 1305, 14, 398, 23115, 370, 1218, 314, 1654, 340, 652, 3181, 1133, 2187, 5966, 14, 221, 1803, 488, 267, 1380, 652, 365, 440, 3962, 370, 1218, 314, 1654, 14, 2728, 408, 267, 340, 1654, 1304, 440, 315, 843, 423, 2682, 63, 5871, 26, 288, 843, 8, 1000, 1304, 9, 267, 327, 7529, 1133, 372, 314, 1256, 12, 7444, 652, 365, 27028, 5836, 3483, 267, 327, 370, 18494, 2682, 63, 23637, 1370, 267, 372, 843, 423, 2682, 63, 5871, 14, 362, 8, 1000, 1304, 9, 272, 485, 362, 27047, 12736, 3120, 275, 18990, 1547, 362, 27047, 12736, 3120, 9, 339, 347, 664, 27047, 12736, 3120, 8, 815, 29, 403, 304, 267, 340, 2256, 365, 440, 488, 26, 288, 642, 1304, 275, 2256, 59, 17, 61, 267, 587, 26, 288, 642, 1304, 275, 428, 321, 12736, 3120, 14, 3472, 63, 6613, 63, 998, 267, 372, 428, 321, 12736, 3120, 423, 362, 27047, 12736, 3120, 8, 3749, 1304, 9, 272, 664, 27047, 12736, 3120, 275, 12822, 8, 362, 27047, 12736, 3120, 9, 339, 347, 12842, 7472, 23637, 837, 267, 367, 1654, 315, 769, 8, 27047, 12736, 3120, 423, 2682, 63, 5871, 14, 1459, 5109, 288, 1654, 14, 8831, 342, 272, 12842, 7472, 23637, 275, 12822, 8, 8831, 7472, 23637, 9, 339, 327, 19688, 10066, 3102, 19688, 339, 347, 636, 826, 721, 277, 12, 1654, 1304, 304, 267, 1613, 8, 27047, 12736, 3120, 12 ]
[ 1898, 8315, 12, 10219, 12, 9079, 12, 8937, 32377, 382, 957, 12, 312, 14, 80, 14, 83, 14, 199, 3, 199, 3, 6529, 26, 21644, 305, 11002, 2411, 665, 2247, 2411, 32, 7828, 382, 957, 14, 1308, 30, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 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, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 11236, 14259, 12, 12066, 11844, 12, 199, 3, 8226, 4828, 221, 11315, 13, 10067, 8217, 14, 199, 199, 3, 327, 19819, 11768, 26, 30162, 66, 446, 1611, 3854, 365, 15131, 2739, 282, 22219, 402, 3598, 3180, 3520, 199, 3, 2385, 23088, 642, 570, 26, 199, 3, 199, 3, 221, 644, 29556, 26, 4999, 26, 27047, 12736, 3120, 423, 2254, 63, 1531, 26, 8051, 627, 503, 1011, 10628, 199, 3, 199, 3, 2002, 367, 3063, 12, 781, 2951, 3507, 3520, 3598, 315, 642, 859, 14, 20737, 199, 3, 199, 3, 4287, 26, 3507, 13, 1328, 29, 55, 29556, 199, 199, 624, 17473, 376, 4236, 696, 32093, 1654, 367, 428, 321, 12736, 5289, 11238, 4865, 1041, 199, 199, 363, 344, 363, 275, 7880, 1304, 17351, 199, 363, 1023, 363, 257, 275, 7880, 12714, 17351, 199, 363, 602, 363, 420, 275, 7880, 2506, 17351, 199, 363, 2502, 363, 259, 275, 298, 52, 676, 305, 11002, 2411, 665, 2247, 2411, 32, 7828, 382, 957, 14, 1308, 4335, 199, 363, 7307, 363, 275, 298, 7384, 334, 67, 9, 8315, 13, 9300, 32377, 382, 957, 12, 312, 14, 80, 14, 83, 2122, 199, 363, 1682, 363, 257, 275, 298, 44, 12006, 2, 199, 199, 504, 18895, 14, 8421, 492, 3563, 1892, 199, 646, 295, 199, 646, 900, 199, 199, 504, 1275, 492, 682, 1247, 199, 504, 1275, 492, 3105, 199, 504, 1275, 492, 8129, 382, 902, 83, 199, 504, 1275, 492, 3788, 199, 504, 1275, 492, 32093, 1000, 199, 504, 1275, 492, 2202, 199, 504, 1275, 492, 503, 696, 63, 929, 199, 504, 1275, 492, 22929, 63, 1751, 199, 504, 1275, 645, 385, 492, 6570, 2300, 199, 199, 893, 26, 272, 492, 32093, 68, 199, 2590, 26, 272, 485, 23660, 68, 63, 4561, 275, 756, 199, 2836, 26, 14821, 485, 23660, 68, 63, 4561, 275, 715, 272, 862, 26, 267, 2519, 8, 23660, 68, 12, 298, 2806, 804, 531, 272, 871, 4281, 26, 267, 485, 23660, 68, 63, 1023, 63, 745, 275, 756, 272, 587, 26, 267, 485, 23660, 68, 63, 1023, 63, 745, 275, 715, 199, 199, 48, 1734, 1028, 53, 2594, 275, 295, 14, 2014, 360, 16045, 87, 60, 83, 4300, 295, 14, 12819, 9, 199, 21677, 275, 295, 14, 2014, 360, 2961, 14519, 60, 1840, 60, 11440, 92, 2229, 11230, 4537, 2862, 23379, 19, 12, 20, 93, 2229, 2687, 60, 83, 6113, 58, 1724, 358, 199, 199, 533, 428, 321, 12736, 3120, 8, 23660, 1000, 14, 27047, 12736, 3120, 304, 272, 327, 1666, 314, 1676, 1021, 367, 3794, 14, 339, 485, 2682, 63, 5871, 275, 1052, 2286, 6186, 63, 6613, 63, 998, 275, 283, 885, 7, 272, 485, 6613, 63, 14546, 275, 469, 3472, 63, 6613, 63, 998, 26, 8129, 382, 902, 83, 14, 3472, 63, 31802, 2080, 654, 5357, 540, 93, 339, 347, 664, 2927, 985, 837, 267, 372, 8129, 382, 902, 83, 14, 14179, 25126, 63, 32550, 540, 272, 664, 2927, 985, 275, 12822, 8, 362, 2927, 985, 9, 339, 347, 664, 27047, 12736, 23637, 837, 267, 8037, 275, 942, 267, 849, 275, 428, 321, 12736, 3120, 423, 362, 27047, 12736, 3120, 8, 27047, 12736, 3120, 14, 3472, 63, 6613, 63, 998, 9, 267, 340, 849, 365, 440, 488, 26, 288, 8037, 14, 740, 8, 885, 9, 288, 367, 859, 315, 849, 14, 513, 63, 1199, 63, 3112, 837, 355, 8037, 14, 740, 8, 27047, 12736, 3120, 423, 362, 27047, 12736, 3120, 8, 578, 430, 267, 372, 8037, 272, 664, 27047, 12736, 23637, 275, 12822, 8, 362, 27047, 12736, 23637, 9, 339, 347, 485, 362, 27047, 12736, 3120, 8, 1886, 12, 1654, 1304, 304, 267, 408, 1767, 376, 4702, 1654, 367, 1627, 1305, 14, 398, 23115, 370, 1218, 314, 1654, 340, 652, 3181, 1133, 2187, 5966, 14, 221, 1803, 488, 267, 1380, 652, 365, 440, 3962, 370, 1218, 314, 1654, 14, 2728, 408, 267, 340, 1654, 1304, 440, 315, 843, 423, 2682, 63, 5871, 26, 288, 843, 8, 1000, 1304, 9, 267, 327, 7529, 1133, 372, 314, 1256, 12, 7444, 652, 365, 27028, 5836, 3483, 267, 327, 370, 18494, 2682, 63, 23637, 1370, 267, 372, 843, 423, 2682, 63, 5871, 14, 362, 8, 1000, 1304, 9, 272, 485, 362, 27047, 12736, 3120, 275, 18990, 1547, 362, 27047, 12736, 3120, 9, 339, 347, 664, 27047, 12736, 3120, 8, 815, 29, 403, 304, 267, 340, 2256, 365, 440, 488, 26, 288, 642, 1304, 275, 2256, 59, 17, 61, 267, 587, 26, 288, 642, 1304, 275, 428, 321, 12736, 3120, 14, 3472, 63, 6613, 63, 998, 267, 372, 428, 321, 12736, 3120, 423, 362, 27047, 12736, 3120, 8, 3749, 1304, 9, 272, 664, 27047, 12736, 3120, 275, 12822, 8, 362, 27047, 12736, 3120, 9, 339, 347, 12842, 7472, 23637, 837, 267, 367, 1654, 315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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 ]
ecd/xhtml2pdf
xhtml2pdf/paragraph2.py
52
26820
#!/bin/env/python # -*- coding: utf-8 -*- # Copyright 2010 Dirk Holtwick, holtwick.it # # 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. """ A paragraph class to be used with ReportLab Platypus. TODO ==== - Bullets - Weblinks and internal links - Borders and margins (Box) - Underline, Background, Strike - Images - Hyphenation + Alignment + Breakline, empty lines + TextIndent - Sub and super """ from reportlab.lib.enums import TA_CENTER, TA_JUSTIFY, TA_LEFT, TA_RIGHT from reportlab.pdfbase.pdfmetrics import stringWidth from reportlab.platypus.flowables import Flowable from reportlab.lib.colors import Color WORD = 1 SPACE = 2 BR = 3 BEGIN = 4 END = 5 IMAGE = 6 class Style(dict): """ Style. Single place for style definitions: Paragraphs and Fragments. The naming follows the convention of CSS written in camelCase letters. """ DEFAULT = { "textAlign": TA_LEFT, "textIndent": 0.0, "width": None, "height": None, "fontName": "Times-Roman", "fontSize": 10.0, "color": Color(0, 0, 0), "lineHeight": 1.5, "lineHeightAbsolute": None, "pdfLineSpacing": 0, "link": None, } def __init__(self, **kw): self.update(self.DEFAULT) self.update(kw) self.spaceBefore = 0 self.spaceAfter = 0 self.keepWithNext = False class Box(dict): """ Box. Handles the following styles: # underline, underLineColor (?) # strike, strikeColor (?) backgroundColor, backgroundImage paddingLeft, paddingRight, paddingTop, paddingBottom marginLeft, marginRight, marginTop, marginBottom borderLeftColor, borderLeftWidth, borderLeftStyle borderRightColor, borderRightWidth, borderRightStyle borderTopColor, borderTopWidth, borderTopStyle borderBottomColor, borderBottomWidth, borderBottomStyle Not used in inline Elements: paddingTop, paddingBottom marginTop, marginBottom Needs also: fontName, fontSize, color """ name = "box" def _drawBefore(self, canvas, x, y, w, h): canvas.saveState() textColor = self.get("color", Color(0, 0, 0)) # Background bg = self.get("backgroundColor", None) if bg is not None: # draw a filled rectangle (with no stroke) using bg color canvas.setFillColor(bg) canvas.rect(x, y, w, h, fill=1, stroke=0) # Borders def _drawBorderLine(bstyle, width, color, x1, y1, x2, y2): # We need width and border style to be able to draw a border if width and bstyle: # If no color for border is given, the text color is used (like defined by W3C) if color is None: color = textColor if color is not None: canvas.setStrokeColor(color) canvas.setLineWidth(width) canvas.line(x1, y1, x2, y2) _drawBorderLine(self.get("borderLeftStyle", None), self.get("borderLeftWidth", None), self.get("borderLeftColor", None), x, y, x, y + h) _drawBorderLine(self.get("borderRightStyle", None), self.get("borderRightWidth", None), self.get("borderRightColor", None), x + w, y, x + w, y + h) _drawBorderLine(self.get("borderTopStyle", None), self.get("borderTopWidth", None), self.get("borderTopColor", None), x, y + h, x + w, y + h) _drawBorderLine(self.get("borderBottomStyle", None), self.get("borderBottomWidth", None), self.get("borderBottomColor", None), x, y, x + w, y) # Underline if self.get("underline", None): ff = 0.125 * self["fontSize"] yUnderline = y - 1.0 * ff canvas.setLineWidth(ff * 0.75) canvas.setStrokeColor(textColor) canvas.line(x, yUnderline, x + w, yUnderline) canvas.restoreState() def _drawAfter(self, canvas, x, y, w, h): # Strike if self.get("strike", None): ff = 0.125 * self["fontSize"] yStrike = y + 2.0 * ff textColor = self.get("color", Color(0, 0, 0)) canvas.saveState() canvas.setLineWidth(ff * 0.75) canvas.setStrokeColor(textColor) canvas.line(x, yStrike, x + w, yStrike) canvas.restoreState() class Fragment(Box): """ Fragment. text: String containing text fontName: fontSize: width: Width of string height: Height of string """ name = "fragment" type = None isSoft = False isText = False isLF = False def calc(self): self["width"] = 0 def __str__(self): if self.isText: return "'%s'" % self["text"] return "<%s>" % self.name.upper() class BoxBegin(Fragment): name = "begin" type = BEGIN def calc(self): self["width"] = self.get("marginLeft", 0) + self.get("paddingLeft", 0) # + border if border def drawBefore(self, canvas, y): # print repr(self) x = self.get("marginLeft", 0) + self["x"] w = self["length"] + self.get("paddingRight", 0) h = self["fontSize"] self["box"] = (x, w, h) self._drawBefore(canvas, x, y, w, h) def drawAfter(self, canvas, y): x, w, h = self["box"] self._drawAfter(canvas, x, y, w, h) class BoxEnd(Fragment): name = "end" type = END def calc(self): self["width"] = self.get("marginRight", 0) + self.get("paddingRight", 0) # + border class Word(Fragment): """ A single word. """ name = "word" type = WORD isText = True def calc(self): """ XXX Cache stringWith if not accelerated?! """ self["width"] = stringWidth(self["text"], self["fontName"], self["fontSize"]) class Space(Fragment): """ A space between fragments that is the usual place for line breaking. """ name = "space" type = SPACE isSoft = True def calc(self): self["width"] = stringWidth(" ", self["fontName"], self["fontSize"]) class LineBreak(Fragment): " Line break. " name = "br" type = BR isSoft = True isLF = True pass class Image(Fragment): name = "image" type = IMAGE isText = True pass class Line(list): """ Container for line fragments. """ LINEHEIGHT = 1.0 def __init__(self, style): self.width = 0 self.height = 0 self.isLast = False self.br = False self.style = style self.boxStack = [] list.__init__(self) def doAlignment(self, width, alignment): # Apply alignment if alignment != TA_LEFT: lineWidth = self[- 1]["x"] + self[- 1]["width"] emptySpace = width - lineWidth if alignment == TA_RIGHT: for frag in self: frag["x"] += emptySpace elif alignment == TA_CENTER: for frag in self: frag["x"] += emptySpace / 2.0 elif alignment == TA_JUSTIFY and not self.br: # XXX Just spaces! Currently divides also sticky fragments delta = emptySpace / (len(self) - 1) for i, frag in enumerate(self): frag["x"] += i * delta # Boxes for frag in self: x = frag["x"] + frag["width"] if isinstance(frag, BoxBegin): self.boxStack.append(frag) elif isinstance(frag, BoxEnd): if self.boxStack: frag = self.boxStack.pop() frag["length"] = x - frag["x"] # Handle the rest for frag in self.boxStack: frag["length"] = x - frag["x"] def doLayout(self, width): "Align words in previous line." # Calculate dimensions self.width = width self.height = self.lineHeight = max(frag.get("fontSize", 0) * self.LINEHEIGHT for frag in self) # Apply line height self.fontSize = max(frag.get("fontSize", 0) for frag in self) y = (self.lineHeight - self.fontSize) # / 2 for frag in self: frag["y"] = y return self.height def dumpFragments(self): print "Line", 40 * "-" for frag in self: print "%s" % frag.get("text", frag.name.upper()), print class Group(list): pass class Text(list): """ Container for text fragments. Helper functions for splitting text into lines and calculating sizes and positions. """ def __init__(self, data=None, style=None): if data is None: data = [] self.lines = [] self.width = 0 self.height = 0 self.maxWidth = 0 self.maxHeight = 0 self.pos = 0 self.oldSpace = None self.newSpace = None self.style = style list.__init__(self, data) def calc(self): """ Calculate sizes of fragments. """ for word in self: word.calc() def getGroup(self): self.oldSpace = self.newSpace # For Space recycing group = [] width = 0 br = False length = len(self) while self.pos < length: frag = self[self.pos] type_ = frag.type self.pos += 1 if type_ == SPACE: self.newSpace = frag # For Space recycing if group: break continue group.append(frag) width += frag.get("width", 0) if type_ == BR: br = True break return width, br, group def splitIntoLines(self, maxWidth, maxHeight, splitted=False): """ Split text into lines and calculate X positions. If we need more space in height than available we return the rest of the text """ self.lines = [] self.pos = 0 self.height = 0 self.maxWidth = self.width = maxWidth self.maxHeight = maxHeight boxStack = [] style = self.style x = 0 # Start with indent in first line of text if not splitted: x = style["textIndent"] # Loop for each line while True: # Reset values for new line posBegin = self.pos line = Line(style) # Update boxes for next line for box in copy.deepcopy(boxStack): box["x"] = 0 line.append(BoxBegin(box)) # Loop for collecting line elements while True: # Get next group of unbreakable elements self.groupPos = self.pos groupWidth, br, group = self.getGroup() # No more groups? Leave line if not group: break # To we fit the line? Reset cursor and finish line if groupWidth + x > maxWidth: self.pos = self.groupPos break # Space recycling if self.oldSpace: group.insert(0, self.oldSpace) # Add fragments to line and update x for frag in group: # Add fragment to line and update x frag["x"] = x x += frag["width"] line.append(frag) # Keep in mind boxes for next lines if isinstance(frag, BoxBegin): boxStack.append(frag) elif isinstance(frag, BoxEnd): boxStack.pop() # We got a new line forced if br: line.br = True break self.newSpace = None # Add line to list line.dumpFragments() if line: self.height += line.doLayout(self.width) self.lines.append(line) # If not enough space for current line force to split if self.height > maxHeight: return posBegin # Reached the end if not group: break # Reset variables x = 0 # Apply alignment self.lines[- 1].br = True for line in self.lines: line.doAlignment(maxWidth, style["textAlign"]) return None def dumpLines(self): """ For debugging dump all line and their content """ for i, line in enumerate(self.lines): print "Line %d:" % i, line.dumpFragments() class Paragraph(Flowable): """A simple Paragraph class respecting alignment. Does text without tags. Respects only the following global style attributes: fontName, fontSize, leading, firstLineIndent, leftIndent, rightIndent, textColor, alignment. (spaceBefore, spaceAfter are handled by the Platypus framework.) """ def __init__(self, text, style, debug=False, splitted=False, **kwDict): Flowable.__init__(self) # self._showBoundary = True self.text = text self.text.calc() self.style = style self.text.style = style self.debug = debug self.splitted = splitted # More attributes for k, v in kwDict.iteritems(): setattr(self, k, v) # set later... self.splitIndex = None # overwritten methods from Flowable class def wrap(self, availWidth, availHeight): """ Determine the rectangle this paragraph really needs. """ # memorize available space self.avWidth = availWidth self.avHeight = availHeight if self.debug: print "*** wrap (%f, %f)" % (availWidth, availHeight) if not self.text: if self.debug: print "*** wrap (%f, %f) needed" % (0, 0) return 0, 0 # Split lines width = availWidth self.splitIndex = self.text.splitIntoLines(width, availHeight) self.width, self.height = availWidth, self.text.height if self.debug: print "*** wrap (%f, %f) needed, splitIndex %r" % (self.width, self.height, self.splitIndex) return self.width, self.height def split(self, availWidth, availHeight): """ Split ourself in two paragraphs. """ if self.debug: print "*** split (%f, %f)" % (availWidth, availHeight) splitted = [] if self.splitIndex: text1 = self.text[:self.splitIndex] text2 = self.text[self.splitIndex:] p1 = Paragraph(Text(text1), self.style, debug=self.debug) p2 = Paragraph(Text(text2), self.style, debug=self.debug, splitted=True) splitted = [p1, p2] if self.debug: print "*** text1 %s / text %s" % (len(text1), len(text2)) if self.debug: print '*** return %s' % self.splitted return splitted def draw(self): """ Render the content of the paragraph. """ if self.debug: print "*** draw" if not self.text: return canvas = self.canv style = self.style canvas.saveState() # Draw box arround paragraph for debugging if self.debug: bw = 0.5 bc = Color(1, 1, 0) bg = Color(0.9, 0.9, 0.9) canvas.setStrokeColor(bc) canvas.setLineWidth(bw) canvas.setFillColor(bg) canvas.rect( style.leftIndent, 0, self.width, self.height, fill=1, stroke=1) y = 0 dy = self.height for line in self.text.lines: y += line.height for frag in line: type_ = frag.type # Box if type_ == BEGIN: frag.drawBefore(canvas, dy - y) # Text if type_ == WORD: canvas.setFont(frag["fontName"], frag["fontSize"]) canvas.setFillColor(frag.get("color", style["color"])) canvas.drawString(frag["x"], dy - y + frag["y"], frag["text"]) # Box if type_ == BEGIN: frag.drawAfter(canvas, dy - y) # XXX LINK link = frag.get("link", None) if link: _scheme_re = re.compile('^[a-zA-Z][-+a-zA-Z0-9]+$') x, y, w, h = frag["x"], dy - y, frag["width"], frag["fontSize"] rect = (x, y, w, h) if isinstance(link, unicode): link = link.encode('utf8') parts = link.split(':', 1) scheme = len(parts) == 2 and parts[0].lower() or '' if _scheme_re.match(scheme) and scheme != 'document': kind = scheme.lower() == 'pdf' and 'GoToR' or 'URI' if kind == 'GoToR': link = parts[1] tx._canvas.linkURL(link, rect, relative=1, kind=kind) else: if link[0] == '#': link = link[1:] scheme = '' canvas.linkRect("", scheme != 'document' and link or parts[1], rect, relative=1) canvas.restoreState() if __name__ == "__main__": from reportlab.platypus import SimpleDocTemplate from reportlab.lib.styles import * from reportlab.rl_config import * from reportlab.lib.units import * import os import copy import re styles = getSampleStyleSheet() ALIGNMENTS = (TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY) TEXT = """ Lörem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. """.strip() def textGenerator(data, fn, fs): i = 1 for word in re.split('\s+', data): if word: yield Word( text="[%d|%s]" % (i, word), fontName=fn, fontSize=fs ) yield Space( fontName=fn, fontSize=fs ) i += 1 def createText(data, fn, fs): text = Text(list(textGenerator(data, fn, fs))) return text def makeBorder(width, style="solid", color=Color(1, 0, 0)): return dict( borderLeftColor=color, borderLeftWidth=width, borderLeftStyle=style, borderRightColor=color, borderRightWidth=width, borderRightStyle=style, borderTopColor=color, borderTopWidth=width, borderTopStyle=style, borderBottomColor=color, borderBottomWidth=width, borderBottomStyle=style ) def makeSpecial(fn="Times-Roman", fs=10): return [ Space( fontName=fn, fontSize=fs), Word( text="TrennbarTrennbar", pairs=[("Trenn-", "barTrennbar")], fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), Word( text="Normal", color=Color(1, 0, 0), fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), BoxBegin( fontName=fn, fontSize=fs, underline=True, strike=True), Word( text="gGrößer", fontName=fn, fontSize=fs * 1.5), Space( fontName=fn, fontSize=fs), Word( text="Bold", fontName="Times-Bold", fontSize=fs), BoxEnd(), Space( fontName=fn, fontSize=fs), Word( text="jItalic", fontName="Times-Italic", fontSize=fs), Space( fontName=fn, fontSize=fs), # <span style="border: 1px solid red;">ipsum <span style="border: 1px solid green; padding: 4px; padding-left: 20px; background: yellow; margin-bottom: 8px; margin-left: 10px;"> # Lo<font size="12pt">re</font>m</span> <span style="background:blue; height: 30px;">ipsum</span> Lorem</span> BoxBegin( fontName=fn, fontSize=fs, **makeBorder(0.5, "solid", Color(0, 1, 0))), Word( text="Lorem", fontName="Times-Bold", fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Word( text="Lorem", fontName="Times-Bold", fontSize=fs), Space( fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), BoxBegin( fontName=fn, fontSize=fs, backgroundColor=Color(1, 1, 0), **makeBorder(1, "solid", Color(1, 0, 0))), Word( text="Lorem", fontName=fn, fontSize=fs), BoxEnd(), Space( fontName=fn, fontSize=fs), Word( text="Lorem", fontName=fn, fontSize=fs), Space( fontName=fn, fontSize=fs), BoxEnd(), LineBreak( fontName=fn, fontSize=fs), LineBreak( fontName=fn, fontSize=fs), ] def test(): doc = SimpleDocTemplate("test.pdf") story = [] style = Style(fontName="Helvetica", textIndent=24.0) fn = style["fontName"] fs = style["fontSize"] sampleText1 = createText(TEXT[:100], fn, fs) sampleText2 = createText(TEXT[100:], fn, fs) text = Text(sampleText1 + makeSpecial(fn, fs) + sampleText2) story.append(Paragraph( copy.copy(text), style, debug=0)) if 0: # FIXME: Why is this here? for i in range(10): style = copy.deepcopy(style) style["textAlign"] = ALIGNMENTS[i % 4] text = createText(("(%d) " % i) + TEXT, fn, fs) story.append(Paragraph( copy.copy(text), style, debug=0)) doc.build(story) def test2(): # text = Text(list(textGenerator(TEXT, "Times-Roman", 10))) text = Text(makeSpecial()) text.calc() print text[1].type while 1: width, br, group = text.getGroup() if not group: print "ENDE", repr(group) break print width, br, " ".join([str(x) for x in group]) # test2() if 1: # FIXME: Again, why this? And the commented lines around here. test() os.system("start test.pdf") # createText(TEXT, styles["Normal"].fontName, styles["Normal"].fontSize)
apache-2.0
[ 3381, 1393, 15, 1813, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 7129, 25866, 75, 869, 393, 8122, 2000, 12, 394, 393, 8122, 2000, 14, 390, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 33, 13168, 1021, 370, 506, 1202, 543, 11774, 22511, 510, 4452, 2279, 527, 14, 199, 199, 11768, 199, 532, 199, 199, 13, 699, 348, 16537, 199, 13, 6001, 4614, 436, 5007, 6220, 199, 13, 699, 14387, 436, 11042, 83, 334, 3532, 9, 199, 13, 25010, 604, 12, 10257, 3928, 12, 31309, 415, 199, 13, 32658, 199, 13, 29591, 17579, 425, 199, 11, 15170, 784, 434, 199, 11, 22535, 604, 12, 2701, 2385, 199, 11, 4516, 7583, 199, 13, 4804, 436, 1613, 199, 199, 624, 199, 199, 504, 21773, 14, 773, 14, 19921, 492, 377, 33, 63, 17611, 12, 377, 33, 63, 42, 7698, 13367, 12, 377, 33, 63, 9894, 12, 377, 33, 63, 12811, 199, 504, 21773, 14, 5607, 1095, 14, 5607, 6759, 492, 1059, 6216, 199, 504, 21773, 14, 14156, 2279, 527, 14, 1659, 5921, 492, 20823, 461, 199, 504, 21773, 14, 773, 14, 7120, 492, 11581, 421, 199, 5172, 275, 413, 199, 11658, 275, 499, 199, 7184, 275, 650, 199, 15947, 275, 841, 199, 3902, 275, 959, 199, 9438, 275, 1227, 421, 199, 533, 19442, 8, 807, 304, 272, 408, 272, 19442, 14, 339, 13050, 4192, 367, 3449, 10269, 26, 2235, 7109, 83, 436, 481, 2527, 1470, 14, 710, 272, 19720, 11924, 314, 16129, 402, 15750, 5313, 315, 31129, 1538, 14435, 14, 272, 408, 339, 6186, 275, 469, 267, 298, 505, 9497, 582, 377, 33, 63, 9894, 12, 267, 298, 505, 7583, 582, 378, 14, 16, 12, 267, 298, 2063, 582, 488, 12, 267, 298, 3333, 582, 488, 12, 267, 298, 4246, 985, 582, 298, 17687, 13, 50, 21604, 401, 267, 298, 31995, 582, 1616, 14, 16, 12, 267, 298, 2326, 582, 11581, 8, 16, 12, 378, 12, 378, 395, 267, 298, 604, 8436, 582, 413, 14, 21, 12, 267, 298, 604, 8436, 24677, 582, 488, 12, 267, 298, 5607, 3049, 24052, 582, 378, 12, 267, 298, 1073, 582, 488, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 14, 873, 8, 277, 14, 3472, 9, 267, 291, 14, 873, 8, 829, 9, 267, 291, 14, 2638, 13569, 275, 378, 267, 291, 14, 2638, 10881, 275, 378, 267, 291, 14, 3250, 3007, 5765, 275, 756, 421, 199, 533, 20783, 8, 807, 304, 272, 408, 272, 20783, 14, 339, 23873, 314, 2569, 15725, 26, 398, 327, 25735, 12, 1334, 3049, 4117, 7558, 9, 267, 327, 4024, 415, 12, 4024, 415, 4117, 7558, 9, 398, 8020, 4117, 12, 8020, 3491, 267, 6273, 8185, 12, 6273, 9121, 12, 6273, 6105, 12, 6273, 22886, 267, 11042, 8185, 12, 11042, 9121, 12, 11042, 6105, 12, 11042, 22886, 267, 9162, 8185, 4117, 12, 9162, 8185, 6216, 12, 9162, 8185, 6609, 267, 9162, 9121, 4117, 12, 9162, 9121, 6216, 12, 9162, 9121, 6609, 267, 9162, 6105, 4117, 12, 9162, 6105, 6216, 12, 9162, 6105, 6609, 267, 9162, 22886, 4117, 12, 9162, 22886, 6216, 12, 9162, 22886, 6609, 339, 2832, 1202, 315, 8308, 6566, 83, 26, 398, 6273, 6105, 12, 6273, 22886, 267, 11042, 6105, 12, 11042, 22886, 339, 29613, 2597, 26, 398, 5023, 985, 12, 5023, 2320, 12, 3164, 339, 408, 339, 536, 275, 298, 1977, 2, 339, 347, 485, 5485, 13569, 8, 277, 12, 10218, 12, 671, 12, 612, 12, 336, 12, 394, 304, 267, 10218, 14, 2117, 2223, 342, 398, 1318, 4117, 275, 291, 14, 362, 480, 2326, 401, 11581, 8, 16, 12, 378, 12, 378, 430, 398, 327, 10257, 3928, 267, 12994, 275, 291, 14, 362, 480, 7451, 4117, 401, 488, 9, 267, 340, 12994, 365, 440, 488, 26, 288, 327, 5954, 282, 13457, 20412, 334, 1045, 949, 22824, 9, 1808, 12994, 3164, 288, 10218, 14, 409, 12914, 4117, 8, 6856, 9, 288, 10218, 14, 1201, 8, 88, 12, 612, 12, 336, 12, 394, 12, 5554, 29, 17, 12, 22824, 29, 16, 9, 398, 327, 699, 14387, 267, 347, 485, 5485, 22590, 3049, 8, 66, 2487, 12, 3462, 12, 3164, 12, 671, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 304, 288, 327, 2136, 1929, 3462, 436, 9162, 3449, 370, 506, 7688, 370, 5954, 282, 9162, 288, 340, 3462, 436, 330, 2487, 26, 355, 327, 982, 949, 3164, 367, 9162, 365, 1627, 12, 314, 1318, 3164, 365, 1202, 334, 2930, 3247, 701, 644, 19, 35, 9, 355, 340, 3164, 365, 488, 26, 490, 3164, 275, 1318, 4117, 355, 340, 3164, 365, 440, 488, 26, 490, 10218, 14, 409, 32492, 4117, 8, 2326, 9, 490, 10218, 14, 409, 3049, 6216, 8, 2063, 9, 490, 10218, 14, 604, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 9, 398, 485, 5485, 22590, 3049, 8, 277, 14, 362, 480, 8665, 8185, 6609, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 8185, 6216, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 8185, 4117, 401, 488, 395, 717, 671, 12, 612, 12, 671, 12, 612, 435, 394, 9, 267, 485, 5485, 22590, 3049, 8, 277, 14, 362, 480, 8665, 9121, 6609, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 9121, 6216, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 9121, 4117, 401, 488, 395, 717, 671, 435, 336, 12, 612, 12, 671, 435, 336, 12, 612, 435, 394 ]
[ 1393, 15, 1813, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 7129, 25866, 75, 869, 393, 8122, 2000, 12, 394, 393, 8122, 2000, 14, 390, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 33, 13168, 1021, 370, 506, 1202, 543, 11774, 22511, 510, 4452, 2279, 527, 14, 199, 199, 11768, 199, 532, 199, 199, 13, 699, 348, 16537, 199, 13, 6001, 4614, 436, 5007, 6220, 199, 13, 699, 14387, 436, 11042, 83, 334, 3532, 9, 199, 13, 25010, 604, 12, 10257, 3928, 12, 31309, 415, 199, 13, 32658, 199, 13, 29591, 17579, 425, 199, 11, 15170, 784, 434, 199, 11, 22535, 604, 12, 2701, 2385, 199, 11, 4516, 7583, 199, 13, 4804, 436, 1613, 199, 199, 624, 199, 199, 504, 21773, 14, 773, 14, 19921, 492, 377, 33, 63, 17611, 12, 377, 33, 63, 42, 7698, 13367, 12, 377, 33, 63, 9894, 12, 377, 33, 63, 12811, 199, 504, 21773, 14, 5607, 1095, 14, 5607, 6759, 492, 1059, 6216, 199, 504, 21773, 14, 14156, 2279, 527, 14, 1659, 5921, 492, 20823, 461, 199, 504, 21773, 14, 773, 14, 7120, 492, 11581, 421, 199, 5172, 275, 413, 199, 11658, 275, 499, 199, 7184, 275, 650, 199, 15947, 275, 841, 199, 3902, 275, 959, 199, 9438, 275, 1227, 421, 199, 533, 19442, 8, 807, 304, 272, 408, 272, 19442, 14, 339, 13050, 4192, 367, 3449, 10269, 26, 2235, 7109, 83, 436, 481, 2527, 1470, 14, 710, 272, 19720, 11924, 314, 16129, 402, 15750, 5313, 315, 31129, 1538, 14435, 14, 272, 408, 339, 6186, 275, 469, 267, 298, 505, 9497, 582, 377, 33, 63, 9894, 12, 267, 298, 505, 7583, 582, 378, 14, 16, 12, 267, 298, 2063, 582, 488, 12, 267, 298, 3333, 582, 488, 12, 267, 298, 4246, 985, 582, 298, 17687, 13, 50, 21604, 401, 267, 298, 31995, 582, 1616, 14, 16, 12, 267, 298, 2326, 582, 11581, 8, 16, 12, 378, 12, 378, 395, 267, 298, 604, 8436, 582, 413, 14, 21, 12, 267, 298, 604, 8436, 24677, 582, 488, 12, 267, 298, 5607, 3049, 24052, 582, 378, 12, 267, 298, 1073, 582, 488, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 14, 873, 8, 277, 14, 3472, 9, 267, 291, 14, 873, 8, 829, 9, 267, 291, 14, 2638, 13569, 275, 378, 267, 291, 14, 2638, 10881, 275, 378, 267, 291, 14, 3250, 3007, 5765, 275, 756, 421, 199, 533, 20783, 8, 807, 304, 272, 408, 272, 20783, 14, 339, 23873, 314, 2569, 15725, 26, 398, 327, 25735, 12, 1334, 3049, 4117, 7558, 9, 267, 327, 4024, 415, 12, 4024, 415, 4117, 7558, 9, 398, 8020, 4117, 12, 8020, 3491, 267, 6273, 8185, 12, 6273, 9121, 12, 6273, 6105, 12, 6273, 22886, 267, 11042, 8185, 12, 11042, 9121, 12, 11042, 6105, 12, 11042, 22886, 267, 9162, 8185, 4117, 12, 9162, 8185, 6216, 12, 9162, 8185, 6609, 267, 9162, 9121, 4117, 12, 9162, 9121, 6216, 12, 9162, 9121, 6609, 267, 9162, 6105, 4117, 12, 9162, 6105, 6216, 12, 9162, 6105, 6609, 267, 9162, 22886, 4117, 12, 9162, 22886, 6216, 12, 9162, 22886, 6609, 339, 2832, 1202, 315, 8308, 6566, 83, 26, 398, 6273, 6105, 12, 6273, 22886, 267, 11042, 6105, 12, 11042, 22886, 339, 29613, 2597, 26, 398, 5023, 985, 12, 5023, 2320, 12, 3164, 339, 408, 339, 536, 275, 298, 1977, 2, 339, 347, 485, 5485, 13569, 8, 277, 12, 10218, 12, 671, 12, 612, 12, 336, 12, 394, 304, 267, 10218, 14, 2117, 2223, 342, 398, 1318, 4117, 275, 291, 14, 362, 480, 2326, 401, 11581, 8, 16, 12, 378, 12, 378, 430, 398, 327, 10257, 3928, 267, 12994, 275, 291, 14, 362, 480, 7451, 4117, 401, 488, 9, 267, 340, 12994, 365, 440, 488, 26, 288, 327, 5954, 282, 13457, 20412, 334, 1045, 949, 22824, 9, 1808, 12994, 3164, 288, 10218, 14, 409, 12914, 4117, 8, 6856, 9, 288, 10218, 14, 1201, 8, 88, 12, 612, 12, 336, 12, 394, 12, 5554, 29, 17, 12, 22824, 29, 16, 9, 398, 327, 699, 14387, 267, 347, 485, 5485, 22590, 3049, 8, 66, 2487, 12, 3462, 12, 3164, 12, 671, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 304, 288, 327, 2136, 1929, 3462, 436, 9162, 3449, 370, 506, 7688, 370, 5954, 282, 9162, 288, 340, 3462, 436, 330, 2487, 26, 355, 327, 982, 949, 3164, 367, 9162, 365, 1627, 12, 314, 1318, 3164, 365, 1202, 334, 2930, 3247, 701, 644, 19, 35, 9, 355, 340, 3164, 365, 488, 26, 490, 3164, 275, 1318, 4117, 355, 340, 3164, 365, 440, 488, 26, 490, 10218, 14, 409, 32492, 4117, 8, 2326, 9, 490, 10218, 14, 409, 3049, 6216, 8, 2063, 9, 490, 10218, 14, 604, 8, 88, 17, 12, 612, 17, 12, 671, 18, 12, 612, 18, 9, 398, 485, 5485, 22590, 3049, 8, 277, 14, 362, 480, 8665, 8185, 6609, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 8185, 6216, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 8185, 4117, 401, 488, 395, 717, 671, 12, 612, 12, 671, 12, 612, 435, 394, 9, 267, 485, 5485, 22590, 3049, 8, 277, 14, 362, 480, 8665, 9121, 6609, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 9121, 6216, 401, 488, 395, 717, 291, 14, 362, 480, 8665, 9121, 4117, 401, 488, 395, 717, 671, 435, 336, 12, 612, 12, 671, 435, 336, 12, 612, 435, 394, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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313
from django.conf.urls import patterns, url from rest_framework.routers import DefaultRouter from cigar_example.restapi import views as views router = DefaultRouter() router.register(r'cigars', views.CigarViewSet) router.register(r'artisan_cigars', views.ArtisanCigarViewSet) urlpatterns = patterns( '', # Examples: url(r'^custom$', views.MyCustomView.as_view()), url(r'^manufacturers/?$', views.ManufacturerList.as_view(), name='list_of_manufacturers'), url(r'^manufacturers/(?P<pk>\d+)/?$', views.ManufacturerDetails.as_view(), name='manufacturer_details'), url(r'^countries/?$', views.CountryList.as_view(), name='list_of_countries'), url(r'^countries/(?P<pk>\d+)/?$', views.CountryDetails.as_view(), name='countries_details'), url(r'^jambalaya_create/$', views.create_jambalaya, name='create-jambalaya'), url(r'^jambalaya_find/$', views.find_jambalaya, name='find-jambalaya'), url(r'^jambalaya_retrieve/$', views.retrieve_jambalaya, name='retrieve-jambalaya'), url(r'^drop_cigar_in_jambalaya/$', views.drop_cigar_in_jambalaya, name='cigar-jambalaya'), url(r'^mix_cigars_in_jambalaya/$', views.mix_cigars_in_jambalaya, name='mix-cigars-jambalaya'), url(r'^custom_create/$', views.create_cigar2, name='custom-create-cigar'), ) urlpatterns += router.urls
bsd-2-clause
[ 504, 1639, 14, 2190, 14, 3603, 492, 7970, 12, 1166, 199, 504, 4618, 63, 4857, 14, 17292, 492, 3758, 11691, 199, 199, 504, 286, 528, 285, 63, 2694, 14, 3911, 1246, 492, 6858, 465, 6858, 421, 199, 4995, 275, 3758, 11691, 342, 199, 4995, 14, 2683, 8, 82, 7, 67, 528, 4291, 297, 6858, 14, 35, 528, 285, 21902, 9, 199, 4995, 14, 2683, 8, 82, 7, 285, 16753, 290, 63, 67, 528, 4291, 297, 6858, 14, 1596, 16753, 290, 35, 528, 285, 21902, 9, 199, 199, 20050, 275, 7970, 8, 272, 3260, 272, 327, 6058, 26, 272, 1166, 8, 82, 4289, 4229, 4268, 6858, 14, 5713, 7223, 2768, 14, 305, 63, 1345, 4000, 272, 1166, 8, 82, 4289, 1237, 17391, 2393, 10197, 4268, 6858, 14, 2395, 21087, 1296, 14, 305, 63, 1345, 1062, 536, 534, 513, 63, 1618, 63, 1237, 17391, 2393, 659, 272, 1166, 8, 82, 4289, 1237, 17391, 2393, 9448, 48, 28, 2051, 3072, 68, 18830, 31, 4268, 6858, 14, 2395, 21087, 11347, 14, 305, 63, 1345, 1062, 536, 534, 32214, 63, 5087, 659, 339, 1166, 8, 82, 4289, 23598, 10197, 4268, 6858, 14, 17393, 1296, 14, 305, 63, 1345, 1062, 536, 534, 513, 63, 1618, 63, 23598, 659, 272, 1166, 8, 82, 4289, 23598, 9448, 48, 28, 2051, 3072, 68, 18830, 31, 4268, 6858, 14, 17393, 11347, 14, 305, 63, 1345, 1062, 536, 534, 23598, 63, 5087, 659, 272, 1166, 8, 82, 4289, 16997, 4982, 1187, 65, 63, 981, 10884, 6858, 14, 981, 63, 16997, 4982, 1187, 65, 12, 536, 534, 981, 13, 16997, 4982, 1187, 65, 659, 272, 1166, 8, 82, 4289, 16997, 4982, 1187, 65, 63, 1623, 10884, 6858, 14, 1623, 63, 16997, 4982, 1187, 65, 12, 536, 534, 1623, 13, 16997, 4982, 1187, 65, 659, 272, 1166, 8, 82, 4289, 16997, 4982, 1187, 65, 63, 14270, 10884, 6858, 14, 14270, 63, 16997, 4982, 1187, 65, 12, 536, 534, 14270, 13, 16997, 4982, 1187, 65, 659, 272, 1166, 8, 82, 4289, 4824, 63, 67, 528, 285, 63, 262, 63, 16997, 4982, 1187, 65, 10884, 6858, 14, 4824, 63, 67, 528, 285, 63, 262, 63, 16997, 4982, 1187, 65, 12, 536, 534, 67, 528, 285, 13, 16997, 4982, 1187, 65, 659, 272, 1166, 8, 82, 4289, 13979, 63, 67, 528, 4291, 63, 262, 63, 16997, 4982, 1187, 65, 10884, 6858, 14, 13979, 63, 67, 528, 4291, 63, 262, 63, 16997, 4982, 1187, 65, 12, 536, 534, 13979, 13, 67, 528, 4291, 13, 16997, 4982, 1187, 65, 659, 272, 1166, 8, 82, 4289, 4229, 63, 981, 10884, 6858, 14, 981, 63, 67, 528, 285, 18, 12, 536, 534, 4229, 13, 981, 13, 67, 528, 285, 659, 199, 9, 199, 199, 20050, 847, 6197, 14, 3603, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 14, 3603, 492, 7970, 12, 1166, 199, 504, 4618, 63, 4857, 14, 17292, 492, 3758, 11691, 199, 199, 504, 286, 528, 285, 63, 2694, 14, 3911, 1246, 492, 6858, 465, 6858, 421, 199, 4995, 275, 3758, 11691, 342, 199, 4995, 14, 2683, 8, 82, 7, 67, 528, 4291, 297, 6858, 14, 35, 528, 285, 21902, 9, 199, 4995, 14, 2683, 8, 82, 7, 285, 16753, 290, 63, 67, 528, 4291, 297, 6858, 14, 1596, 16753, 290, 35, 528, 285, 21902, 9, 199, 199, 20050, 275, 7970, 8, 272, 3260, 272, 327, 6058, 26, 272, 1166, 8, 82, 4289, 4229, 4268, 6858, 14, 5713, 7223, 2768, 14, 305, 63, 1345, 4000, 272, 1166, 8, 82, 4289, 1237, 17391, 2393, 10197, 4268, 6858, 14, 2395, 21087, 1296, 14, 305, 63, 1345, 1062, 536, 534, 513, 63, 1618, 63, 1237, 17391, 2393, 659, 272, 1166, 8, 82, 4289, 1237, 17391, 2393, 9448, 48, 28, 2051, 3072, 68, 18830, 31, 4268, 6858, 14, 2395, 21087, 11347, 14, 305, 63, 1345, 1062, 536, 534, 32214, 63, 5087, 659, 339, 1166, 8, 82, 4289, 23598, 10197, 4268, 6858, 14, 17393, 1296, 14, 305, 63, 1345, 1062, 536, 534, 513, 63, 1618, 63, 23598, 659, 272, 1166, 8, 82, 4289, 23598, 9448, 48, 28, 2051, 3072, 68, 18830, 31, 4268, 6858, 14, 17393, 11347, 14, 305, 63, 1345, 1062, 536, 534, 23598, 63, 5087, 659, 272, 1166, 8, 82, 4289, 16997, 4982, 1187, 65, 63, 981, 10884, 6858, 14, 981, 63, 16997, 4982, 1187, 65, 12, 536, 534, 981, 13, 16997, 4982, 1187, 65, 659, 272, 1166, 8, 82, 4289, 16997, 4982, 1187, 65, 63, 1623, 10884, 6858, 14, 1623, 63, 16997, 4982, 1187, 65, 12, 536, 534, 1623, 13, 16997, 4982, 1187, 65, 659, 272, 1166, 8, 82, 4289, 16997, 4982, 1187, 65, 63, 14270, 10884, 6858, 14, 14270, 63, 16997, 4982, 1187, 65, 12, 536, 534, 14270, 13, 16997, 4982, 1187, 65, 659, 272, 1166, 8, 82, 4289, 4824, 63, 67, 528, 285, 63, 262, 63, 16997, 4982, 1187, 65, 10884, 6858, 14, 4824, 63, 67, 528, 285, 63, 262, 63, 16997, 4982, 1187, 65, 12, 536, 534, 67, 528, 285, 13, 16997, 4982, 1187, 65, 659, 272, 1166, 8, 82, 4289, 13979, 63, 67, 528, 4291, 63, 262, 63, 16997, 4982, 1187, 65, 10884, 6858, 14, 13979, 63, 67, 528, 4291, 63, 262, 63, 16997, 4982, 1187, 65, 12, 536, 534, 13979, 13, 67, 528, 4291, 13, 16997, 4982, 1187, 65, 659, 272, 1166, 8, 82, 4289, 4229, 63, 981, 10884, 6858, 14, 981, 63, 67, 528, 285, 18, 12, 536, 534, 4229, 13, 981, 13, 67, 528, 285, 659, 199, 9, 199, 199, 20050, 847, 6197, 14, 3603, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
andres-root/bitcoinxt
qa/rpc-tests/test_framework/mininode.py
126
36289
# mininode.py - Bitcoin P2P network half-a-node # # Distributed under the MIT/X11 software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. # # This python code was modified from ArtForz' public domain half-a-node, as # found in the mini-node branch of http://github.com/jgarzik/pynode. # # NodeConn: an object which manages p2p connectivity to a bitcoin node # NodeConnCB: a base class that describes the interface for receiving # callbacks with network messages from a NodeConn # CBlock, CTransaction, CBlockHeader, CTxIn, CTxOut, etc....: # data structures that should map to corresponding structures in # bitcoin/primitives # msg_block, msg_tx, msg_headers, etc.: # data structures that represent network messages # ser_*, deser_*: functions that handle serialization/deserialization import struct import socket import asyncore import binascii import time import sys import random import cStringIO import hashlib from threading import RLock from threading import Thread import logging import copy BIP0031_VERSION = 60000 MY_VERSION = 60001 # past bip-31 for ping/pong MY_SUBVERSION = "/python-mininode-tester:0.0.1/" MAX_INV_SZ = 50000 # Keep our own socket map for asyncore, so that we can track disconnects # ourselves (to workaround an issue with closing an asyncore socket when # using select) mininode_socket_map = dict() # One lock for synchronizing all data access between the networking thread (see # NetworkThread below) and the thread running the test logic. For simplicity, # NodeConn acquires this lock whenever delivering a message to to a NodeConnCB, # and whenever adding anything to the send buffer (in send_message()). This # lock should be acquired in the thread running the test logic to synchronize # access to any data shared with the NodeConnCB or NodeConn. mininode_lock = RLock() # Serialization/deserialization tools def sha256(s): return hashlib.new('sha256', s).digest() def hash256(s): return sha256(sha256(s)) def deser_string(f): nit = struct.unpack("<B", f.read(1))[0] if nit == 253: nit = struct.unpack("<H", f.read(2))[0] elif nit == 254: nit = struct.unpack("<I", f.read(4))[0] elif nit == 255: nit = struct.unpack("<Q", f.read(8))[0] return f.read(nit) def ser_string(s): if len(s) < 253: return chr(len(s)) + s elif len(s) < 0x10000: return chr(253) + struct.pack("<H", len(s)) + s elif len(s) < 0x100000000L: return chr(254) + struct.pack("<I", len(s)) + s return chr(255) + struct.pack("<Q", len(s)) + s def deser_uint256(f): r = 0L for i in xrange(8): t = struct.unpack("<I", f.read(4))[0] r += t << (i * 32) return r def ser_uint256(u): rs = "" for i in xrange(8): rs += struct.pack("<I", u & 0xFFFFFFFFL) u >>= 32 return rs def uint256_from_str(s): r = 0L t = struct.unpack("<IIIIIIII", s[:32]) for i in xrange(8): r += t[i] << (i * 32) return r def uint256_from_compact(c): nbytes = (c >> 24) & 0xFF v = (c & 0xFFFFFFL) << (8 * (nbytes - 3)) return v def deser_vector(f, c): nit = struct.unpack("<B", f.read(1))[0] if nit == 253: nit = struct.unpack("<H", f.read(2))[0] elif nit == 254: nit = struct.unpack("<I", f.read(4))[0] elif nit == 255: nit = struct.unpack("<Q", f.read(8))[0] r = [] for i in xrange(nit): t = c() t.deserialize(f) r.append(t) return r def ser_vector(l): r = "" if len(l) < 253: r = chr(len(l)) elif len(l) < 0x10000: r = chr(253) + struct.pack("<H", len(l)) elif len(l) < 0x100000000L: r = chr(254) + struct.pack("<I", len(l)) else: r = chr(255) + struct.pack("<Q", len(l)) for i in l: r += i.serialize() return r def deser_uint256_vector(f): nit = struct.unpack("<B", f.read(1))[0] if nit == 253: nit = struct.unpack("<H", f.read(2))[0] elif nit == 254: nit = struct.unpack("<I", f.read(4))[0] elif nit == 255: nit = struct.unpack("<Q", f.read(8))[0] r = [] for i in xrange(nit): t = deser_uint256(f) r.append(t) return r def ser_uint256_vector(l): r = "" if len(l) < 253: r = chr(len(l)) elif len(l) < 0x10000: r = chr(253) + struct.pack("<H", len(l)) elif len(l) < 0x100000000L: r = chr(254) + struct.pack("<I", len(l)) else: r = chr(255) + struct.pack("<Q", len(l)) for i in l: r += ser_uint256(i) return r def deser_string_vector(f): nit = struct.unpack("<B", f.read(1))[0] if nit == 253: nit = struct.unpack("<H", f.read(2))[0] elif nit == 254: nit = struct.unpack("<I", f.read(4))[0] elif nit == 255: nit = struct.unpack("<Q", f.read(8))[0] r = [] for i in xrange(nit): t = deser_string(f) r.append(t) return r def ser_string_vector(l): r = "" if len(l) < 253: r = chr(len(l)) elif len(l) < 0x10000: r = chr(253) + struct.pack("<H", len(l)) elif len(l) < 0x100000000L: r = chr(254) + struct.pack("<I", len(l)) else: r = chr(255) + struct.pack("<Q", len(l)) for sv in l: r += ser_string(sv) return r def deser_int_vector(f): nit = struct.unpack("<B", f.read(1))[0] if nit == 253: nit = struct.unpack("<H", f.read(2))[0] elif nit == 254: nit = struct.unpack("<I", f.read(4))[0] elif nit == 255: nit = struct.unpack("<Q", f.read(8))[0] r = [] for i in xrange(nit): t = struct.unpack("<i", f.read(4))[0] r.append(t) return r def ser_int_vector(l): r = "" if len(l) < 253: r = chr(len(l)) elif len(l) < 0x10000: r = chr(253) + struct.pack("<H", len(l)) elif len(l) < 0x100000000L: r = chr(254) + struct.pack("<I", len(l)) else: r = chr(255) + struct.pack("<Q", len(l)) for i in l: r += struct.pack("<i", i) return r # Objects that map to bitcoind objects, which can be serialized/deserialized class CAddress(object): def __init__(self): self.nServices = 1 self.pchReserved = "\x00" * 10 + "\xff" * 2 self.ip = "0.0.0.0" self.port = 0 def deserialize(self, f): self.nServices = struct.unpack("<Q", f.read(8))[0] self.pchReserved = f.read(12) self.ip = socket.inet_ntoa(f.read(4)) self.port = struct.unpack(">H", f.read(2))[0] def serialize(self): r = "" r += struct.pack("<Q", self.nServices) r += self.pchReserved r += socket.inet_aton(self.ip) r += struct.pack(">H", self.port) return r def __repr__(self): return "CAddress(nServices=%i ip=%s port=%i)" % (self.nServices, self.ip, self.port) class CInv(object): typemap = { 0: "Error", 1: "TX", 2: "Block"} def __init__(self, t=0, h=0L): self.type = t self.hash = h def deserialize(self, f): self.type = struct.unpack("<i", f.read(4))[0] self.hash = deser_uint256(f) def serialize(self): r = "" r += struct.pack("<i", self.type) r += ser_uint256(self.hash) return r def __repr__(self): return "CInv(type=%s hash=%064x)" \ % (self.typemap[self.type], self.hash) class CBlockLocator(object): def __init__(self): self.nVersion = MY_VERSION self.vHave = [] def deserialize(self, f): self.nVersion = struct.unpack("<i", f.read(4))[0] self.vHave = deser_uint256_vector(f) def serialize(self): r = "" r += struct.pack("<i", self.nVersion) r += ser_uint256_vector(self.vHave) return r def __repr__(self): return "CBlockLocator(nVersion=%i vHave=%s)" \ % (self.nVersion, repr(self.vHave)) class COutPoint(object): def __init__(self, hash=0, n=0): self.hash = hash self.n = n def deserialize(self, f): self.hash = deser_uint256(f) self.n = struct.unpack("<I", f.read(4))[0] def serialize(self): r = "" r += ser_uint256(self.hash) r += struct.pack("<I", self.n) return r def __repr__(self): return "COutPoint(hash=%064x n=%i)" % (self.hash, self.n) class CTxIn(object): def __init__(self, outpoint=None, scriptSig="", nSequence=0): if outpoint is None: self.prevout = COutPoint() else: self.prevout = outpoint self.scriptSig = scriptSig self.nSequence = nSequence def deserialize(self, f): self.prevout = COutPoint() self.prevout.deserialize(f) self.scriptSig = deser_string(f) self.nSequence = struct.unpack("<I", f.read(4))[0] def serialize(self): r = "" r += self.prevout.serialize() r += ser_string(self.scriptSig) r += struct.pack("<I", self.nSequence) return r def __repr__(self): return "CTxIn(prevout=%s scriptSig=%s nSequence=%i)" \ % (repr(self.prevout), binascii.hexlify(self.scriptSig), self.nSequence) class CTxOut(object): def __init__(self, nValue=0, scriptPubKey=""): self.nValue = nValue self.scriptPubKey = scriptPubKey def deserialize(self, f): self.nValue = struct.unpack("<q", f.read(8))[0] self.scriptPubKey = deser_string(f) def serialize(self): r = "" r += struct.pack("<q", self.nValue) r += ser_string(self.scriptPubKey) return r def __repr__(self): return "CTxOut(nValue=%i.%08i scriptPubKey=%s)" \ % (self.nValue // 100000000, self.nValue % 100000000, binascii.hexlify(self.scriptPubKey)) class CTransaction(object): def __init__(self, tx=None): if tx is None: self.nVersion = 1 self.vin = [] self.vout = [] self.nLockTime = 0 self.sha256 = None self.hash = None else: self.nVersion = tx.nVersion self.vin = copy.deepcopy(tx.vin) self.vout = copy.deepcopy(tx.vout) self.nLockTime = tx.nLockTime self.sha256 = None self.hash = None def deserialize(self, f): self.nVersion = struct.unpack("<i", f.read(4))[0] self.vin = deser_vector(f, CTxIn) self.vout = deser_vector(f, CTxOut) self.nLockTime = struct.unpack("<I", f.read(4))[0] self.sha256 = None self.hash = None def serialize(self): r = "" r += struct.pack("<i", self.nVersion) r += ser_vector(self.vin) r += ser_vector(self.vout) r += struct.pack("<I", self.nLockTime) return r def rehash(self): self.sha256 = None self.calc_sha256() def calc_sha256(self): if self.sha256 is None: self.sha256 = uint256_from_str(hash256(self.serialize())) self.hash = hash256(self.serialize())[::-1].encode('hex_codec') def is_valid(self): self.calc_sha256() for tout in self.vout: if tout.nValue < 0 or tout.nValue > 21000000L * 100000000L: return False return True def __repr__(self): return "CTransaction(nVersion=%i vin=%s vout=%s nLockTime=%i)" \ % (self.nVersion, repr(self.vin), repr(self.vout), self.nLockTime) class CBlockHeader(object): def __init__(self, header=None): if header is None: self.set_null() else: self.nVersion = header.nVersion self.hashPrevBlock = header.hashPrevBlock self.hashMerkleRoot = header.hashMerkleRoot self.nTime = header.nTime self.nBits = header.nBits self.nNonce = header.nNonce self.sha256 = header.sha256 self.hash = header.hash self.calc_sha256() def set_null(self): self.nVersion = 1 self.hashPrevBlock = 0 self.hashMerkleRoot = 0 self.nTime = 0 self.nBits = 0 self.nNonce = 0 self.sha256 = None self.hash = None def deserialize(self, f): self.nVersion = struct.unpack("<i", f.read(4))[0] self.hashPrevBlock = deser_uint256(f) self.hashMerkleRoot = deser_uint256(f) self.nTime = struct.unpack("<I", f.read(4))[0] self.nBits = struct.unpack("<I", f.read(4))[0] self.nNonce = struct.unpack("<I", f.read(4))[0] self.sha256 = None self.hash = None def serialize(self): r = "" r += struct.pack("<i", self.nVersion) r += ser_uint256(self.hashPrevBlock) r += ser_uint256(self.hashMerkleRoot) r += struct.pack("<I", self.nTime) r += struct.pack("<I", self.nBits) r += struct.pack("<I", self.nNonce) return r def calc_sha256(self): if self.sha256 is None: r = "" r += struct.pack("<i", self.nVersion) r += ser_uint256(self.hashPrevBlock) r += ser_uint256(self.hashMerkleRoot) r += struct.pack("<I", self.nTime) r += struct.pack("<I", self.nBits) r += struct.pack("<I", self.nNonce) self.sha256 = uint256_from_str(hash256(r)) self.hash = hash256(r)[::-1].encode('hex_codec') def rehash(self): self.sha256 = None self.calc_sha256() return self.sha256 def __repr__(self): return "CBlockHeader(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x nTime=%s nBits=%08x nNonce=%08x)" \ % (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, time.ctime(self.nTime), self.nBits, self.nNonce) class CBlock(CBlockHeader): def __init__(self, header=None): super(CBlock, self).__init__(header) self.vtx = [] def deserialize(self, f): super(CBlock, self).deserialize(f) self.vtx = deser_vector(f, CTransaction) def serialize(self): r = "" r += super(CBlock, self).serialize() r += ser_vector(self.vtx) return r def calc_merkle_root(self): hashes = [] for tx in self.vtx: tx.calc_sha256() hashes.append(ser_uint256(tx.sha256)) while len(hashes) > 1: newhashes = [] for i in xrange(0, len(hashes), 2): i2 = min(i+1, len(hashes)-1) newhashes.append(hash256(hashes[i] + hashes[i2])) hashes = newhashes return uint256_from_str(hashes[0]) def is_valid(self): self.calc_sha256() target = uint256_from_compact(self.nBits) if self.sha256 > target: return False for tx in self.vtx: if not tx.is_valid(): return False if self.calc_merkle_root() != self.hashMerkleRoot: return False return True def solve(self): self.calc_sha256() target = uint256_from_compact(self.nBits) while self.sha256 > target: self.nNonce += 1 self.rehash() def __repr__(self): return "CBlock(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x nTime=%s nBits=%08x nNonce=%08x vtx=%s)" \ % (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, time.ctime(self.nTime), self.nBits, self.nNonce, repr(self.vtx)) class CUnsignedAlert(object): def __init__(self): self.nVersion = 1 self.nRelayUntil = 0 self.nExpiration = 0 self.nID = 0 self.nCancel = 0 self.setCancel = [] self.nMinVer = 0 self.nMaxVer = 0 self.setSubVer = [] self.nPriority = 0 self.strComment = "" self.strStatusBar = "" self.strReserved = "" def deserialize(self, f): self.nVersion = struct.unpack("<i", f.read(4))[0] self.nRelayUntil = struct.unpack("<q", f.read(8))[0] self.nExpiration = struct.unpack("<q", f.read(8))[0] self.nID = struct.unpack("<i", f.read(4))[0] self.nCancel = struct.unpack("<i", f.read(4))[0] self.setCancel = deser_int_vector(f) self.nMinVer = struct.unpack("<i", f.read(4))[0] self.nMaxVer = struct.unpack("<i", f.read(4))[0] self.setSubVer = deser_string_vector(f) self.nPriority = struct.unpack("<i", f.read(4))[0] self.strComment = deser_string(f) self.strStatusBar = deser_string(f) self.strReserved = deser_string(f) def serialize(self): r = "" r += struct.pack("<i", self.nVersion) r += struct.pack("<q", self.nRelayUntil) r += struct.pack("<q", self.nExpiration) r += struct.pack("<i", self.nID) r += struct.pack("<i", self.nCancel) r += ser_int_vector(self.setCancel) r += struct.pack("<i", self.nMinVer) r += struct.pack("<i", self.nMaxVer) r += ser_string_vector(self.setSubVer) r += struct.pack("<i", self.nPriority) r += ser_string(self.strComment) r += ser_string(self.strStatusBar) r += ser_string(self.strReserved) return r def __repr__(self): return "CUnsignedAlert(nVersion %d, nRelayUntil %d, nExpiration %d, nID %d, nCancel %d, nMinVer %d, nMaxVer %d, nPriority %d, strComment %s, strStatusBar %s, strReserved %s)" \ % (self.nVersion, self.nRelayUntil, self.nExpiration, self.nID, self.nCancel, self.nMinVer, self.nMaxVer, self.nPriority, self.strComment, self.strStatusBar, self.strReserved) class CAlert(object): def __init__(self): self.vchMsg = "" self.vchSig = "" def deserialize(self, f): self.vchMsg = deser_string(f) self.vchSig = deser_string(f) def serialize(self): r = "" r += ser_string(self.vchMsg) r += ser_string(self.vchSig) return r def __repr__(self): return "CAlert(vchMsg.sz %d, vchSig.sz %d)" \ % (len(self.vchMsg), len(self.vchSig)) # Objects that correspond to messages on the wire class msg_version(object): command = "version" def __init__(self): self.nVersion = MY_VERSION self.nServices = 1 self.nTime = time.time() self.addrTo = CAddress() self.addrFrom = CAddress() self.nNonce = random.getrandbits(64) self.strSubVer = MY_SUBVERSION self.nStartingHeight = -1 def deserialize(self, f): self.nVersion = struct.unpack("<i", f.read(4))[0] if self.nVersion == 10300: self.nVersion = 300 self.nServices = struct.unpack("<Q", f.read(8))[0] self.nTime = struct.unpack("<q", f.read(8))[0] self.addrTo = CAddress() self.addrTo.deserialize(f) if self.nVersion >= 106: self.addrFrom = CAddress() self.addrFrom.deserialize(f) self.nNonce = struct.unpack("<Q", f.read(8))[0] self.strSubVer = deser_string(f) if self.nVersion >= 209: self.nStartingHeight = struct.unpack("<i", f.read(4))[0] else: self.nStartingHeight = None else: self.addrFrom = None self.nNonce = None self.strSubVer = None self.nStartingHeight = None def serialize(self): r = "" r += struct.pack("<i", self.nVersion) r += struct.pack("<Q", self.nServices) r += struct.pack("<q", self.nTime) r += self.addrTo.serialize() r += self.addrFrom.serialize() r += struct.pack("<Q", self.nNonce) r += ser_string(self.strSubVer) r += struct.pack("<i", self.nStartingHeight) return r def __repr__(self): return 'msg_version(nVersion=%i nServices=%i nTime=%s addrTo=%s addrFrom=%s nNonce=0x%016X strSubVer=%s nStartingHeight=%i)' \ % (self.nVersion, self.nServices, time.ctime(self.nTime), repr(self.addrTo), repr(self.addrFrom), self.nNonce, self.strSubVer, self.nStartingHeight) class msg_verack(object): command = "verack" def __init__(self): pass def deserialize(self, f): pass def serialize(self): return "" def __repr__(self): return "msg_verack()" class msg_addr(object): command = "addr" def __init__(self): self.addrs = [] def deserialize(self, f): self.addrs = deser_vector(f, CAddress) def serialize(self): return ser_vector(self.addrs) def __repr__(self): return "msg_addr(addrs=%s)" % (repr(self.addrs)) class msg_alert(object): command = "alert" def __init__(self): self.alert = CAlert() def deserialize(self, f): self.alert = CAlert() self.alert.deserialize(f) def serialize(self): r = "" r += self.alert.serialize() return r def __repr__(self): return "msg_alert(alert=%s)" % (repr(self.alert), ) class msg_inv(object): command = "inv" def __init__(self, inv=None): if inv is None: self.inv = [] else: self.inv = inv def deserialize(self, f): self.inv = deser_vector(f, CInv) def serialize(self): return ser_vector(self.inv) def __repr__(self): return "msg_inv(inv=%s)" % (repr(self.inv)) class msg_getdata(object): command = "getdata" def __init__(self): self.inv = [] def deserialize(self, f): self.inv = deser_vector(f, CInv) def serialize(self): return ser_vector(self.inv) def __repr__(self): return "msg_getdata(inv=%s)" % (repr(self.inv)) class msg_getblocks(object): command = "getblocks" def __init__(self): self.locator = CBlockLocator() self.hashstop = 0L def deserialize(self, f): self.locator = CBlockLocator() self.locator.deserialize(f) self.hashstop = deser_uint256(f) def serialize(self): r = "" r += self.locator.serialize() r += ser_uint256(self.hashstop) return r def __repr__(self): return "msg_getblocks(locator=%s hashstop=%064x)" \ % (repr(self.locator), self.hashstop) class msg_tx(object): command = "tx" def __init__(self, tx=CTransaction()): self.tx = tx def deserialize(self, f): self.tx.deserialize(f) def serialize(self): return self.tx.serialize() def __repr__(self): return "msg_tx(tx=%s)" % (repr(self.tx)) class msg_block(object): command = "block" def __init__(self, block=None): if block is None: self.block = CBlock() else: self.block = block def deserialize(self, f): self.block.deserialize(f) def serialize(self): return self.block.serialize() def __repr__(self): return "msg_block(block=%s)" % (repr(self.block)) class msg_getaddr(object): command = "getaddr" def __init__(self): pass def deserialize(self, f): pass def serialize(self): return "" def __repr__(self): return "msg_getaddr()" class msg_ping_prebip31(object): command = "ping" def __init__(self): pass def deserialize(self, f): pass def serialize(self): return "" def __repr__(self): return "msg_ping() (pre-bip31)" class msg_ping(object): command = "ping" def __init__(self, nonce=0L): self.nonce = nonce def deserialize(self, f): self.nonce = struct.unpack("<Q", f.read(8))[0] def serialize(self): r = "" r += struct.pack("<Q", self.nonce) return r def __repr__(self): return "msg_ping(nonce=%08x)" % self.nonce class msg_pong(object): command = "pong" def __init__(self, nonce=0L): self.nonce = nonce def deserialize(self, f): self.nonce = struct.unpack("<Q", f.read(8))[0] def serialize(self): r = "" r += struct.pack("<Q", self.nonce) return r def __repr__(self): return "msg_pong(nonce=%08x)" % self.nonce class msg_mempool(object): command = "mempool" def __init__(self): pass def deserialize(self, f): pass def serialize(self): return "" def __repr__(self): return "msg_mempool()" # getheaders message has # number of entries # vector of hashes # hash_stop (hash of last desired block header, 0 to get as many as possible) class msg_getheaders(object): command = "getheaders" def __init__(self): self.locator = CBlockLocator() self.hashstop = 0L def deserialize(self, f): self.locator = CBlockLocator() self.locator.deserialize(f) self.hashstop = deser_uint256(f) def serialize(self): r = "" r += self.locator.serialize() r += ser_uint256(self.hashstop) return r def __repr__(self): return "msg_getheaders(locator=%s, stop=%064x)" \ % (repr(self.locator), self.hashstop) # headers message has # <count> <vector of block headers> class msg_headers(object): command = "headers" def __init__(self): self.headers = [] def deserialize(self, f): # comment in bitcoind indicates these should be deserialized as blocks blocks = deser_vector(f, CBlock) for x in blocks: self.headers.append(CBlockHeader(x)) def serialize(self): blocks = [CBlock(x) for x in self.headers] return ser_vector(blocks) def __repr__(self): return "msg_headers(headers=%s)" % repr(self.headers) class msg_reject(object): command = "reject" def __init__(self): self.message = "" self.code = "" self.reason = "" self.data = 0L def deserialize(self, f): self.message = deser_string(f) self.code = struct.unpack("<B", f.read(1))[0] self.reason = deser_string(f) if (self.message == "block" or self.message == "tx"): self.data = deser_uint256(f) def serialize(self): r = ser_string(self.message) r += struct.pack("<B", self.code) r += ser_string(self.reason) if (self.message == "block" or self.message == "tx"): r += ser_uint256(self.data) return r def __repr__(self): return "msg_reject: %s %d %s [%064x]" \ % (self.message, self.code, self.reason, self.data) # This is what a callback should look like for NodeConn # Reimplement the on_* functions to provide handling for events class NodeConnCB(object): def __init__(self): self.verack_received = False # Derived classes should call this function once to set the message map # which associates the derived classes' functions to incoming messages def create_callback_map(self): self.cbmap = { "version": self.on_version, "verack": self.on_verack, "addr": self.on_addr, "alert": self.on_alert, "inv": self.on_inv, "getdata": self.on_getdata, "getblocks": self.on_getblocks, "tx": self.on_tx, "block": self.on_block, "getaddr": self.on_getaddr, "ping": self.on_ping, "pong": self.on_pong, "headers": self.on_headers, "getheaders": self.on_getheaders, "reject": self.on_reject, "mempool": self.on_mempool } def deliver(self, conn, message): with mininode_lock: try: self.cbmap[message.command](conn, message) except: print "ERROR delivering %s (%s)" % (repr(message), sys.exc_info()[0]) def on_version(self, conn, message): if message.nVersion >= 209: conn.send_message(msg_verack()) conn.ver_send = min(MY_VERSION, message.nVersion) if message.nVersion < 209: conn.ver_recv = conn.ver_send def on_verack(self, conn, message): conn.ver_recv = conn.ver_send self.verack_received = True def on_inv(self, conn, message): want = msg_getdata() for i in message.inv: if i.type != 0: want.inv.append(i) if len(want.inv): conn.send_message(want) def on_addr(self, conn, message): pass def on_alert(self, conn, message): pass def on_getdata(self, conn, message): pass def on_getblocks(self, conn, message): pass def on_tx(self, conn, message): pass def on_block(self, conn, message): pass def on_getaddr(self, conn, message): pass def on_headers(self, conn, message): pass def on_getheaders(self, conn, message): pass def on_ping(self, conn, message): if conn.ver_send > BIP0031_VERSION: conn.send_message(msg_pong(message.nonce)) def on_reject(self, conn, message): pass def on_close(self, conn): pass def on_mempool(self, conn): pass def on_pong(self, conn, message): pass # The actual NodeConn class # This class provides an interface for a p2p connection to a specified node class NodeConn(asyncore.dispatcher): messagemap = { "version": msg_version, "verack": msg_verack, "addr": msg_addr, "alert": msg_alert, "inv": msg_inv, "getdata": msg_getdata, "getblocks": msg_getblocks, "tx": msg_tx, "block": msg_block, "getaddr": msg_getaddr, "ping": msg_ping, "pong": msg_pong, "headers": msg_headers, "getheaders": msg_getheaders, "reject": msg_reject, "mempool": msg_mempool } MAGIC_BYTES = { "mainnet": "\xf9\xbe\xb4\xd9", # mainnet "testnet3": "\x0b\x11\x09\x07", # testnet3 "regtest": "\xfa\xbf\xb5\xda" # regtest } def __init__(self, dstaddr, dstport, rpc, callback, net="regtest"): asyncore.dispatcher.__init__(self, map=mininode_socket_map) self.log = logging.getLogger("NodeConn(%s:%d)" % (dstaddr, dstport)) self.dstaddr = dstaddr self.dstport = dstport self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.sendbuf = "" self.recvbuf = "" self.ver_send = 209 self.ver_recv = 209 self.last_sent = 0 self.state = "connecting" self.network = net self.cb = callback self.disconnect = False # stuff version msg into sendbuf vt = msg_version() vt.addrTo.ip = self.dstaddr vt.addrTo.port = self.dstport vt.addrFrom.ip = "0.0.0.0" vt.addrFrom.port = 0 self.send_message(vt, True) print 'MiniNode: Connecting to Bitcoin Node IP # ' + dstaddr + ':' \ + str(dstport) try: self.connect((dstaddr, dstport)) except: self.handle_close() self.rpc = rpc def show_debug_msg(self, msg): self.log.debug(msg) def handle_connect(self): self.show_debug_msg("MiniNode: Connected & Listening: \n") self.state = "connected" def handle_close(self): self.show_debug_msg("MiniNode: Closing Connection to %s:%d... " % (self.dstaddr, self.dstport)) self.state = "closed" self.recvbuf = "" self.sendbuf = "" try: self.close() except: pass self.cb.on_close(self) def handle_read(self): try: t = self.recv(8192) if len(t) > 0: self.recvbuf += t self.got_data() except: pass def readable(self): return True def writable(self): with mininode_lock: length = len(self.sendbuf) return (length > 0) def handle_write(self): with mininode_lock: try: sent = self.send(self.sendbuf) except: self.handle_close() return self.sendbuf = self.sendbuf[sent:] def got_data(self): while True: if len(self.recvbuf) < 4: return if self.recvbuf[:4] != self.MAGIC_BYTES[self.network]: raise ValueError("got garbage %s" % repr(self.recvbuf)) if self.ver_recv < 209: if len(self.recvbuf) < 4 + 12 + 4: return command = self.recvbuf[4:4+12].split("\x00", 1)[0] msglen = struct.unpack("<i", self.recvbuf[4+12:4+12+4])[0] checksum = None if len(self.recvbuf) < 4 + 12 + 4 + msglen: return msg = self.recvbuf[4+12+4:4+12+4+msglen] self.recvbuf = self.recvbuf[4+12+4+msglen:] else: if len(self.recvbuf) < 4 + 12 + 4 + 4: return command = self.recvbuf[4:4+12].split("\x00", 1)[0] msglen = struct.unpack("<i", self.recvbuf[4+12:4+12+4])[0] checksum = self.recvbuf[4+12+4:4+12+4+4] if len(self.recvbuf) < 4 + 12 + 4 + 4 + msglen: return msg = self.recvbuf[4+12+4+4:4+12+4+4+msglen] th = sha256(msg) h = sha256(th) if checksum != h[:4]: raise ValueError("got bad checksum " + repr(self.recvbuf)) self.recvbuf = self.recvbuf[4+12+4+4+msglen:] if command in self.messagemap: f = cStringIO.StringIO(msg) t = self.messagemap[command]() t.deserialize(f) self.got_message(t) else: self.show_debug_msg("Unknown command: '" + command + "' " + repr(msg)) def send_message(self, message, pushbuf=False): if self.state != "connected" and not pushbuf: return self.show_debug_msg("Send %s" % repr(message)) command = message.command data = message.serialize() tmsg = self.MAGIC_BYTES[self.network] tmsg += command tmsg += "\x00" * (12 - len(command)) tmsg += struct.pack("<I", len(data)) if self.ver_send >= 209: th = sha256(data) h = sha256(th) tmsg += h[:4] tmsg += data with mininode_lock: self.sendbuf += tmsg self.last_sent = time.time() def got_message(self, message): if message.command == "version": if message.nVersion <= BIP0031_VERSION: self.messagemap['ping'] = msg_ping_prebip31 if self.last_sent + 30 * 60 < time.time(): self.send_message(self.messagemap['ping']()) self.show_debug_msg("Recv %s" % repr(message)) self.cb.deliver(self, message) def disconnect_node(self): self.disconnect = True class NetworkThread(Thread): def run(self): while mininode_socket_map: # We check for whether to disconnect outside of the asyncore # loop to workaround the behavior of asyncore when using # select disconnected = [] for fd, obj in mininode_socket_map.items(): if obj.disconnect: disconnected.append(obj) [ obj.handle_close() for obj in disconnected ] asyncore.loop(0.1, use_poll=True, map=mininode_socket_map, count=1) # An exception we can raise if we detect a potential disconnect # (p2p or rpc) before the test is complete class EarlyDisconnectError(Exception): def __init__(self, value): self.value = value def __str__(self): return repr(self.value)
mit
[ 3, 1748, 15993, 14, 647, 446, 21158, 510, 18, 48, 2784, 12995, 13, 65, 13, 932, 199, 3, 199, 3, 17484, 1334, 314, 10697, 15, 56, 845, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 3, 199, 3, 961, 2366, 1233, 1990, 6042, 687, 1952, 84, 1858, 90, 7, 4575, 2881, 221, 12995, 13, 65, 13, 932, 12, 465, 199, 3, 1911, 315, 314, 20536, 13, 932, 5246, 402, 1455, 921, 5031, 14, 957, 15, 74, 23909, 90, 3258, 15, 647, 932, 14, 199, 3, 199, 3, 5013, 6805, 26, 376, 909, 1314, 31965, 299, 18, 80, 20170, 370, 282, 27214, 1031, 199, 3, 5013, 6805, 9956, 26, 282, 1300, 1021, 626, 23369, 314, 3217, 367, 18390, 199, 3, 3777, 13484, 543, 2784, 3788, 687, 282, 5013, 6805, 199, 3, 445, 3142, 12, 445, 10161, 12, 445, 3142, 2567, 12, 445, 8052, 607, 12, 445, 8052, 2204, 12, 5423, 4496, 26, 199, 3, 258, 666, 13955, 626, 1077, 2341, 370, 5226, 13955, 315, 199, 3, 258, 27214, 15, 1359, 22337, 199, 3, 1499, 63, 1457, 12, 1499, 63, 2347, 12, 1499, 63, 2139, 12, 5423, 16781, 199, 3, 258, 666, 13955, 626, 2954, 2784, 3788, 199, 3, 8926, 63, 10381, 477, 332, 15192, 26, 3423, 626, 2429, 16953, 15, 271, 12161, 421, 199, 646, 2702, 199, 646, 2838, 199, 646, 30328, 199, 646, 14755, 199, 646, 900, 199, 646, 984, 199, 646, 2196, 199, 646, 15073, 199, 646, 8337, 199, 504, 5796, 492, 820, 6432, 199, 504, 5796, 492, 11086, 199, 646, 2050, 199, 646, 1331, 199, 199, 34, 1772, 383, 2192, 63, 4612, 275, 1227, 993, 199, 12339, 63, 4612, 275, 1227, 4183, 221, 327, 13541, 330, 711, 13, 2192, 367, 18249, 15, 26992, 199, 12339, 63, 6348, 4612, 275, 3286, 1548, 13, 827, 15993, 13, 8234, 26, 16, 14, 16, 14, 17, 6687, 199, 199, 4283, 63, 568, 54, 63, 18101, 275, 959, 993, 199, 199, 3, 14797, 4154, 5705, 2838, 2341, 367, 30328, 12, 880, 626, 781, 883, 4426, 17639, 83, 199, 3, 26495, 334, 475, 18092, 376, 4976, 543, 11261, 376, 30328, 2838, 1380, 221, 199, 3, 1808, 3504, 9, 199, 827, 15993, 63, 3450, 63, 1130, 275, 1211, 342, 199, 199, 3, 7309, 4650, 367, 15354, 9147, 1006, 666, 2879, 3382, 314, 2784, 316, 2462, 334, 3239, 199, 3, 7220, 4436, 5084, 9, 436, 314, 2462, 3879, 314, 511, 9661, 14, 221, 2104, 17553, 3690, 12, 199, 3, 5013, 6805, 1066, 3340, 642, 4650, 18119, 28503, 316, 282, 1245, 370, 370, 282, 5013, 6805, 9956, 12, 199, 3, 436, 18119, 7791, 7003, 370, 314, 3222, 3335, 334, 262, 3222, 63, 1188, 8801, 221, 961, 199, 3, 4650, 1077, 506, 28320, 315, 314, 2462, 3879, 314, 511, 9661, 370, 31021, 199, 3, 2879, 370, 1263, 666, 5709, 543, 314, 5013, 6805, 9956, 503, 5013, 6805, 14, 199, 827, 15993, 63, 831, 275, 820, 6432, 342, 199, 199, 3, 11973, 2072, 15, 271, 12161, 7249, 199, 318, 7793, 3912, 8, 83, 304, 272, 372, 8337, 14, 1222, 360, 4835, 3912, 297, 308, 680, 5671, 342, 421, 199, 318, 2631, 3912, 8, 83, 304, 272, 372, 7793, 3912, 8, 4835, 3912, 8, 83, 430, 421, 199, 318, 477, 332, 63, 875, 8, 70, 304, 272, 302, 390, 275, 2702, 14, 5301, 6757, 34, 401, 289, 14, 739, 8, 17, 11515, 16, 61, 272, 340, 302, 390, 508, 26727, 26, 267, 302, 390, 275, 2702, 14, 5301, 6757, 40, 401, 289, 14, 739, 8, 18, 11515, 16, 61, 272, 916, 302, 390, 508, 22540, 26, 267, 302, 390, 275, 2702, 14, 5301, 6757, 41, 401, 289, 14, 739, 8, 20, 11515, 16, 61, 272, 916, 302, 390, 508, 5450, 26, 267, 302, 390, 275, 2702, 14, 5301, 6757, 49, 401, 289, 14, 739, 8, 24, 11515, 16, 61, 272, 372, 289, 14, 739, 8, 30436, 9, 421, 199, 318, 8926, 63, 875, 8, 83, 304, 272, 340, 822, 8, 83, 9, 665, 26727, 26, 267, 372, 8678, 8, 552, 8, 83, 430, 435, 308, 272, 916, 822, 8, 83, 9, 665, 378, 88, 9943, 26, 267, 372, 8678, 8, 3781, 9, 435, 2702, 14, 1389, 6757, 40, 401, 822, 8, 83, 430, 435, 308, 272, 916, 822, 8, 83, 9, 665, 378, 88, 17, 3607, 44, 26, 267, 372, 8678, 8, 8306, 9, 435, 2702, 14, 1389, 6757, 41, 401, 822, 8, 83, 430, 435, 308, 272, 372, 8678, 8, 2299, 9, 435, 2702, 14, 1389, 6757, 49, 401, 822, 8, 83, 430, 435, 308, 421, 199, 318, 477, 332, 63, 1635, 3912, 8, 70, 304, 272, 519, 275, 378, 44, 272, 367, 284, 315, 4945, 8, 24, 304, 267, 307, 275, 2702, 14, 5301, 6757, 41, 401, 289, 14, 739, 8, 20, 11515, 16, 61, 267, 519, 847, 307, 5213, 334, 73, 627, 4337, 9, 272, 372, 519, 421, 199, 318, 8926, 63, 1635, 3912, 8, 85, 304, 272, 10717, 275, 3087, 272, 367, 284, 315, 4945, 8, 24, 304, 267, 10717, 847, 2702, 14, 1389, 6757, 41, 401, 399, 1253, 378, 32158, 44, 9, 267, 399, 4331, 29, 4337, 272, 372, 10717, 421, 199, 318, 3152, 3912, 63, 504, 63, 495, 8, 83, 304, 272, 519, 275, 378, 44, 272, 307, 275, 2702, 14, 5301, 6757, 8921, 8921, 8921, 8921, 401, 308, 1491, 708, 566, 272, 367, 284, 315, 4945, 8, 24, 304, 267, 519, 847, 307, 59, 73, 61, 5213, 334, 73, 627, 4337, 9, 272, 372, 519, 421, 199, 318, 3152, 3912, 63, 504, 63, 23046, 8, 67, 304, 272, 302, 2394, 275, 334, 67, 4331, 5504, 9, 1253, 378, 9039, 272, 373, 275, 334, 67, 1253, 378, 23973, 1665, 44, 9, 5213, 334, 24, 627, 334, 31417, 446, 650, 430, 272, 372, 373, 421, 199, 318, 477, 332, 63, 4106, 8, 70, 12, 286, 304, 272, 302, 390, 275, 2702, 14, 5301, 6757, 34, 401, 289, 14, 739, 8, 17, 11515, 16, 61, 272, 340, 302, 390, 508, 26727, 26, 267, 302, 390, 275, 2702, 14, 5301, 6757, 40, 401, 289, 14, 739, 8, 18, 11515, 16, 61 ]
[ 1748, 15993, 14, 647, 446, 21158, 510, 18, 48, 2784, 12995, 13, 65, 13, 932, 199, 3, 199, 3, 17484, 1334, 314, 10697, 15, 56, 845, 2032, 4190, 12, 1937, 314, 23073, 199, 3, 570, 9685, 503, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 14, 199, 3, 199, 3, 961, 2366, 1233, 1990, 6042, 687, 1952, 84, 1858, 90, 7, 4575, 2881, 221, 12995, 13, 65, 13, 932, 12, 465, 199, 3, 1911, 315, 314, 20536, 13, 932, 5246, 402, 1455, 921, 5031, 14, 957, 15, 74, 23909, 90, 3258, 15, 647, 932, 14, 199, 3, 199, 3, 5013, 6805, 26, 376, 909, 1314, 31965, 299, 18, 80, 20170, 370, 282, 27214, 1031, 199, 3, 5013, 6805, 9956, 26, 282, 1300, 1021, 626, 23369, 314, 3217, 367, 18390, 199, 3, 3777, 13484, 543, 2784, 3788, 687, 282, 5013, 6805, 199, 3, 445, 3142, 12, 445, 10161, 12, 445, 3142, 2567, 12, 445, 8052, 607, 12, 445, 8052, 2204, 12, 5423, 4496, 26, 199, 3, 258, 666, 13955, 626, 1077, 2341, 370, 5226, 13955, 315, 199, 3, 258, 27214, 15, 1359, 22337, 199, 3, 1499, 63, 1457, 12, 1499, 63, 2347, 12, 1499, 63, 2139, 12, 5423, 16781, 199, 3, 258, 666, 13955, 626, 2954, 2784, 3788, 199, 3, 8926, 63, 10381, 477, 332, 15192, 26, 3423, 626, 2429, 16953, 15, 271, 12161, 421, 199, 646, 2702, 199, 646, 2838, 199, 646, 30328, 199, 646, 14755, 199, 646, 900, 199, 646, 984, 199, 646, 2196, 199, 646, 15073, 199, 646, 8337, 199, 504, 5796, 492, 820, 6432, 199, 504, 5796, 492, 11086, 199, 646, 2050, 199, 646, 1331, 199, 199, 34, 1772, 383, 2192, 63, 4612, 275, 1227, 993, 199, 12339, 63, 4612, 275, 1227, 4183, 221, 327, 13541, 330, 711, 13, 2192, 367, 18249, 15, 26992, 199, 12339, 63, 6348, 4612, 275, 3286, 1548, 13, 827, 15993, 13, 8234, 26, 16, 14, 16, 14, 17, 6687, 199, 199, 4283, 63, 568, 54, 63, 18101, 275, 959, 993, 199, 199, 3, 14797, 4154, 5705, 2838, 2341, 367, 30328, 12, 880, 626, 781, 883, 4426, 17639, 83, 199, 3, 26495, 334, 475, 18092, 376, 4976, 543, 11261, 376, 30328, 2838, 1380, 221, 199, 3, 1808, 3504, 9, 199, 827, 15993, 63, 3450, 63, 1130, 275, 1211, 342, 199, 199, 3, 7309, 4650, 367, 15354, 9147, 1006, 666, 2879, 3382, 314, 2784, 316, 2462, 334, 3239, 199, 3, 7220, 4436, 5084, 9, 436, 314, 2462, 3879, 314, 511, 9661, 14, 221, 2104, 17553, 3690, 12, 199, 3, 5013, 6805, 1066, 3340, 642, 4650, 18119, 28503, 316, 282, 1245, 370, 370, 282, 5013, 6805, 9956, 12, 199, 3, 436, 18119, 7791, 7003, 370, 314, 3222, 3335, 334, 262, 3222, 63, 1188, 8801, 221, 961, 199, 3, 4650, 1077, 506, 28320, 315, 314, 2462, 3879, 314, 511, 9661, 370, 31021, 199, 3, 2879, 370, 1263, 666, 5709, 543, 314, 5013, 6805, 9956, 503, 5013, 6805, 14, 199, 827, 15993, 63, 831, 275, 820, 6432, 342, 199, 199, 3, 11973, 2072, 15, 271, 12161, 7249, 199, 318, 7793, 3912, 8, 83, 304, 272, 372, 8337, 14, 1222, 360, 4835, 3912, 297, 308, 680, 5671, 342, 421, 199, 318, 2631, 3912, 8, 83, 304, 272, 372, 7793, 3912, 8, 4835, 3912, 8, 83, 430, 421, 199, 318, 477, 332, 63, 875, 8, 70, 304, 272, 302, 390, 275, 2702, 14, 5301, 6757, 34, 401, 289, 14, 739, 8, 17, 11515, 16, 61, 272, 340, 302, 390, 508, 26727, 26, 267, 302, 390, 275, 2702, 14, 5301, 6757, 40, 401, 289, 14, 739, 8, 18, 11515, 16, 61, 272, 916, 302, 390, 508, 22540, 26, 267, 302, 390, 275, 2702, 14, 5301, 6757, 41, 401, 289, 14, 739, 8, 20, 11515, 16, 61, 272, 916, 302, 390, 508, 5450, 26, 267, 302, 390, 275, 2702, 14, 5301, 6757, 49, 401, 289, 14, 739, 8, 24, 11515, 16, 61, 272, 372, 289, 14, 739, 8, 30436, 9, 421, 199, 318, 8926, 63, 875, 8, 83, 304, 272, 340, 822, 8, 83, 9, 665, 26727, 26, 267, 372, 8678, 8, 552, 8, 83, 430, 435, 308, 272, 916, 822, 8, 83, 9, 665, 378, 88, 9943, 26, 267, 372, 8678, 8, 3781, 9, 435, 2702, 14, 1389, 6757, 40, 401, 822, 8, 83, 430, 435, 308, 272, 916, 822, 8, 83, 9, 665, 378, 88, 17, 3607, 44, 26, 267, 372, 8678, 8, 8306, 9, 435, 2702, 14, 1389, 6757, 41, 401, 822, 8, 83, 430, 435, 308, 272, 372, 8678, 8, 2299, 9, 435, 2702, 14, 1389, 6757, 49, 401, 822, 8, 83, 430, 435, 308, 421, 199, 318, 477, 332, 63, 1635, 3912, 8, 70, 304, 272, 519, 275, 378, 44, 272, 367, 284, 315, 4945, 8, 24, 304, 267, 307, 275, 2702, 14, 5301, 6757, 41, 401, 289, 14, 739, 8, 20, 11515, 16, 61, 267, 519, 847, 307, 5213, 334, 73, 627, 4337, 9, 272, 372, 519, 421, 199, 318, 8926, 63, 1635, 3912, 8, 85, 304, 272, 10717, 275, 3087, 272, 367, 284, 315, 4945, 8, 24, 304, 267, 10717, 847, 2702, 14, 1389, 6757, 41, 401, 399, 1253, 378, 32158, 44, 9, 267, 399, 4331, 29, 4337, 272, 372, 10717, 421, 199, 318, 3152, 3912, 63, 504, 63, 495, 8, 83, 304, 272, 519, 275, 378, 44, 272, 307, 275, 2702, 14, 5301, 6757, 8921, 8921, 8921, 8921, 401, 308, 1491, 708, 566, 272, 367, 284, 315, 4945, 8, 24, 304, 267, 519, 847, 307, 59, 73, 61, 5213, 334, 73, 627, 4337, 9, 272, 372, 519, 421, 199, 318, 3152, 3912, 63, 504, 63, 23046, 8, 67, 304, 272, 302, 2394, 275, 334, 67, 4331, 5504, 9, 1253, 378, 9039, 272, 373, 275, 334, 67, 1253, 378, 23973, 1665, 44, 9, 5213, 334, 24, 627, 334, 31417, 446, 650, 430, 272, 372, 373, 421, 199, 318, 477, 332, 63, 4106, 8, 70, 12, 286, 304, 272, 302, 390, 275, 2702, 14, 5301, 6757, 34, 401, 289, 14, 739, 8, 17, 11515, 16, 61, 272, 340, 302, 390, 508, 26727, 26, 267, 302, 390, 275, 2702, 14, 5301, 6757, 40, 401, 289, 14, 739, 8, 18, 11515, 16, 61, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cleett/plyer
plyer/platforms/android/gps.py
3
2608
''' Android GPS ----------- ''' from plyer.facades import GPS from plyer.platforms.android import activity from jnius import autoclass, java_method, PythonJavaClass Looper = autoclass('android.os.Looper') LocationManager = autoclass('android.location.LocationManager') Context = autoclass('android.content.Context') class _LocationListener(PythonJavaClass): __javainterfaces__ = ['android/location/LocationListener'] def __init__(self, root): self.root = root super(_LocationListener, self).__init__() @java_method('(Landroid/location/Location;)V') def onLocationChanged(self, location): self.root.on_location( lat=location.getLatitude(), lon=location.getLongitude(), speed=location.getSpeed(), bearing=location.getBearing(), altitude=location.getAltitude()) @java_method('(Ljava/lang/String;)V') def onProviderEnabled(self, status): if self.root.on_status: self.root.on_status('provider-enabled', status) @java_method('(Ljava/lang/String;)V') def onProviderDisabled(self, status): if self.root.on_status: self.root.on_status('provider-disabled', status) @java_method('(Ljava/lang/String;ILandroid/os/Bundle;)V') def onStatusChanged(self, provider, status, extras): if self.root.on_status: s_status = 'unknown' if status == 0x00: s_status = 'out-of-service' elif status == 0x01: s_status = 'temporarily-unavailable' elif status == 0x02: s_status = 'available' self.root.on_status('provider-status', '{}: {}'.format( provider, s_status)) class AndroidGPS(GPS): def _configure(self): if not hasattr(self, '_location_manager'): self._location_manager = activity.getSystemService( Context.LOCATION_SERVICE) self._location_listener = _LocationListener(self) def _start(self): # XXX defaults should be configurable by the user, later providers = self._location_manager.getProviders(False).toArray() for provider in providers: self._location_manager.requestLocationUpdates( provider, 1000, # minTime, in milliseconds 1, # minDistance, in meters self._location_listener, Looper.getMainLooper()) def _stop(self): self._location_manager.removeUpdates(self._location_listener) def instance(): return AndroidGPS()
mit
[ 2344, 199, 20762, 598, 5067, 199, 13715, 199, 2344, 199, 199, 504, 299, 590, 281, 14, 12668, 65, 3424, 492, 598, 5067, 199, 504, 299, 590, 281, 14, 19601, 14, 6238, 492, 10679, 199, 504, 1335, 8445, 527, 492, 2599, 533, 12, 12120, 63, 765, 12, 2018, 12576, 2543, 199, 199, 2041, 2262, 275, 2599, 533, 360, 6238, 14, 736, 14, 2041, 2262, 358, 199, 6592, 2988, 275, 2599, 533, 360, 6238, 14, 1985, 14, 6592, 2988, 358, 199, 2998, 275, 2599, 533, 360, 6238, 14, 1317, 14, 2998, 358, 421, 199, 533, 485, 6592, 10464, 8, 4718, 12576, 2543, 304, 272, 636, 6138, 7436, 363, 275, 788, 6238, 15, 1985, 15, 6592, 10464, 418, 339, 347, 636, 826, 721, 277, 12, 1738, 304, 267, 291, 14, 1231, 275, 1738, 267, 1613, 1547, 6592, 10464, 12, 291, 2843, 826, 4533, 339, 768, 6138, 63, 765, 14097, 14752, 15, 1985, 15, 6592, 27, 9, 54, 358, 272, 347, 641, 6592, 6970, 8, 277, 12, 2909, 304, 267, 291, 14, 1231, 14, 265, 63, 1985, 8, 288, 8396, 29, 1985, 14, 362, 44, 31429, 3786, 1062, 288, 6132, 29, 1985, 14, 362, 9551, 7779, 1062, 288, 8112, 29, 1985, 14, 362, 15146, 1062, 288, 506, 9332, 29, 1985, 14, 362, 30860, 316, 1062, 288, 29534, 29, 1985, 14, 362, 2439, 7951, 1012, 339, 768, 6138, 63, 765, 14097, 24457, 15, 4159, 15, 1558, 27, 9, 54, 358, 272, 347, 641, 6663, 6589, 8, 277, 12, 2004, 304, 267, 340, 291, 14, 1231, 14, 265, 63, 1205, 26, 288, 291, 14, 1231, 14, 265, 63, 1205, 360, 3780, 13, 3827, 297, 2004, 9, 339, 768, 6138, 63, 765, 14097, 24457, 15, 4159, 15, 1558, 27, 9, 54, 358, 272, 347, 641, 6663, 15049, 8, 277, 12, 2004, 304, 267, 340, 291, 14, 1231, 14, 265, 63, 1205, 26, 288, 291, 14, 1231, 14, 265, 63, 1205, 360, 3780, 13, 7011, 297, 2004, 9, 339, 768, 6138, 63, 765, 14097, 24457, 15, 4159, 15, 1558, 27, 1193, 6238, 15, 736, 15, 12320, 27, 9, 54, 358, 272, 347, 641, 3694, 6970, 8, 277, 12, 5022, 12, 2004, 12, 13751, 304, 267, 340, 291, 14, 1231, 14, 265, 63, 1205, 26, 288, 308, 63, 1205, 275, 283, 5187, 7, 288, 340, 2004, 508, 378, 88, 383, 26, 355, 308, 63, 1205, 275, 283, 548, 13, 1618, 13, 1364, 7, 288, 916, 2004, 508, 378, 88, 614, 26, 355, 308, 63, 1205, 275, 283, 808, 269, 11406, 13, 28119, 7, 288, 916, 2004, 508, 378, 88, 996, 26, 355, 308, 63, 1205, 275, 283, 4561, 7, 288, 291, 14, 1231, 14, 265, 63, 1205, 360, 3780, 13, 1205, 297, 9005, 26, 9499, 908, 8, 355, 5022, 12, 308, 63, 1205, 430, 421, 199, 533, 14694, 26359, 8, 26359, 304, 339, 347, 485, 6472, 8, 277, 304, 267, 340, 440, 2688, 8, 277, 12, 2513, 1985, 63, 2609, 735, 288, 291, 423, 1985, 63, 2609, 275, 10679, 14, 362, 3989, 3167, 8, 490, 9470, 14, 16575, 63, 10486, 9, 288, 291, 423, 1985, 63, 9799, 275, 485, 6592, 10464, 8, 277, 9, 339, 347, 485, 928, 8, 277, 304, 267, 327, 5787, 4243, 1077, 506, 30241, 701, 314, 922, 12, 2945, 267, 18032, 275, 291, 423, 1985, 63, 2609, 14, 362, 6663, 83, 8, 797, 680, 475, 3836, 342, 267, 367, 5022, 315, 18032, 26, 288, 291, 423, 1985, 63, 2609, 14, 1069, 6592, 16083, 8, 355, 5022, 12, 355, 5198, 12, 221, 327, 1748, 1366, 12, 315, 21131, 355, 413, 12, 221, 327, 1748, 10076, 12, 315, 24808, 355, 291, 423, 1985, 63, 9799, 12, 355, 3835, 2262, 14, 362, 6756, 2041, 2262, 1012, 339, 347, 485, 2379, 8, 277, 304, 267, 291, 423, 1985, 63, 2609, 14, 2168, 16083, 8, 277, 423, 1985, 63, 9799, 9, 421, 199, 318, 1256, 837, 272, 372, 14694, 26359, 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 ]
[ 199, 20762, 598, 5067, 199, 13715, 199, 2344, 199, 199, 504, 299, 590, 281, 14, 12668, 65, 3424, 492, 598, 5067, 199, 504, 299, 590, 281, 14, 19601, 14, 6238, 492, 10679, 199, 504, 1335, 8445, 527, 492, 2599, 533, 12, 12120, 63, 765, 12, 2018, 12576, 2543, 199, 199, 2041, 2262, 275, 2599, 533, 360, 6238, 14, 736, 14, 2041, 2262, 358, 199, 6592, 2988, 275, 2599, 533, 360, 6238, 14, 1985, 14, 6592, 2988, 358, 199, 2998, 275, 2599, 533, 360, 6238, 14, 1317, 14, 2998, 358, 421, 199, 533, 485, 6592, 10464, 8, 4718, 12576, 2543, 304, 272, 636, 6138, 7436, 363, 275, 788, 6238, 15, 1985, 15, 6592, 10464, 418, 339, 347, 636, 826, 721, 277, 12, 1738, 304, 267, 291, 14, 1231, 275, 1738, 267, 1613, 1547, 6592, 10464, 12, 291, 2843, 826, 4533, 339, 768, 6138, 63, 765, 14097, 14752, 15, 1985, 15, 6592, 27, 9, 54, 358, 272, 347, 641, 6592, 6970, 8, 277, 12, 2909, 304, 267, 291, 14, 1231, 14, 265, 63, 1985, 8, 288, 8396, 29, 1985, 14, 362, 44, 31429, 3786, 1062, 288, 6132, 29, 1985, 14, 362, 9551, 7779, 1062, 288, 8112, 29, 1985, 14, 362, 15146, 1062, 288, 506, 9332, 29, 1985, 14, 362, 30860, 316, 1062, 288, 29534, 29, 1985, 14, 362, 2439, 7951, 1012, 339, 768, 6138, 63, 765, 14097, 24457, 15, 4159, 15, 1558, 27, 9, 54, 358, 272, 347, 641, 6663, 6589, 8, 277, 12, 2004, 304, 267, 340, 291, 14, 1231, 14, 265, 63, 1205, 26, 288, 291, 14, 1231, 14, 265, 63, 1205, 360, 3780, 13, 3827, 297, 2004, 9, 339, 768, 6138, 63, 765, 14097, 24457, 15, 4159, 15, 1558, 27, 9, 54, 358, 272, 347, 641, 6663, 15049, 8, 277, 12, 2004, 304, 267, 340, 291, 14, 1231, 14, 265, 63, 1205, 26, 288, 291, 14, 1231, 14, 265, 63, 1205, 360, 3780, 13, 7011, 297, 2004, 9, 339, 768, 6138, 63, 765, 14097, 24457, 15, 4159, 15, 1558, 27, 1193, 6238, 15, 736, 15, 12320, 27, 9, 54, 358, 272, 347, 641, 3694, 6970, 8, 277, 12, 5022, 12, 2004, 12, 13751, 304, 267, 340, 291, 14, 1231, 14, 265, 63, 1205, 26, 288, 308, 63, 1205, 275, 283, 5187, 7, 288, 340, 2004, 508, 378, 88, 383, 26, 355, 308, 63, 1205, 275, 283, 548, 13, 1618, 13, 1364, 7, 288, 916, 2004, 508, 378, 88, 614, 26, 355, 308, 63, 1205, 275, 283, 808, 269, 11406, 13, 28119, 7, 288, 916, 2004, 508, 378, 88, 996, 26, 355, 308, 63, 1205, 275, 283, 4561, 7, 288, 291, 14, 1231, 14, 265, 63, 1205, 360, 3780, 13, 1205, 297, 9005, 26, 9499, 908, 8, 355, 5022, 12, 308, 63, 1205, 430, 421, 199, 533, 14694, 26359, 8, 26359, 304, 339, 347, 485, 6472, 8, 277, 304, 267, 340, 440, 2688, 8, 277, 12, 2513, 1985, 63, 2609, 735, 288, 291, 423, 1985, 63, 2609, 275, 10679, 14, 362, 3989, 3167, 8, 490, 9470, 14, 16575, 63, 10486, 9, 288, 291, 423, 1985, 63, 9799, 275, 485, 6592, 10464, 8, 277, 9, 339, 347, 485, 928, 8, 277, 304, 267, 327, 5787, 4243, 1077, 506, 30241, 701, 314, 922, 12, 2945, 267, 18032, 275, 291, 423, 1985, 63, 2609, 14, 362, 6663, 83, 8, 797, 680, 475, 3836, 342, 267, 367, 5022, 315, 18032, 26, 288, 291, 423, 1985, 63, 2609, 14, 1069, 6592, 16083, 8, 355, 5022, 12, 355, 5198, 12, 221, 327, 1748, 1366, 12, 315, 21131, 355, 413, 12, 221, 327, 1748, 10076, 12, 315, 24808, 355, 291, 423, 1985, 63, 9799, 12, 355, 3835, 2262, 14, 362, 6756, 2041, 2262, 1012, 339, 347, 485, 2379, 8, 277, 304, 267, 291, 423, 1985, 63, 2609, 14, 2168, 16083, 8, 277, 423, 1985, 63, 9799, 9, 421, 199, 318, 1256, 837, 272, 372, 14694, 26359, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mrares/incubator-airflow
airflow/contrib/operators/ssh_operator.py
6
4238
# -*- coding: utf-8 -*- # # 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 base64 import b64encode from airflow import configuration from airflow.contrib.hooks.ssh_hook import SSHHook from airflow.exceptions import AirflowException from airflow.models import BaseOperator from airflow.utils.decorators import apply_defaults class SSHOperator(BaseOperator): """ SSHOperator to execute commands on given remote host using the ssh_hook. :param ssh_hook: predefined ssh_hook to use for remote execution :type ssh_hook: :class:`SSHHook` :param ssh_conn_id: connection id from airflow Connections :type ssh_conn_id: str :param remote_host: remote host to connect :type remote_host: str :param command: command to execute on remote host :type command: str :param timeout: timeout for executing the command. :type timeout: int :param do_xcom_push: return the stdout which also get set in xcom by airflow platform :type do_xcom_push: bool """ template_fields = ('command',) @apply_defaults def __init__(self, ssh_hook=None, ssh_conn_id=None, remote_host=None, command=None, timeout=10, do_xcom_push=False, *args, **kwargs): super(SSHOperator, self).__init__(*args, **kwargs) self.ssh_hook = ssh_hook self.ssh_conn_id = ssh_conn_id self.remote_host = remote_host self.command = command self.timeout = timeout self.do_xcom_push = do_xcom_push def execute(self, context): try: if self.ssh_conn_id and not self.ssh_hook: self.ssh_hook = SSHHook(ssh_conn_id=self.ssh_conn_id) if not self.ssh_hook: raise AirflowException("can not operate without ssh_hook or ssh_conn_id") if self.remote_host is not None: self.ssh_hook.remote_host = self.remote_host ssh_client = self.ssh_hook.get_conn() if not self.command: raise AirflowException("no command specified so nothing to execute here.") # Auto apply tty when its required in case of sudo get_pty = False if self.command.startswith('sudo'): get_pty = True # set timeout taken as params stdin, stdout, stderr = ssh_client.exec_command(command=self.command, get_pty=get_pty, timeout=self.timeout ) exit_status = stdout.channel.recv_exit_status() if exit_status is 0: # only returning on output if do_xcom_push is set # otherwise its not suppose to be disclosed if self.do_xcom_push: enable_pickling = configuration.getboolean('core', 'enable_xcom_pickling') if enable_pickling: return stdout.read() else: return b64encode(stdout.read()).decode('utf-8') else: error_msg = stderr.read() raise AirflowException("error running cmd: {0}, error: {1}" .format(self.command, error_msg)) except Exception as e: raise AirflowException("SSH operator error: {0}".format(str(e))) return True def tunnel(self): ssh_client = self.ssh_hook.get_conn() ssh_client.get_transport()
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 1300, 772, 492, 330, 772, 2143, 199, 199, 504, 16321, 492, 2897, 199, 504, 16321, 14, 2828, 14, 7922, 14, 5510, 63, 3664, 492, 12027, 8481, 199, 504, 16321, 14, 3924, 492, 31040, 1726, 199, 504, 16321, 14, 992, 492, 3523, 7961, 199, 504, 16321, 14, 1208, 14, 11582, 492, 4838, 63, 4322, 421, 199, 533, 32101, 2979, 529, 707, 8, 1563, 7961, 304, 339, 408, 272, 32101, 2979, 529, 707, 370, 5341, 3718, 641, 1627, 3982, 1591, 1808, 314, 8635, 63, 3664, 14, 339, 520, 635, 8635, 63, 3664, 26, 27684, 8635, 63, 3664, 370, 675, 367, 3982, 6451, 272, 520, 466, 8635, 63, 3664, 26, 520, 533, 1705, 13716, 8481, 64, 272, 520, 635, 8635, 63, 1631, 63, 344, 26, 1950, 1305, 687, 16321, 8113, 83, 272, 520, 466, 8635, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 3982, 63, 1102, 26, 3982, 1591, 370, 4907, 272, 520, 466, 3982, 63, 1102, 26, 620, 272, 520, 635, 1414, 26, 1414, 370, 5341, 641, 3982, 1591, 272, 520, 466, 1414, 26, 620, 272, 520, 635, 2653, 26, 2653, 367, 14043, 314, 1414, 14, 272, 520, 466, 2653, 26, 1109, 272, 520, 635, 886, 63, 88, 957, 63, 5335, 26, 372, 314, 3839, 1314, 2597, 664, 663, 315, 671, 957, 701, 16321, 4298, 272, 520, 466, 886, 63, 88, 957, 63, 5335, 26, 2155, 272, 408, 339, 1978, 63, 955, 275, 661, 1531, 9538, 339, 768, 4998, 63, 4322, 272, 347, 636, 826, 721, 277, 12, 326, 8635, 63, 3664, 29, 403, 12, 326, 8635, 63, 1631, 63, 344, 29, 403, 12, 326, 3982, 63, 1102, 29, 403, 12, 326, 1414, 29, 403, 12, 326, 2653, 29, 709, 12, 326, 886, 63, 88, 957, 63, 5335, 29, 797, 12, 326, 627, 589, 12, 326, 1011, 958, 304, 267, 1613, 8, 2300, 2979, 529, 707, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 5510, 63, 3664, 275, 8635, 63, 3664, 267, 291, 14, 5510, 63, 1631, 63, 344, 275, 8635, 63, 1631, 63, 344, 267, 291, 14, 3846, 63, 1102, 275, 3982, 63, 1102, 267, 291, 14, 1531, 275, 1414, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 1117, 63, 88, 957, 63, 5335, 275, 886, 63, 88, 957, 63, 5335, 339, 347, 5341, 8, 277, 12, 1067, 304, 267, 862, 26, 288, 340, 291, 14, 5510, 63, 1631, 63, 344, 436, 440, 291, 14, 5510, 63, 3664, 26, 355, 291, 14, 5510, 63, 3664, 275, 12027, 8481, 8, 5510, 63, 1631, 63, 344, 29, 277, 14, 5510, 63, 1631, 63, 344, 9, 953, 340, 440, 291, 14, 5510, 63, 3664, 26, 355, 746, 31040, 1726, 480, 2425, 440, 19218, 1928, 8635, 63, 3664, 503, 8635, 63, 1631, 63, 344, 531, 953, 340, 291, 14, 3846, 63, 1102, 365, 440, 488, 26, 355, 291, 14, 5510, 63, 3664, 14, 3846, 63, 1102, 275, 291, 14, 3846, 63, 1102, 953, 8635, 63, 1258, 275, 291, 14, 5510, 63, 3664, 14, 362, 63, 1631, 342, 953, 340, 440, 291, 14, 1531, 26, 355, 746, 31040, 1726, 480, 889, 1414, 2013, 880, 6548, 370, 5341, 2348, 2685, 953, 327, 9195, 4838, 21862, 1380, 2399, 1415, 315, 1930, 402, 14682, 288, 664, 63, 28563, 275, 756, 288, 340, 291, 14, 1531, 14, 2460, 360, 12095, 735, 355, 664, 63, 28563, 275, 715, 953, 327, 663, 2653, 9394, 465, 1862, 288, 9009, 12, 3839, 12, 4635, 275, 8635, 63, 1258, 14, 1628, 63, 1531, 8, 1531, 29, 277, 14, 1531, 12, 14663, 664, 63, 28563, 29, 362, 63, 28563, 12, 14663, 2653, 29, 277, 14, 2593, 14663, 776, 288, 4458, 63, 1205, 275, 3839, 14, 2775, 14, 7637, 63, 2224, 63, 1205, 342, 288, 340, 4458, 63, 1205, 365, 378, 26, 355, 327, 1454, 8152, 641, 1072, 340, 886, 63, 88, 957, 63, 5335, 365, 663, 355, 327, 4257, 2399, 440, 1029, 4070, 370, 506, 4339, 320, 939, 355, 340, 291, 14, 1117, 63, 88, 957, 63, 5335, 26, 490, 4756, 63, 24773, 275, 2897, 14, 30356, 360, 1018, 297, 18295, 283, 4296, 63, 88, 957, 63, 24773, 358, 490, 340, 4756, 63, 24773, 26, 717, 372, 3839, 14, 739, 342, 490, 587, 26, 717, 372, 330, 772, 2143, 8, 2703, 14, 739, 8801, 2708, 360, 1624, 13, 24, 358, 953, 587, 26, 355, 1125, 63, 1328, 275, 4635, 14, 739, 342, 355, 746, 31040, 1726, 480, 705, 3879, 2088, 26, 469, 16, 1386, 1125, 26, 469, 17, 7063, 3147, 1275, 908, 8, 277, 14, 1531, 12, 1125, 63, 1328, 430, 398, 871, 2186, 465, 325, 26, 288, 746, 31040, 1726, 480, 13716, 4182, 1125, 26, 469, 16, 5469, 908, 8, 495, 8, 69, 1724, 398, 372, 715, 339, 347, 21496, 8, 277, 304, 267, 8635, 63, 1258, 275, 291, 14, 5510, 63, 3664, 14, 362, 63, 1631, 342, 267, 8635, 63, 1258, 14, 362, 63, 5545, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 504, 1300, 772, 492, 330, 772, 2143, 199, 199, 504, 16321, 492, 2897, 199, 504, 16321, 14, 2828, 14, 7922, 14, 5510, 63, 3664, 492, 12027, 8481, 199, 504, 16321, 14, 3924, 492, 31040, 1726, 199, 504, 16321, 14, 992, 492, 3523, 7961, 199, 504, 16321, 14, 1208, 14, 11582, 492, 4838, 63, 4322, 421, 199, 533, 32101, 2979, 529, 707, 8, 1563, 7961, 304, 339, 408, 272, 32101, 2979, 529, 707, 370, 5341, 3718, 641, 1627, 3982, 1591, 1808, 314, 8635, 63, 3664, 14, 339, 520, 635, 8635, 63, 3664, 26, 27684, 8635, 63, 3664, 370, 675, 367, 3982, 6451, 272, 520, 466, 8635, 63, 3664, 26, 520, 533, 1705, 13716, 8481, 64, 272, 520, 635, 8635, 63, 1631, 63, 344, 26, 1950, 1305, 687, 16321, 8113, 83, 272, 520, 466, 8635, 63, 1631, 63, 344, 26, 620, 272, 520, 635, 3982, 63, 1102, 26, 3982, 1591, 370, 4907, 272, 520, 466, 3982, 63, 1102, 26, 620, 272, 520, 635, 1414, 26, 1414, 370, 5341, 641, 3982, 1591, 272, 520, 466, 1414, 26, 620, 272, 520, 635, 2653, 26, 2653, 367, 14043, 314, 1414, 14, 272, 520, 466, 2653, 26, 1109, 272, 520, 635, 886, 63, 88, 957, 63, 5335, 26, 372, 314, 3839, 1314, 2597, 664, 663, 315, 671, 957, 701, 16321, 4298, 272, 520, 466, 886, 63, 88, 957, 63, 5335, 26, 2155, 272, 408, 339, 1978, 63, 955, 275, 661, 1531, 9538, 339, 768, 4998, 63, 4322, 272, 347, 636, 826, 721, 277, 12, 326, 8635, 63, 3664, 29, 403, 12, 326, 8635, 63, 1631, 63, 344, 29, 403, 12, 326, 3982, 63, 1102, 29, 403, 12, 326, 1414, 29, 403, 12, 326, 2653, 29, 709, 12, 326, 886, 63, 88, 957, 63, 5335, 29, 797, 12, 326, 627, 589, 12, 326, 1011, 958, 304, 267, 1613, 8, 2300, 2979, 529, 707, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 5510, 63, 3664, 275, 8635, 63, 3664, 267, 291, 14, 5510, 63, 1631, 63, 344, 275, 8635, 63, 1631, 63, 344, 267, 291, 14, 3846, 63, 1102, 275, 3982, 63, 1102, 267, 291, 14, 1531, 275, 1414, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 1117, 63, 88, 957, 63, 5335, 275, 886, 63, 88, 957, 63, 5335, 339, 347, 5341, 8, 277, 12, 1067, 304, 267, 862, 26, 288, 340, 291, 14, 5510, 63, 1631, 63, 344, 436, 440, 291, 14, 5510, 63, 3664, 26, 355, 291, 14, 5510, 63, 3664, 275, 12027, 8481, 8, 5510, 63, 1631, 63, 344, 29, 277, 14, 5510, 63, 1631, 63, 344, 9, 953, 340, 440, 291, 14, 5510, 63, 3664, 26, 355, 746, 31040, 1726, 480, 2425, 440, 19218, 1928, 8635, 63, 3664, 503, 8635, 63, 1631, 63, 344, 531, 953, 340, 291, 14, 3846, 63, 1102, 365, 440, 488, 26, 355, 291, 14, 5510, 63, 3664, 14, 3846, 63, 1102, 275, 291, 14, 3846, 63, 1102, 953, 8635, 63, 1258, 275, 291, 14, 5510, 63, 3664, 14, 362, 63, 1631, 342, 953, 340, 440, 291, 14, 1531, 26, 355, 746, 31040, 1726, 480, 889, 1414, 2013, 880, 6548, 370, 5341, 2348, 2685, 953, 327, 9195, 4838, 21862, 1380, 2399, 1415, 315, 1930, 402, 14682, 288, 664, 63, 28563, 275, 756, 288, 340, 291, 14, 1531, 14, 2460, 360, 12095, 735, 355, 664, 63, 28563, 275, 715, 953, 327, 663, 2653, 9394, 465, 1862, 288, 9009, 12, 3839, 12, 4635, 275, 8635, 63, 1258, 14, 1628, 63, 1531, 8, 1531, 29, 277, 14, 1531, 12, 14663, 664, 63, 28563, 29, 362, 63, 28563, 12, 14663, 2653, 29, 277, 14, 2593, 14663, 776, 288, 4458, 63, 1205, 275, 3839, 14, 2775, 14, 7637, 63, 2224, 63, 1205, 342, 288, 340, 4458, 63, 1205, 365, 378, 26, 355, 327, 1454, 8152, 641, 1072, 340, 886, 63, 88, 957, 63, 5335, 365, 663, 355, 327, 4257, 2399, 440, 1029, 4070, 370, 506, 4339, 320, 939, 355, 340, 291, 14, 1117, 63, 88, 957, 63, 5335, 26, 490, 4756, 63, 24773, 275, 2897, 14, 30356, 360, 1018, 297, 18295, 283, 4296, 63, 88, 957, 63, 24773, 358, 490, 340, 4756, 63, 24773, 26, 717, 372, 3839, 14, 739, 342, 490, 587, 26, 717, 372, 330, 772, 2143, 8, 2703, 14, 739, 8801, 2708, 360, 1624, 13, 24, 358, 953, 587, 26, 355, 1125, 63, 1328, 275, 4635, 14, 739, 342, 355, 746, 31040, 1726, 480, 705, 3879, 2088, 26, 469, 16, 1386, 1125, 26, 469, 17, 7063, 3147, 1275, 908, 8, 277, 14, 1531, 12, 1125, 63, 1328, 430, 398, 871, 2186, 465, 325, 26, 288, 746, 31040, 1726, 480, 13716, 4182, 1125, 26, 469, 16, 5469, 908, 8, 495, 8, 69, 1724, 398, 372, 715, 339, 347, 21496, 8, 277, 304, 267, 8635, 63, 1258, 275, 291, 14, 5510, 63, 3664, 14, 362, 63, 1631, 342, 267, 8635, 63, 1258, 14, 362, 63, 5545, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
vertelab/odoo-smart
project_gtd/__init__.py
6
1130
# -*- 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/>. # ############################################################################## __all__ = ['project_gtd', 'wizard'] from . import project_gtd from . import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 363, 452, 363, 275, 788, 1715, 63, 71, 2076, 297, 283, 9819, 418, 199, 199, 504, 1275, 492, 2199, 63, 71, 2076, 199, 504, 1275, 492, 12262, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 363, 452, 363, 275, 788, 1715, 63, 71, 2076, 297, 283, 9819, 418, 199, 199, 504, 1275, 492, 2199, 63, 71, 2076, 199, 504, 1275, 492, 12262, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cvium/Flexget
flexget/plugins/modify/path_select.py
13
4423
from __future__ import unicode_literals, division, absolute_import import logging import os import random from collections import namedtuple from flexget import plugin from flexget.event import event from flexget.config_schema import parse_size, parse_percent from flexget.config_schema import one_or_more log = logging.getLogger('path_select') disk_stats_tuple = namedtuple( 'disk_stats', [ 'path', 'free_bytes', 'used_bytes', 'total_bytes', 'free_percent', 'used_percent' ] ) def os_disk_stats(folder): """ Return drive free, used and total bytes """ if os.name == 'nt': import ctypes free_bytes = ctypes.c_ulonglong(0) total_bytes = ctypes.c_ulonglong(0) ctypes.windll.kernel32.GetDiskFreeSpaceExW( ctypes.c_wchar_p(folder), None, ctypes.pointer(total_bytes), ctypes.pointer(free_bytes) ) return free_bytes.value, total_bytes.value else: stats = os.statvfs(folder) return stats.f_bavail * stats.f_frsize, stats.f_blocks * stats.f_frsize def disk_stats(folder): free_bytes, total_bytes = os_disk_stats(folder) used_bytes = total_bytes - free_bytes free_percent = 0.0 if total_bytes == 0 else 100 * free_bytes / total_bytes used_percent = 0.0 if total_bytes == 0 else 100 * used_bytes / total_bytes return disk_stats_tuple(folder, free_bytes, used_bytes, total_bytes, free_percent, used_percent) def _path_selector(paths, within, stat_attr): paths_stats = [disk_stats(path) for path in paths] # Sort paths by key paths_stats.sort(key=lambda p: getattr(p, stat_attr), reverse=True) valid_paths = [paths_stats[0].path] if within > 0: valid_paths.extend([ path_stat.path for path_stat in paths_stats[1:] if abs(getattr(path_stat, stat_attr) - getattr(paths_stats[0], stat_attr)) <= within ]) return random.choice(valid_paths) def select_most_free(paths, within): return _path_selector(paths, within, 'free_bytes') def select_most_used(paths, within): return _path_selector(paths, within, 'used_bytes') def select_most_free_percent(paths, within): return _path_selector(paths, within, 'free_percent') def select_most_used_percent(paths, within): return _path_selector(paths, within, 'used_percent') selector_map = { 'most_free': select_most_free, 'most_used': select_most_used, 'most_free_percent': select_most_free_percent, 'most_used_percent': select_most_used_percent, } class PluginPathSelect(object): """Allows setting a field to a folder based on it's space Path will be selected at random if multiple paths match the within Example: path_select: select: most_free_percent # or most_free, most_used, most_used_percent, has_free within: 9000 # within in MB or percent. paths: - /drive1/ - /drive2/ - /drive3/ """ schema = { 'type': 'object', 'properties': { 'select': {'type': 'string', 'enum': selector_map.keys()}, 'to_field': {'type': 'string', 'default': 'path'}, 'paths': one_or_more({'type': 'string', 'format': 'path'}), 'within': { 'oneOf': [ {'type': 'string', 'format': 'size'}, {'type': 'string', 'format': 'percent'}, ] }, }, 'required': ['paths', 'select'], 'additionalProperties': False, } @plugin.priority(250) # run before other plugins def on_task_metainfo(self, task, config): selector = selector_map[config['select']] # Convert within to bytes (int) or percent (float) within = config.get('within') if isinstance(within, basestring) and '%' in within: within = parse_percent(within) else: within = parse_size(within) path = selector(config['paths'], within=within) if path: log.debug('Path %s selected due to (%s)' % (path, config['select'])) for entry in task.all_entries: entry[config['to_field']] = path else: task.abort('Unable to select a path based on %s' % config['select']) return @event('plugin.register') def register_plugin(): plugin.register(PluginPathSelect, 'path_select', api_ver=2)
mit
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 12, 4629, 12, 3679, 63, 646, 199, 646, 2050, 199, 646, 747, 199, 646, 2196, 199, 504, 5055, 492, 12863, 199, 199, 504, 20758, 362, 492, 3589, 199, 504, 20758, 362, 14, 1430, 492, 1566, 199, 504, 20758, 362, 14, 888, 63, 3629, 492, 2198, 63, 890, 12, 2198, 63, 7045, 199, 504, 20758, 362, 14, 888, 63, 3629, 492, 1373, 63, 269, 63, 6878, 199, 199, 793, 275, 2050, 14, 5572, 360, 515, 63, 2416, 358, 421, 199, 4032, 63, 3200, 63, 2960, 275, 12863, 8, 272, 283, 4032, 63, 3200, 297, 359, 267, 283, 515, 297, 283, 4624, 63, 2394, 297, 283, 2972, 63, 2394, 297, 283, 2923, 63, 2394, 297, 283, 4624, 63, 7045, 297, 283, 2972, 63, 7045, 7, 272, 1622, 199, 9, 421, 199, 318, 747, 63, 4032, 63, 3200, 8, 3741, 304, 272, 408, 1432, 12912, 2867, 12, 1202, 436, 3141, 2783, 408, 272, 340, 747, 14, 354, 508, 283, 343, 356, 267, 492, 5577, 267, 2867, 63, 2394, 275, 5577, 14, 67, 63, 32020, 8, 16, 9, 267, 3141, 63, 2394, 275, 5577, 14, 67, 63, 32020, 8, 16, 9, 267, 5577, 14, 25522, 14, 4989, 708, 14, 1002, 10690, 10146, 7643, 920, 55, 8, 288, 5577, 14, 67, 63, 23118, 63, 80, 8, 3741, 395, 288, 488, 12, 288, 5577, 14, 3929, 8, 2923, 63, 2394, 395, 288, 5577, 14, 3929, 8, 4624, 63, 2394, 9, 267, 776, 398, 372, 2867, 63, 2394, 14, 585, 12, 3141, 63, 2394, 14, 585, 272, 587, 26, 267, 5020, 275, 747, 14, 3736, 20970, 8, 3741, 9, 267, 372, 5020, 14, 70, 63, 66, 18961, 627, 5020, 14, 70, 63, 4391, 890, 12, 5020, 14, 70, 63, 4166, 627, 5020, 14, 70, 63, 4391, 890, 421, 199, 318, 4543, 63, 3200, 8, 3741, 304, 339, 2867, 63, 2394, 12, 3141, 63, 2394, 275, 747, 63, 4032, 63, 3200, 8, 3741, 9, 272, 1202, 63, 2394, 275, 3141, 63, 2394, 446, 2867, 63, 2394, 272, 2867, 63, 7045, 275, 378, 14, 16, 340, 3141, 63, 2394, 508, 378, 587, 2948, 627, 2867, 63, 2394, 1182, 3141, 63, 2394, 272, 1202, 63, 7045, 275, 378, 14, 16, 340, 3141, 63, 2394, 508, 378, 587, 2948, 627, 1202, 63, 2394, 1182, 3141, 63, 2394, 339, 372, 4543, 63, 3200, 63, 2960, 8, 3741, 12, 2867, 63, 2394, 12, 1202, 63, 2394, 12, 3141, 63, 2394, 12, 2867, 63, 7045, 12, 1202, 63, 7045, 9, 421, 199, 318, 485, 515, 63, 6662, 8, 3771, 12, 4453, 12, 5672, 63, 962, 304, 272, 3792, 63, 3200, 275, 359, 4032, 63, 3200, 8, 515, 9, 367, 931, 315, 3792, 61, 339, 327, 16722, 3792, 701, 790, 272, 3792, 63, 3200, 14, 3191, 8, 498, 29, 2734, 299, 26, 2519, 8, 80, 12, 5672, 63, 962, 395, 3837, 29, 549, 9, 339, 1686, 63, 3771, 275, 359, 3771, 63, 3200, 59, 16, 1055, 515, 61, 339, 340, 4453, 690, 378, 26, 267, 1686, 63, 3771, 14, 2880, 779, 288, 931, 63, 3736, 14, 515, 367, 931, 63, 3736, 315, 3792, 63, 3200, 59, 17, 2938, 288, 340, 2853, 8, 5675, 8, 515, 63, 3736, 12, 5672, 63, 962, 9, 446, 2519, 8, 3771, 63, 3200, 59, 16, 467, 5672, 63, 962, 430, 2695, 4453, 267, 4794, 339, 372, 2196, 14, 5095, 8, 1078, 63, 3771, 9, 421, 199, 318, 3504, 63, 2786, 63, 4624, 8, 3771, 12, 4453, 304, 272, 372, 485, 515, 63, 6662, 8, 3771, 12, 4453, 12, 283, 4624, 63, 2394, 358, 421, 199, 318, 3504, 63, 2786, 63, 2972, 8, 3771, 12, 4453, 304, 272, 372, 485, 515, 63, 6662, 8, 3771, 12, 4453, 12, 283, 2972, 63, 2394, 358, 421, 199, 318, 3504, 63, 2786, 63, 4624, 63, 7045, 8, 3771, 12, 4453, 304, 272, 372, 485, 515, 63, 6662, 8, 3771, 12, 4453, 12, 283, 4624, 63, 7045, 358, 421, 199, 318, 3504, 63, 2786, 63, 2972, 63, 7045, 8, 3771, 12, 4453, 304, 272, 372, 485, 515, 63, 6662, 8, 3771, 12, 4453, 12, 283, 2972, 63, 7045, 358, 421, 199, 6662, 63, 1130, 275, 469, 272, 283, 2786, 63, 4624, 356, 3504, 63, 2786, 63, 4624, 12, 272, 283, 2786, 63, 2972, 356, 3504, 63, 2786, 63, 2972, 12, 272, 283, 2786, 63, 4624, 63, 7045, 356, 3504, 63, 2786, 63, 4624, 63, 7045, 12, 272, 283, 2786, 63, 2972, 63, 7045, 356, 3504, 63, 2786, 63, 2972, 63, 7045, 12, 199, 93, 421, 199, 533, 11349, 2042, 5446, 8, 785, 304, 272, 408, 19780, 4260, 282, 901, 370, 282, 4922, 4079, 641, 652, 1159, 4601, 339, 6912, 911, 506, 4895, 737, 2196, 340, 3663, 3792, 1336, 314, 4453, 339, 5679, 26, 339, 931, 63, 2416, 26, 489, 3504, 26, 4750, 63, 4624, 63, 7045, 327, 503, 4750, 63, 4624, 12, 4750, 63, 2972, 12, 4750, 63, 2972, 63, 7045, 12, 965, 63, 4624, 489, 4453, 26, 1749, 1493, 327, 4453, 315, 19487, 503, 8878, 14, 489, 3792, 26, 267, 446, 1182, 9541, 17, 15, 267, 446, 1182, 9541, 18, 15, 267, 446, 1182, 9541, 19, 15, 272, 408, 339, 4177, 275, 469, 267, 283, 466, 356, 283, 785, 297, 267, 283, 3282, 356, 469, 288, 283, 2416, 356, 791, 466, 356, 283, 875, 297, 283, 4869, 356, 9759, 63, 1130, 14, 1612, 342, 1386, 288, 283, 475, 63, 698, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 283, 515, 2267, 288, 283, 3771, 356, 1373, 63, 269, 63, 6878, 3252, 466, 356, 283, 875, 297, 283, 908, 356, 283, 515, 1604, 288, 283, 12541, 356, 469, 355, 283, 368, 3466, 356, 359, 490, 791, 466, 356, 283, 875, 297, 283, 908, 356, 283, 890, 2267, 490, 791, 466, 356, 283, 875, 297, 283, 908, 356, 283, 7045, 2267, 355, 1622, 288, 1660, 267, 1660, 267, 283, 2427, 356, 788, 3771, 297, 283, 2416, 995, 267, 283, 8460, 8516, 356, 756, 12, 272, 789, 339, 768, 2718, 14, 6693, 8, 7991, 9, 221, 327, 1255, 2544, 1163, 8963, 272, 347, 641, 63, 1765, 63, 2024, 815, 8, 277, 12, 2120, 12, 1101, 304, 398, 9759, 275, 9759, 63 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 12, 4629, 12, 3679, 63, 646, 199, 646, 2050, 199, 646, 747, 199, 646, 2196, 199, 504, 5055, 492, 12863, 199, 199, 504, 20758, 362, 492, 3589, 199, 504, 20758, 362, 14, 1430, 492, 1566, 199, 504, 20758, 362, 14, 888, 63, 3629, 492, 2198, 63, 890, 12, 2198, 63, 7045, 199, 504, 20758, 362, 14, 888, 63, 3629, 492, 1373, 63, 269, 63, 6878, 199, 199, 793, 275, 2050, 14, 5572, 360, 515, 63, 2416, 358, 421, 199, 4032, 63, 3200, 63, 2960, 275, 12863, 8, 272, 283, 4032, 63, 3200, 297, 359, 267, 283, 515, 297, 283, 4624, 63, 2394, 297, 283, 2972, 63, 2394, 297, 283, 2923, 63, 2394, 297, 283, 4624, 63, 7045, 297, 283, 2972, 63, 7045, 7, 272, 1622, 199, 9, 421, 199, 318, 747, 63, 4032, 63, 3200, 8, 3741, 304, 272, 408, 1432, 12912, 2867, 12, 1202, 436, 3141, 2783, 408, 272, 340, 747, 14, 354, 508, 283, 343, 356, 267, 492, 5577, 267, 2867, 63, 2394, 275, 5577, 14, 67, 63, 32020, 8, 16, 9, 267, 3141, 63, 2394, 275, 5577, 14, 67, 63, 32020, 8, 16, 9, 267, 5577, 14, 25522, 14, 4989, 708, 14, 1002, 10690, 10146, 7643, 920, 55, 8, 288, 5577, 14, 67, 63, 23118, 63, 80, 8, 3741, 395, 288, 488, 12, 288, 5577, 14, 3929, 8, 2923, 63, 2394, 395, 288, 5577, 14, 3929, 8, 4624, 63, 2394, 9, 267, 776, 398, 372, 2867, 63, 2394, 14, 585, 12, 3141, 63, 2394, 14, 585, 272, 587, 26, 267, 5020, 275, 747, 14, 3736, 20970, 8, 3741, 9, 267, 372, 5020, 14, 70, 63, 66, 18961, 627, 5020, 14, 70, 63, 4391, 890, 12, 5020, 14, 70, 63, 4166, 627, 5020, 14, 70, 63, 4391, 890, 421, 199, 318, 4543, 63, 3200, 8, 3741, 304, 339, 2867, 63, 2394, 12, 3141, 63, 2394, 275, 747, 63, 4032, 63, 3200, 8, 3741, 9, 272, 1202, 63, 2394, 275, 3141, 63, 2394, 446, 2867, 63, 2394, 272, 2867, 63, 7045, 275, 378, 14, 16, 340, 3141, 63, 2394, 508, 378, 587, 2948, 627, 2867, 63, 2394, 1182, 3141, 63, 2394, 272, 1202, 63, 7045, 275, 378, 14, 16, 340, 3141, 63, 2394, 508, 378, 587, 2948, 627, 1202, 63, 2394, 1182, 3141, 63, 2394, 339, 372, 4543, 63, 3200, 63, 2960, 8, 3741, 12, 2867, 63, 2394, 12, 1202, 63, 2394, 12, 3141, 63, 2394, 12, 2867, 63, 7045, 12, 1202, 63, 7045, 9, 421, 199, 318, 485, 515, 63, 6662, 8, 3771, 12, 4453, 12, 5672, 63, 962, 304, 272, 3792, 63, 3200, 275, 359, 4032, 63, 3200, 8, 515, 9, 367, 931, 315, 3792, 61, 339, 327, 16722, 3792, 701, 790, 272, 3792, 63, 3200, 14, 3191, 8, 498, 29, 2734, 299, 26, 2519, 8, 80, 12, 5672, 63, 962, 395, 3837, 29, 549, 9, 339, 1686, 63, 3771, 275, 359, 3771, 63, 3200, 59, 16, 1055, 515, 61, 339, 340, 4453, 690, 378, 26, 267, 1686, 63, 3771, 14, 2880, 779, 288, 931, 63, 3736, 14, 515, 367, 931, 63, 3736, 315, 3792, 63, 3200, 59, 17, 2938, 288, 340, 2853, 8, 5675, 8, 515, 63, 3736, 12, 5672, 63, 962, 9, 446, 2519, 8, 3771, 63, 3200, 59, 16, 467, 5672, 63, 962, 430, 2695, 4453, 267, 4794, 339, 372, 2196, 14, 5095, 8, 1078, 63, 3771, 9, 421, 199, 318, 3504, 63, 2786, 63, 4624, 8, 3771, 12, 4453, 304, 272, 372, 485, 515, 63, 6662, 8, 3771, 12, 4453, 12, 283, 4624, 63, 2394, 358, 421, 199, 318, 3504, 63, 2786, 63, 2972, 8, 3771, 12, 4453, 304, 272, 372, 485, 515, 63, 6662, 8, 3771, 12, 4453, 12, 283, 2972, 63, 2394, 358, 421, 199, 318, 3504, 63, 2786, 63, 4624, 63, 7045, 8, 3771, 12, 4453, 304, 272, 372, 485, 515, 63, 6662, 8, 3771, 12, 4453, 12, 283, 4624, 63, 7045, 358, 421, 199, 318, 3504, 63, 2786, 63, 2972, 63, 7045, 8, 3771, 12, 4453, 304, 272, 372, 485, 515, 63, 6662, 8, 3771, 12, 4453, 12, 283, 2972, 63, 7045, 358, 421, 199, 6662, 63, 1130, 275, 469, 272, 283, 2786, 63, 4624, 356, 3504, 63, 2786, 63, 4624, 12, 272, 283, 2786, 63, 2972, 356, 3504, 63, 2786, 63, 2972, 12, 272, 283, 2786, 63, 4624, 63, 7045, 356, 3504, 63, 2786, 63, 4624, 63, 7045, 12, 272, 283, 2786, 63, 2972, 63, 7045, 356, 3504, 63, 2786, 63, 2972, 63, 7045, 12, 199, 93, 421, 199, 533, 11349, 2042, 5446, 8, 785, 304, 272, 408, 19780, 4260, 282, 901, 370, 282, 4922, 4079, 641, 652, 1159, 4601, 339, 6912, 911, 506, 4895, 737, 2196, 340, 3663, 3792, 1336, 314, 4453, 339, 5679, 26, 339, 931, 63, 2416, 26, 489, 3504, 26, 4750, 63, 4624, 63, 7045, 327, 503, 4750, 63, 4624, 12, 4750, 63, 2972, 12, 4750, 63, 2972, 63, 7045, 12, 965, 63, 4624, 489, 4453, 26, 1749, 1493, 327, 4453, 315, 19487, 503, 8878, 14, 489, 3792, 26, 267, 446, 1182, 9541, 17, 15, 267, 446, 1182, 9541, 18, 15, 267, 446, 1182, 9541, 19, 15, 272, 408, 339, 4177, 275, 469, 267, 283, 466, 356, 283, 785, 297, 267, 283, 3282, 356, 469, 288, 283, 2416, 356, 791, 466, 356, 283, 875, 297, 283, 4869, 356, 9759, 63, 1130, 14, 1612, 342, 1386, 288, 283, 475, 63, 698, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 283, 515, 2267, 288, 283, 3771, 356, 1373, 63, 269, 63, 6878, 3252, 466, 356, 283, 875, 297, 283, 908, 356, 283, 515, 1604, 288, 283, 12541, 356, 469, 355, 283, 368, 3466, 356, 359, 490, 791, 466, 356, 283, 875, 297, 283, 908, 356, 283, 890, 2267, 490, 791, 466, 356, 283, 875, 297, 283, 908, 356, 283, 7045, 2267, 355, 1622, 288, 1660, 267, 1660, 267, 283, 2427, 356, 788, 3771, 297, 283, 2416, 995, 267, 283, 8460, 8516, 356, 756, 12, 272, 789, 339, 768, 2718, 14, 6693, 8, 7991, 9, 221, 327, 1255, 2544, 1163, 8963, 272, 347, 641, 63, 1765, 63, 2024, 815, 8, 277, 12, 2120, 12, 1101, 304, 398, 9759, 275, 9759, 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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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 ]
mattesno1/Sick-Beard
lib/sqlalchemy/dialects/maxdb/base.py
15
42802
# maxdb/base.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 """Support for the MaxDB database. This dialect is *not* ported to SQLAlchemy 0.6 or 0.7. This dialect is *not* tested on SQLAlchemy 0.6 or 0.7. Overview -------- The ``maxdb`` dialect is **experimental** and has only been tested on 7.6.03.007 and 7.6.00.037. Of these, **only 7.6.03.007 will work** with SQLAlchemy's ORM. The earlier version has severe ``LEFT JOIN`` limitations and will return incorrect results from even very simple ORM queries. Only the native Python DB-API is currently supported. ODBC driver support is a future enhancement. Connecting ---------- The username is case-sensitive. If you usually connect to the database with sqlcli and other tools in lower case, you likely need to use upper case for DB-API. Implementation Notes -------------------- With the 7.6.00.37 driver and Python 2.5, it seems that all DB-API generated exceptions are broken and can cause Python to crash. For 'somecol.in_([])' to work, the IN operator's generation must be changed to cast 'NULL' to a numeric, i.e. NUM(NULL). The DB-API doesn't accept a bind parameter there, so that particular generation must inline the NULL value, which depends on [ticket:807]. The DB-API is very picky about where bind params may be used in queries. Bind params for some functions (e.g. MOD) need type information supplied. The dialect does not yet do this automatically. Max will occasionally throw up 'bad sql, compile again' exceptions for perfectly valid SQL. The dialect does not currently handle these, more research is needed. MaxDB 7.5 and Sap DB <= 7.4 reportedly do not support schemas. A very slightly different version of this dialect would be required to support those versions, and can easily be added if there is demand. Some other required components such as an Max-aware 'old oracle style' join compiler (thetas with (+) outer indicators) are already done and available for integration- email the devel list if you're interested in working on this. Versions tested: 7.6.03.07 and 7.6.00.37, native Python DB-API * MaxDB has severe limitations on OUTER JOINs, which are essential to ORM eager loading. And rather than raise an error if a SELECT can't be serviced, the database simply returns incorrect results. * Version 7.6.03.07 seems to JOIN properly, however the docs do not show the OUTER restrictions being lifted (as of this writing), and no changelog is available to confirm either. If you are using a different server version and your tasks require the ORM or any semi-advanced SQL through the SQL layer, running the SQLAlchemy test suite against your database is HIGHLY recommended before you begin. * Version 7.6.00.37 is LHS/RHS sensitive in `FROM lhs LEFT OUTER JOIN rhs ON lhs.col=rhs.col` vs `rhs.col=lhs.col`! * Version 7.6.00.37 is confused by `SELECT DISTINCT col as alias FROM t ORDER BY col` - these aliased, DISTINCT, ordered queries need to be re-written to order by the alias name. * Version 7.6.x supports creating a SAVEPOINT but not its RELEASE. * MaxDB supports autoincrement-style columns (DEFAULT SERIAL) and independent sequences. When including a DEFAULT SERIAL column in an insert, 0 needs to be inserted rather than NULL to generate a value. * MaxDB supports ANSI and "old Oracle style" theta joins with (+) outer join indicators. * The SQLAlchemy dialect is schema-aware and probably won't function correctly on server versions (pre-7.6?). Support for schema-less server versions could be added if there's call. * ORDER BY is not supported in subqueries. LIMIT is not supported in subqueries. In 7.6.00.37, TOP does work in subqueries, but without limit not so useful. OFFSET does not work in 7.6 despite being in the docs. Row number tricks in WHERE via ROWNO may be possible but it only seems to allow less-than comparison! * Version 7.6.03.07 can't LIMIT if a derived table is in FROM: `SELECT * FROM (SELECT * FROM a) LIMIT 2` * MaxDB does not support sql's CAST and can only usefullly cast two types. There isn't much implicit type conversion, so be precise when creating `PassiveDefaults` in DDL generation: `'3'` and `3` aren't the same. sapdb.dbapi ^^^^^^^^^^^ * As of 2007-10-22 the Python 2.4 and 2.5 compatible versions of the DB-API are no longer available. A forum posting at SAP states that the Python driver will be available again "in the future". The last release from MySQL AB works if you can find it. * sequence.NEXTVAL skips every other value! * No rowcount for executemany() * If an INSERT into a table with a DEFAULT SERIAL column inserts the results of a function `INSERT INTO t VALUES (LENGTH('foo'))`, the cursor won't have the serial id. It needs to be manually yanked from tablename.CURRVAL. * Super-duper picky about where bind params can be placed. Not smart about converting Python types for some functions, such as `MOD(5, ?)`. * LONG (text, binary) values in result sets are read-once. The dialect uses a caching RowProxy when these types are present. * Connection objects seem like they want to be either `close()`d or garbage collected, but not both. There's a warning issued but it seems harmless. """ import datetime, itertools, re from sqlalchemy import exc, schema, sql, util, processors from sqlalchemy.sql import operators as sql_operators, expression as sql_expr from sqlalchemy.sql import compiler, visitors from sqlalchemy.engine import base as engine_base, default, reflection from sqlalchemy import types as sqltypes class _StringType(sqltypes.String): _type = None def __init__(self, length=None, encoding=None, **kw): super(_StringType, self).__init__(length=length, **kw) self.encoding = encoding def bind_processor(self, dialect): if self.encoding == 'unicode': return None else: def process(value): if isinstance(value, unicode): return value.encode(dialect.encoding) else: return value return process def result_processor(self, dialect, coltype): #XXX: this code is probably very slow and one should try (if at all # possible) to determine the correct code path on a per-connection # basis (ie, here in result_processor, instead of inside the processor # function itself) and probably also use a few generic # processors, or possibly per query (though there is no mechanism # for that yet). def process(value): while True: if value is None: return None elif isinstance(value, unicode): return value elif isinstance(value, str): if self.convert_unicode or dialect.convert_unicode: return value.decode(dialect.encoding) else: return value elif hasattr(value, 'read'): # some sort of LONG, snarf and retry value = value.read(value.remainingLength()) continue else: # unexpected type, return as-is return value return process class MaxString(_StringType): _type = 'VARCHAR' class MaxUnicode(_StringType): _type = 'VARCHAR' def __init__(self, length=None, **kw): kw['encoding'] = 'unicode' super(MaxUnicode, self).__init__(length=length, **kw) class MaxChar(_StringType): _type = 'CHAR' class MaxText(_StringType): _type = 'LONG' def __init__(self, length=None, **kw): super(MaxText, self).__init__(length, **kw) def get_col_spec(self): spec = 'LONG' if self.encoding is not None: spec = ' '.join((spec, self.encoding)) elif self.convert_unicode: spec = ' '.join((spec, 'UNICODE')) return spec class MaxNumeric(sqltypes.Numeric): """The FIXED (also NUMERIC, DECIMAL) data type.""" def __init__(self, precision=None, scale=None, **kw): kw.setdefault('asdecimal', True) super(MaxNumeric, self).__init__(scale=scale, precision=precision, **kw) def bind_processor(self, dialect): return None class MaxTimestamp(sqltypes.DateTime): def bind_processor(self, dialect): def process(value): if value is None: return None elif isinstance(value, basestring): return value elif dialect.datetimeformat == 'internal': ms = getattr(value, 'microsecond', 0) return value.strftime("%Y%m%d%H%M%S" + ("%06u" % ms)) elif dialect.datetimeformat == 'iso': ms = getattr(value, 'microsecond', 0) return value.strftime("%Y-%m-%d %H:%M:%S." + ("%06u" % ms)) else: raise exc.InvalidRequestError( "datetimeformat '%s' is not supported." % ( dialect.datetimeformat,)) return process def result_processor(self, dialect, coltype): if dialect.datetimeformat == 'internal': def process(value): if value is None: return None else: return datetime.datetime( *[int(v) for v in (value[0:4], value[4:6], value[6:8], value[8:10], value[10:12], value[12:14], value[14:])]) elif dialect.datetimeformat == 'iso': def process(value): if value is None: return None else: return datetime.datetime( *[int(v) for v in (value[0:4], value[5:7], value[8:10], value[11:13], value[14:16], value[17:19], value[20:])]) else: raise exc.InvalidRequestError( "datetimeformat '%s' is not supported." % dialect.datetimeformat) return process class MaxDate(sqltypes.Date): def bind_processor(self, dialect): def process(value): if value is None: return None elif isinstance(value, basestring): return value elif dialect.datetimeformat == 'internal': return value.strftime("%Y%m%d") elif dialect.datetimeformat == 'iso': return value.strftime("%Y-%m-%d") else: raise exc.InvalidRequestError( "datetimeformat '%s' is not supported." % ( dialect.datetimeformat,)) return process def result_processor(self, dialect, coltype): if dialect.datetimeformat == 'internal': def process(value): if value is None: return None else: return datetime.date(int(value[0:4]), int(value[4:6]), int(value[6:8])) elif dialect.datetimeformat == 'iso': def process(value): if value is None: return None else: return datetime.date(int(value[0:4]), int(value[5:7]), int(value[8:10])) else: raise exc.InvalidRequestError( "datetimeformat '%s' is not supported." % dialect.datetimeformat) return process class MaxTime(sqltypes.Time): def bind_processor(self, dialect): def process(value): if value is None: return None elif isinstance(value, basestring): return value elif dialect.datetimeformat == 'internal': return value.strftime("%H%M%S") elif dialect.datetimeformat == 'iso': return value.strftime("%H-%M-%S") else: raise exc.InvalidRequestError( "datetimeformat '%s' is not supported." % ( dialect.datetimeformat,)) return process def result_processor(self, dialect, coltype): if dialect.datetimeformat == 'internal': def process(value): if value is None: return None else: return datetime.time(int(value[0:4]), int(value[4:6]), int(value[6:8])) elif dialect.datetimeformat == 'iso': def process(value): if value is None: return None else: return datetime.time(int(value[0:4]), int(value[5:7]), int(value[8:10])) else: raise exc.InvalidRequestError( "datetimeformat '%s' is not supported." % dialect.datetimeformat) return process class MaxBlob(sqltypes.LargeBinary): def bind_processor(self, dialect): return processors.to_str def result_processor(self, dialect, coltype): def process(value): if value is None: return None else: return value.read(value.remainingLength()) return process class MaxDBTypeCompiler(compiler.GenericTypeCompiler): def _string_spec(self, string_spec, type_): if type_.length is None: spec = 'LONG' else: spec = '%s(%s)' % (string_spec, type_.length) if getattr(type_, 'encoding'): spec = ' '.join([spec, getattr(type_, 'encoding').upper()]) return spec def visit_text(self, type_): spec = 'LONG' if getattr(type_, 'encoding', None): spec = ' '.join((spec, type_.encoding)) elif type_.convert_unicode: spec = ' '.join((spec, 'UNICODE')) return spec def visit_char(self, type_): return self._string_spec("CHAR", type_) def visit_string(self, type_): return self._string_spec("VARCHAR", type_) def visit_large_binary(self, type_): return "LONG BYTE" def visit_numeric(self, type_): if type_.scale and type_.precision: return 'FIXED(%s, %s)' % (type_.precision, type_.scale) elif type_.precision: return 'FIXED(%s)' % type_.precision else: return 'INTEGER' def visit_BOOLEAN(self, type_): return "BOOLEAN" colspecs = { sqltypes.Numeric: MaxNumeric, sqltypes.DateTime: MaxTimestamp, sqltypes.Date: MaxDate, sqltypes.Time: MaxTime, sqltypes.String: MaxString, sqltypes.Unicode:MaxUnicode, sqltypes.LargeBinary: MaxBlob, sqltypes.Text: MaxText, sqltypes.CHAR: MaxChar, sqltypes.TIMESTAMP: MaxTimestamp, sqltypes.BLOB: MaxBlob, sqltypes.Unicode: MaxUnicode, } ischema_names = { 'boolean': sqltypes.BOOLEAN, 'char': sqltypes.CHAR, 'character': sqltypes.CHAR, 'date': sqltypes.DATE, 'fixed': sqltypes.Numeric, 'float': sqltypes.FLOAT, 'int': sqltypes.INT, 'integer': sqltypes.INT, 'long binary': sqltypes.BLOB, 'long unicode': sqltypes.Text, 'long': sqltypes.Text, 'long': sqltypes.Text, 'smallint': sqltypes.SmallInteger, 'time': sqltypes.Time, 'timestamp': sqltypes.TIMESTAMP, 'varchar': sqltypes.VARCHAR, } # TODO: migrate this to sapdb.py class MaxDBExecutionContext(default.DefaultExecutionContext): def post_exec(self): # DB-API bug: if there were any functions as values, # then do another select and pull CURRVAL from the # autoincrement column's implicit sequence... ugh if self.compiled.isinsert and not self.executemany: table = self.compiled.statement.table index, serial_col = _autoserial_column(table) if serial_col and (not self.compiled._safeserial or not(self._last_inserted_ids) or self._last_inserted_ids[index] in (None, 0)): if table.schema: sql = "SELECT %s.CURRVAL FROM DUAL" % ( self.compiled.preparer.format_table(table)) else: sql = "SELECT CURRENT_SCHEMA.%s.CURRVAL FROM DUAL" % ( self.compiled.preparer.format_table(table)) rs = self.cursor.execute(sql) id = rs.fetchone()[0] if not self._last_inserted_ids: # This shouldn't ever be > 1? Right? self._last_inserted_ids = \ [None] * len(table.primary_key.columns) self._last_inserted_ids[index] = id super(MaxDBExecutionContext, self).post_exec() def get_result_proxy(self): if self.cursor.description is not None: for column in self.cursor.description: if column[1] in ('Long Binary', 'Long', 'Long Unicode'): return MaxDBResultProxy(self) return engine_base.ResultProxy(self) @property def rowcount(self): if hasattr(self, '_rowcount'): return self._rowcount else: return self.cursor.rowcount def fire_sequence(self, seq): if seq.optional: return None return self._execute_scalar("SELECT %s.NEXTVAL FROM DUAL" % ( self.dialect.identifier_preparer.format_sequence(seq))) class MaxDBCachedColumnRow(engine_base.RowProxy): """A RowProxy that only runs result_processors once per column.""" def __init__(self, parent, row): super(MaxDBCachedColumnRow, self).__init__(parent, row) self.columns = {} self._row = row self._parent = parent def _get_col(self, key): if key not in self.columns: self.columns[key] = self._parent._get_col(self._row, key) return self.columns[key] def __iter__(self): for i in xrange(len(self._row)): yield self._get_col(i) def __repr__(self): return repr(list(self)) def __eq__(self, other): return ((other is self) or (other == tuple([self._get_col(key) for key in xrange(len(self._row))]))) def __getitem__(self, key): if isinstance(key, slice): indices = key.indices(len(self._row)) return tuple([self._get_col(i) for i in xrange(*indices)]) else: return self._get_col(key) def __getattr__(self, name): try: return self._get_col(name) except KeyError: raise AttributeError(name) class MaxDBResultProxy(engine_base.ResultProxy): _process_row = MaxDBCachedColumnRow class MaxDBCompiler(compiler.SQLCompiler): function_conversion = { 'CURRENT_DATE': 'DATE', 'CURRENT_TIME': 'TIME', 'CURRENT_TIMESTAMP': 'TIMESTAMP', } # These functions must be written without parens when called with no # parameters. e.g. 'SELECT DATE FROM DUAL' not 'SELECT DATE() FROM DUAL' bare_functions = set([ 'CURRENT_SCHEMA', 'DATE', 'FALSE', 'SYSDBA', 'TIME', 'TIMESTAMP', 'TIMEZONE', 'TRANSACTION', 'TRUE', 'USER', 'UID', 'USERGROUP', 'UTCDATE', 'UTCDIFF']) def visit_mod(self, binary, **kw): return "mod(%s, %s)" % \ (self.process(binary.left), self.process(binary.right)) def default_from(self): return ' FROM DUAL' def for_update_clause(self, select): clause = select.for_update if clause is True: return " WITH LOCK EXCLUSIVE" elif clause is None: return "" elif clause == "read": return " WITH LOCK" elif clause == "ignore": return " WITH LOCK (IGNORE) EXCLUSIVE" elif clause == "nowait": return " WITH LOCK (NOWAIT) EXCLUSIVE" elif isinstance(clause, basestring): return " WITH LOCK %s" % clause.upper() elif not clause: return "" else: return " WITH LOCK EXCLUSIVE" def function_argspec(self, fn, **kw): if fn.name.upper() in self.bare_functions: return "" elif len(fn.clauses) > 0: return compiler.SQLCompiler.function_argspec(self, fn, **kw) else: return "" def visit_function(self, fn, **kw): transform = self.function_conversion.get(fn.name.upper(), None) if transform: fn = fn._clone() fn.name = transform return super(MaxDBCompiler, self).visit_function(fn, **kw) def visit_cast(self, cast, **kwargs): # MaxDB only supports casts * to NUMERIC, * to VARCHAR or # date/time to VARCHAR. Casts of LONGs will fail. if isinstance(cast.type, (sqltypes.Integer, sqltypes.Numeric)): return "NUM(%s)" % self.process(cast.clause) elif isinstance(cast.type, sqltypes.String): return "CHR(%s)" % self.process(cast.clause) else: return self.process(cast.clause) def visit_sequence(self, sequence): if sequence.optional: return None else: return ( self.dialect.identifier_preparer.format_sequence(sequence) + ".NEXTVAL") class ColumnSnagger(visitors.ClauseVisitor): def __init__(self): self.count = 0 self.column = None def visit_column(self, column): self.column = column self.count += 1 def _find_labeled_columns(self, columns, use_labels=False): labels = {} for column in columns: if isinstance(column, basestring): continue snagger = self.ColumnSnagger() snagger.traverse(column) if snagger.count == 1: if isinstance(column, sql_expr._Label): labels[unicode(snagger.column)] = column.name elif use_labels: labels[unicode(snagger.column)] = column._label return labels def order_by_clause(self, select, **kw): order_by = self.process(select._order_by_clause, **kw) # ORDER BY clauses in DISTINCT queries must reference aliased # inner columns by alias name, not true column name. if order_by and getattr(select, '_distinct', False): labels = self._find_labeled_columns(select.inner_columns, select.use_labels) if labels: for needs_alias in labels.keys(): r = re.compile(r'(^| )(%s)(,| |$)' % re.escape(needs_alias)) order_by = r.sub((r'\1%s\3' % labels[needs_alias]), order_by) # No ORDER BY in subqueries. if order_by: if self.is_subquery(): # It's safe to simply drop the ORDER BY if there is no # LIMIT. Right? Other dialects seem to get away with # dropping order. if select._limit: raise exc.CompileError( "MaxDB does not support ORDER BY in subqueries") else: return "" return " ORDER BY " + order_by else: return "" def get_select_precolumns(self, select): # Convert a subquery's LIMIT to TOP sql = select._distinct and 'DISTINCT ' or '' if self.is_subquery() and select._limit: if select._offset: raise exc.InvalidRequestError( 'MaxDB does not support LIMIT with an offset.') sql += 'TOP %s ' % select._limit return sql def limit_clause(self, select): # The docs say offsets are supported with LIMIT. But they're not. # TODO: maybe emulate by adding a ROWNO/ROWNUM predicate? # TODO: does MaxDB support bind params for LIMIT / TOP ? if self.is_subquery(): # sub queries need TOP return '' elif select._offset: raise exc.InvalidRequestError( 'MaxDB does not support LIMIT with an offset.') else: return ' \n LIMIT %s' % (select._limit,) def visit_insert(self, insert): self.isinsert = True self._safeserial = True colparams = self._get_colparams(insert) for value in (insert.parameters or {}).itervalues(): if isinstance(value, sql_expr.Function): self._safeserial = False break return ''.join(('INSERT INTO ', self.preparer.format_table(insert.table), ' (', ', '.join([self.preparer.format_column(c[0]) for c in colparams]), ') VALUES (', ', '.join([c[1] for c in colparams]), ')')) class MaxDBIdentifierPreparer(compiler.IdentifierPreparer): reserved_words = set([ 'abs', 'absolute', 'acos', 'adddate', 'addtime', 'all', 'alpha', 'alter', 'any', 'ascii', 'asin', 'atan', 'atan2', 'avg', 'binary', 'bit', 'boolean', 'byte', 'case', 'ceil', 'ceiling', 'char', 'character', 'check', 'chr', 'column', 'concat', 'constraint', 'cos', 'cosh', 'cot', 'count', 'cross', 'curdate', 'current', 'curtime', 'database', 'date', 'datediff', 'day', 'dayname', 'dayofmonth', 'dayofweek', 'dayofyear', 'dec', 'decimal', 'decode', 'default', 'degrees', 'delete', 'digits', 'distinct', 'double', 'except', 'exists', 'exp', 'expand', 'first', 'fixed', 'float', 'floor', 'for', 'from', 'full', 'get_objectname', 'get_schema', 'graphic', 'greatest', 'group', 'having', 'hex', 'hextoraw', 'hour', 'ifnull', 'ignore', 'index', 'initcap', 'inner', 'insert', 'int', 'integer', 'internal', 'intersect', 'into', 'join', 'key', 'last', 'lcase', 'least', 'left', 'length', 'lfill', 'list', 'ln', 'locate', 'log', 'log10', 'long', 'longfile', 'lower', 'lpad', 'ltrim', 'makedate', 'maketime', 'mapchar', 'max', 'mbcs', 'microsecond', 'min', 'minute', 'mod', 'month', 'monthname', 'natural', 'nchar', 'next', 'no', 'noround', 'not', 'now', 'null', 'num', 'numeric', 'object', 'of', 'on', 'order', 'packed', 'pi', 'power', 'prev', 'primary', 'radians', 'real', 'reject', 'relative', 'replace', 'rfill', 'right', 'round', 'rowid', 'rowno', 'rpad', 'rtrim', 'second', 'select', 'selupd', 'serial', 'set', 'show', 'sign', 'sin', 'sinh', 'smallint', 'some', 'soundex', 'space', 'sqrt', 'stamp', 'statistics', 'stddev', 'subdate', 'substr', 'substring', 'subtime', 'sum', 'sysdba', 'table', 'tan', 'tanh', 'time', 'timediff', 'timestamp', 'timezone', 'to', 'toidentifier', 'transaction', 'translate', 'trim', 'trunc', 'truncate', 'ucase', 'uid', 'unicode', 'union', 'update', 'upper', 'user', 'usergroup', 'using', 'utcdate', 'utcdiff', 'value', 'values', 'varchar', 'vargraphic', 'variance', 'week', 'weekofyear', 'when', 'where', 'with', 'year', 'zoned' ]) def _normalize_name(self, name): if name is None: return None if name.isupper(): lc_name = name.lower() if not self._requires_quotes(lc_name): return lc_name return name def _denormalize_name(self, name): if name is None: return None elif (name.islower() and not self._requires_quotes(name)): return name.upper() else: return name def _maybe_quote_identifier(self, name): if self._requires_quotes(name): return self.quote_identifier(name) else: return name class MaxDBDDLCompiler(compiler.DDLCompiler): def get_column_specification(self, column, **kw): colspec = [self.preparer.format_column(column), self.dialect.type_compiler.process(column.type)] if not column.nullable: colspec.append('NOT NULL') default = column.default default_str = self.get_column_default_string(column) # No DDL default for columns specified with non-optional sequence- # this defaulting behavior is entirely client-side. (And as a # consequence, non-reflectable.) if (default and isinstance(default, schema.Sequence) and not default.optional): pass # Regular default elif default_str is not None: colspec.append('DEFAULT %s' % default_str) # Assign DEFAULT SERIAL heuristically elif column.primary_key and column.autoincrement: # For SERIAL on a non-primary key member, use # DefaultClause(text('SERIAL')) try: first = [c for c in column.table.primary_key.columns if (c.autoincrement and (isinstance(c.type, sqltypes.Integer) or (isinstance(c.type, MaxNumeric) and c.type.precision)) and not c.foreign_keys)].pop(0) if column is first: colspec.append('DEFAULT SERIAL') except IndexError: pass return ' '.join(colspec) def get_column_default_string(self, column): if isinstance(column.server_default, schema.DefaultClause): if isinstance(column.default.arg, basestring): if isinstance(column.type, sqltypes.Integer): return str(column.default.arg) else: return "'%s'" % column.default.arg else: return unicode(self._compile(column.default.arg, None)) else: return None def visit_create_sequence(self, create): """Creates a SEQUENCE. TODO: move to module doc? start With an integer value, set the START WITH option. increment An integer value to increment by. Default is the database default. maxdb_minvalue maxdb_maxvalue With an integer value, sets the corresponding sequence option. maxdb_no_minvalue maxdb_no_maxvalue Defaults to False. If true, sets the corresponding sequence option. maxdb_cycle Defaults to False. If true, sets the CYCLE option. maxdb_cache With an integer value, sets the CACHE option. maxdb_no_cache Defaults to False. If true, sets NOCACHE. """ sequence = create.element if (not sequence.optional and (not self.checkfirst or not self.dialect.has_sequence(self.connection, sequence.name))): ddl = ['CREATE SEQUENCE', self.preparer.format_sequence(sequence)] sequence.increment = 1 if sequence.increment is not None: ddl.extend(('INCREMENT BY', str(sequence.increment))) if sequence.start is not None: ddl.extend(('START WITH', str(sequence.start))) opts = dict([(pair[0][6:].lower(), pair[1]) for pair in sequence.kwargs.items() if pair[0].startswith('maxdb_')]) if 'maxvalue' in opts: ddl.extend(('MAXVALUE', str(opts['maxvalue']))) elif opts.get('no_maxvalue', False): ddl.append('NOMAXVALUE') if 'minvalue' in opts: ddl.extend(('MINVALUE', str(opts['minvalue']))) elif opts.get('no_minvalue', False): ddl.append('NOMINVALUE') if opts.get('cycle', False): ddl.append('CYCLE') if 'cache' in opts: ddl.extend(('CACHE', str(opts['cache']))) elif opts.get('no_cache', False): ddl.append('NOCACHE') return ' '.join(ddl) class MaxDBDialect(default.DefaultDialect): name = 'maxdb' supports_alter = True supports_unicode_statements = True max_identifier_length = 32 supports_sane_rowcount = True supports_sane_multi_rowcount = False preparer = MaxDBIdentifierPreparer statement_compiler = MaxDBCompiler ddl_compiler = MaxDBDDLCompiler execution_ctx_cls = MaxDBExecutionContext ported_sqla_06 = False colspecs = colspecs ischema_names = ischema_names # MaxDB-specific datetimeformat = 'internal' def __init__(self, _raise_known_sql_errors=False, **kw): super(MaxDBDialect, self).__init__(**kw) self._raise_known = _raise_known_sql_errors if self.dbapi is None: self.dbapi_type_map = {} else: self.dbapi_type_map = { 'Long Binary': MaxBlob(), 'Long byte_t': MaxBlob(), 'Long Unicode': MaxText(), 'Timestamp': MaxTimestamp(), 'Date': MaxDate(), 'Time': MaxTime(), datetime.datetime: MaxTimestamp(), datetime.date: MaxDate(), datetime.time: MaxTime(), } def do_execute(self, cursor, statement, parameters, context=None): res = cursor.execute(statement, parameters) if isinstance(res, int) and context is not None: context._rowcount = res def do_release_savepoint(self, connection, name): # Does MaxDB truly support RELEASE SAVEPOINT <id>? All my attempts # produce "SUBTRANS COMMIT/ROLLBACK not allowed without SUBTRANS # BEGIN SQLSTATE: I7065" # Note that ROLLBACK TO works fine. In theory, a RELEASE should # just free up some transactional resources early, before the overall # COMMIT/ROLLBACK so omitting it should be relatively ok. pass def _get_default_schema_name(self, connection): return self.identifier_preparer._normalize_name( connection.execute( 'SELECT CURRENT_SCHEMA FROM DUAL').scalar()) def has_table(self, connection, table_name, schema=None): denormalize = self.identifier_preparer._denormalize_name bind = [denormalize(table_name)] if schema is None: sql = ("SELECT tablename FROM TABLES " "WHERE TABLES.TABLENAME=? AND" " TABLES.SCHEMANAME=CURRENT_SCHEMA ") else: sql = ("SELECT tablename FROM TABLES " "WHERE TABLES.TABLENAME = ? AND" " TABLES.SCHEMANAME=? ") bind.append(denormalize(schema)) rp = connection.execute(sql, bind) return bool(rp.first()) @reflection.cache def get_table_names(self, connection, schema=None, **kw): if schema is None: sql = (" SELECT TABLENAME FROM TABLES WHERE " " SCHEMANAME=CURRENT_SCHEMA ") rs = connection.execute(sql) else: sql = (" SELECT TABLENAME FROM TABLES WHERE " " SCHEMANAME=? ") matchname = self.identifier_preparer._denormalize_name(schema) rs = connection.execute(sql, matchname) normalize = self.identifier_preparer._normalize_name return [normalize(row[0]) for row in rs] def reflecttable(self, connection, table, include_columns): denormalize = self.identifier_preparer._denormalize_name normalize = self.identifier_preparer._normalize_name st = ('SELECT COLUMNNAME, MODE, DATATYPE, CODETYPE, LEN, DEC, ' ' NULLABLE, "DEFAULT", DEFAULTFUNCTION ' 'FROM COLUMNS ' 'WHERE TABLENAME=? AND SCHEMANAME=%s ' 'ORDER BY POS') fk = ('SELECT COLUMNNAME, FKEYNAME, ' ' REFSCHEMANAME, REFTABLENAME, REFCOLUMNNAME, RULE, ' ' (CASE WHEN REFSCHEMANAME = CURRENT_SCHEMA ' ' THEN 1 ELSE 0 END) AS in_schema ' 'FROM FOREIGNKEYCOLUMNS ' 'WHERE TABLENAME=? AND SCHEMANAME=%s ' 'ORDER BY FKEYNAME ') params = [denormalize(table.name)] if not table.schema: st = st % 'CURRENT_SCHEMA' fk = fk % 'CURRENT_SCHEMA' else: st = st % '?' fk = fk % '?' params.append(denormalize(table.schema)) rows = connection.execute(st, params).fetchall() if not rows: raise exc.NoSuchTableError(table.fullname) include_columns = set(include_columns or []) for row in rows: (name, mode, col_type, encoding, length, scale, nullable, constant_def, func_def) = row name = normalize(name) if include_columns and name not in include_columns: continue type_args, type_kw = [], {} if col_type == 'FIXED': type_args = length, scale # Convert FIXED(10) DEFAULT SERIAL to our Integer if (scale == 0 and func_def is not None and func_def.startswith('SERIAL')): col_type = 'INTEGER' type_args = length, elif col_type in 'FLOAT': type_args = length, elif col_type in ('CHAR', 'VARCHAR'): type_args = length, type_kw['encoding'] = encoding elif col_type == 'LONG': type_kw['encoding'] = encoding try: type_cls = ischema_names[col_type.lower()] type_instance = type_cls(*type_args, **type_kw) except KeyError: util.warn("Did not recognize type '%s' of column '%s'" % (col_type, name)) type_instance = sqltypes.NullType col_kw = {'autoincrement': False} col_kw['nullable'] = (nullable == 'YES') col_kw['primary_key'] = (mode == 'KEY') if func_def is not None: if func_def.startswith('SERIAL'): if col_kw['primary_key']: # No special default- let the standard autoincrement # support handle SERIAL pk columns. col_kw['autoincrement'] = True else: # strip current numbering col_kw['server_default'] = schema.DefaultClause( sql.text('SERIAL')) col_kw['autoincrement'] = True else: col_kw['server_default'] = schema.DefaultClause( sql.text(func_def)) elif constant_def is not None: col_kw['server_default'] = schema.DefaultClause(sql.text( "'%s'" % constant_def.replace("'", "''"))) table.append_column(schema.Column(name, type_instance, **col_kw)) fk_sets = itertools.groupby(connection.execute(fk, params), lambda row: row.FKEYNAME) for fkeyname, fkey in fk_sets: fkey = list(fkey) if include_columns: key_cols = set([r.COLUMNNAME for r in fkey]) if key_cols != include_columns: continue columns, referants = [], [] quote = self.identifier_preparer._maybe_quote_identifier for row in fkey: columns.append(normalize(row.COLUMNNAME)) if table.schema or not row.in_schema: referants.append('.'.join( [quote(normalize(row[c])) for c in ('REFSCHEMANAME', 'REFTABLENAME', 'REFCOLUMNNAME')])) else: referants.append('.'.join( [quote(normalize(row[c])) for c in ('REFTABLENAME', 'REFCOLUMNNAME')])) constraint_kw = {'name': fkeyname.lower()} if fkey[0].RULE is not None: rule = fkey[0].RULE if rule.startswith('DELETE '): rule = rule[7:] constraint_kw['ondelete'] = rule table_kw = {} if table.schema or not row.in_schema: table_kw['schema'] = normalize(fkey[0].REFSCHEMANAME) ref_key = schema._get_table_key(normalize(fkey[0].REFTABLENAME), table_kw.get('schema')) if ref_key not in table.metadata.tables: schema.Table(normalize(fkey[0].REFTABLENAME), table.metadata, autoload=True, autoload_with=connection, **table_kw) constraint = schema.ForeignKeyConstraint( columns, referants, link_to_name=True, **constraint_kw) table.append_constraint(constraint) def has_sequence(self, connection, name): # [ticket:726] makes this schema-aware. denormalize = self.identifier_preparer._denormalize_name sql = ("SELECT sequence_name FROM SEQUENCES " "WHERE SEQUENCE_NAME=? ") rp = connection.execute(sql, denormalize(name)) return bool(rp.first()) def _autoserial_column(table): """Finds the effective DEFAULT SERIAL column of a Table, if any.""" for index, col in enumerate(table.primary_key.columns): if (isinstance(col.type, (sqltypes.Integer, sqltypes.Numeric)) and col.autoincrement): if isinstance(col.default, schema.Sequence): if col.default.optional: return index, col elif (col.default is None or (not isinstance(col.server_default, schema.DefaultClause))): return index, col return None, None
gpl-3.0
[ 3, 1390, 697, 15, 1095, 14, 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, 624, 11532, 367, 314, 8228, 2846, 3050, 14, 199, 199, 2765, 10982, 365, 627, 1397, 10, 299, 1376, 370, 14303, 378, 14, 22, 503, 378, 14, 23, 14, 199, 199, 2765, 10982, 365, 627, 1397, 10, 12470, 641, 14303, 378, 14, 22, 503, 378, 14, 23, 14, 199, 199, 28077, 199, 518, 199, 199, 1918, 1124, 28255, 1040, 10982, 365, 1011, 18924, 538, 436, 965, 1454, 2757, 12470, 641, 1520, 14, 22, 14, 1644, 14, 8255, 199, 460, 1520, 14, 22, 14, 383, 14, 18325, 14, 221, 24545, 3520, 12, 1011, 2118, 1520, 14, 22, 14, 1644, 14, 8255, 911, 1736, 538, 543, 14303, 1159, 23383, 14, 199, 1918, 14119, 1015, 965, 542, 432, 264, 1124, 9894, 10593, 1040, 4204, 436, 911, 372, 199, 15448, 2058, 687, 2755, 7437, 3486, 23383, 9212, 14, 199, 199, 5903, 314, 5438, 2018, 6249, 13, 3735, 365, 5544, 3748, 14, 221, 593, 23317, 5253, 2291, 199, 374, 282, 6466, 655, 14666, 434, 14, 199, 199, 32000, 199, 9460, 199, 199, 1918, 3434, 365, 1930, 13, 7361, 14, 221, 982, 1265, 9987, 4907, 370, 314, 199, 4659, 543, 3875, 2764, 436, 1163, 7249, 315, 5117, 1930, 12, 1265, 12060, 1929, 370, 199, 1180, 7008, 1930, 367, 6249, 13, 3735, 14, 199, 199, 7921, 8144, 199, 777, 375, 199, 199, 3007, 314, 1520, 14, 22, 14, 383, 14, 1401, 5253, 436, 2018, 499, 14, 21, 12, 652, 12237, 626, 1006, 6249, 13, 3735, 199, 10176, 4967, 787, 10529, 436, 883, 7675, 2018, 370, 12420, 14, 199, 199, 1858, 283, 3972, 761, 14, 262, 63, 4157, 7, 370, 1736, 12, 314, 1621, 4182, 1159, 10152, 1471, 506, 2896, 199, 475, 9106, 283, 8084, 7, 370, 282, 8950, 12, 284, 14, 69, 14, 11576, 8, 8084, 680, 221, 710, 6249, 13, 3735, 3181, 1133, 4729, 282, 199, 3409, 2725, 2337, 12, 880, 626, 6770, 10152, 1471, 8308, 314, 5962, 574, 12, 199, 6777, 8350, 641, 359, 9201, 26, 11369, 1055, 199, 199, 1918, 6249, 13, 3735, 365, 7437, 3732, 89, 3595, 2382, 5398, 1862, 1443, 506, 1202, 315, 9212, 14, 199, 199, 8198, 1862, 367, 2005, 3423, 334, 69, 14, 71, 14, 30920, 9, 1929, 730, 2556, 6841, 14, 199, 1918, 10982, 1630, 440, 5966, 886, 642, 5847, 14, 199, 199, 4261, 911, 14706, 305, 1636, 1183, 7978, 1536, 283, 4087, 3875, 12, 6555, 4020, 7, 4967, 367, 199, 9452, 449, 590, 1686, 5385, 14, 221, 710, 10982, 1630, 440, 5544, 2429, 3520, 12, 1655, 199, 31788, 365, 4346, 14, 199, 199, 4261, 2846, 1520, 14, 21, 436, 428, 439, 6249, 2695, 1520, 14, 20, 14581, 590, 886, 440, 2291, 32536, 14, 221, 437, 7437, 199, 83, 4040, 590, 3365, 1015, 402, 642, 10982, 3955, 506, 1415, 370, 2291, 199, 273, 3362, 5459, 12, 436, 883, 16174, 506, 3483, 340, 2337, 365, 29237, 14, 221, 6601, 1163, 199, 2427, 7323, 4066, 465, 376, 8228, 13, 14600, 283, 1753, 28123, 3449, 7, 4263, 6365, 199, 8, 273, 386, 305, 543, 334, 8771, 6890, 7262, 2750, 9, 787, 2575, 4224, 436, 2808, 367, 199, 15092, 13, 3031, 314, 477, 1090, 769, 340, 1265, 3984, 22201, 315, 6449, 641, 199, 3749, 14, 199, 199, 21167, 12470, 26, 1520, 14, 22, 14, 1644, 14, 1780, 436, 1520, 14, 22, 14, 383, 14, 1401, 12, 5438, 2018, 6249, 13, 3735, 199, 199, 10, 8228, 2846, 965, 542, 432, 264, 4204, 641, 31682, 10593, 83, 12, 1314, 787, 22829, 1009, 370, 23383, 523, 21719, 8697, 14, 6061, 7830, 2419, 746, 376, 1125, 340, 282, 10468, 883, 1133, 506, 2435, 68, 12, 523, 314, 3050, 9329, 2529, 8927, 2058, 14, 199, 10, 3394, 1520, 14, 22, 14, 1644, 14, 1780, 12237, 370, 10593, 7684, 12, 13432, 314, 9149, 886, 440, 2498, 314, 523, 31682, 24488, 3769, 221, 853, 471, 334, 305, 402, 642, 3575, 395, 436, 949, 1570, 793, 365, 523, 2808, 370, 12679, 1902, 14, 982, 1265, 787, 1808, 282, 3365, 1654, 1015, 436, 523, 2195, 6527, 4409, 314, 23383, 503, 1263, 18734, 13, 14652, 5385, 4012, 314, 5385, 4045, 12, 523, 3879, 314, 14303, 511, 5241, 6169, 2195, 3050, 365, 869, 13454, 6084, 523, 14318, 2544, 1265, 5386, 14, 199, 10, 3394, 1520, 14, 22, 14, 383, 14, 1401, 365, 491, 15467, 15, 50, 15467, 18423, 315, 658, 12491, 13180, 6578, 31682, 10593, 9085, 5258, 523, 13180, 14, 761, 29, 12071, 14, 761, 64, 8118, 658, 12071, 14, 761, 29, 12697, 14, 761, 64, 1, 199, 10, 3394, 1520, 14, 22, 14, 383, 14, 1401, 365, 3743, 2972, 701, 658, 4859, 28424, 28437, 1048, 465, 5162, 4442, 307, 16044, 523, 6515, 1048, 64, 446, 3520, 26642, 12, 28424, 28437, 12, 7741, 9212, 1929, 370, 506, 295, 13, 8938, 370, 523, 1865, 701, 314, 5162, 536, 14, 199, 10, 3394, 1520, 14, 22, 14, 88, 5171, 6425, 282, 13950, 2524, 7217, 1325, 440, 2399, 5363, 17177, 14, 199, 10, 8228, 2846, 5171, 32497, 13, 2487, 4362, 334, 3472, 7017, 4938, 9, 436, 12717, 523, 8013, 14, 3979, 5893, 282, 6186, 7017, 4938, 2763, 315, 376, 5518, 12, 378, 4839, 370, 523, 506, 11788, 7830, 2419, 5962, 370, 3550, 282, 574, 14, 199, 10, 8228, 2846, 5171, 25600, 436, 298, 1753, 15309, 3449, 2, 12724, 18266, 543, 334, 8771, 6890, 4263, 523, 7262, 2750, 14, 199, 10, 710, 14303, 10982, 365, 4177, 13, 14600, 436, 8646, 7859, 1133, 805, 6657, 523, 641, 1654, 5459, 334, 657, 13, 23, 14, 22, 31, 680, 12502, 367, 4177, 13, 2003, 1654, 5459, 4293, 523, 506, 3483, 340, 2337, 1159, 1240, 14, 199, 10, 16044, 6515, 365, 440, 3748, 315, 1007, 10590, 14, 5138, 365, 440, 3748, 315, 523, 1007, 10590, 14, 1010, 1520, 14, 22, 14, 383, 14, 1401, 12, 32582, 1630, 1736, 315, 1007, 10590, 12, 1325, 1928, 2304, 440, 523, 880, 2997, 14, 32633, 3597, 1630, 440 ]
[ 1390, 697, 15, 1095, 14, 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, 624, 11532, 367, 314, 8228, 2846, 3050, 14, 199, 199, 2765, 10982, 365, 627, 1397, 10, 299, 1376, 370, 14303, 378, 14, 22, 503, 378, 14, 23, 14, 199, 199, 2765, 10982, 365, 627, 1397, 10, 12470, 641, 14303, 378, 14, 22, 503, 378, 14, 23, 14, 199, 199, 28077, 199, 518, 199, 199, 1918, 1124, 28255, 1040, 10982, 365, 1011, 18924, 538, 436, 965, 1454, 2757, 12470, 641, 1520, 14, 22, 14, 1644, 14, 8255, 199, 460, 1520, 14, 22, 14, 383, 14, 18325, 14, 221, 24545, 3520, 12, 1011, 2118, 1520, 14, 22, 14, 1644, 14, 8255, 911, 1736, 538, 543, 14303, 1159, 23383, 14, 199, 1918, 14119, 1015, 965, 542, 432, 264, 1124, 9894, 10593, 1040, 4204, 436, 911, 372, 199, 15448, 2058, 687, 2755, 7437, 3486, 23383, 9212, 14, 199, 199, 5903, 314, 5438, 2018, 6249, 13, 3735, 365, 5544, 3748, 14, 221, 593, 23317, 5253, 2291, 199, 374, 282, 6466, 655, 14666, 434, 14, 199, 199, 32000, 199, 9460, 199, 199, 1918, 3434, 365, 1930, 13, 7361, 14, 221, 982, 1265, 9987, 4907, 370, 314, 199, 4659, 543, 3875, 2764, 436, 1163, 7249, 315, 5117, 1930, 12, 1265, 12060, 1929, 370, 199, 1180, 7008, 1930, 367, 6249, 13, 3735, 14, 199, 199, 7921, 8144, 199, 777, 375, 199, 199, 3007, 314, 1520, 14, 22, 14, 383, 14, 1401, 5253, 436, 2018, 499, 14, 21, 12, 652, 12237, 626, 1006, 6249, 13, 3735, 199, 10176, 4967, 787, 10529, 436, 883, 7675, 2018, 370, 12420, 14, 199, 199, 1858, 283, 3972, 761, 14, 262, 63, 4157, 7, 370, 1736, 12, 314, 1621, 4182, 1159, 10152, 1471, 506, 2896, 199, 475, 9106, 283, 8084, 7, 370, 282, 8950, 12, 284, 14, 69, 14, 11576, 8, 8084, 680, 221, 710, 6249, 13, 3735, 3181, 1133, 4729, 282, 199, 3409, 2725, 2337, 12, 880, 626, 6770, 10152, 1471, 8308, 314, 5962, 574, 12, 199, 6777, 8350, 641, 359, 9201, 26, 11369, 1055, 199, 199, 1918, 6249, 13, 3735, 365, 7437, 3732, 89, 3595, 2382, 5398, 1862, 1443, 506, 1202, 315, 9212, 14, 199, 199, 8198, 1862, 367, 2005, 3423, 334, 69, 14, 71, 14, 30920, 9, 1929, 730, 2556, 6841, 14, 199, 1918, 10982, 1630, 440, 5966, 886, 642, 5847, 14, 199, 199, 4261, 911, 14706, 305, 1636, 1183, 7978, 1536, 283, 4087, 3875, 12, 6555, 4020, 7, 4967, 367, 199, 9452, 449, 590, 1686, 5385, 14, 221, 710, 10982, 1630, 440, 5544, 2429, 3520, 12, 1655, 199, 31788, 365, 4346, 14, 199, 199, 4261, 2846, 1520, 14, 21, 436, 428, 439, 6249, 2695, 1520, 14, 20, 14581, 590, 886, 440, 2291, 32536, 14, 221, 437, 7437, 199, 83, 4040, 590, 3365, 1015, 402, 642, 10982, 3955, 506, 1415, 370, 2291, 199, 273, 3362, 5459, 12, 436, 883, 16174, 506, 3483, 340, 2337, 365, 29237, 14, 221, 6601, 1163, 199, 2427, 7323, 4066, 465, 376, 8228, 13, 14600, 283, 1753, 28123, 3449, 7, 4263, 6365, 199, 8, 273, 386, 305, 543, 334, 8771, 6890, 7262, 2750, 9, 787, 2575, 4224, 436, 2808, 367, 199, 15092, 13, 3031, 314, 477, 1090, 769, 340, 1265, 3984, 22201, 315, 6449, 641, 199, 3749, 14, 199, 199, 21167, 12470, 26, 1520, 14, 22, 14, 1644, 14, 1780, 436, 1520, 14, 22, 14, 383, 14, 1401, 12, 5438, 2018, 6249, 13, 3735, 199, 199, 10, 8228, 2846, 965, 542, 432, 264, 4204, 641, 31682, 10593, 83, 12, 1314, 787, 22829, 1009, 370, 23383, 523, 21719, 8697, 14, 6061, 7830, 2419, 746, 376, 1125, 340, 282, 10468, 883, 1133, 506, 2435, 68, 12, 523, 314, 3050, 9329, 2529, 8927, 2058, 14, 199, 10, 3394, 1520, 14, 22, 14, 1644, 14, 1780, 12237, 370, 10593, 7684, 12, 13432, 314, 9149, 886, 440, 2498, 314, 523, 31682, 24488, 3769, 221, 853, 471, 334, 305, 402, 642, 3575, 395, 436, 949, 1570, 793, 365, 523, 2808, 370, 12679, 1902, 14, 982, 1265, 787, 1808, 282, 3365, 1654, 1015, 436, 523, 2195, 6527, 4409, 314, 23383, 503, 1263, 18734, 13, 14652, 5385, 4012, 314, 5385, 4045, 12, 523, 3879, 314, 14303, 511, 5241, 6169, 2195, 3050, 365, 869, 13454, 6084, 523, 14318, 2544, 1265, 5386, 14, 199, 10, 3394, 1520, 14, 22, 14, 383, 14, 1401, 365, 491, 15467, 15, 50, 15467, 18423, 315, 658, 12491, 13180, 6578, 31682, 10593, 9085, 5258, 523, 13180, 14, 761, 29, 12071, 14, 761, 64, 8118, 658, 12071, 14, 761, 29, 12697, 14, 761, 64, 1, 199, 10, 3394, 1520, 14, 22, 14, 383, 14, 1401, 365, 3743, 2972, 701, 658, 4859, 28424, 28437, 1048, 465, 5162, 4442, 307, 16044, 523, 6515, 1048, 64, 446, 3520, 26642, 12, 28424, 28437, 12, 7741, 9212, 1929, 370, 506, 295, 13, 8938, 370, 523, 1865, 701, 314, 5162, 536, 14, 199, 10, 3394, 1520, 14, 22, 14, 88, 5171, 6425, 282, 13950, 2524, 7217, 1325, 440, 2399, 5363, 17177, 14, 199, 10, 8228, 2846, 5171, 32497, 13, 2487, 4362, 334, 3472, 7017, 4938, 9, 436, 12717, 523, 8013, 14, 3979, 5893, 282, 6186, 7017, 4938, 2763, 315, 376, 5518, 12, 378, 4839, 370, 523, 506, 11788, 7830, 2419, 5962, 370, 3550, 282, 574, 14, 199, 10, 8228, 2846, 5171, 25600, 436, 298, 1753, 15309, 3449, 2, 12724, 18266, 543, 334, 8771, 6890, 4263, 523, 7262, 2750, 14, 199, 10, 710, 14303, 10982, 365, 4177, 13, 14600, 436, 8646, 7859, 1133, 805, 6657, 523, 641, 1654, 5459, 334, 657, 13, 23, 14, 22, 31, 680, 12502, 367, 4177, 13, 2003, 1654, 5459, 4293, 523, 506, 3483, 340, 2337, 1159, 1240, 14, 199, 10, 16044, 6515, 365, 440, 3748, 315, 1007, 10590, 14, 5138, 365, 440, 3748, 315, 523, 1007, 10590, 14, 1010, 1520, 14, 22, 14, 383, 14, 1401, 12, 32582, 1630, 1736, 315, 1007, 10590, 12, 1325, 1928, 2304, 440, 523, 880, 2997, 14, 32633, 3597, 1630, 440, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
npuichigo/ttsflow
third_party/tensorflow/tensorflow/contrib/labeled_tensor/python/ops/io_ops.py
172
6373
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Input parsing code for LabeledTensors.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from six import string_types from tensorflow.contrib.labeled_tensor.python.ops import _typecheck as tc from tensorflow.contrib.labeled_tensor.python.ops import core from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import parsing_ops class FixedLenFeature(object): """Configuration for parsing a fixed-length input feature. Fields: axes: A list of Axis objects or tuples (axis_name, axis_value), where `axis_name` is a string and `axis_value` is None (unknown size), an integer or a list of tick labels. dtype: Data type of input. default_value: Value to be used if an example is missing this feature. It must be compatible with `dtype`. """ def __init__(self, axes, dtype, default_value=None): self._axes = [core.as_axis(a) for a in axes] self._dtype = dtype self._default_value = default_value @property def axes(self): return self._axes @property def dtype(self): return self._dtype @property def default_value(self): return self._default_value @tc.returns(tc.Dict(string_types, parsing_ops.FixedLenFeature)) @tc.accepts(tc.Mapping(string_types, FixedLenFeature)) def _labeled_to_unlabeled_features(features): """Convert a dict of lt.FixedLenFeature into a dict of tf.FixedLenFeature.""" unlabeled_features = {} for name, labeled_feature in features.items(): shape = [ax.size for ax in labeled_feature.axes] if any(size is None for size in shape): # This should be caught on the TensorFlow side, but it isn't yet: # https://github.com/tensorflow/tensorflow/issues/2874 raise ValueError('axes with unknown size are not supported') dtype = labeled_feature.dtype default_value = labeled_feature.default_value unlabeled_features[name] = parsing_ops.FixedLenFeature( shape, dtype, default_value) return unlabeled_features @tc.returns(tc.Dict(string_types, core.LabeledTensor)) @tc.accepts(core.LabeledTensorLike, tc.Mapping(string_types, FixedLenFeature), tc.Optional(string_types), object) def parse_example(serialized, features, name=None, example_names=None): """Parse `Example` protos into a `dict` of labeled tensors. See tf.parse_example. Args: serialized: A 1-D LabeledTensor of strings, a batch of binary serialized `Example` protos. features: A `dict` mapping feature keys to `labeled_tensor.FixedLenFeature` values. name: A name for this operation (optional). example_names: A vector (1-D Tensor) of strings (optional), the names of the serialized protos in the batch. Returns: A `dict` mapping feature keys to `LabeledTensor` values. The single axis from `serialized` will be prepended to the axes provided by each feature. Raises: ValueError: if any feature is invalid. """ serialized = core.convert_to_labeled_tensor(serialized) unlabeled_features = _labeled_to_unlabeled_features(features) unlabeled_parsed = parsing_ops.parse_example( serialized.tensor, unlabeled_features, name, example_names) parsed = {} for name, parsed_feature in unlabeled_parsed.items(): axes = list(serialized.axes.values()) + features[name].axes parsed[name] = core.LabeledTensor(parsed_feature, axes) return parsed @tc.returns(tc.Dict(string_types, core.LabeledTensor)) @tc.accepts(core.LabeledTensorLike, tc.Mapping(string_types, FixedLenFeature), tc.Optional(string_types), object) def parse_single_example(serialized, features, name=None, example_names=None): """Parses a single `Example` proto. See tf.parse_single_example. Args: serialized: A scalar string Tensor or LabeledTensor, a single serialized Example. features: A `dict` mapping feature keys to `labeled_tensor.FixedLenFeature` values. name: A name for this operation (optional). example_names: (Optional) A scalar string Tensor, the associated name. Returns: A `dict` mapping feature keys to `LabeledTensor` values. Raises: ValueError: if any feature is invalid. """ serialized = core.convert_to_labeled_tensor(serialized) unlabeled_features = _labeled_to_unlabeled_features(features) unlabeled_parsed = parsing_ops.parse_single_example( serialized.tensor, unlabeled_features, name, example_names) parsed = {} for name, parsed_feature in unlabeled_parsed.items(): parsed[name] = core.LabeledTensor(parsed_feature, features[name].axes) return parsed @tc.returns(core.LabeledTensor) @tc.accepts(dtypes.DType, tc.Collection(tc.Union(string_types, core.AxisLike)), tc.Optional(string_types)) def placeholder(dtype, axes, name=None): """Create a placeholder for a labeled tensor. For example: lt.placeholder(tf.float32, ['batch', ('channel', ['r', 'g', 'b'])]) See tf.placeholder for more details. Args: dtype: The type of elements in the tensor to be fed. axes: sequence of strings (denoting axes of unknown size) and/or objects convertable to lt.Axis to label the result. name: Optional op name. Returns: Placeholder labeled tensor. """ with ops.name_scope(name, 'lt_placeholder', []) as scope: axes = core.Axes([(axis, None) if isinstance(axis, string_types) else axis for axis in axes]) shape = [axis.size for axis in axes.values()] tensor = array_ops.placeholder(dtype, shape, name=scope) return core.LabeledTensor(tensor, axes)
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 3205, 6057, 1233, 367, 491, 14502, 29212, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3816, 492, 1059, 63, 1313, 199, 199, 504, 3228, 14, 2828, 14, 21242, 63, 3128, 14, 1548, 14, 1483, 492, 485, 466, 1074, 465, 14415, 199, 504, 3228, 14, 2828, 14, 21242, 63, 3128, 14, 1548, 14, 1483, 492, 6170, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6057, 63, 1483, 421, 199, 533, 18659, 28556, 8, 785, 304, 523, 408, 5688, 367, 6057, 282, 6317, 13, 1267, 1324, 3878, 14, 819, 16424, 26, 272, 7824, 26, 437, 769, 402, 23205, 2251, 503, 6346, 334, 3127, 63, 354, 12, 3114, 63, 585, 395, 489, 2382, 658, 3127, 63, 354, 64, 365, 282, 1059, 436, 658, 3127, 63, 585, 64, 365, 488, 334, 5187, 1568, 395, 376, 489, 3000, 503, 282, 769, 402, 11748, 3628, 14, 272, 2152, 26, 3918, 730, 402, 1324, 14, 272, 849, 63, 585, 26, 1594, 370, 506, 1202, 340, 376, 2893, 365, 4124, 642, 3878, 14, 2779, 267, 1471, 506, 9025, 543, 658, 2271, 2313, 523, 408, 819, 347, 636, 826, 721, 277, 12, 7824, 12, 2152, 12, 849, 63, 585, 29, 403, 304, 272, 291, 423, 6402, 275, 359, 1018, 14, 305, 63, 3127, 8, 65, 9, 367, 282, 315, 7824, 61, 272, 291, 423, 2271, 275, 2152, 272, 291, 423, 885, 63, 585, 275, 849, 63, 585, 819, 768, 1829, 523, 347, 7824, 8, 277, 304, 272, 372, 291, 423, 6402, 819, 768, 1829, 523, 347, 2152, 8, 277, 304, 272, 372, 291, 423, 2271, 819, 768, 1829, 523, 347, 849, 63, 585, 8, 277, 304, 272, 372, 291, 423, 885, 63, 585, 421, 199, 32, 3641, 14, 5808, 8, 3641, 14, 2141, 8, 875, 63, 1313, 12, 6057, 63, 1483, 14, 9515, 28556, 430, 199, 32, 3641, 14, 27692, 8, 3641, 14, 7674, 8, 875, 63, 1313, 12, 18659, 28556, 430, 199, 318, 485, 21242, 63, 475, 63, 324, 21242, 63, 3179, 8, 3179, 304, 523, 408, 7306, 282, 1211, 402, 22146, 14, 9515, 28556, 1901, 282, 1211, 402, 2833, 14, 9515, 28556, 1041, 523, 625, 21242, 63, 3179, 275, 1052, 523, 367, 536, 12, 23677, 63, 4445, 315, 4534, 14, 1744, 837, 272, 2215, 275, 359, 1219, 14, 890, 367, 2185, 315, 23677, 63, 4445, 14, 6402, 61, 272, 340, 1263, 8, 890, 365, 488, 367, 1568, 315, 2215, 304, 489, 327, 961, 1077, 506, 15604, 641, 314, 9134, 5366, 12, 1325, 652, 5712, 1133, 5966, 26, 489, 327, 4178, 921, 5031, 14, 957, 15, 16008, 15, 16008, 15, 10115, 15, 1651, 1342, 489, 746, 1722, 360, 6402, 543, 5809, 1568, 787, 440, 3748, 358, 272, 2152, 275, 23677, 63, 4445, 14, 2271, 272, 849, 63, 585, 275, 23677, 63, 4445, 14, 885, 63, 585, 272, 625, 21242, 63, 3179, 59, 354, 61, 275, 6057, 63, 1483, 14, 9515, 28556, 8, 267, 2215, 12, 2152, 12, 849, 63, 585, 9, 523, 372, 625, 21242, 63, 3179, 421, 199, 32, 3641, 14, 5808, 8, 3641, 14, 2141, 8, 875, 63, 1313, 12, 6170, 14, 26545, 3861, 430, 199, 32, 3641, 14, 27692, 8, 1018, 14, 26545, 3861, 12545, 12, 14415, 14, 7674, 8, 875, 63, 1313, 12, 18659, 28556, 395, 288, 14415, 14, 7012, 8, 875, 63, 1313, 395, 909, 9, 199, 318, 2198, 63, 2694, 8, 8397, 12, 4534, 12, 536, 29, 403, 12, 2893, 63, 1247, 29, 403, 304, 523, 408, 4003, 658, 9846, 64, 4104, 83, 1901, 282, 658, 807, 64, 402, 23677, 10519, 14, 819, 1666, 2833, 14, 1122, 63, 2694, 14, 819, 3033, 26, 272, 6380, 26, 437, 413, 13, 36, 491, 14502, 3861, 402, 3326, 12, 282, 3522, 402, 3366, 6380, 489, 658, 9846, 64, 4104, 83, 14, 272, 4534, 26, 437, 658, 807, 64, 4412, 3878, 2883, 370, 658, 21242, 63, 3128, 14, 9515, 28556, 64, 489, 1338, 14, 272, 536, 26, 437, 536, 367, 642, 3439, 334, 4144, 680, 272, 2893, 63, 1247, 26, 437, 5477, 334, 17, 13, 36, 5878, 9, 402, 3326, 334, 4144, 395, 314, 1561, 402, 489, 314, 6380, 4104, 83, 315, 314, 3522, 14, 819, 1803, 26, 272, 437, 658, 807, 64, 4412, 3878, 2883, 370, 658, 26545, 3861, 64, 1338, 14, 710, 2849, 3114, 272, 687, 658, 8397, 64, 911, 506, 20247, 370, 314, 7824, 2741, 701, 1924, 3878, 14, 819, 6218, 26, 272, 1722, 26, 340, 1263, 3878, 365, 3866, 14, 523, 408, 523, 6380, 275, 6170, 14, 3916, 63, 475, 63, 21242, 63, 3128, 8, 8397, 9, 523, 625, 21242, 63, 3179, 275, 485, 21242, 63, 475, 63, 324, 21242, 63, 3179, 8, 3179, 9, 819, 625, 21242, 63, 6751, 275, 6057, 63, 1483, 14, 1122, 63, 2694, 8, 489, 6380, 14, 3128, 12, 625, 21242, 63, 3179, 12, 536, 12, 2893, 63, 1247, 9, 819, 4565, 275, 1052, 523, 367, 536, 12, 4565, 63, 4445, 315, 625, 21242, 63, 6751, 14, 1744, 837, 272, 7824, 275, 769, 8, 8397, 14, 6402, 14, 1459, 1012, 435, 4534, 59 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 199, 624, 3205, 6057, 1233, 367, 491, 14502, 29212, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3816, 492, 1059, 63, 1313, 199, 199, 504, 3228, 14, 2828, 14, 21242, 63, 3128, 14, 1548, 14, 1483, 492, 485, 466, 1074, 465, 14415, 199, 504, 3228, 14, 2828, 14, 21242, 63, 3128, 14, 1548, 14, 1483, 492, 6170, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6057, 63, 1483, 421, 199, 533, 18659, 28556, 8, 785, 304, 523, 408, 5688, 367, 6057, 282, 6317, 13, 1267, 1324, 3878, 14, 819, 16424, 26, 272, 7824, 26, 437, 769, 402, 23205, 2251, 503, 6346, 334, 3127, 63, 354, 12, 3114, 63, 585, 395, 489, 2382, 658, 3127, 63, 354, 64, 365, 282, 1059, 436, 658, 3127, 63, 585, 64, 365, 488, 334, 5187, 1568, 395, 376, 489, 3000, 503, 282, 769, 402, 11748, 3628, 14, 272, 2152, 26, 3918, 730, 402, 1324, 14, 272, 849, 63, 585, 26, 1594, 370, 506, 1202, 340, 376, 2893, 365, 4124, 642, 3878, 14, 2779, 267, 1471, 506, 9025, 543, 658, 2271, 2313, 523, 408, 819, 347, 636, 826, 721, 277, 12, 7824, 12, 2152, 12, 849, 63, 585, 29, 403, 304, 272, 291, 423, 6402, 275, 359, 1018, 14, 305, 63, 3127, 8, 65, 9, 367, 282, 315, 7824, 61, 272, 291, 423, 2271, 275, 2152, 272, 291, 423, 885, 63, 585, 275, 849, 63, 585, 819, 768, 1829, 523, 347, 7824, 8, 277, 304, 272, 372, 291, 423, 6402, 819, 768, 1829, 523, 347, 2152, 8, 277, 304, 272, 372, 291, 423, 2271, 819, 768, 1829, 523, 347, 849, 63, 585, 8, 277, 304, 272, 372, 291, 423, 885, 63, 585, 421, 199, 32, 3641, 14, 5808, 8, 3641, 14, 2141, 8, 875, 63, 1313, 12, 6057, 63, 1483, 14, 9515, 28556, 430, 199, 32, 3641, 14, 27692, 8, 3641, 14, 7674, 8, 875, 63, 1313, 12, 18659, 28556, 430, 199, 318, 485, 21242, 63, 475, 63, 324, 21242, 63, 3179, 8, 3179, 304, 523, 408, 7306, 282, 1211, 402, 22146, 14, 9515, 28556, 1901, 282, 1211, 402, 2833, 14, 9515, 28556, 1041, 523, 625, 21242, 63, 3179, 275, 1052, 523, 367, 536, 12, 23677, 63, 4445, 315, 4534, 14, 1744, 837, 272, 2215, 275, 359, 1219, 14, 890, 367, 2185, 315, 23677, 63, 4445, 14, 6402, 61, 272, 340, 1263, 8, 890, 365, 488, 367, 1568, 315, 2215, 304, 489, 327, 961, 1077, 506, 15604, 641, 314, 9134, 5366, 12, 1325, 652, 5712, 1133, 5966, 26, 489, 327, 4178, 921, 5031, 14, 957, 15, 16008, 15, 16008, 15, 10115, 15, 1651, 1342, 489, 746, 1722, 360, 6402, 543, 5809, 1568, 787, 440, 3748, 358, 272, 2152, 275, 23677, 63, 4445, 14, 2271, 272, 849, 63, 585, 275, 23677, 63, 4445, 14, 885, 63, 585, 272, 625, 21242, 63, 3179, 59, 354, 61, 275, 6057, 63, 1483, 14, 9515, 28556, 8, 267, 2215, 12, 2152, 12, 849, 63, 585, 9, 523, 372, 625, 21242, 63, 3179, 421, 199, 32, 3641, 14, 5808, 8, 3641, 14, 2141, 8, 875, 63, 1313, 12, 6170, 14, 26545, 3861, 430, 199, 32, 3641, 14, 27692, 8, 1018, 14, 26545, 3861, 12545, 12, 14415, 14, 7674, 8, 875, 63, 1313, 12, 18659, 28556, 395, 288, 14415, 14, 7012, 8, 875, 63, 1313, 395, 909, 9, 199, 318, 2198, 63, 2694, 8, 8397, 12, 4534, 12, 536, 29, 403, 12, 2893, 63, 1247, 29, 403, 304, 523, 408, 4003, 658, 9846, 64, 4104, 83, 1901, 282, 658, 807, 64, 402, 23677, 10519, 14, 819, 1666, 2833, 14, 1122, 63, 2694, 14, 819, 3033, 26, 272, 6380, 26, 437, 413, 13, 36, 491, 14502, 3861, 402, 3326, 12, 282, 3522, 402, 3366, 6380, 489, 658, 9846, 64, 4104, 83, 14, 272, 4534, 26, 437, 658, 807, 64, 4412, 3878, 2883, 370, 658, 21242, 63, 3128, 14, 9515, 28556, 64, 489, 1338, 14, 272, 536, 26, 437, 536, 367, 642, 3439, 334, 4144, 680, 272, 2893, 63, 1247, 26, 437, 5477, 334, 17, 13, 36, 5878, 9, 402, 3326, 334, 4144, 395, 314, 1561, 402, 489, 314, 6380, 4104, 83, 315, 314, 3522, 14, 819, 1803, 26, 272, 437, 658, 807, 64, 4412, 3878, 2883, 370, 658, 26545, 3861, 64, 1338, 14, 710, 2849, 3114, 272, 687, 658, 8397, 64, 911, 506, 20247, 370, 314, 7824, 2741, 701, 1924, 3878, 14, 819, 6218, 26, 272, 1722, 26, 340, 1263, 3878, 365, 3866, 14, 523, 408, 523, 6380, 275, 6170, 14, 3916, 63, 475, 63, 21242, 63, 3128, 8, 8397, 9, 523, 625, 21242, 63, 3179, 275, 485, 21242, 63, 475, 63, 324, 21242, 63, 3179, 8, 3179, 9, 819, 625, 21242, 63, 6751, 275, 6057, 63, 1483, 14, 1122, 63, 2694, 8, 489, 6380, 14, 3128, 12, 625, 21242, 63, 3179, 12, 536, 12, 2893, 63, 1247, 9, 819, 4565, 275, 1052, 523, 367, 536, 12, 4565, 63, 4445, 315, 625, 21242, 63, 6751, 14, 1744, 837, 272, 7824, 275, 769, 8, 8397, 14, 6402, 14, 1459, 1012, 435, 4534, 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,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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 ]
LaoZhongGu/kbengine
kbe/res/scripts/common/Lib/plat-aix4/IN.py
108
3622
# Generated by h2py from /usr/include/netinet/in.h # Included from net/nh.h # Included from sys/machine.h LITTLE_ENDIAN = 1234 BIG_ENDIAN = 4321 PDP_ENDIAN = 3412 BYTE_ORDER = BIG_ENDIAN DEFAULT_GPR = 0xDEADBEEF MSR_EE = 0x8000 MSR_PR = 0x4000 MSR_FP = 0x2000 MSR_ME = 0x1000 MSR_FE = 0x0800 MSR_FE0 = 0x0800 MSR_SE = 0x0400 MSR_BE = 0x0200 MSR_IE = 0x0100 MSR_FE1 = 0x0100 MSR_AL = 0x0080 MSR_IP = 0x0040 MSR_IR = 0x0020 MSR_DR = 0x0010 MSR_PM = 0x0004 DEFAULT_MSR = (MSR_EE | MSR_ME | MSR_AL | MSR_IR | MSR_DR) DEFAULT_USER_MSR = (DEFAULT_MSR | MSR_PR) CR_LT = 0x80000000 CR_GT = 0x40000000 CR_EQ = 0x20000000 CR_SO = 0x10000000 CR_FX = 0x08000000 CR_FEX = 0x04000000 CR_VX = 0x02000000 CR_OX = 0x01000000 XER_SO = 0x80000000 XER_OV = 0x40000000 XER_CA = 0x20000000 def XER_COMP_BYTE(xer): return ((xer >> 8) & 0x000000FF) def XER_LENGTH(xer): return (xer & 0x0000007F) DSISR_IO = 0x80000000 DSISR_PFT = 0x40000000 DSISR_LOCK = 0x20000000 DSISR_FPIO = 0x10000000 DSISR_PROT = 0x08000000 DSISR_LOOP = 0x04000000 DSISR_DRST = 0x04000000 DSISR_ST = 0x02000000 DSISR_SEGB = 0x01000000 DSISR_DABR = 0x00400000 DSISR_EAR = 0x00100000 SRR_IS_PFT = 0x40000000 SRR_IS_ISPEC = 0x20000000 SRR_IS_IIO = 0x10000000 SRR_IS_GUARD = 0x10000000 SRR_IS_PROT = 0x08000000 SRR_IS_LOOP = 0x04000000 SRR_PR_FPEN = 0x00100000 SRR_PR_INVAL = 0x00080000 SRR_PR_PRIV = 0x00040000 SRR_PR_TRAP = 0x00020000 SRR_PR_IMPRE = 0x00010000 def BUID_7F_SRVAL(raddr): return (0x87F00000 | (((uint)(raddr)) >> 28)) BT_256M = 0x1FFC BT_128M = 0x0FFC BT_64M = 0x07FC BT_32M = 0x03FC BT_16M = 0x01FC BT_8M = 0x00FC BT_4M = 0x007C BT_2M = 0x003C BT_1M = 0x001C BT_512K = 0x000C BT_256K = 0x0004 BT_128K = 0x0000 BT_NOACCESS = 0x0 BT_RDONLY = 0x1 BT_WRITE = 0x2 BT_VS = 0x2 BT_VP = 0x1 def BAT_ESEG(dbatu): return (((uint)(dbatu) >> 28)) MIN_BAT_SIZE = 0x00020000 MAX_BAT_SIZE = 0x10000000 def ntohl(x): return (x) def ntohs(x): return (x) def htonl(x): return (x) def htons(x): return (x) IPPROTO_IP = 0 IPPROTO_ICMP = 1 IPPROTO_IGMP = 2 IPPROTO_GGP = 3 IPPROTO_TCP = 6 IPPROTO_EGP = 8 IPPROTO_PUP = 12 IPPROTO_UDP = 17 IPPROTO_IDP = 22 IPPROTO_TP = 29 IPPROTO_LOCAL = 63 IPPROTO_EON = 80 IPPROTO_BIP = 0x53 IPPROTO_RAW = 255 IPPROTO_MAX = 256 IPPORT_RESERVED = 1024 IPPORT_USERRESERVED = 5000 IPPORT_TIMESERVER = 37 def IN_CLASSA(i): return (((int)(i) & 0x80000000) == 0) IN_CLASSA_NET = 0xff000000 IN_CLASSA_NSHIFT = 24 IN_CLASSA_HOST = 0x00ffffff IN_CLASSA_MAX = 128 def IN_CLASSB(i): return (((int)(i) & 0xc0000000) == 0x80000000) IN_CLASSB_NET = 0xffff0000 IN_CLASSB_NSHIFT = 16 IN_CLASSB_HOST = 0x0000ffff IN_CLASSB_MAX = 65536 def IN_CLASSC(i): return (((int)(i) & 0xe0000000) == 0xc0000000) IN_CLASSC_NET = 0xffffff00 IN_CLASSC_NSHIFT = 8 IN_CLASSC_HOST = 0x000000ff def IN_CLASSD(i): return (((int)(i) & 0xf0000000) == 0xe0000000) def IN_MULTICAST(i): return IN_CLASSD(i) IN_CLASSD_NET = 0xf0000000 IN_CLASSD_NSHIFT = 28 IN_CLASSD_HOST = 0x0fffffff INADDR_UNSPEC_GROUP = 0xe0000000 INADDR_ALLHOSTS_GROUP = 0xe0000001 INADDR_MAX_LOCAL_GROUP = 0xe00000ff def IN_EXPERIMENTAL(i): return (((int)(i) & 0xe0000000) == 0xe0000000) def IN_BADCLASS(i): return (((int)(i) & 0xf0000000) == 0xf0000000) INADDR_ANY = 0x00000000 INADDR_BROADCAST = 0xffffffff INADDR_LOOPBACK = 0x7f000001 INADDR_NONE = 0xffffffff IN_LOOPBACKNET = 127 IP_OPTIONS = 1 IP_HDRINCL = 2 IP_TOS = 3 IP_TTL = 4 IP_RECVOPTS = 5 IP_RECVRETOPTS = 6 IP_RECVDSTADDR = 7 IP_RETOPTS = 8 IP_MULTICAST_IF = 9 IP_MULTICAST_TTL = 10 IP_MULTICAST_LOOP = 11 IP_ADD_MEMBERSHIP = 12 IP_DROP_MEMBERSHIP = 13 IP_DEFAULT_MULTICAST_TTL = 1 IP_DEFAULT_MULTICAST_LOOP = 1 IP_MAX_MEMBERSHIPS = 20
lgpl-3.0
[ 3, 17065, 701, 394, 18, 647, 687, 1182, 2647, 15, 2613, 15, 846, 10811, 15, 262, 14, 72, 199, 199, 3, 32732, 687, 1851, 15, 29199, 14, 72, 199, 199, 3, 32732, 687, 984, 15, 6744, 14, 72, 199, 44, 31783, 63, 21046, 275, 14763, 199, 18643, 63, 21046, 275, 841, 12638, 199, 11435, 48, 63, 21046, 275, 8177, 713, 199, 19714, 63, 12125, 275, 16524, 63, 21046, 199, 3472, 63, 39, 3311, 275, 378, 88, 29031, 6773, 14153, 199, 3053, 50, 63, 8699, 275, 378, 88, 15214, 199, 3053, 50, 63, 3311, 275, 378, 88, 23641, 199, 3053, 50, 63, 17095, 275, 378, 88, 8269, 199, 3053, 50, 63, 3635, 275, 378, 88, 5279, 199, 3053, 50, 63, 5100, 275, 378, 88, 25822, 199, 3053, 50, 63, 5100, 16, 275, 378, 88, 25822, 199, 3053, 50, 63, 899, 275, 378, 88, 27130, 199, 3053, 50, 63, 6773, 275, 378, 88, 24215, 199, 3053, 50, 63, 4332, 275, 378, 88, 16569, 199, 3053, 50, 63, 5100, 17, 275, 378, 88, 16569, 199, 3053, 50, 63, 748, 275, 378, 88, 23686, 199, 3053, 50, 63, 1772, 275, 378, 88, 25665, 199, 3053, 50, 63, 3927, 275, 378, 88, 20734, 199, 3053, 50, 63, 4564, 275, 378, 88, 17657, 199, 3053, 50, 63, 10793, 275, 378, 88, 16643, 199, 3472, 63, 3053, 50, 275, 334, 3053, 50, 63, 8699, 1204, 603, 5943, 63, 3635, 1204, 603, 5943, 63, 748, 1204, 603, 5943, 63, 3927, 1204, 603, 5943, 63, 4564, 9, 199, 3472, 63, 3791, 63, 3053, 50, 275, 334, 3472, 63, 3053, 50, 1204, 603, 5943, 63, 3311, 9, 199, 2944, 63, 17090, 275, 378, 88, 24, 9084, 199, 2944, 63, 8391, 275, 378, 88, 20, 9084, 199, 2944, 63, 17420, 275, 378, 88, 18, 9084, 199, 2944, 63, 4118, 275, 378, 88, 17, 9084, 199, 2944, 63, 22322, 275, 378, 88, 2036, 3273, 199, 2944, 63, 38, 1438, 275, 378, 88, 966, 3273, 199, 2944, 63, 28493, 275, 378, 88, 996, 3273, 199, 2944, 63, 29544, 275, 378, 88, 614, 3273, 199, 56, 540, 63, 4118, 275, 378, 88, 24, 9084, 199, 56, 540, 63, 30692, 275, 378, 88, 20, 9084, 199, 56, 540, 63, 3263, 275, 378, 88, 18, 9084, 199, 318, 1323, 540, 63, 6790, 63, 19714, 8, 32200, 304, 372, 3666, 32200, 4331, 1695, 9, 1253, 378, 88, 3273, 1665, 9, 199, 199, 318, 1323, 540, 63, 9127, 8, 32200, 304, 372, 334, 32200, 1253, 378, 88, 3273, 23, 38, 9, 199, 199, 3177, 1311, 50, 63, 2090, 275, 378, 88, 24, 9084, 199, 3177, 1311, 50, 63, 48, 2161, 275, 378, 88, 20, 9084, 199, 3177, 1311, 50, 63, 4406, 275, 378, 88, 18, 9084, 199, 3177, 1311, 50, 63, 17095, 2090, 275, 378, 88, 17, 9084, 199, 3177, 1311, 50, 63, 21998, 275, 378, 88, 2036, 3273, 199, 3177, 1311, 50, 63, 26573, 275, 378, 88, 966, 3273, 199, 3177, 1311, 50, 63, 4564, 840, 275, 378, 88, 966, 3273, 199, 3177, 1311, 50, 63, 840, 275, 378, 88, 996, 3273, 199, 3177, 1311, 50, 63, 899, 6487, 275, 378, 88, 614, 3273, 199, 3177, 1311, 50, 63, 36, 1217, 50, 275, 378, 88, 7979, 5345, 199, 3177, 1311, 50, 63, 15550, 275, 378, 88, 4587, 5345, 199, 5943, 50, 63, 1311, 63, 48, 2161, 275, 378, 88, 20, 9084, 199, 5943, 50, 63, 1311, 63, 1311, 1510, 35, 275, 378, 88, 18, 9084, 199, 5943, 50, 63, 1311, 63, 41, 2090, 275, 378, 88, 17, 9084, 199, 5943, 50, 63, 1311, 63, 17188, 7816, 275, 378, 88, 17, 9084, 199, 5943, 50, 63, 1311, 63, 21998, 275, 378, 88, 2036, 3273, 199, 5943, 50, 63, 1311, 63, 26573, 275, 378, 88, 966, 3273, 199, 5943, 50, 63, 3311, 63, 17095, 742, 275, 378, 88, 4587, 5345, 199, 5943, 50, 63, 3311, 63, 568, 3204, 275, 378, 88, 19141, 993, 199, 5943, 50, 63, 3311, 63, 13420, 275, 378, 88, 16643, 993, 199, 5943, 50, 63, 3311, 63, 1766, 1282, 275, 378, 88, 9425, 993, 199, 5943, 50, 63, 3311, 63, 1469, 4225, 275, 378, 88, 4183, 993, 199, 318, 699, 6685, 63, 23, 38, 63, 5943, 3204, 8, 22958, 82, 304, 372, 334, 16, 88, 1555, 38, 5345, 1204, 20337, 1635, 5130, 22958, 82, 430, 4331, 7294, 430, 199, 199, 19162, 63, 3912, 45, 275, 378, 88, 17, 1665, 35, 199, 19162, 63, 3933, 45, 275, 378, 88, 16, 1665, 35, 199, 19162, 63, 772, 45, 275, 378, 88, 1780, 4161, 199, 19162, 63, 708, 45, 275, 378, 88, 1644, 4161, 199, 19162, 63, 975, 45, 275, 378, 88, 614, 4161, 199, 19162, 63, 24, 45, 275, 378, 88, 383, 4161, 199, 19162, 63, 20, 45, 275, 378, 88, 8255, 35, 199, 19162, 63, 18, 45, 275, 378, 88, 8262, 35, 199, 19162, 63, 17, 45, 275, 378, 88, 4587, 35, 199, 19162, 63, 7736, 43, 275, 378, 88, 1493, 35, 199, 19162, 63, 3912, 43, 275, 378, 88, 16643, 199, 19162, 63, 3933, 43, 275, 378, 88, 993, 199, 19162, 63, 2826, 11074, 275, 378, 88, 16, 199, 19162, 63, 15543, 10452, 275, 378, 88, 17, 199, 19162, 63, 10387, 275, 378, 88, 18, 199, 19162, 63, 7428, 275, 378, 88, 18, 199, 19162, 63, 14159, 275, 378, 88, 17, 199, 318, 699, 619, 63, 654, 4680, 8, 697, 292, 85, 304, 372, 20337, 1635, 5130, 697, 292, 85, 9, 4331, 7294, 430, 199, 199, 4896, 63, 28839, 63, 4305, 275, 378, 88, 9425, 993, 199, 4283, 63, 28839, 63, 4305, 275, 378, 88, 17, 9084, 199, 318, 302, 475, 15544, 8, 88, 304, 372, 334, 88, 9, 199, 199, 318, 302, 475, 4213, 8, 88, 304, 372, 334, 88, 9, 199, 199, 318, 1243, 265, 76, 8, 88, 304, 372, 334, 88, 9, 199, 199, 318, 1243, 4654, 8, 88, 304, 372, 334, 88, 9, 199, 199, 20130, 63, 1772, 275, 378, 199, 20130, 63, 26616, 275, 413, 199, 20130, 63, 1277, 1658, 275, 499, 199, 20130, 63, 2916, 48, 275, 650, 199, 20130, 63, 9735, 275, 1227, 199, 20130, 63, 4680, 48, 275, 1695, 199, 20130, 63, 48, 2160, 275, 3144, 199, 20130, 63, 17457, 275 ]
[ 17065, 701, 394, 18, 647, 687, 1182, 2647, 15, 2613, 15, 846, 10811, 15, 262, 14, 72, 199, 199, 3, 32732, 687, 1851, 15, 29199, 14, 72, 199, 199, 3, 32732, 687, 984, 15, 6744, 14, 72, 199, 44, 31783, 63, 21046, 275, 14763, 199, 18643, 63, 21046, 275, 841, 12638, 199, 11435, 48, 63, 21046, 275, 8177, 713, 199, 19714, 63, 12125, 275, 16524, 63, 21046, 199, 3472, 63, 39, 3311, 275, 378, 88, 29031, 6773, 14153, 199, 3053, 50, 63, 8699, 275, 378, 88, 15214, 199, 3053, 50, 63, 3311, 275, 378, 88, 23641, 199, 3053, 50, 63, 17095, 275, 378, 88, 8269, 199, 3053, 50, 63, 3635, 275, 378, 88, 5279, 199, 3053, 50, 63, 5100, 275, 378, 88, 25822, 199, 3053, 50, 63, 5100, 16, 275, 378, 88, 25822, 199, 3053, 50, 63, 899, 275, 378, 88, 27130, 199, 3053, 50, 63, 6773, 275, 378, 88, 24215, 199, 3053, 50, 63, 4332, 275, 378, 88, 16569, 199, 3053, 50, 63, 5100, 17, 275, 378, 88, 16569, 199, 3053, 50, 63, 748, 275, 378, 88, 23686, 199, 3053, 50, 63, 1772, 275, 378, 88, 25665, 199, 3053, 50, 63, 3927, 275, 378, 88, 20734, 199, 3053, 50, 63, 4564, 275, 378, 88, 17657, 199, 3053, 50, 63, 10793, 275, 378, 88, 16643, 199, 3472, 63, 3053, 50, 275, 334, 3053, 50, 63, 8699, 1204, 603, 5943, 63, 3635, 1204, 603, 5943, 63, 748, 1204, 603, 5943, 63, 3927, 1204, 603, 5943, 63, 4564, 9, 199, 3472, 63, 3791, 63, 3053, 50, 275, 334, 3472, 63, 3053, 50, 1204, 603, 5943, 63, 3311, 9, 199, 2944, 63, 17090, 275, 378, 88, 24, 9084, 199, 2944, 63, 8391, 275, 378, 88, 20, 9084, 199, 2944, 63, 17420, 275, 378, 88, 18, 9084, 199, 2944, 63, 4118, 275, 378, 88, 17, 9084, 199, 2944, 63, 22322, 275, 378, 88, 2036, 3273, 199, 2944, 63, 38, 1438, 275, 378, 88, 966, 3273, 199, 2944, 63, 28493, 275, 378, 88, 996, 3273, 199, 2944, 63, 29544, 275, 378, 88, 614, 3273, 199, 56, 540, 63, 4118, 275, 378, 88, 24, 9084, 199, 56, 540, 63, 30692, 275, 378, 88, 20, 9084, 199, 56, 540, 63, 3263, 275, 378, 88, 18, 9084, 199, 318, 1323, 540, 63, 6790, 63, 19714, 8, 32200, 304, 372, 3666, 32200, 4331, 1695, 9, 1253, 378, 88, 3273, 1665, 9, 199, 199, 318, 1323, 540, 63, 9127, 8, 32200, 304, 372, 334, 32200, 1253, 378, 88, 3273, 23, 38, 9, 199, 199, 3177, 1311, 50, 63, 2090, 275, 378, 88, 24, 9084, 199, 3177, 1311, 50, 63, 48, 2161, 275, 378, 88, 20, 9084, 199, 3177, 1311, 50, 63, 4406, 275, 378, 88, 18, 9084, 199, 3177, 1311, 50, 63, 17095, 2090, 275, 378, 88, 17, 9084, 199, 3177, 1311, 50, 63, 21998, 275, 378, 88, 2036, 3273, 199, 3177, 1311, 50, 63, 26573, 275, 378, 88, 966, 3273, 199, 3177, 1311, 50, 63, 4564, 840, 275, 378, 88, 966, 3273, 199, 3177, 1311, 50, 63, 840, 275, 378, 88, 996, 3273, 199, 3177, 1311, 50, 63, 899, 6487, 275, 378, 88, 614, 3273, 199, 3177, 1311, 50, 63, 36, 1217, 50, 275, 378, 88, 7979, 5345, 199, 3177, 1311, 50, 63, 15550, 275, 378, 88, 4587, 5345, 199, 5943, 50, 63, 1311, 63, 48, 2161, 275, 378, 88, 20, 9084, 199, 5943, 50, 63, 1311, 63, 1311, 1510, 35, 275, 378, 88, 18, 9084, 199, 5943, 50, 63, 1311, 63, 41, 2090, 275, 378, 88, 17, 9084, 199, 5943, 50, 63, 1311, 63, 17188, 7816, 275, 378, 88, 17, 9084, 199, 5943, 50, 63, 1311, 63, 21998, 275, 378, 88, 2036, 3273, 199, 5943, 50, 63, 1311, 63, 26573, 275, 378, 88, 966, 3273, 199, 5943, 50, 63, 3311, 63, 17095, 742, 275, 378, 88, 4587, 5345, 199, 5943, 50, 63, 3311, 63, 568, 3204, 275, 378, 88, 19141, 993, 199, 5943, 50, 63, 3311, 63, 13420, 275, 378, 88, 16643, 993, 199, 5943, 50, 63, 3311, 63, 1766, 1282, 275, 378, 88, 9425, 993, 199, 5943, 50, 63, 3311, 63, 1469, 4225, 275, 378, 88, 4183, 993, 199, 318, 699, 6685, 63, 23, 38, 63, 5943, 3204, 8, 22958, 82, 304, 372, 334, 16, 88, 1555, 38, 5345, 1204, 20337, 1635, 5130, 22958, 82, 430, 4331, 7294, 430, 199, 199, 19162, 63, 3912, 45, 275, 378, 88, 17, 1665, 35, 199, 19162, 63, 3933, 45, 275, 378, 88, 16, 1665, 35, 199, 19162, 63, 772, 45, 275, 378, 88, 1780, 4161, 199, 19162, 63, 708, 45, 275, 378, 88, 1644, 4161, 199, 19162, 63, 975, 45, 275, 378, 88, 614, 4161, 199, 19162, 63, 24, 45, 275, 378, 88, 383, 4161, 199, 19162, 63, 20, 45, 275, 378, 88, 8255, 35, 199, 19162, 63, 18, 45, 275, 378, 88, 8262, 35, 199, 19162, 63, 17, 45, 275, 378, 88, 4587, 35, 199, 19162, 63, 7736, 43, 275, 378, 88, 1493, 35, 199, 19162, 63, 3912, 43, 275, 378, 88, 16643, 199, 19162, 63, 3933, 43, 275, 378, 88, 993, 199, 19162, 63, 2826, 11074, 275, 378, 88, 16, 199, 19162, 63, 15543, 10452, 275, 378, 88, 17, 199, 19162, 63, 10387, 275, 378, 88, 18, 199, 19162, 63, 7428, 275, 378, 88, 18, 199, 19162, 63, 14159, 275, 378, 88, 17, 199, 318, 699, 619, 63, 654, 4680, 8, 697, 292, 85, 304, 372, 20337, 1635, 5130, 697, 292, 85, 9, 4331, 7294, 430, 199, 199, 4896, 63, 28839, 63, 4305, 275, 378, 88, 9425, 993, 199, 4283, 63, 28839, 63, 4305, 275, 378, 88, 17, 9084, 199, 318, 302, 475, 15544, 8, 88, 304, 372, 334, 88, 9, 199, 199, 318, 302, 475, 4213, 8, 88, 304, 372, 334, 88, 9, 199, 199, 318, 1243, 265, 76, 8, 88, 304, 372, 334, 88, 9, 199, 199, 318, 1243, 4654, 8, 88, 304, 372, 334, 88, 9, 199, 199, 20130, 63, 1772, 275, 378, 199, 20130, 63, 26616, 275, 413, 199, 20130, 63, 1277, 1658, 275, 499, 199, 20130, 63, 2916, 48, 275, 650, 199, 20130, 63, 9735, 275, 1227, 199, 20130, 63, 4680, 48, 275, 1695, 199, 20130, 63, 48, 2160, 275, 3144, 199, 20130, 63, 17457, 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, 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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 ]
teto/ns-3-dev-git
doc/tutorial/source/conf.py
1
7057
# -*- coding: utf-8 -*- # # ns-3 documentation build configuration file, created by # sphinx-quickstart on Tue Dec 14 09:00:39 2010. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.imgmath'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'ns-3' copyright = u'2010, ns-3 project' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = 'ns-3-dev' # The full version, including alpha/beta/rc tags. release = 'ns-3-dev' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'ns3_html_theme' # 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 = 'Tutorial' # 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 %H:%M' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a <link> tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'ns-3doc' # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'ns-3-tutorial.tex', u'ns-3 Tutorial', u'ns-3 project', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. latex_logo = '../../ns3_html_theme/static/ns-3.png' # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Additional stuff for the LaTeX preamble. latex_preamble = '\usepackage{amssymb}' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'ns-3-tutorial', u'ns-3 Tutorial', [u'ns-3 project'], 1) ]
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 700, 13, 19, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 13966, 4329, 21798, 26, 383, 26, 1355, 7129, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 4060, 3442, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 561, 13, 19, 7, 199, 7307, 275, 399, 7, 6542, 12, 700, 13, 19, 2199, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 561, 13, 19, 13, 2374, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 561, 13, 19, 13, 2374, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 942, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 561, 19, 63, 1360, 63, 7915, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 1360, 63, 7915, 63, 515, 275, 788, 5093, 703, 418, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 1360, 63, 1213, 275, 283, 52, 15888, 7, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 6188, 370, 642, 2082, 9, 370, 4192, 737, 314, 2746, 199, 3, 402, 314, 18437, 14, 199, 3, 1360, 63, 9733, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016, 570, 17048, 12802, 9, 3769, 3193, 88 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 700, 13, 19, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 13966, 4329, 21798, 26, 383, 26, 1355, 7129, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 3, 1274, 14, 515, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 4060, 3442, 418, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 7009, 2348, 12, 3847, 370, 642, 2082, 14, 199, 5876, 63, 515, 275, 4044, 5876, 418, 199, 199, 3, 710, 4739, 402, 1350, 6203, 14, 199, 1365, 63, 4511, 275, 1987, 8332, 7, 199, 199, 3, 710, 2644, 402, 1350, 1584, 14, 199, 3, 1365, 63, 2991, 275, 283, 1624, 13, 24, 13, 4093, 7, 199, 199, 3, 710, 5288, 28310, 2213, 14, 199, 4133, 63, 1301, 275, 283, 1080, 7, 199, 199, 3, 1696, 2556, 3595, 314, 2199, 14, 199, 1715, 275, 399, 7, 561, 13, 19, 7, 199, 7307, 275, 399, 7, 6542, 12, 700, 13, 19, 2199, 7, 199, 199, 3, 710, 1015, 2256, 367, 314, 2199, 1265, 3984, 29904, 12, 17795, 465, 8343, 367, 199, 3, 1204, 1023, 92, 436, 1204, 3221, 18712, 2597, 1202, 315, 7750, 1163, 9825, 23088, 314, 199, 3, 6137, 8247, 14, 199, 3, 199, 3, 710, 3974, 1323, 14, 57, 1015, 14, 199, 1023, 275, 283, 561, 13, 19, 13, 2374, 7, 199, 3, 710, 2615, 1015, 12, 5893, 5131, 15, 5683, 15, 1195, 3762, 14, 199, 3221, 275, 283, 561, 13, 19, 13, 2374, 7, 199, 199, 3, 710, 2637, 367, 1564, 18392, 701, 10229, 14, 21751, 370, 3794, 199, 3, 367, 282, 769, 402, 3748, 10815, 14, 199, 3, 3671, 275, 488, 199, 199, 3, 6006, 787, 2877, 1511, 367, 15810, 1204, 8136, 25004, 1902, 12, 1265, 663, 11168, 370, 2005, 199, 3, 2222, 13, 3910, 574, 12, 2066, 652, 365, 1202, 26, 199, 3, 8136, 275, 2125, 199, 3, 19524, 12, 11168, 63, 5045, 365, 1202, 465, 314, 1475, 367, 282, 14053, 1240, 14, 199, 3, 8136, 63, 5045, 275, 1543, 34, 450, 68, 12, 450, 57, 7, 199, 199, 3, 3820, 402, 7970, 12, 3847, 370, 1350, 2082, 12, 626, 1336, 1584, 436, 199, 3, 6602, 370, 3686, 1380, 10023, 367, 1350, 1584, 14, 199, 5473, 63, 7435, 275, 942, 199, 199, 3, 710, 20883, 849, 4719, 334, 2972, 367, 642, 9189, 26, 658, 505, 10522, 370, 675, 367, 1006, 8247, 14, 199, 3, 885, 63, 3756, 275, 488, 199, 199, 3, 982, 2549, 12, 26380, 911, 506, 11544, 370, 520, 1532, 26, 5423, 14, 8059, 13, 4443, 1318, 14, 199, 3, 525, 63, 1593, 63, 25510, 275, 715, 199, 199, 3, 982, 2549, 12, 314, 1453, 859, 536, 911, 506, 20247, 370, 1006, 1369, 199, 3, 4137, 16194, 334, 10180, 465, 2508, 805, 32469, 199, 3, 525, 63, 578, 63, 1247, 275, 715, 199, 199, 3, 982, 2549, 12, 3420, 2502, 436, 28966, 13502, 911, 506, 9164, 315, 314, 199, 3, 1072, 14, 9322, 787, 5525, 701, 849, 14, 199, 3, 2384, 63, 8149, 275, 756, 199, 199, 3, 710, 536, 402, 314, 14493, 334, 7093, 22437, 9, 3449, 370, 675, 14, 199, 12173, 63, 2487, 275, 283, 8008, 7, 199, 199, 3, 437, 769, 402, 5525, 13158, 367, 859, 1478, 13351, 14, 199, 3, 27555, 63, 2330, 63, 1861, 275, 942, 421, 199, 3, 1553, 8394, 367, 4163, 1072, 9527, 2595, 199, 199, 3, 710, 8879, 370, 675, 367, 4163, 436, 4163, 15456, 6497, 14, 221, 1666, 314, 3794, 367, 199, 3, 282, 769, 402, 6762, 17915, 14, 199, 1360, 63, 7915, 275, 283, 561, 19, 63, 1360, 63, 7915, 7, 199, 199, 3, 23978, 1511, 787, 8879, 13, 6100, 436, 17551, 314, 3648, 436, 23109, 402, 282, 8879, 199, 3, 9848, 14, 221, 2104, 282, 769, 402, 1511, 2808, 367, 1924, 8879, 12, 1937, 314, 199, 3, 3794, 14, 199, 3, 1360, 63, 7915, 63, 1419, 275, 1052, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 1360, 63, 7915, 63, 515, 275, 788, 5093, 703, 418, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 199, 1360, 63, 1213, 275, 283, 52, 15888, 7, 199, 199, 3, 437, 18299, 2538, 367, 314, 19191, 4681, 14, 221, 3758, 365, 314, 2011, 465, 3517, 63, 1213, 14, 199, 3, 1360, 63, 3612, 63, 1213, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 6188, 370, 642, 2082, 9, 370, 4192, 737, 314, 2746, 199, 3, 402, 314, 18437, 14, 199, 3, 1360, 63, 9733, 275, 488, 199, 199, 3, 710, 536, 402, 376, 1834, 570, 334, 12541, 314, 2955, 931, 9, 370, 675, 465, 29139, 402, 314, 199, 3, 9149, 14, 221, 961, 570, 1077, 506, 282, 5417, 7016, 570, 17048, 12802, 9, 3769, 3193, 88, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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in/python2.4 # # Copyright 2008 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Contains objects used with Google Apps.""" __author__ = 'google-apps-apis@googlegroups.com' import atom import gdata # XML namespaces which are often used in Google Apps entity. APPS_NAMESPACE = 'http://schemas.google.com/apps/2006' APPS_TEMPLATE = '{http://schemas.google.com/apps/2006}%s' class Rfc822Msg(atom.AtomBase): """The Migration rfc822Msg element.""" _tag = 'rfc822Msg' _namespace = APPS_NAMESPACE _children = atom.AtomBase._children.copy() _attributes = atom.AtomBase._attributes.copy() _attributes['encoding'] = 'encoding' def __init__(self, extension_elements=None, extension_attributes=None, text=None): self.text = text self.encoding = 'base64' self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def Rfc822MsgFromString(xml_string): """Parse in the Rrc822 message from the XML definition.""" return atom.CreateClassFromXMLString(Rfc822Msg, xml_string) class MailItemProperty(atom.AtomBase): """The Migration mailItemProperty element.""" _tag = 'mailItemProperty' _namespace = APPS_NAMESPACE _children = atom.AtomBase._children.copy() _attributes = atom.AtomBase._attributes.copy() _attributes['value'] = 'value' def __init__(self, value=None, extension_elements=None, extension_attributes=None, text=None): self.value = value self.text = text self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def MailItemPropertyFromString(xml_string): """Parse in the MailItemProperiy from the XML definition.""" return atom.CreateClassFromXMLString(MailItemProperty, xml_string) class Label(atom.AtomBase): """The Migration label element.""" _tag = 'label' _namespace = APPS_NAMESPACE _children = atom.AtomBase._children.copy() _attributes = atom.AtomBase._attributes.copy() _attributes['labelName'] = 'label_name' def __init__(self, label_name=None, extension_elements=None, extension_attributes=None, text=None): self.label_name = label_name self.text = text self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def LabelFromString(xml_string): """Parse in the mailItemProperty from the XML definition.""" return atom.CreateClassFromXMLString(Label, xml_string) class MailEntry(gdata.GDataEntry): """A Google Migration flavor of an Atom Entry.""" _tag = 'entry' _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataEntry._children.copy() _attributes = gdata.GDataEntry._attributes.copy() _children['{%s}rfc822Msg' % APPS_NAMESPACE] = ('rfc822_msg', Rfc822Msg) _children['{%s}mailItemProperty' % APPS_NAMESPACE] = ('mail_item_property', [MailItemProperty]) _children['{%s}label' % APPS_NAMESPACE] = ('label', [Label]) def __init__(self, author=None, category=None, content=None, atom_id=None, link=None, published=None, title=None, updated=None, rfc822_msg=None, mail_item_property=None, label=None, extended_property=None, extension_elements=None, extension_attributes=None, text=None): gdata.GDataEntry.__init__(self, author=author, category=category, content=content, atom_id=atom_id, link=link, published=published, title=title, updated=updated) self.rfc822_msg = rfc822_msg self.mail_item_property = mail_item_property self.label = label self.extended_property = extended_property or [] self.text = text self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def MailEntryFromString(xml_string): """Parse in the MailEntry from the XML definition.""" return atom.CreateClassFromXMLString(MailEntry, xml_string) class BatchMailEntry(gdata.BatchEntry): """A Google Migration flavor of an Atom Entry.""" _tag = gdata.BatchEntry._tag _namespace = gdata.BatchEntry._namespace _children = gdata.BatchEntry._children.copy() _attributes = gdata.BatchEntry._attributes.copy() _children['{%s}rfc822Msg' % APPS_NAMESPACE] = ('rfc822_msg', Rfc822Msg) _children['{%s}mailItemProperty' % APPS_NAMESPACE] = ('mail_item_property', [MailItemProperty]) _children['{%s}label' % APPS_NAMESPACE] = ('label', [Label]) def __init__(self, author=None, category=None, content=None, atom_id=None, link=None, published=None, title=None, updated=None, rfc822_msg=None, mail_item_property=None, label=None, batch_operation=None, batch_id=None, batch_status=None, extended_property=None, extension_elements=None, extension_attributes=None, text=None): gdata.BatchEntry.__init__(self, author=author, category=category, content=content, atom_id=atom_id, link=link, published=published, batch_operation=batch_operation, batch_id=batch_id, batch_status=batch_status, title=title, updated=updated) self.rfc822_msg = rfc822_msg or None self.mail_item_property = mail_item_property or [] self.label = label or [] self.extended_property = extended_property or [] self.text = text self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def BatchMailEntryFromString(xml_string): """Parse in the BatchMailEntry from the XML definition.""" return atom.CreateClassFromXMLString(BatchMailEntry, xml_string) class BatchMailEventFeed(gdata.BatchFeed): """A Migration event feed flavor of an Atom Feed.""" _tag = gdata.BatchFeed._tag _namespace = gdata.BatchFeed._namespace _children = gdata.BatchFeed._children.copy() _attributes = gdata.BatchFeed._attributes.copy() _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [BatchMailEntry]) def __init__(self, author=None, category=None, contributor=None, generator=None, icon=None, atom_id=None, link=None, logo=None, rights=None, subtitle=None, title=None, updated=None, entry=None, total_results=None, start_index=None, items_per_page=None, interrupted=None, extension_elements=None, extension_attributes=None, text=None): gdata.BatchFeed.__init__(self, author=author, category=category, contributor=contributor, generator=generator, icon=icon, atom_id=atom_id, link=link, logo=logo, rights=rights, subtitle=subtitle, title=title, updated=updated, entry=entry, total_results=total_results, start_index=start_index, items_per_page=items_per_page, interrupted=interrupted, extension_elements=extension_elements, extension_attributes=extension_attributes, text=text) class MailEntryProperties(object): """Represents a mail message and its attributes.""" def __init__(self, mail_message=None, mail_item_properties=None, mail_labels=None, identifier=None): self.mail_message = mail_message self.mail_item_properties = mail_item_properties or [] self.mail_labels = mail_labels or [] self.identifier = identifier def BatchMailEventFeedFromString(xml_string): """Parse in the BatchMailEventFeed from the XML definition.""" return atom.CreateClassFromXMLString(BatchMailEventFeed, xml_string)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 18, 14, 20, 199, 3, 199, 3, 1898, 9079, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 6906, 2251, 1202, 543, 4475, 4693, 83, 1041, 199, 199, 363, 2502, 363, 275, 283, 3098, 13, 5181, 13, 12662, 32, 3098, 2634, 14, 957, 7, 421, 199, 646, 6222, 199, 646, 11006, 421, 199, 3, 4692, 10747, 1314, 787, 14115, 1202, 315, 4475, 4693, 83, 4642, 14, 199, 14219, 63, 13001, 275, 283, 1014, 921, 9482, 14, 3098, 14, 957, 15, 5181, 15, 7968, 7, 199, 14219, 63, 7433, 275, 5041, 1014, 921, 9482, 14, 3098, 14, 957, 15, 5181, 15, 7968, 22109, 83, 7, 421, 199, 533, 820, 3003, 10228, 6173, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 12090, 18158, 10228, 6173, 1819, 1041, 819, 485, 1450, 275, 283, 8973, 10228, 6173, 7, 523, 485, 3251, 275, 10319, 5067, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 523, 485, 2987, 459, 2991, 418, 275, 283, 2991, 7, 819, 347, 636, 826, 721, 277, 12, 3329, 63, 5527, 29, 403, 12, 2049, 3329, 63, 2987, 29, 403, 12, 1318, 29, 403, 304, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 2991, 275, 283, 1095, 772, 7, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 421, 199, 318, 820, 3003, 10228, 6173, 7671, 8, 1652, 63, 875, 304, 523, 408, 4003, 315, 314, 820, 1195, 10228, 1245, 687, 314, 4692, 5492, 1041, 819, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 50, 3003, 10228, 6173, 12, 2748, 63, 875, 9, 421, 199, 533, 18027, 2081, 3697, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 12090, 6016, 2081, 3697, 1819, 1041, 819, 485, 1450, 275, 283, 1198, 2081, 3697, 7, 523, 485, 3251, 275, 10319, 5067, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 523, 485, 2987, 459, 585, 418, 275, 283, 585, 7, 819, 347, 636, 826, 721, 277, 12, 574, 29, 403, 12, 3329, 63, 5527, 29, 403, 12, 2049, 3329, 63, 2987, 29, 403, 12, 1318, 29, 403, 304, 272, 291, 14, 585, 275, 574, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 421, 199, 318, 18027, 2081, 3697, 7671, 8, 1652, 63, 875, 304, 523, 408, 4003, 315, 314, 18027, 2081, 919, 5490, 89, 687, 314, 4692, 5492, 1041, 819, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 13681, 2081, 3697, 12, 2748, 63, 875, 9, 421, 199, 533, 10354, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 12090, 1768, 1819, 1041, 819, 485, 1450, 275, 283, 1302, 7, 523, 485, 3251, 275, 10319, 5067, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 523, 485, 2987, 459, 1302, 985, 418, 275, 283, 1302, 63, 354, 7, 819, 347, 636, 826, 721, 277, 12, 1768, 63, 354, 29, 403, 12, 2049, 3329, 63, 5527, 29, 403, 12, 3329, 63, 2987, 29, 403, 12, 2049, 1318, 29, 403, 304, 272, 291, 14, 1302, 63, 354, 275, 1768, 63, 354, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 421, 199, 318, 10354, 7671, 8, 1652, 63, 875, 304, 523, 408, 4003, 315, 314, 6016, 2081, 3697, 687, 314, 4692, 5492, 1041, 819, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 4314, 12, 2748, 63, 875, 9, 421, 199, 533, 18027, 3900, 8, 15275, 14, 27413, 3900, 304, 523, 408, 33, 4475, 12090, 8541, 402, 376, 18840, 11855, 1041, 819, 485, 1450, 275, 283, 2373, 7, 523, 485, 3251, 275, 6222, 14, 22479, 63, 13001, 523, 485, 3223, 275, 11006, 14, 27413, 3900, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 11006, 14, 27413, 3900, 423, 2987, 14, 1574, 342, 523, 485, 3223, 32074, 83, 93, 8973, 10228, 6173, 7, 450, 10319, 5067, 63, 13001, 61, 275, 661, 8973, 10228, 63, 1328, 297, 820, 3003, 10228, 6173, 9, 523, 485, 3223, 32074, 83, 93, 1198, 2081, 3697, 7, 450, 10319, 5067, 63, 13001, 61, 275, 661, 1198, 63, 1053, 63, 1829, 297, 9144, 359, 13681, 2081, 3697, 566, 523, 485, 3223, 32074, 83, 93, 1302, 7, 450, 10319, 5067, 63, 13001, 61, 275, 661, 1302, 297, 359, 4314, 566, 819, 347, 636, 826, 721, 277, 12, 4132, 29, 403, 12, 4637, 29, 403, 12, 1564, 29, 403, 12, 2049, 6222, 63, 344, 29, 403, 12, 2142, 29, 403, 12, 3267, 29, 403, 12, 2049, 2538, 29, 403, 12, 4588, 29, 403, 12, 2049, 18158, 10228, 63, 1328, 29, 403, 12, 6016, 63, 1053, 63, 1829, 29, 403, 12, 1768, 29, 403, 12, 2049, 9243, 63, 1829, 29, 403, 12, 2049, 3329, 63, 5527, 29, 403, 12, 3329, 63, 2987, 29, 403, 12, 1318, 29, 403, 304, 339, 11006, 14, 27413 ]
[ 2647, 15, 1393, 15, 1548, 18, 14, 20, 199, 3, 199, 3, 1898, 9079, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 6906, 2251, 1202, 543, 4475, 4693, 83, 1041, 199, 199, 363, 2502, 363, 275, 283, 3098, 13, 5181, 13, 12662, 32, 3098, 2634, 14, 957, 7, 421, 199, 646, 6222, 199, 646, 11006, 421, 199, 3, 4692, 10747, 1314, 787, 14115, 1202, 315, 4475, 4693, 83, 4642, 14, 199, 14219, 63, 13001, 275, 283, 1014, 921, 9482, 14, 3098, 14, 957, 15, 5181, 15, 7968, 7, 199, 14219, 63, 7433, 275, 5041, 1014, 921, 9482, 14, 3098, 14, 957, 15, 5181, 15, 7968, 22109, 83, 7, 421, 199, 533, 820, 3003, 10228, 6173, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 12090, 18158, 10228, 6173, 1819, 1041, 819, 485, 1450, 275, 283, 8973, 10228, 6173, 7, 523, 485, 3251, 275, 10319, 5067, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 523, 485, 2987, 459, 2991, 418, 275, 283, 2991, 7, 819, 347, 636, 826, 721, 277, 12, 3329, 63, 5527, 29, 403, 12, 2049, 3329, 63, 2987, 29, 403, 12, 1318, 29, 403, 304, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 2991, 275, 283, 1095, 772, 7, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 421, 199, 318, 820, 3003, 10228, 6173, 7671, 8, 1652, 63, 875, 304, 523, 408, 4003, 315, 314, 820, 1195, 10228, 1245, 687, 314, 4692, 5492, 1041, 819, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 50, 3003, 10228, 6173, 12, 2748, 63, 875, 9, 421, 199, 533, 18027, 2081, 3697, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 12090, 6016, 2081, 3697, 1819, 1041, 819, 485, 1450, 275, 283, 1198, 2081, 3697, 7, 523, 485, 3251, 275, 10319, 5067, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 523, 485, 2987, 459, 585, 418, 275, 283, 585, 7, 819, 347, 636, 826, 721, 277, 12, 574, 29, 403, 12, 3329, 63, 5527, 29, 403, 12, 2049, 3329, 63, 2987, 29, 403, 12, 1318, 29, 403, 304, 272, 291, 14, 585, 275, 574, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 421, 199, 318, 18027, 2081, 3697, 7671, 8, 1652, 63, 875, 304, 523, 408, 4003, 315, 314, 18027, 2081, 919, 5490, 89, 687, 314, 4692, 5492, 1041, 819, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 13681, 2081, 3697, 12, 2748, 63, 875, 9, 421, 199, 533, 10354, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 12090, 1768, 1819, 1041, 819, 485, 1450, 275, 283, 1302, 7, 523, 485, 3251, 275, 10319, 5067, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 523, 485, 2987, 459, 1302, 985, 418, 275, 283, 1302, 63, 354, 7, 819, 347, 636, 826, 721, 277, 12, 1768, 63, 354, 29, 403, 12, 2049, 3329, 63, 5527, 29, 403, 12, 3329, 63, 2987, 29, 403, 12, 2049, 1318, 29, 403, 304, 272, 291, 14, 1302, 63, 354, 275, 1768, 63, 354, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 421, 199, 318, 10354, 7671, 8, 1652, 63, 875, 304, 523, 408, 4003, 315, 314, 6016, 2081, 3697, 687, 314, 4692, 5492, 1041, 819, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 4314, 12, 2748, 63, 875, 9, 421, 199, 533, 18027, 3900, 8, 15275, 14, 27413, 3900, 304, 523, 408, 33, 4475, 12090, 8541, 402, 376, 18840, 11855, 1041, 819, 485, 1450, 275, 283, 2373, 7, 523, 485, 3251, 275, 6222, 14, 22479, 63, 13001, 523, 485, 3223, 275, 11006, 14, 27413, 3900, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 11006, 14, 27413, 3900, 423, 2987, 14, 1574, 342, 523, 485, 3223, 32074, 83, 93, 8973, 10228, 6173, 7, 450, 10319, 5067, 63, 13001, 61, 275, 661, 8973, 10228, 63, 1328, 297, 820, 3003, 10228, 6173, 9, 523, 485, 3223, 32074, 83, 93, 1198, 2081, 3697, 7, 450, 10319, 5067, 63, 13001, 61, 275, 661, 1198, 63, 1053, 63, 1829, 297, 9144, 359, 13681, 2081, 3697, 566, 523, 485, 3223, 32074, 83, 93, 1302, 7, 450, 10319, 5067, 63, 13001, 61, 275, 661, 1302, 297, 359, 4314, 566, 819, 347, 636, 826, 721, 277, 12, 4132, 29, 403, 12, 4637, 29, 403, 12, 1564, 29, 403, 12, 2049, 6222, 63, 344, 29, 403, 12, 2142, 29, 403, 12, 3267, 29, 403, 12, 2049, 2538, 29, 403, 12, 4588, 29, 403, 12, 2049, 18158, 10228, 63, 1328, 29, 403, 12, 6016, 63, 1053, 63, 1829, 29, 403, 12, 1768, 29, 403, 12, 2049, 9243, 63, 1829, 29, 403, 12, 2049, 3329, 63, 5527, 29, 403, 12, 3329, 63, 2987, 29, 403, 12, 1318, 29, 403, 304, 339, 11006, 14, 27413, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
alisidd/tensorflow
tensorflow/contrib/keras/python/keras/layers/pooling_test.py
24
6087
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for pooling layers.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.contrib.keras.python import keras from tensorflow.contrib.keras.python.keras import testing_utils from tensorflow.python.platform import test class GlobalPoolingTest(test.TestCase): def test_globalpooling_1d(self): with self.test_session(): testing_utils.layer_test(keras.layers.pooling.GlobalMaxPooling1D, input_shape=(3, 4, 5)) testing_utils.layer_test( keras.layers.pooling.GlobalAveragePooling1D, input_shape=(3, 4, 5)) def test_globalpooling_2d(self): with self.test_session(): testing_utils.layer_test( keras.layers.pooling.GlobalMaxPooling2D, kwargs={'data_format': 'channels_first'}, input_shape=(3, 4, 5, 6)) testing_utils.layer_test( keras.layers.pooling.GlobalMaxPooling2D, kwargs={'data_format': 'channels_last'}, input_shape=(3, 5, 6, 4)) testing_utils.layer_test( keras.layers.pooling.GlobalAveragePooling2D, kwargs={'data_format': 'channels_first'}, input_shape=(3, 4, 5, 6)) testing_utils.layer_test( keras.layers.pooling.GlobalAveragePooling2D, kwargs={'data_format': 'channels_last'}, input_shape=(3, 5, 6, 4)) def test_globalpooling_3d(self): with self.test_session(): testing_utils.layer_test( keras.layers.pooling.GlobalMaxPooling3D, kwargs={'data_format': 'channels_first'}, input_shape=(3, 4, 3, 4, 3)) testing_utils.layer_test( keras.layers.pooling.GlobalMaxPooling3D, kwargs={'data_format': 'channels_last'}, input_shape=(3, 4, 3, 4, 3)) testing_utils.layer_test( keras.layers.pooling.GlobalAveragePooling3D, kwargs={'data_format': 'channels_first'}, input_shape=(3, 4, 3, 4, 3)) testing_utils.layer_test( keras.layers.pooling.GlobalAveragePooling3D, kwargs={'data_format': 'channels_last'}, input_shape=(3, 4, 3, 4, 3)) class Pooling2DTest(test.TestCase): def test_maxpooling_2d(self): pool_size = (3, 3) with self.test_session(): for strides in [(1, 1), (2, 2)]: testing_utils.layer_test( keras.layers.MaxPooling2D, kwargs={ 'strides': strides, 'padding': 'valid', 'pool_size': pool_size }, input_shape=(3, 5, 6, 4)) def test_averagepooling_2d(self): with self.test_session(): testing_utils.layer_test( keras.layers.AveragePooling2D, kwargs={'strides': (2, 2), 'padding': 'same', 'pool_size': (2, 2)}, input_shape=(3, 5, 6, 4)) testing_utils.layer_test( keras.layers.AveragePooling2D, kwargs={'strides': (2, 2), 'padding': 'valid', 'pool_size': (3, 3)}, input_shape=(3, 5, 6, 4)) testing_utils.layer_test( keras.layers.AveragePooling2D, kwargs={ 'strides': (1, 1), 'padding': 'valid', 'pool_size': (2, 2), 'data_format': 'channels_first' }, input_shape=(3, 4, 5, 6)) class Pooling3DTest(test.TestCase): def test_maxpooling_3d(self): pool_size = (3, 3, 3) with self.test_session(): testing_utils.layer_test( keras.layers.MaxPooling3D, kwargs={'strides': 2, 'padding': 'valid', 'pool_size': pool_size}, input_shape=(3, 11, 12, 10, 4)) testing_utils.layer_test( keras.layers.MaxPooling3D, kwargs={ 'strides': 3, 'padding': 'valid', 'data_format': 'channels_first', 'pool_size': pool_size }, input_shape=(3, 4, 11, 12, 10)) def test_averagepooling_3d(self): pool_size = (3, 3, 3) with self.test_session(): testing_utils.layer_test( keras.layers.AveragePooling3D, kwargs={'strides': 2, 'padding': 'valid', 'pool_size': pool_size}, input_shape=(3, 11, 12, 10, 4)) testing_utils.layer_test( keras.layers.AveragePooling3D, kwargs={ 'strides': 3, 'padding': 'valid', 'data_format': 'channels_first', 'pool_size': pool_size }, input_shape=(3, 4, 11, 12, 10)) class Pooling1DTest(test.TestCase): def test_maxpooling_1d(self): with self.test_session(): for padding in ['valid', 'same']: for stride in [1, 2]: testing_utils.layer_test( keras.layers.MaxPooling1D, kwargs={'strides': stride, 'padding': padding}, input_shape=(3, 5, 4)) def test_averagepooling_1d(self): with self.test_session(): for padding in ['valid', 'same']: for stride in [1, 2]: testing_utils.layer_test( keras.layers.AveragePooling1D, kwargs={'strides': stride, 'padding': padding}, input_shape=(3, 5, 4)) if __name__ == '__main__': test.main()
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 20699, 9393, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1548, 492, 11708, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1548, 14, 8811, 492, 5343, 63, 1208, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 13641, 22349, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 63, 2966, 28624, 63, 17, 68, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 8811, 14, 4359, 14, 28624, 14, 7025, 4261, 22349, 17, 36, 12, 3044, 1324, 63, 1392, 2687, 19, 12, 841, 12, 959, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 17400, 22349, 17, 36, 12, 1324, 63, 1392, 2687, 19, 12, 841, 12, 959, 430, 819, 347, 511, 63, 2966, 28624, 63, 18, 68, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 4261, 22349, 18, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2246, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 959, 12, 1227, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 4261, 22349, 18, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2019, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 959, 12, 1227, 12, 841, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 17400, 22349, 18, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2246, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 959, 12, 1227, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 17400, 22349, 18, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2019, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 959, 12, 1227, 12, 841, 430, 819, 347, 511, 63, 2966, 28624, 63, 19, 68, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 4261, 22349, 19, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2246, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 650, 12, 841, 12, 650, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 4261, 22349, 19, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2019, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 650, 12, 841, 12, 650, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 17400, 22349, 19, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2246, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 650, 12, 841, 12, 650, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 17400, 22349, 19, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2019, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 650, 12, 841, 12, 650, 430, 421, 199, 533, 15553, 316, 18, 36, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 63, 988, 28624, 63, 18, 68, 8, 277, 304, 272, 4203, 63, 890, 275, 334, 19, 12, 650, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 367, 11883, 315, 3842, 17, 12, 413, 395, 334, 18, 12, 499, 19532, 267, 5343, 63, 1208, 14, 1897, 63, 396, 8, 288, 11708, 14, 4359, 14, 4261, 22349, 18, 36, 12, 288, 2074, 3126, 355, 283, 16759, 356, 11883, 12, 355, 283, 8358, 356, 283, 1078, 297, 355, 283, 2293, 63, 890, 356, 4203, 63, 890, 288, 1660, 288, 1324, 63, 1392, 2687, 19, 12, 959, 12, 1227, 12, 841, 430, 819, 347, 511, 63, 8536, 28624, 63, 18, 68, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 17400, 22349, 18, 36, 12, 881, 2074, 3713, 16759, 356, 334, 18, 12, 499, 395, 2116, 283, 8358, 356, 283, 7191, 297, 2116, 283, 2293, 63, 890, 356, 334, 18, 12, 499, 16658, 881, 1324, 63, 1392, 2687, 19, 12, 959, 12, 1227, 12, 841, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 17400, 22349, 18, 36, 12, 881, 2074, 3713, 16759, 356, 334, 18, 12, 499, 395, 2116, 283, 8358, 356, 283, 1078, 297, 2116, 283, 2293, 63, 890, 356, 334, 19, 12, 650, 16658, 881, 1324, 63, 1392, 2687, 19, 12, 959, 12, 1227, 12, 841, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 17400, 22349, 18, 36, 12, 881, 2074, 3126, 1598, 283, 16759, 356, 334, 17, 12, 413, 395, 1598, 283, 8358, 356 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 20699, 9393, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1548, 492, 11708, 199, 504, 3228, 14, 2828, 14, 8811, 14, 1548, 14, 8811, 492, 5343, 63, 1208, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 13641, 22349, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 63, 2966, 28624, 63, 17, 68, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 8811, 14, 4359, 14, 28624, 14, 7025, 4261, 22349, 17, 36, 12, 3044, 1324, 63, 1392, 2687, 19, 12, 841, 12, 959, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 17400, 22349, 17, 36, 12, 1324, 63, 1392, 2687, 19, 12, 841, 12, 959, 430, 819, 347, 511, 63, 2966, 28624, 63, 18, 68, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 4261, 22349, 18, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2246, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 959, 12, 1227, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 4261, 22349, 18, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2019, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 959, 12, 1227, 12, 841, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 17400, 22349, 18, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2246, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 959, 12, 1227, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 17400, 22349, 18, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2019, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 959, 12, 1227, 12, 841, 430, 819, 347, 511, 63, 2966, 28624, 63, 19, 68, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 4261, 22349, 19, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2246, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 650, 12, 841, 12, 650, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 4261, 22349, 19, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2019, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 650, 12, 841, 12, 650, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 17400, 22349, 19, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2246, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 650, 12, 841, 12, 650, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 28624, 14, 7025, 17400, 22349, 19, 36, 12, 881, 2074, 3713, 576, 63, 908, 356, 283, 6324, 63, 2019, 2267, 881, 1324, 63, 1392, 2687, 19, 12, 841, 12, 650, 12, 841, 12, 650, 430, 421, 199, 533, 15553, 316, 18, 36, 774, 8, 396, 14, 1746, 304, 819, 347, 511, 63, 988, 28624, 63, 18, 68, 8, 277, 304, 272, 4203, 63, 890, 275, 334, 19, 12, 650, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 367, 11883, 315, 3842, 17, 12, 413, 395, 334, 18, 12, 499, 19532, 267, 5343, 63, 1208, 14, 1897, 63, 396, 8, 288, 11708, 14, 4359, 14, 4261, 22349, 18, 36, 12, 288, 2074, 3126, 355, 283, 16759, 356, 11883, 12, 355, 283, 8358, 356, 283, 1078, 297, 355, 283, 2293, 63, 890, 356, 4203, 63, 890, 288, 1660, 288, 1324, 63, 1392, 2687, 19, 12, 959, 12, 1227, 12, 841, 430, 819, 347, 511, 63, 8536, 28624, 63, 18, 68, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 17400, 22349, 18, 36, 12, 881, 2074, 3713, 16759, 356, 334, 18, 12, 499, 395, 2116, 283, 8358, 356, 283, 7191, 297, 2116, 283, 2293, 63, 890, 356, 334, 18, 12, 499, 16658, 881, 1324, 63, 1392, 2687, 19, 12, 959, 12, 1227, 12, 841, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 17400, 22349, 18, 36, 12, 881, 2074, 3713, 16759, 356, 334, 18, 12, 499, 395, 2116, 283, 8358, 356, 283, 1078, 297, 2116, 283, 2293, 63, 890, 356, 334, 19, 12, 650, 16658, 881, 1324, 63, 1392, 2687, 19, 12, 959, 12, 1227, 12, 841, 430, 489, 5343, 63, 1208, 14, 1897, 63, 396, 8, 881, 11708, 14, 4359, 14, 17400, 22349, 18, 36, 12, 881, 2074, 3126, 1598, 283, 16759, 356, 334, 17, 12, 413, 395, 1598, 283, 8358, 356, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
mwmuni/LIGGGHTS_GUI
OpenGL/platform/glx.py
9
3820
"""GLX (x-windows)-specific platform features""" import ctypes, ctypes.util from functools import wraps from OpenGL.platform import baseplatform, ctypesloader class GLXPlatform( baseplatform.BasePlatform ): """Posix (Linux, FreeBSD, etceteras) implementation for PyOpenGL""" # On Linux (and, I assume, most GLX platforms, we have to load # GL and GLU with the "global" flag to allow GLUT to resolve its # references to GL/GLU functions). @baseplatform.lazy_property def GL(self): try: return ctypesloader.loadLibrary( ctypes.cdll, 'GL', mode=ctypes.RTLD_GLOBAL ) except OSError as err: raise ImportError("Unable to load OpenGL library", *err.args) @baseplatform.lazy_property def GLU(self): try: return ctypesloader.loadLibrary( ctypes.cdll, 'GLU', mode=ctypes.RTLD_GLOBAL ) except OSError as err: return None @baseplatform.lazy_property def GLUT( self ): try: return ctypesloader.loadLibrary( ctypes.cdll, 'glut', mode=ctypes.RTLD_GLOBAL ) except OSError as err: return None # GLX doesn't seem to have its own loadable module? @baseplatform.lazy_property def GLX(self): return self.GL @baseplatform.lazy_property def GLES1(self): try: return ctypesloader.loadLibrary( ctypes.cdll, 'GLESv1_CM', # ick mode=ctypes.RTLD_GLOBAL ) except OSError as err: return None @baseplatform.lazy_property def GLES2(self): try: return ctypesloader.loadLibrary( ctypes.cdll, 'GLESv2', mode=ctypes.RTLD_GLOBAL ) except OSError as err: return None @baseplatform.lazy_property def GLES3(self): # implementers guide says to use the same name for the DLL return self.GLES2 @baseplatform.lazy_property def glXGetProcAddressARB(self): base = self.GLX.glXGetProcAddressARB base.restype = ctypes.c_void_p return base @baseplatform.lazy_property def getExtensionProcedure(self): return self.glXGetProcAddressARB @baseplatform.lazy_property def GLE( self ): try: return ctypesloader.loadLibrary( ctypes.cdll, 'gle', mode=ctypes.RTLD_GLOBAL ) except OSError as err: return None DEFAULT_FUNCTION_TYPE = staticmethod( ctypes.CFUNCTYPE ) # This loads the GLX functions from the GL .so, not sure if that's # really kosher... @baseplatform.lazy_property def GetCurrentContext( self ): return self.GL.glXGetCurrentContext def getGLUTFontPointer( self, constant ): """Platform specific function to retrieve a GLUT font pointer GLUTAPI void *glutBitmap9By15; #define GLUT_BITMAP_9_BY_15 (&glutBitmap9By15) Key here is that we want the addressof the pointer in the DLL, not the pointer in the DLL. That is, our pointer is to the pointer defined in the DLL, we don't want the *value* stored in that pointer. """ name = [ x.title() for x in constant.split( '_' )[1:] ] internal = 'glut' + "".join( [x.title() for x in name] ) pointer = ctypes.c_void_p.in_dll( self.GLUT, internal ) return ctypes.c_void_p(ctypes.addressof(pointer)) @baseplatform.lazy_property def glGetError( self ): return self.GL.glGetError
gpl-3.0
[ 624, 17620, 334, 88, 13, 8258, 7216, 6100, 4298, 4534, 624, 199, 646, 5577, 12, 5577, 14, 1974, 199, 504, 9143, 492, 14018, 199, 504, 24374, 14, 3246, 492, 1300, 3246, 12, 5577, 3422, 199, 199, 533, 3563, 56, 10397, 8, 1300, 3246, 14, 1563, 10397, 3461, 272, 408, 1575, 4174, 334, 14091, 12, 2868, 15400, 12, 10844, 301, 351, 305, 9, 4514, 367, 1611, 4299, 2226, 624, 272, 327, 4068, 10130, 334, 460, 12, 473, 5534, 12, 4750, 3563, 56, 10677, 12, 781, 1172, 370, 2248, 5591, 327, 3563, 436, 3563, 53, 543, 314, 298, 2966, 2, 3305, 370, 2040, 3563, 934, 370, 7512, 2399, 272, 327, 6941, 370, 3563, 15, 20935, 3423, 680, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 8, 277, 304, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 2226, 297, 8892, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 4960, 871, 6440, 465, 2329, 26, 288, 746, 3545, 480, 6005, 370, 2248, 24374, 3555, 401, 627, 1508, 14, 589, 9, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 53, 8, 277, 304, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 20935, 297, 355, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 267, 871, 6440, 465, 2329, 26, 288, 372, 488, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 934, 8, 291, 3461, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 3528, 337, 297, 8892, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 267, 871, 6440, 465, 2329, 26, 288, 372, 488, 272, 327, 3563, 56, 3181, 1133, 17021, 370, 1172, 2399, 5705, 32519, 859, 31, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 56, 8, 277, 304, 372, 291, 14, 2226, 339, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 654, 17, 8, 277, 304, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 2226, 654, 86, 17, 63, 9249, 297, 327, 284, 346, 355, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 267, 871, 6440, 465, 2329, 26, 288, 372, 488, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 654, 18, 8, 277, 304, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 2226, 654, 86, 18, 297, 8892, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 267, 871, 6440, 465, 2329, 26, 288, 372, 488, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 654, 19, 8, 277, 304, 267, 327, 2456, 1410, 878, 22885, 20065, 370, 675, 314, 2011, 536, 367, 314, 577, 4464, 267, 372, 291, 14, 2226, 654, 18, 2286, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 6482, 56, 1002, 15019, 1476, 8611, 8, 277, 304, 267, 1300, 275, 291, 14, 17620, 14, 27226, 1002, 15019, 1476, 8611, 267, 1300, 14, 9990, 275, 5577, 14, 67, 63, 1647, 63, 80, 267, 372, 1300, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 664, 6382, 919, 12194, 8, 277, 304, 267, 372, 291, 14, 27226, 1002, 15019, 1476, 8611, 2286, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 598, 906, 8, 291, 3461, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 3845, 297, 8892, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 267, 871, 6440, 465, 2329, 26, 288, 372, 488, 339, 6186, 63, 15476, 63, 2711, 275, 12822, 8, 5577, 14, 5487, 10637, 776, 339, 327, 961, 14404, 314, 3563, 56, 3423, 687, 314, 3563, 1275, 1152, 12, 440, 3238, 340, 626, 1159, 272, 327, 7710, 20817, 609, 281, 1396, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 2372, 5639, 2998, 8, 291, 3461, 267, 372, 291, 14, 2226, 14, 27226, 29058, 2998, 339, 347, 664, 2226, 6610, 1888, 12190, 8, 291, 12, 4413, 3461, 267, 408, 10397, 2488, 805, 370, 8044, 282, 3563, 934, 5023, 7849, 2728, 3563, 934, 3735, 2309, 627, 3528, 337, 16469, 25, 2175, 1046, 27, 267, 327, 4640, 3563, 934, 63, 30189, 63, 25, 63, 8285, 63, 1046, 198, 198, 24168, 3528, 337, 16469, 25, 2175, 1046, 9, 2728, 2606, 2348, 365, 626, 781, 2934, 314, 2287, 1618, 314, 7849, 315, 314, 577, 4464, 12, 267, 440, 314, 7849, 315, 314, 577, 4464, 14, 221, 10314, 365, 12, 4154, 7849, 365, 370, 314, 4960, 7849, 3247, 315, 314, 577, 4464, 12, 781, 2793, 1133, 2934, 314, 627, 585, 10, 5489, 315, 267, 626, 7849, 14, 267, 408, 267, 536, 275, 359, 671, 14, 1213, 342, 367, 671, 315, 4413, 14, 1294, 8, 14135, 29688, 17, 2938, 1622, 267, 5007, 275, 283, 3528, 337, 7, 435, 10587, 904, 8, 359, 88, 14, 1213, 342, 367, 671, 315, 536, 61, 776, 267, 7849, 275, 5577, 14, 67, 63, 1647, 63, 80, 14, 262, 63, 9259, 8, 291, 14, 2226, 934, 12, 5007, 776, 267, 372, 5577, 14, 67, 63, 1647, 63, 80, 8, 9798, 14, 1562, 1618, 8, 3929, 430, 2286, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 6482, 1002, 547, 8, 291, 3461, 267, 372, 291, 14, 2226, 14, 19681, 547, 16872, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 17620, 334, 88, 13, 8258, 7216, 6100, 4298, 4534, 624, 199, 646, 5577, 12, 5577, 14, 1974, 199, 504, 9143, 492, 14018, 199, 504, 24374, 14, 3246, 492, 1300, 3246, 12, 5577, 3422, 199, 199, 533, 3563, 56, 10397, 8, 1300, 3246, 14, 1563, 10397, 3461, 272, 408, 1575, 4174, 334, 14091, 12, 2868, 15400, 12, 10844, 301, 351, 305, 9, 4514, 367, 1611, 4299, 2226, 624, 272, 327, 4068, 10130, 334, 460, 12, 473, 5534, 12, 4750, 3563, 56, 10677, 12, 781, 1172, 370, 2248, 5591, 327, 3563, 436, 3563, 53, 543, 314, 298, 2966, 2, 3305, 370, 2040, 3563, 934, 370, 7512, 2399, 272, 327, 6941, 370, 3563, 15, 20935, 3423, 680, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 8, 277, 304, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 2226, 297, 8892, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 4960, 871, 6440, 465, 2329, 26, 288, 746, 3545, 480, 6005, 370, 2248, 24374, 3555, 401, 627, 1508, 14, 589, 9, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 53, 8, 277, 304, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 20935, 297, 355, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 267, 871, 6440, 465, 2329, 26, 288, 372, 488, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 934, 8, 291, 3461, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 3528, 337, 297, 8892, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 267, 871, 6440, 465, 2329, 26, 288, 372, 488, 272, 327, 3563, 56, 3181, 1133, 17021, 370, 1172, 2399, 5705, 32519, 859, 31, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 56, 8, 277, 304, 372, 291, 14, 2226, 339, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 654, 17, 8, 277, 304, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 2226, 654, 86, 17, 63, 9249, 297, 327, 284, 346, 355, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 267, 871, 6440, 465, 2329, 26, 288, 372, 488, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 654, 18, 8, 277, 304, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 2226, 654, 86, 18, 297, 8892, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 267, 871, 6440, 465, 2329, 26, 288, 372, 488, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 3563, 654, 19, 8, 277, 304, 267, 327, 2456, 1410, 878, 22885, 20065, 370, 675, 314, 2011, 536, 367, 314, 577, 4464, 267, 372, 291, 14, 2226, 654, 18, 2286, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 6482, 56, 1002, 15019, 1476, 8611, 8, 277, 304, 267, 1300, 275, 291, 14, 17620, 14, 27226, 1002, 15019, 1476, 8611, 267, 1300, 14, 9990, 275, 5577, 14, 67, 63, 1647, 63, 80, 267, 372, 1300, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 664, 6382, 919, 12194, 8, 277, 304, 267, 372, 291, 14, 27226, 1002, 15019, 1476, 8611, 2286, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 598, 906, 8, 291, 3461, 267, 862, 26, 288, 372, 5577, 3422, 14, 912, 7424, 8, 355, 5577, 14, 2866, 914, 12, 355, 283, 3845, 297, 8892, 818, 29, 9798, 14, 11876, 6533, 63, 13808, 7205, 776, 267, 871, 6440, 465, 2329, 26, 288, 372, 488, 339, 6186, 63, 15476, 63, 2711, 275, 12822, 8, 5577, 14, 5487, 10637, 776, 339, 327, 961, 14404, 314, 3563, 56, 3423, 687, 314, 3563, 1275, 1152, 12, 440, 3238, 340, 626, 1159, 272, 327, 7710, 20817, 609, 281, 1396, 272, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 2372, 5639, 2998, 8, 291, 3461, 267, 372, 291, 14, 2226, 14, 27226, 29058, 2998, 339, 347, 664, 2226, 6610, 1888, 12190, 8, 291, 12, 4413, 3461, 267, 408, 10397, 2488, 805, 370, 8044, 282, 3563, 934, 5023, 7849, 2728, 3563, 934, 3735, 2309, 627, 3528, 337, 16469, 25, 2175, 1046, 27, 267, 327, 4640, 3563, 934, 63, 30189, 63, 25, 63, 8285, 63, 1046, 198, 198, 24168, 3528, 337, 16469, 25, 2175, 1046, 9, 2728, 2606, 2348, 365, 626, 781, 2934, 314, 2287, 1618, 314, 7849, 315, 314, 577, 4464, 12, 267, 440, 314, 7849, 315, 314, 577, 4464, 14, 221, 10314, 365, 12, 4154, 7849, 365, 370, 314, 4960, 7849, 3247, 315, 314, 577, 4464, 12, 781, 2793, 1133, 2934, 314, 627, 585, 10, 5489, 315, 267, 626, 7849, 14, 267, 408, 267, 536, 275, 359, 671, 14, 1213, 342, 367, 671, 315, 4413, 14, 1294, 8, 14135, 29688, 17, 2938, 1622, 267, 5007, 275, 283, 3528, 337, 7, 435, 10587, 904, 8, 359, 88, 14, 1213, 342, 367, 671, 315, 536, 61, 776, 267, 7849, 275, 5577, 14, 67, 63, 1647, 63, 80, 14, 262, 63, 9259, 8, 291, 14, 2226, 934, 12, 5007, 776, 267, 372, 5577, 14, 67, 63, 1647, 63, 80, 8, 9798, 14, 1562, 1618, 8, 3929, 430, 2286, 768, 1095, 3246, 14, 6395, 63, 1829, 272, 347, 6482, 1002, 547, 8, 291, 3461, 267, 372, 291, 14, 2226, 14, 19681, 547, 16872, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
madhurrajn/samashthi
lib/django/contrib/messages/storage/session.py
478
1714
import json from django.contrib.messages.storage.base import BaseStorage from django.contrib.messages.storage.cookie import ( MessageDecoder, MessageEncoder, ) from django.utils import six class SessionStorage(BaseStorage): """ Stores messages in the session (that is, django.contrib.sessions). """ session_key = '_messages' def __init__(self, request, *args, **kwargs): assert hasattr(request, 'session'), "The session-based temporary "\ "message storage requires session middleware to be installed, "\ "and come before the message middleware in the "\ "MIDDLEWARE_CLASSES list." super(SessionStorage, self).__init__(request, *args, **kwargs) def _get(self, *args, **kwargs): """ Retrieves a list of messages from the request's session. This storage always stores everything it is given, so return True for the all_retrieved flag. """ return self.deserialize_messages(self.request.session.get(self.session_key)), True def _store(self, messages, response, *args, **kwargs): """ Stores a list of messages to the request's session. """ if messages: self.request.session[self.session_key] = self.serialize_messages(messages) else: self.request.session.pop(self.session_key, None) return [] def serialize_messages(self, messages): encoder = MessageEncoder(separators=(',', ':')) return encoder.encode(messages) def deserialize_messages(self, data): if data and isinstance(data, six.string_types): return json.loads(data, cls=MessageDecoder) return data
bsd-3-clause
[ 646, 2022, 199, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1095, 492, 3523, 6408, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 5306, 492, 334, 272, 6430, 8326, 12, 6430, 6679, 12, 199, 9, 199, 504, 1639, 14, 1208, 492, 3816, 421, 199, 533, 8596, 6408, 8, 1563, 6408, 304, 272, 408, 272, 31299, 3788, 315, 314, 2351, 334, 9099, 365, 12, 1639, 14, 2828, 14, 11676, 680, 272, 408, 272, 2351, 63, 498, 275, 2513, 3431, 7, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 702, 2688, 8, 1069, 12, 283, 1730, 659, 298, 1918, 2351, 13, 6788, 7937, 1867, 288, 298, 1188, 4887, 5074, 2351, 10816, 370, 506, 4903, 12, 1867, 288, 298, 460, 11492, 2544, 314, 1245, 10816, 315, 314, 1867, 288, 298, 19987, 63, 13748, 769, 2122, 267, 1613, 8, 4434, 6408, 12, 291, 2843, 826, 721, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 485, 362, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 27940, 282, 769, 402, 3788, 687, 314, 1056, 1159, 2351, 14, 221, 961, 4887, 267, 3544, 14086, 8137, 652, 365, 1627, 12, 880, 372, 715, 367, 314, 267, 1006, 63, 11235, 27986, 3305, 14, 267, 408, 267, 372, 291, 14, 11143, 63, 3431, 8, 277, 14, 1069, 14, 1730, 14, 362, 8, 277, 14, 1730, 63, 498, 1826, 715, 339, 347, 485, 1617, 8, 277, 12, 3788, 12, 1177, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 31299, 282, 769, 402, 3788, 370, 314, 1056, 1159, 2351, 14, 267, 408, 267, 340, 3788, 26, 288, 291, 14, 1069, 14, 1730, 59, 277, 14, 1730, 63, 498, 61, 275, 291, 14, 3549, 63, 3431, 8, 3431, 9, 267, 587, 26, 288, 291, 14, 1069, 14, 1730, 14, 1935, 8, 277, 14, 1730, 63, 498, 12, 488, 9, 267, 372, 942, 339, 347, 8437, 63, 3431, 8, 277, 12, 3788, 304, 267, 10295, 275, 6430, 6679, 8, 29862, 2687, 23324, 7596, 1333, 267, 372, 10295, 14, 2143, 8, 3431, 9, 339, 347, 22920, 63, 3431, 8, 277, 12, 666, 304, 267, 340, 666, 436, 1228, 8, 576, 12, 3816, 14, 875, 63, 1313, 304, 288, 372, 2022, 14, 3640, 8, 576, 12, 843, 29, 2209, 8326, 9, 267, 372, 666, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2022, 199, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 1095, 492, 3523, 6408, 199, 504, 1639, 14, 2828, 14, 3431, 14, 3494, 14, 5306, 492, 334, 272, 6430, 8326, 12, 6430, 6679, 12, 199, 9, 199, 504, 1639, 14, 1208, 492, 3816, 421, 199, 533, 8596, 6408, 8, 1563, 6408, 304, 272, 408, 272, 31299, 3788, 315, 314, 2351, 334, 9099, 365, 12, 1639, 14, 2828, 14, 11676, 680, 272, 408, 272, 2351, 63, 498, 275, 2513, 3431, 7, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 702, 2688, 8, 1069, 12, 283, 1730, 659, 298, 1918, 2351, 13, 6788, 7937, 1867, 288, 298, 1188, 4887, 5074, 2351, 10816, 370, 506, 4903, 12, 1867, 288, 298, 460, 11492, 2544, 314, 1245, 10816, 315, 314, 1867, 288, 298, 19987, 63, 13748, 769, 2122, 267, 1613, 8, 4434, 6408, 12, 291, 2843, 826, 721, 1069, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 485, 362, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 27940, 282, 769, 402, 3788, 687, 314, 1056, 1159, 2351, 14, 221, 961, 4887, 267, 3544, 14086, 8137, 652, 365, 1627, 12, 880, 372, 715, 367, 314, 267, 1006, 63, 11235, 27986, 3305, 14, 267, 408, 267, 372, 291, 14, 11143, 63, 3431, 8, 277, 14, 1069, 14, 1730, 14, 362, 8, 277, 14, 1730, 63, 498, 1826, 715, 339, 347, 485, 1617, 8, 277, 12, 3788, 12, 1177, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 31299, 282, 769, 402, 3788, 370, 314, 1056, 1159, 2351, 14, 267, 408, 267, 340, 3788, 26, 288, 291, 14, 1069, 14, 1730, 59, 277, 14, 1730, 63, 498, 61, 275, 291, 14, 3549, 63, 3431, 8, 3431, 9, 267, 587, 26, 288, 291, 14, 1069, 14, 1730, 14, 1935, 8, 277, 14, 1730, 63, 498, 12, 488, 9, 267, 372, 942, 339, 347, 8437, 63, 3431, 8, 277, 12, 3788, 304, 267, 10295, 275, 6430, 6679, 8, 29862, 2687, 23324, 7596, 1333, 267, 372, 10295, 14, 2143, 8, 3431, 9, 339, 347, 22920, 63, 3431, 8, 277, 12, 666, 304, 267, 340, 666, 436, 1228, 8, 576, 12, 3816, 14, 875, 63, 1313, 304, 288, 372, 2022, 14, 3640, 8, 576, 12, 843, 29, 2209, 8326, 9, 267, 372, 666, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
shawnwanderson/cmput404-project
venv/lib/python2.7/site-packages/django/contrib/gis/gdal/raster/band.py
308
5382
from ctypes import byref, c_int from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.gdal.prototypes import raster as capi from django.contrib.gis.shortcuts import numpy from django.utils import six from django.utils.encoding import force_text from django.utils.six.moves import range from .const import GDAL_INTEGER_TYPES, GDAL_PIXEL_TYPES, GDAL_TO_CTYPES class GDALBand(GDALBase): """ Wraps a GDAL raster band, needs to be obtained from a GDALRaster object. """ def __init__(self, source, index): self.source = source self._ptr = capi.get_ds_raster_band(source._ptr, index) @property def description(self): """ Returns the description string of the band. """ return force_text(capi.get_band_description(self._ptr)) @property def width(self): """ Width (X axis) in pixels of the band. """ return capi.get_band_xsize(self._ptr) @property def height(self): """ Height (Y axis) in pixels of the band. """ return capi.get_band_ysize(self._ptr) @property def pixel_count(self): """ Returns the total number of pixels in this band. """ return self.width * self.height @property def min(self): """ Returns the minimum pixel value for this band. """ return capi.get_band_minimum(self._ptr, byref(c_int())) @property def max(self): """ Returns the maximum pixel value for this band. """ return capi.get_band_maximum(self._ptr, byref(c_int())) @property def nodata_value(self): """ Returns the nodata value for this band, or None if it isn't set. """ # Get value and nodata exists flag nodata_exists = c_int() value = capi.get_band_nodata_value(self._ptr, nodata_exists) if not nodata_exists: value = None # If the pixeltype is an integer, convert to int elif self.datatype() in GDAL_INTEGER_TYPES: value = int(value) return value @nodata_value.setter def nodata_value(self, value): """ Sets the nodata value for this band. """ if not isinstance(value, (int, float)): raise ValueError('Nodata value must be numeric.') capi.set_band_nodata_value(self._ptr, value) self.source._flush() def datatype(self, as_string=False): """ Returns the GDAL Pixel Datatype for this band. """ dtype = capi.get_band_datatype(self._ptr) if as_string: dtype = GDAL_PIXEL_TYPES[dtype] return dtype def data(self, data=None, offset=None, size=None, as_memoryview=False): """ Reads or writes pixel values for this band. Blocks of data can be accessed by specifying the width, height and offset of the desired block. The same specification can be used to update parts of a raster by providing an array of values. Allowed input data types are bytes, memoryview, list, tuple, and array. """ if not offset: offset = (0, 0) if not size: size = (self.width - offset[0], self.height - offset[1]) if any(x <= 0 for x in size): raise ValueError('Offset too big for this raster.') if size[0] > self.width or size[1] > self.height: raise ValueError('Size is larger than raster.') # Create ctypes type array generator ctypes_array = GDAL_TO_CTYPES[self.datatype()] * (size[0] * size[1]) if data is None: # Set read mode access_flag = 0 # Prepare empty ctypes array data_array = ctypes_array() else: # Set write mode access_flag = 1 # Instantiate ctypes array holding the input data if isinstance(data, (bytes, six.memoryview)) or (numpy and isinstance(data, numpy.ndarray)): data_array = ctypes_array.from_buffer_copy(data) else: data_array = ctypes_array(*data) # Access band capi.band_io(self._ptr, access_flag, offset[0], offset[1], size[0], size[1], byref(data_array), size[0], size[1], self.datatype(), 0, 0) # Return data as numpy array if possible, otherwise as list if data is None: if as_memoryview: return memoryview(data_array) elif numpy: return numpy.frombuffer( data_array, dtype=numpy.dtype(data_array)).reshape(size) else: return list(data_array) else: self.source._flush() class BandList(list): def __init__(self, source): self.source = source list.__init__(self) def __iter__(self): for idx in range(1, len(self) + 1): yield GDALBand(self.source, idx) def __len__(self): return capi.get_ds_raster_count(self.source._ptr) def __getitem__(self, index): try: return GDALBand(self.source, index + 1) except GDALException: raise GDALException('Unable to get band index %d' % index)
gpl-3.0
[ 504, 5577, 492, 15968, 12, 286, 63, 442, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 1095, 492, 15801, 1563, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 705, 492, 15801, 1726, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 16141, 83, 492, 19775, 465, 13648, 199, 504, 1639, 14, 2828, 14, 5668, 14, 17469, 492, 2680, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 1425, 199, 199, 504, 1275, 1297, 492, 15801, 63, 9596, 63, 7893, 12, 15801, 63, 23357, 63, 7893, 12, 15801, 63, 2566, 63, 1028, 24583, 421, 199, 533, 15801, 11675, 8, 17835, 1563, 304, 272, 408, 272, 644, 8146, 282, 15801, 19775, 10981, 12, 4839, 370, 506, 15884, 687, 282, 15801, 13284, 909, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1350, 12, 1478, 304, 267, 291, 14, 1365, 275, 1350, 267, 291, 423, 4695, 275, 13648, 14, 362, 63, 795, 63, 20876, 63, 7877, 8, 1365, 423, 4695, 12, 1478, 9, 339, 768, 1829, 272, 347, 1369, 8, 277, 304, 267, 408, 267, 1803, 314, 1369, 1059, 402, 314, 10981, 14, 267, 408, 267, 372, 3542, 63, 505, 8, 14145, 14, 362, 63, 7877, 63, 1802, 8, 277, 423, 4695, 430, 339, 768, 1829, 272, 347, 3462, 8, 277, 304, 267, 408, 267, 644, 1466, 334, 56, 3114, 9, 315, 11094, 402, 314, 10981, 14, 267, 408, 267, 372, 13648, 14, 362, 63, 7877, 63, 88, 890, 8, 277, 423, 4695, 9, 339, 768, 1829, 272, 347, 4569, 8, 277, 304, 267, 408, 267, 5311, 1070, 334, 57, 3114, 9, 315, 11094, 402, 314, 10981, 14, 267, 408, 267, 372, 13648, 14, 362, 63, 7877, 63, 89, 890, 8, 277, 423, 4695, 9, 339, 768, 1829, 272, 347, 7148, 63, 835, 8, 277, 304, 267, 408, 267, 1803, 314, 3141, 1329, 402, 11094, 315, 642, 10981, 14, 267, 408, 267, 372, 291, 14, 2063, 627, 291, 14, 3333, 339, 768, 1829, 272, 347, 1748, 8, 277, 304, 267, 408, 267, 1803, 314, 7481, 7148, 574, 367, 642, 10981, 14, 267, 408, 267, 372, 13648, 14, 362, 63, 7877, 63, 10700, 8, 277, 423, 4695, 12, 15968, 8, 67, 63, 442, 4059, 339, 768, 1829, 272, 347, 1390, 8, 277, 304, 267, 408, 267, 1803, 314, 5696, 7148, 574, 367, 642, 10981, 14, 267, 408, 267, 372, 13648, 14, 362, 63, 7877, 63, 11555, 8, 277, 423, 4695, 12, 15968, 8, 67, 63, 442, 4059, 339, 768, 1829, 272, 347, 302, 22971, 63, 585, 8, 277, 304, 267, 408, 267, 1803, 314, 302, 22971, 574, 367, 642, 10981, 12, 503, 488, 340, 652, 5712, 1133, 663, 14, 267, 408, 267, 327, 2372, 574, 436, 302, 22971, 3495, 3305, 267, 302, 22971, 63, 2444, 275, 286, 63, 442, 342, 267, 574, 275, 13648, 14, 362, 63, 7877, 63, 18950, 419, 63, 585, 8, 277, 423, 4695, 12, 302, 22971, 63, 2444, 9, 267, 340, 440, 302, 22971, 63, 2444, 26, 288, 574, 275, 488, 267, 327, 982, 314, 7148, 466, 365, 376, 3000, 12, 3957, 370, 1109, 267, 916, 291, 14, 14184, 342, 315, 15801, 63, 9596, 63, 7893, 26, 288, 574, 275, 1109, 8, 585, 9, 267, 372, 574, 339, 768, 18950, 419, 63, 585, 14, 8345, 272, 347, 302, 22971, 63, 585, 8, 277, 12, 574, 304, 267, 408, 267, 10729, 314, 302, 22971, 574, 367, 642, 10981, 14, 267, 408, 267, 340, 440, 1228, 8, 585, 12, 334, 442, 12, 2069, 2298, 288, 746, 1722, 360, 46, 22971, 574, 1471, 506, 8950, 2659, 267, 13648, 14, 409, 63, 7877, 63, 18950, 419, 63, 585, 8, 277, 423, 4695, 12, 574, 9, 267, 291, 14, 1365, 423, 4939, 342, 339, 347, 16048, 8, 277, 12, 465, 63, 875, 29, 797, 304, 267, 408, 267, 1803, 314, 15801, 510, 5887, 577, 292, 8588, 367, 642, 10981, 14, 267, 408, 267, 2152, 275, 13648, 14, 362, 63, 7877, 63, 14184, 8, 277, 423, 4695, 9, 267, 340, 465, 63, 875, 26, 288, 2152, 275, 15801, 63, 23357, 63, 7893, 59, 2271, 61, 267, 372, 2152, 339, 347, 666, 8, 277, 12, 666, 29, 403, 12, 3268, 29, 403, 12, 1568, 29, 403, 12, 465, 63, 31519, 29, 797, 304, 267, 408, 267, 26129, 503, 14511, 7148, 1338, 367, 642, 10981, 14, 8651, 83, 402, 666, 883, 267, 506, 13810, 701, 9176, 314, 3462, 12, 4569, 436, 3268, 402, 314, 267, 6387, 1853, 14, 710, 2011, 8929, 883, 506, 1202, 370, 1678, 267, 4184, 402, 282, 19775, 701, 13070, 376, 1625, 402, 1338, 14, 398, 27301, 1324, 666, 2943, 787, 2783, 12, 20228, 12, 769, 12, 2008, 12, 436, 1625, 14, 267, 408, 267, 340, 440, 3268, 26, 288, 3268, 275, 334, 16, 12, 378, 9, 398, 340, 440, 1568, 26, 288, 1568, 275, 334, 277, 14, 2063, 446, 3268, 59, 16, 467, 291, 14, 3333, 446, 3268, 59, 17, 566, 398, 340, 1263, 8, 88, 2695, 378, 367, 671, 315, 1568, 304, 288, 746, 1722, 360, 6397, 4634, 7282, 367, 642, 19775, 2659, 398, 340, 1568, 59, 16, 61, 690, 291, 14, 2063, 503, 1568, 59, 17, 61, 690, 291, 14, 3333, 26, 288, 746, 1722, 360, 2320, 365, 12142, 2419, 19775, 2659, 398, 327, 2790, 5577, 730, 1625, 4306, 267, 5577, 63, 1144, 275, 15801, 63, 2566, 63, 1028, 24583, 59, 277, 14, 14184, 5106, 627, 334, 890, 59, 16, 61, 627, 1568, 59, 17, 566, 398, 340, 666, 365, 488, 26, 288, 327, 2494, 1586, 818, 288, 2879, 63, 4173, 275, 378, 288, 327, 17008, 2701, 5577, 1625, 288, 666, 63, 1144, 275, 5577, 63, 1144, 342, 267, 587, 26, 288, 327, 2494, 2218, 818, 288, 2879, 63, 4173, 275, 413, 953, 327, 32092, 5577, 1625, 17573, 314, 1324, 666, 288, 340, 1228, 8, 576, 12, 334, 2394, 12, 3816, 14, 31519, 430, 503, 334, 4714, 436, 1228, 8, 576, 12, 2680, 14, 8237, 2298, 355, 666, 63, 1144, 275, 5577, 63, 1144, 14, 504, 63, 2738, 63, 1574, 8, 576, 9, 288, 587, 26, 355, 666, 63, 1144 ]
[ 5577, 492, 15968, 12, 286, 63, 442, 199, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 1095, 492, 15801, 1563, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 705, 492, 15801, 1726, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 16141, 83, 492, 19775, 465, 13648, 199, 504, 1639, 14, 2828, 14, 5668, 14, 17469, 492, 2680, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 1425, 199, 199, 504, 1275, 1297, 492, 15801, 63, 9596, 63, 7893, 12, 15801, 63, 23357, 63, 7893, 12, 15801, 63, 2566, 63, 1028, 24583, 421, 199, 533, 15801, 11675, 8, 17835, 1563, 304, 272, 408, 272, 644, 8146, 282, 15801, 19775, 10981, 12, 4839, 370, 506, 15884, 687, 282, 15801, 13284, 909, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1350, 12, 1478, 304, 267, 291, 14, 1365, 275, 1350, 267, 291, 423, 4695, 275, 13648, 14, 362, 63, 795, 63, 20876, 63, 7877, 8, 1365, 423, 4695, 12, 1478, 9, 339, 768, 1829, 272, 347, 1369, 8, 277, 304, 267, 408, 267, 1803, 314, 1369, 1059, 402, 314, 10981, 14, 267, 408, 267, 372, 3542, 63, 505, 8, 14145, 14, 362, 63, 7877, 63, 1802, 8, 277, 423, 4695, 430, 339, 768, 1829, 272, 347, 3462, 8, 277, 304, 267, 408, 267, 644, 1466, 334, 56, 3114, 9, 315, 11094, 402, 314, 10981, 14, 267, 408, 267, 372, 13648, 14, 362, 63, 7877, 63, 88, 890, 8, 277, 423, 4695, 9, 339, 768, 1829, 272, 347, 4569, 8, 277, 304, 267, 408, 267, 5311, 1070, 334, 57, 3114, 9, 315, 11094, 402, 314, 10981, 14, 267, 408, 267, 372, 13648, 14, 362, 63, 7877, 63, 89, 890, 8, 277, 423, 4695, 9, 339, 768, 1829, 272, 347, 7148, 63, 835, 8, 277, 304, 267, 408, 267, 1803, 314, 3141, 1329, 402, 11094, 315, 642, 10981, 14, 267, 408, 267, 372, 291, 14, 2063, 627, 291, 14, 3333, 339, 768, 1829, 272, 347, 1748, 8, 277, 304, 267, 408, 267, 1803, 314, 7481, 7148, 574, 367, 642, 10981, 14, 267, 408, 267, 372, 13648, 14, 362, 63, 7877, 63, 10700, 8, 277, 423, 4695, 12, 15968, 8, 67, 63, 442, 4059, 339, 768, 1829, 272, 347, 1390, 8, 277, 304, 267, 408, 267, 1803, 314, 5696, 7148, 574, 367, 642, 10981, 14, 267, 408, 267, 372, 13648, 14, 362, 63, 7877, 63, 11555, 8, 277, 423, 4695, 12, 15968, 8, 67, 63, 442, 4059, 339, 768, 1829, 272, 347, 302, 22971, 63, 585, 8, 277, 304, 267, 408, 267, 1803, 314, 302, 22971, 574, 367, 642, 10981, 12, 503, 488, 340, 652, 5712, 1133, 663, 14, 267, 408, 267, 327, 2372, 574, 436, 302, 22971, 3495, 3305, 267, 302, 22971, 63, 2444, 275, 286, 63, 442, 342, 267, 574, 275, 13648, 14, 362, 63, 7877, 63, 18950, 419, 63, 585, 8, 277, 423, 4695, 12, 302, 22971, 63, 2444, 9, 267, 340, 440, 302, 22971, 63, 2444, 26, 288, 574, 275, 488, 267, 327, 982, 314, 7148, 466, 365, 376, 3000, 12, 3957, 370, 1109, 267, 916, 291, 14, 14184, 342, 315, 15801, 63, 9596, 63, 7893, 26, 288, 574, 275, 1109, 8, 585, 9, 267, 372, 574, 339, 768, 18950, 419, 63, 585, 14, 8345, 272, 347, 302, 22971, 63, 585, 8, 277, 12, 574, 304, 267, 408, 267, 10729, 314, 302, 22971, 574, 367, 642, 10981, 14, 267, 408, 267, 340, 440, 1228, 8, 585, 12, 334, 442, 12, 2069, 2298, 288, 746, 1722, 360, 46, 22971, 574, 1471, 506, 8950, 2659, 267, 13648, 14, 409, 63, 7877, 63, 18950, 419, 63, 585, 8, 277, 423, 4695, 12, 574, 9, 267, 291, 14, 1365, 423, 4939, 342, 339, 347, 16048, 8, 277, 12, 465, 63, 875, 29, 797, 304, 267, 408, 267, 1803, 314, 15801, 510, 5887, 577, 292, 8588, 367, 642, 10981, 14, 267, 408, 267, 2152, 275, 13648, 14, 362, 63, 7877, 63, 14184, 8, 277, 423, 4695, 9, 267, 340, 465, 63, 875, 26, 288, 2152, 275, 15801, 63, 23357, 63, 7893, 59, 2271, 61, 267, 372, 2152, 339, 347, 666, 8, 277, 12, 666, 29, 403, 12, 3268, 29, 403, 12, 1568, 29, 403, 12, 465, 63, 31519, 29, 797, 304, 267, 408, 267, 26129, 503, 14511, 7148, 1338, 367, 642, 10981, 14, 8651, 83, 402, 666, 883, 267, 506, 13810, 701, 9176, 314, 3462, 12, 4569, 436, 3268, 402, 314, 267, 6387, 1853, 14, 710, 2011, 8929, 883, 506, 1202, 370, 1678, 267, 4184, 402, 282, 19775, 701, 13070, 376, 1625, 402, 1338, 14, 398, 27301, 1324, 666, 2943, 787, 2783, 12, 20228, 12, 769, 12, 2008, 12, 436, 1625, 14, 267, 408, 267, 340, 440, 3268, 26, 288, 3268, 275, 334, 16, 12, 378, 9, 398, 340, 440, 1568, 26, 288, 1568, 275, 334, 277, 14, 2063, 446, 3268, 59, 16, 467, 291, 14, 3333, 446, 3268, 59, 17, 566, 398, 340, 1263, 8, 88, 2695, 378, 367, 671, 315, 1568, 304, 288, 746, 1722, 360, 6397, 4634, 7282, 367, 642, 19775, 2659, 398, 340, 1568, 59, 16, 61, 690, 291, 14, 2063, 503, 1568, 59, 17, 61, 690, 291, 14, 3333, 26, 288, 746, 1722, 360, 2320, 365, 12142, 2419, 19775, 2659, 398, 327, 2790, 5577, 730, 1625, 4306, 267, 5577, 63, 1144, 275, 15801, 63, 2566, 63, 1028, 24583, 59, 277, 14, 14184, 5106, 627, 334, 890, 59, 16, 61, 627, 1568, 59, 17, 566, 398, 340, 666, 365, 488, 26, 288, 327, 2494, 1586, 818, 288, 2879, 63, 4173, 275, 378, 288, 327, 17008, 2701, 5577, 1625, 288, 666, 63, 1144, 275, 5577, 63, 1144, 342, 267, 587, 26, 288, 327, 2494, 2218, 818, 288, 2879, 63, 4173, 275, 413, 953, 327, 32092, 5577, 1625, 17573, 314, 1324, 666, 288, 340,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
jigarkb/Programming
LeetCode/037-H-SudokuSolver.py
2
2012
# Write a program to solve a Sudoku puzzle by filling the empty cells. # # Empty cells are indicated by the character '.'. # # You may assume that there will be only one unique solution. class Solution(object): def solveSudoku(self, board): """ :type board: List[List[str]] :rtype: void Do not return anything, modify board in-place instead. """ self.board = board self.solve() def findUnassigned(self): for row in range(9): for col in range(9): if self.board[row][col] == ".": return row, col return -1, -1 def solve(self): row, col = self.findUnassigned() # no unassigned position is found, puzzle solved if row == -1 and col == -1: return True for num in ["1", "2", "3", "4", "5", "6", "7", "8", "9"]: if self.isSafe(row, col, num): self.board[row][col] = num if self.solve(): return True self.board[row][col] = "." return False def isSafe(self, row, col, ch): boxrow = row - row % 3 boxcol = col - col % 3 return self.checkrow(row, ch) and self.checkcol(col, ch) and self.checksquare(boxrow, boxcol, ch) def checkrow(self, row, ch): for col in range(9): if self.board[row][col] == ch: return False return True def checkcol(self, col, ch): for row in range(9): if self.board[row][col] == ch: return False return True def checksquare(self, row, col, ch): for r in range(row, row + 3): for c in range(col, col + 3): if self.board[r][c] == ch: return False return True # Note: # Traditional backtracking algorithm, if it is safe to place a number in unassigned position we set it and recursively # move forward. Else we back track and try another number.
mit
[ 3, 6990, 282, 2240, 370, 14241, 282, 428, 1181, 745, 85, 18848, 17622, 701, 32499, 314, 2701, 10106, 14, 199, 3, 199, 3, 9630, 10106, 787, 22141, 701, 314, 4528, 15671, 199, 3, 199, 3, 2047, 1443, 5534, 626, 2337, 911, 506, 1454, 1373, 3747, 8744, 14, 421, 199, 533, 9274, 8, 785, 304, 272, 347, 14241, 51, 1181, 745, 85, 8, 277, 12, 13811, 304, 267, 408, 267, 520, 466, 13811, 26, 3820, 59, 1296, 59, 495, 2677, 267, 520, 4500, 26, 2309, 4226, 440, 372, 7003, 12, 2811, 13811, 315, 13, 2778, 3140, 14, 267, 408, 267, 291, 14, 3576, 275, 13811, 267, 291, 14, 11356, 342, 339, 347, 2342, 1358, 12941, 8, 277, 304, 267, 367, 1962, 315, 1425, 8, 25, 304, 288, 367, 1048, 315, 1425, 8, 25, 304, 355, 340, 291, 14, 3576, 59, 1143, 1527, 761, 61, 508, 3680, 582, 490, 372, 1962, 12, 1048, 267, 372, 446, 17, 12, 446, 17, 339, 347, 14241, 8, 277, 304, 267, 1962, 12, 1048, 275, 291, 14, 1623, 1358, 12941, 342, 267, 327, 949, 625, 12941, 3421, 365, 1911, 12, 18848, 17622, 308, 7064, 267, 340, 1962, 508, 446, 17, 436, 1048, 508, 446, 17, 26, 288, 372, 715, 267, 367, 1967, 315, 2097, 17, 401, 298, 18, 401, 298, 19, 401, 298, 20, 401, 298, 21, 401, 298, 22, 401, 298, 23, 401, 298, 24, 401, 298, 25, 6229, 288, 340, 291, 14, 374, 11090, 8, 1143, 12, 1048, 12, 1967, 304, 355, 291, 14, 3576, 59, 1143, 1527, 761, 61, 275, 1967, 355, 340, 291, 14, 11356, 837, 490, 372, 715, 355, 291, 14, 3576, 59, 1143, 1527, 761, 61, 275, 14530, 267, 372, 756, 339, 347, 365, 11090, 8, 277, 12, 1962, 12, 1048, 12, 682, 304, 267, 5689, 1143, 275, 1962, 446, 1962, 450, 650, 267, 5689, 761, 275, 1048, 446, 1048, 450, 650, 267, 372, 291, 14, 1074, 1143, 8, 1143, 12, 682, 9, 436, 291, 14, 1074, 761, 8, 761, 12, 682, 9, 436, 291, 14, 8625, 5937, 8, 1977, 1143, 12, 5689, 761, 12, 682, 9, 339, 347, 1104, 1143, 8, 277, 12, 1962, 12, 682, 304, 267, 367, 1048, 315, 1425, 8, 25, 304, 288, 340, 291, 14, 3576, 59, 1143, 1527, 761, 61, 508, 682, 26, 355, 372, 756, 267, 372, 715, 339, 347, 1104, 761, 8, 277, 12, 1048, 12, 682, 304, 267, 367, 1962, 315, 1425, 8, 25, 304, 288, 340, 291, 14, 3576, 59, 1143, 1527, 761, 61, 508, 682, 26, 355, 372, 756, 267, 372, 715, 339, 347, 5920, 5937, 8, 277, 12, 1962, 12, 1048, 12, 682, 304, 267, 367, 519, 315, 1425, 8, 1143, 12, 1962, 435, 650, 304, 288, 367, 286, 315, 1425, 8, 761, 12, 1048, 435, 650, 304, 355, 340, 291, 14, 3576, 59, 82, 1527, 67, 61, 508, 682, 26, 490, 372, 756, 267, 372, 715, 199, 199, 3, 3390, 26, 199, 3, 12643, 2603, 1771, 14428, 5563, 12, 340, 652, 365, 5048, 370, 4192, 282, 1329, 315, 625, 12941, 3421, 781, 663, 652, 436, 15035, 199, 3, 4057, 7568, 14, 19524, 781, 1771, 4426, 436, 862, 4573, 1329, 14, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6990, 282, 2240, 370, 14241, 282, 428, 1181, 745, 85, 18848, 17622, 701, 32499, 314, 2701, 10106, 14, 199, 3, 199, 3, 9630, 10106, 787, 22141, 701, 314, 4528, 15671, 199, 3, 199, 3, 2047, 1443, 5534, 626, 2337, 911, 506, 1454, 1373, 3747, 8744, 14, 421, 199, 533, 9274, 8, 785, 304, 272, 347, 14241, 51, 1181, 745, 85, 8, 277, 12, 13811, 304, 267, 408, 267, 520, 466, 13811, 26, 3820, 59, 1296, 59, 495, 2677, 267, 520, 4500, 26, 2309, 4226, 440, 372, 7003, 12, 2811, 13811, 315, 13, 2778, 3140, 14, 267, 408, 267, 291, 14, 3576, 275, 13811, 267, 291, 14, 11356, 342, 339, 347, 2342, 1358, 12941, 8, 277, 304, 267, 367, 1962, 315, 1425, 8, 25, 304, 288, 367, 1048, 315, 1425, 8, 25, 304, 355, 340, 291, 14, 3576, 59, 1143, 1527, 761, 61, 508, 3680, 582, 490, 372, 1962, 12, 1048, 267, 372, 446, 17, 12, 446, 17, 339, 347, 14241, 8, 277, 304, 267, 1962, 12, 1048, 275, 291, 14, 1623, 1358, 12941, 342, 267, 327, 949, 625, 12941, 3421, 365, 1911, 12, 18848, 17622, 308, 7064, 267, 340, 1962, 508, 446, 17, 436, 1048, 508, 446, 17, 26, 288, 372, 715, 267, 367, 1967, 315, 2097, 17, 401, 298, 18, 401, 298, 19, 401, 298, 20, 401, 298, 21, 401, 298, 22, 401, 298, 23, 401, 298, 24, 401, 298, 25, 6229, 288, 340, 291, 14, 374, 11090, 8, 1143, 12, 1048, 12, 1967, 304, 355, 291, 14, 3576, 59, 1143, 1527, 761, 61, 275, 1967, 355, 340, 291, 14, 11356, 837, 490, 372, 715, 355, 291, 14, 3576, 59, 1143, 1527, 761, 61, 275, 14530, 267, 372, 756, 339, 347, 365, 11090, 8, 277, 12, 1962, 12, 1048, 12, 682, 304, 267, 5689, 1143, 275, 1962, 446, 1962, 450, 650, 267, 5689, 761, 275, 1048, 446, 1048, 450, 650, 267, 372, 291, 14, 1074, 1143, 8, 1143, 12, 682, 9, 436, 291, 14, 1074, 761, 8, 761, 12, 682, 9, 436, 291, 14, 8625, 5937, 8, 1977, 1143, 12, 5689, 761, 12, 682, 9, 339, 347, 1104, 1143, 8, 277, 12, 1962, 12, 682, 304, 267, 367, 1048, 315, 1425, 8, 25, 304, 288, 340, 291, 14, 3576, 59, 1143, 1527, 761, 61, 508, 682, 26, 355, 372, 756, 267, 372, 715, 339, 347, 1104, 761, 8, 277, 12, 1048, 12, 682, 304, 267, 367, 1962, 315, 1425, 8, 25, 304, 288, 340, 291, 14, 3576, 59, 1143, 1527, 761, 61, 508, 682, 26, 355, 372, 756, 267, 372, 715, 339, 347, 5920, 5937, 8, 277, 12, 1962, 12, 1048, 12, 682, 304, 267, 367, 519, 315, 1425, 8, 1143, 12, 1962, 435, 650, 304, 288, 367, 286, 315, 1425, 8, 761, 12, 1048, 435, 650, 304, 355, 340, 291, 14, 3576, 59, 82, 1527, 67, 61, 508, 682, 26, 490, 372, 756, 267, 372, 715, 199, 199, 3, 3390, 26, 199, 3, 12643, 2603, 1771, 14428, 5563, 12, 340, 652, 365, 5048, 370, 4192, 282, 1329, 315, 625, 12941, 3421, 781, 663, 652, 436, 15035, 199, 3, 4057, 7568, 14, 19524, 781, 1771, 4426, 436, 862, 4573, 1329, 14, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
benschmaus/catapult
dashboard/dashboard/benchmark_health_report_test.py
2
5261
# Copyright 2017 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import datetime import unittest import webapp2 import webtest from google.appengine.ext import ndb from dashboard import benchmark_health_report from dashboard import update_test_suites from dashboard.common import stored_object from dashboard.common import testing_common from dashboard.common import utils from dashboard.models import anomaly from dashboard.models import graph_data class BenchmarkHealthReportTest(testing_common.TestCase): def setUp(self): super(BenchmarkHealthReportTest, self).setUp() app = webapp2.WSGIApplication( [('/benchmark_health_report', benchmark_health_report.BenchmarkHealthReportHandler)]) self.testapp = webtest.TestApp(app) def _AddAnomalyEntities( self, revision_ranges, test_key, bug_id=None): """Adds a group of Anomaly entities to the datastore.""" urlsafe_keys = [] for start_rev, end_rev in revision_ranges: anomaly_key = anomaly.Anomaly( start_revision=start_rev, end_revision=end_rev, test=test_key, bug_id=bug_id, median_before_anomaly=100, median_after_anomaly=200).put() urlsafe_keys.append(anomaly_key.urlsafe()) return urlsafe_keys def _AddTests(self): """Adds sample TestMetadata entities and returns their keys.""" testing_common.AddTests(['ChromiumPerf'], ['linux'], { 'sunspider': { 'Total': {}, 'ref': {}, }, 'page_cycler': { 'load_time': { 'cnn.com': {}, 'google.com': {}, } } }) tests = graph_data.TestMetadata.query() for test in tests: test.improvement_direction = anomaly.DOWN ndb.put_multi(tests) def _AddCachedSuites(self): test_suites = { 'sunspider': { 'mas': {'ChromiumPerf': {'mac': False, 'linux': False}}, 'mon': [], }, 'page_cycler': { 'mas': {'ChromiumPerf': {'linux': False}, 'CrOS': {'foo': False}}, 'mon': ['load_time'], }, 'speedometer': { 'mas': {'CrOS': {'foo': False, 'bar': False}}, 'mon': [], } } key = update_test_suites._NamespaceKey( update_test_suites._LIST_SUITES_CACHE_KEY) stored_object.Set(key, test_suites) def testGet(self): response = self.testapp.get('/benchmark_health_report') self.assertEqual('text/html', response.content_type) self.assertIn('Chrome Performance Dashboard', response.body) def testPost_MasterArgument_ListsTestsForMaster(self): self._AddCachedSuites() response = self.testapp.post( '/benchmark_health_report', {'master': 'CrOS'}) benchmark_list = self.GetJsonValue(response, 'benchmarks') self.assertItemsEqual(benchmark_list, [{ 'name': 'page_cycler', 'monitored': True, 'bots': ['foo'], }, { 'name': 'speedometer', 'monitored': False, 'bots': ['bar', 'foo'], }]) def testPost_BenchmarkArgument_ListsAlertsAndBots(self): self._AddCachedSuites() self._AddTests() self._AddAnomalyEntities( [(200, 400), (600, 800)], utils.TestKey('ChromiumPerf/linux/page_cycler/load_time')) self._AddAnomalyEntities( [(500, 700)], utils.TestKey('ChromiumPerf/linux/page_cycler/load_time/cnn.com')) response = self.testapp.post( '/benchmark_health_report', { 'benchmark': 'page_cycler', 'num_days': '30', 'master': 'ChromiumPerf', }) bots = self.GetJsonValue(response, 'bots') self.assertItemsEqual(bots, ['linux']) self.assertTrue(self.GetJsonValue(response, 'monitored')) alerts = self.GetJsonValue(response, 'alerts') self.assertEqual(3, len(alerts)) def testPost_Benchmark_NotMonitored(self): self._AddCachedSuites() self._AddTests() response = self.testapp.post( '/benchmark_health_report', { 'benchmark': 'sunspider', 'num_days': '30', 'master': 'ChromiumPerf', }) self.assertFalse(self.GetJsonValue(response, 'monitored')) def testPost_BenchmarkArgumentNumDaysArgument_ListsCorrectAlerts(self): self._AddCachedSuites() self._AddTests() self._AddAnomalyEntities( [(200, 400), (600, 800)], utils.TestKey('ChromiumPerf/linux/page_cycler/load_time')) self._AddAnomalyEntities( [(500, 700)], utils.TestKey('ChromiumPerf/linux/page_cycler/load_time/cnn.com')) anomalies = anomaly.Anomaly.query().fetch() anomalies[0].timestamp = datetime.datetime.now() - datetime.timedelta( days=20) anomalies[0].put() response = self.testapp.post( '/benchmark_health_report', {'benchmark': 'page_cycler', 'num_days': '5', 'master': 'ChromiumPerf'}) bots = self.GetJsonValue(response, 'bots') self.assertItemsEqual(bots, ['linux']) self.assertTrue(self.GetJsonValue(response, 'monitored')) alerts = self.GetJsonValue(response, 'alerts') self.assertEqual(2, len(alerts)) if __name__ == '__main__': unittest.main()
bsd-3-clause
[ 3, 1898, 9708, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2197, 199, 646, 2882, 199, 199, 646, 24812, 18, 199, 646, 3330, 396, 199, 199, 504, 6233, 14, 15358, 14, 832, 492, 23788, 199, 199, 504, 17216, 492, 12338, 63, 9665, 63, 3070, 199, 504, 17216, 492, 1678, 63, 396, 63, 27034, 199, 504, 17216, 14, 2330, 492, 5489, 63, 785, 199, 504, 17216, 14, 2330, 492, 5343, 63, 2330, 199, 504, 17216, 14, 2330, 492, 3778, 199, 504, 17216, 14, 992, 492, 28813, 199, 504, 17216, 14, 992, 492, 3343, 63, 576, 421, 199, 533, 27067, 18850, 7457, 774, 8, 4776, 63, 2330, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 1613, 8, 18644, 18850, 7457, 774, 12, 291, 680, 5996, 342, 272, 1145, 275, 24812, 18, 14, 16828, 5039, 8, 267, 359, 2336, 11861, 63, 9665, 63, 3070, 297, 881, 12338, 63, 9665, 63, 3070, 14, 18644, 18850, 7457, 2461, 3948, 272, 291, 14, 19700, 275, 3330, 396, 14, 774, 2640, 8, 571, 9, 819, 347, 485, 1123, 2493, 16523, 24672, 8, 489, 291, 12, 6974, 63, 8404, 12, 511, 63, 498, 12, 6519, 63, 344, 29, 403, 304, 272, 408, 14995, 282, 1572, 402, 1626, 16523, 9045, 370, 314, 12007, 1041, 272, 8187, 6504, 63, 1612, 275, 942, 272, 367, 1343, 63, 4964, 12, 1284, 63, 4964, 315, 6974, 63, 8404, 26, 489, 28813, 63, 498, 275, 28813, 14, 2493, 16523, 8, 881, 1343, 63, 5792, 29, 928, 63, 4964, 12, 1284, 63, 5792, 29, 500, 63, 4964, 12, 881, 511, 29, 396, 63, 498, 12, 6519, 63, 344, 29, 1266, 63, 344, 12, 881, 17312, 63, 5182, 63, 32048, 29, 1960, 12, 17312, 63, 4399, 63, 32048, 29, 1840, 680, 524, 342, 489, 8187, 6504, 63, 1612, 14, 740, 8, 32048, 63, 498, 14, 28201, 1012, 272, 372, 8187, 6504, 63, 1612, 819, 347, 485, 1123, 2925, 8, 277, 304, 272, 408, 14995, 2690, 1379, 5142, 9045, 436, 2529, 3932, 2883, 1041, 272, 5343, 63, 2330, 14, 1123, 2925, 2941, 29381, 12387, 995, 788, 5135, 995, 469, 267, 283, 11846, 12856, 356, 469, 288, 283, 7316, 356, 5479, 288, 283, 1121, 356, 5479, 267, 1660, 267, 283, 1606, 63, 1480, 32046, 356, 469, 288, 283, 912, 63, 521, 356, 469, 355, 283, 67, 4411, 14, 957, 356, 5479, 355, 283, 3098, 14, 957, 356, 5479, 288, 789, 267, 789, 272, 3828, 272, 2295, 275, 3343, 63, 576, 14, 774, 5142, 14, 1131, 342, 272, 367, 511, 315, 2295, 26, 489, 511, 14, 3236, 11750, 434, 63, 6874, 275, 28813, 14, 8819, 272, 23788, 14, 524, 63, 3029, 8, 2219, 9, 819, 347, 485, 1123, 16138, 24458, 8, 277, 304, 272, 511, 63, 27034, 275, 469, 267, 283, 11846, 12856, 356, 469, 288, 283, 5892, 356, 791, 29381, 12387, 356, 791, 3088, 356, 756, 12, 283, 5135, 356, 756, 13459, 288, 283, 2106, 356, 990, 267, 1660, 267, 283, 1606, 63, 1480, 32046, 356, 469, 288, 283, 5892, 356, 791, 29381, 12387, 356, 791, 5135, 356, 756, 1386, 283, 17345, 3100, 356, 791, 1421, 356, 756, 13459, 288, 283, 2106, 356, 788, 912, 63, 521, 995, 267, 1660, 267, 283, 7625, 1377, 351, 356, 469, 288, 283, 5892, 356, 791, 17345, 3100, 356, 791, 1421, 356, 756, 12, 283, 1700, 356, 756, 13459, 288, 283, 2106, 356, 990, 267, 789, 272, 789, 272, 790, 275, 1678, 63, 396, 63, 27034, 423, 8814, 1197, 8, 267, 1678, 63, 396, 63, 27034, 423, 4924, 63, 6195, 649, 654, 63, 8677, 63, 3078, 9, 272, 5489, 63, 785, 14, 1084, 8, 498, 12, 511, 63, 27034, 9, 819, 347, 19970, 8, 277, 304, 272, 1177, 275, 291, 14, 19700, 14, 362, 2336, 11861, 63, 9665, 63, 3070, 358, 272, 291, 14, 629, 360, 505, 15, 1360, 297, 1177, 14, 1317, 63, 466, 9, 272, 291, 14, 4080, 360, 18083, 32117, 577, 1119, 3576, 297, 1177, 14, 2030, 9, 819, 347, 511, 6564, 63, 12288, 5201, 63, 15116, 2925, 1858, 12288, 8, 277, 304, 272, 291, 423, 1123, 16138, 24458, 342, 272, 1177, 275, 291, 14, 19700, 14, 1932, 8, 267, 1994, 11861, 63, 9665, 63, 3070, 297, 791, 4133, 356, 283, 17345, 3100, 3071, 272, 12338, 63, 513, 275, 291, 14, 1002, 9653, 1110, 8, 1310, 12, 283, 11861, 83, 358, 272, 291, 14, 19673, 8, 11861, 63, 513, 12, 8910, 267, 283, 354, 356, 283, 1606, 63, 1480, 32046, 297, 267, 283, 2106, 17043, 356, 715, 12, 267, 283, 28143, 356, 788, 1421, 995, 272, 1660, 469, 267, 283, 354, 356, 283, 7625, 1377, 351, 297, 267, 283, 2106, 17043, 356, 756, 12, 267, 283, 28143, 356, 788, 1700, 297, 283, 1421, 995, 272, 789, 566, 819, 347, 511, 6564, 63, 18644, 5201, 63, 15116, 33, 16676, 3325, 14026, 83, 8, 277, 304, 272, 291, 423, 1123, 16138, 24458, 342, 272, 291, 423, 1123, 2925, 342, 272, 291, 423, 1123, 2493, 16523, 24672, 8, 267, 3842, 1840, 12, 8290, 395, 334, 6683, 12, 23466, 4360, 267, 3778, 14, 774, 1197, 360, 29381, 12387, 15, 5135, 15, 1606, 63, 1480, 32046, 15, 912, 63, 521, 1333, 272, 291, 423, 1123, 2493, 16523, 24672, 8, 267, 3842, 5783, 12, 30071, 4360, 267, 3778, 14, 774, 1197, 360, 29381, 12387, 15, 5135, 15, 1606, 63, 1480, 32046, 15, 912, 63, 521, 15, 67, 4411, 14, 957, 1333, 272, 1177, 275, 291, 14, 19700, 14, 1932, 8, 267, 1994, 11861, 63, 9665, 63, 3070, 297, 469, 288, 283, 11861, 356, 283, 1606, 63, 1480, 32046, 297, 288, 283, 1507, 63, 4899, 356, 283, 1216, 297, 288, 283, 4133, 356, 283, 29381, 12387, 297, 267, 3828, 272, 31726, 275, 291, 14, 1002, 9653, 1110, 8, 1310, 12, 283, 28143, 358, 272, 291, 14, 19673, 8, 28143, 12, 788, 5135, 1105, 272, 291, 14, 1815, 8, 277, 14, 1002, 9653, 1110, 8, 1310, 12, 283, 2106, 17043, 1333, 272, 31529, 275, 291, 14, 1002, 9653, 1110, 8, 1310, 12, 283, 24501, 358, 272, 291, 14, 629, 8 ]
[ 1898, 9708, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2197, 199, 646, 2882, 199, 199, 646, 24812, 18, 199, 646, 3330, 396, 199, 199, 504, 6233, 14, 15358, 14, 832, 492, 23788, 199, 199, 504, 17216, 492, 12338, 63, 9665, 63, 3070, 199, 504, 17216, 492, 1678, 63, 396, 63, 27034, 199, 504, 17216, 14, 2330, 492, 5489, 63, 785, 199, 504, 17216, 14, 2330, 492, 5343, 63, 2330, 199, 504, 17216, 14, 2330, 492, 3778, 199, 504, 17216, 14, 992, 492, 28813, 199, 504, 17216, 14, 992, 492, 3343, 63, 576, 421, 199, 533, 27067, 18850, 7457, 774, 8, 4776, 63, 2330, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 1613, 8, 18644, 18850, 7457, 774, 12, 291, 680, 5996, 342, 272, 1145, 275, 24812, 18, 14, 16828, 5039, 8, 267, 359, 2336, 11861, 63, 9665, 63, 3070, 297, 881, 12338, 63, 9665, 63, 3070, 14, 18644, 18850, 7457, 2461, 3948, 272, 291, 14, 19700, 275, 3330, 396, 14, 774, 2640, 8, 571, 9, 819, 347, 485, 1123, 2493, 16523, 24672, 8, 489, 291, 12, 6974, 63, 8404, 12, 511, 63, 498, 12, 6519, 63, 344, 29, 403, 304, 272, 408, 14995, 282, 1572, 402, 1626, 16523, 9045, 370, 314, 12007, 1041, 272, 8187, 6504, 63, 1612, 275, 942, 272, 367, 1343, 63, 4964, 12, 1284, 63, 4964, 315, 6974, 63, 8404, 26, 489, 28813, 63, 498, 275, 28813, 14, 2493, 16523, 8, 881, 1343, 63, 5792, 29, 928, 63, 4964, 12, 1284, 63, 5792, 29, 500, 63, 4964, 12, 881, 511, 29, 396, 63, 498, 12, 6519, 63, 344, 29, 1266, 63, 344, 12, 881, 17312, 63, 5182, 63, 32048, 29, 1960, 12, 17312, 63, 4399, 63, 32048, 29, 1840, 680, 524, 342, 489, 8187, 6504, 63, 1612, 14, 740, 8, 32048, 63, 498, 14, 28201, 1012, 272, 372, 8187, 6504, 63, 1612, 819, 347, 485, 1123, 2925, 8, 277, 304, 272, 408, 14995, 2690, 1379, 5142, 9045, 436, 2529, 3932, 2883, 1041, 272, 5343, 63, 2330, 14, 1123, 2925, 2941, 29381, 12387, 995, 788, 5135, 995, 469, 267, 283, 11846, 12856, 356, 469, 288, 283, 7316, 356, 5479, 288, 283, 1121, 356, 5479, 267, 1660, 267, 283, 1606, 63, 1480, 32046, 356, 469, 288, 283, 912, 63, 521, 356, 469, 355, 283, 67, 4411, 14, 957, 356, 5479, 355, 283, 3098, 14, 957, 356, 5479, 288, 789, 267, 789, 272, 3828, 272, 2295, 275, 3343, 63, 576, 14, 774, 5142, 14, 1131, 342, 272, 367, 511, 315, 2295, 26, 489, 511, 14, 3236, 11750, 434, 63, 6874, 275, 28813, 14, 8819, 272, 23788, 14, 524, 63, 3029, 8, 2219, 9, 819, 347, 485, 1123, 16138, 24458, 8, 277, 304, 272, 511, 63, 27034, 275, 469, 267, 283, 11846, 12856, 356, 469, 288, 283, 5892, 356, 791, 29381, 12387, 356, 791, 3088, 356, 756, 12, 283, 5135, 356, 756, 13459, 288, 283, 2106, 356, 990, 267, 1660, 267, 283, 1606, 63, 1480, 32046, 356, 469, 288, 283, 5892, 356, 791, 29381, 12387, 356, 791, 5135, 356, 756, 1386, 283, 17345, 3100, 356, 791, 1421, 356, 756, 13459, 288, 283, 2106, 356, 788, 912, 63, 521, 995, 267, 1660, 267, 283, 7625, 1377, 351, 356, 469, 288, 283, 5892, 356, 791, 17345, 3100, 356, 791, 1421, 356, 756, 12, 283, 1700, 356, 756, 13459, 288, 283, 2106, 356, 990, 267, 789, 272, 789, 272, 790, 275, 1678, 63, 396, 63, 27034, 423, 8814, 1197, 8, 267, 1678, 63, 396, 63, 27034, 423, 4924, 63, 6195, 649, 654, 63, 8677, 63, 3078, 9, 272, 5489, 63, 785, 14, 1084, 8, 498, 12, 511, 63, 27034, 9, 819, 347, 19970, 8, 277, 304, 272, 1177, 275, 291, 14, 19700, 14, 362, 2336, 11861, 63, 9665, 63, 3070, 358, 272, 291, 14, 629, 360, 505, 15, 1360, 297, 1177, 14, 1317, 63, 466, 9, 272, 291, 14, 4080, 360, 18083, 32117, 577, 1119, 3576, 297, 1177, 14, 2030, 9, 819, 347, 511, 6564, 63, 12288, 5201, 63, 15116, 2925, 1858, 12288, 8, 277, 304, 272, 291, 423, 1123, 16138, 24458, 342, 272, 1177, 275, 291, 14, 19700, 14, 1932, 8, 267, 1994, 11861, 63, 9665, 63, 3070, 297, 791, 4133, 356, 283, 17345, 3100, 3071, 272, 12338, 63, 513, 275, 291, 14, 1002, 9653, 1110, 8, 1310, 12, 283, 11861, 83, 358, 272, 291, 14, 19673, 8, 11861, 63, 513, 12, 8910, 267, 283, 354, 356, 283, 1606, 63, 1480, 32046, 297, 267, 283, 2106, 17043, 356, 715, 12, 267, 283, 28143, 356, 788, 1421, 995, 272, 1660, 469, 267, 283, 354, 356, 283, 7625, 1377, 351, 297, 267, 283, 2106, 17043, 356, 756, 12, 267, 283, 28143, 356, 788, 1700, 297, 283, 1421, 995, 272, 789, 566, 819, 347, 511, 6564, 63, 18644, 5201, 63, 15116, 33, 16676, 3325, 14026, 83, 8, 277, 304, 272, 291, 423, 1123, 16138, 24458, 342, 272, 291, 423, 1123, 2925, 342, 272, 291, 423, 1123, 2493, 16523, 24672, 8, 267, 3842, 1840, 12, 8290, 395, 334, 6683, 12, 23466, 4360, 267, 3778, 14, 774, 1197, 360, 29381, 12387, 15, 5135, 15, 1606, 63, 1480, 32046, 15, 912, 63, 521, 1333, 272, 291, 423, 1123, 2493, 16523, 24672, 8, 267, 3842, 5783, 12, 30071, 4360, 267, 3778, 14, 774, 1197, 360, 29381, 12387, 15, 5135, 15, 1606, 63, 1480, 32046, 15, 912, 63, 521, 15, 67, 4411, 14, 957, 1333, 272, 1177, 275, 291, 14, 19700, 14, 1932, 8, 267, 1994, 11861, 63, 9665, 63, 3070, 297, 469, 288, 283, 11861, 356, 283, 1606, 63, 1480, 32046, 297, 288, 283, 1507, 63, 4899, 356, 283, 1216, 297, 288, 283, 4133, 356, 283, 29381, 12387, 297, 267, 3828, 272, 31726, 275, 291, 14, 1002, 9653, 1110, 8, 1310, 12, 283, 28143, 358, 272, 291, 14, 19673, 8, 28143, 12, 788, 5135, 1105, 272, 291, 14, 1815, 8, 277, 14, 1002, 9653, 1110, 8, 1310, 12, 283, 2106, 17043, 1333, 272, 31529, 275, 291, 14, 1002, 9653, 1110, 8, 1310, 12, 283, 24501, 358, 272, 291, 14, 629, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
sestrella/ansible
lib/ansible/modules/packaging/os/apk.py
13
11168
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2015, Kevin Brebanov <https://github.com/kbrebanov> # Based on pacman (Afterburn <https://github.com/afterburn>, Aaron Bull Schaefer <aaron@elasticdog.com>) # and apt (Matthew Williams <matthew@flowroute.com>) modules. # # 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': 'community'} DOCUMENTATION = ''' --- module: apk short_description: Manages apk packages description: - Manages I(apk) packages for Alpine Linux. author: "Kevin Brebanov (@kbrebanov)" version_added: "2.0" options: available: description: - During upgrade, reset versioned world dependencies and change logic to prefer replacing or downgrading packages (instead of holding them) if the currently installed package is no longer available from any repository. type: bool default: 'no' version_added: "2.4" name: description: - A package name, like C(foo), or multiple packages, like C(foo, bar). type: list elements: str repository: description: - A package repository or multiple repositories. Unlike with the underlying apk command, this list will override the system repositories rather than supplement them. version_added: "2.4" state: description: - Indicates the desired package(s) state. - C(present) ensures the package(s) is/are present. - C(absent) ensures the package(s) is/are absent. - C(latest) ensures the package(s) is/are present and the latest version(s). default: present choices: [ "present", "absent", "latest" ] update_cache: description: - Update repository indexes. Can be run with other steps or on it's own. type: bool default: 'no' upgrade: description: - Upgrade all installed packages to their latest version. type: bool default: 'no' notes: - '"name" and "upgrade" are mutually exclusive.' - When used with a `loop:` each package will be processed individually, it is much more efficient to pass the list directly to the `name` option. ''' EXAMPLES = ''' # Update repositories and install "foo" package - apk: name: foo update_cache: yes # Update repositories and install "foo" and "bar" packages - apk: name: foo,bar update_cache: yes # Remove "foo" package - apk: name: foo state: absent # Remove "foo" and "bar" packages - apk: name: foo,bar state: absent # Install the package "foo" - apk: name: foo state: present # Install the packages "foo" and "bar" - apk: name: foo,bar state: present # Update repositories and update package "foo" to latest version - apk: name: foo state: latest update_cache: yes # Update repositories and update packages "foo" and "bar" to latest versions - apk: name: foo,bar state: latest update_cache: yes # Update all installed packages to the latest versions - apk: upgrade: yes # Upgrade / replace / downgrade / uninstall all installed packages to the latest versions available - apk: available: yes upgrade: yes # Update repositories as a separate step - apk: update_cache: yes # Install package from a specific repository - apk: name: foo state: latest update_cache: yes repository: http://dl-3.alpinelinux.org/alpine/edge/main ''' RETURN = ''' packages: description: a list of packages that have been changed returned: when packages have changed type: list sample: ['package', 'other-package'] ''' import re # Import module snippets. from ansible.module_utils.basic import AnsibleModule def parse_for_packages(stdout): packages = [] data = stdout.split('\n') regex = re.compile(r'^\(\d+/\d+\)\s+\S+\s+(\S+)') for l in data: p = regex.search(l) if p: packages.append(p.group(1)) return packages def update_package_db(module, exit): cmd = "%s update" % (APK_PATH) rc, stdout, stderr = module.run_command(cmd, check_rc=False) if rc != 0: module.fail_json(msg="could not update package db", stdout=stdout, stderr=stderr) elif exit: module.exit_json(changed=True, msg='updated repository indexes', stdout=stdout, stderr=stderr) else: return True def query_toplevel(module, name): # /etc/apk/world contains a list of top-level packages separated by ' ' or \n # packages may contain repository (@) or version (=<>~) separator characters or start with negation ! regex = re.compile(r'^' + re.escape(name) + r'([@=<>~].+)?$') with open('/etc/apk/world') as f: content = f.read().split() for p in content: if regex.search(p): return True return False def query_package(module, name): cmd = "%s -v info --installed %s" % (APK_PATH, name) rc, stdout, stderr = module.run_command(cmd, check_rc=False) if rc == 0: return True else: return False def query_latest(module, name): cmd = "%s version %s" % (APK_PATH, name) rc, stdout, stderr = module.run_command(cmd, check_rc=False) search_pattern = r"(%s)-[\d\.\w]+-[\d\w]+\s+(.)\s+[\d\.\w]+-[\d\w]+\s+" % (re.escape(name)) match = re.search(search_pattern, stdout) if match and match.group(2) == "<": return False return True def query_virtual(module, name): cmd = "%s -v info --description %s" % (APK_PATH, name) rc, stdout, stderr = module.run_command(cmd, check_rc=False) search_pattern = r"^%s: virtual meta package" % (re.escape(name)) if re.search(search_pattern, stdout): return True return False def get_dependencies(module, name): cmd = "%s -v info --depends %s" % (APK_PATH, name) rc, stdout, stderr = module.run_command(cmd, check_rc=False) dependencies = stdout.split() if len(dependencies) > 1: return dependencies[1:] else: return [] def upgrade_packages(module, available): if module.check_mode: cmd = "%s upgrade --simulate" % (APK_PATH) else: cmd = "%s upgrade" % (APK_PATH) if available: cmd = "%s --available" % cmd rc, stdout, stderr = module.run_command(cmd, check_rc=False) packagelist = parse_for_packages(stdout) if rc != 0: module.fail_json(msg="failed to upgrade packages", stdout=stdout, stderr=stderr, packages=packagelist) if re.search(r'^OK', stdout): module.exit_json(changed=False, msg="packages already upgraded", stdout=stdout, stderr=stderr, packages=packagelist) module.exit_json(changed=True, msg="upgraded packages", stdout=stdout, stderr=stderr, packages=packagelist) def install_packages(module, names, state): upgrade = False to_install = [] to_upgrade = [] for name in names: # Check if virtual package if query_virtual(module, name): # Get virtual package dependencies dependencies = get_dependencies(module, name) for dependency in dependencies: if state == 'latest' and not query_latest(module, dependency): to_upgrade.append(dependency) else: if not query_toplevel(module, name): to_install.append(name) elif state == 'latest' and not query_latest(module, name): to_upgrade.append(name) if to_upgrade: upgrade = True if not to_install and not upgrade: module.exit_json(changed=False, msg="package(s) already installed") packages = " ".join(to_install + to_upgrade) if upgrade: if module.check_mode: cmd = "%s add --upgrade --simulate %s" % (APK_PATH, packages) else: cmd = "%s add --upgrade %s" % (APK_PATH, packages) else: if module.check_mode: cmd = "%s add --simulate %s" % (APK_PATH, packages) else: cmd = "%s add %s" % (APK_PATH, packages) rc, stdout, stderr = module.run_command(cmd, check_rc=False) packagelist = parse_for_packages(stdout) if rc != 0: module.fail_json(msg="failed to install %s" % (packages), stdout=stdout, stderr=stderr, packages=packagelist) module.exit_json(changed=True, msg="installed %s package(s)" % (packages), stdout=stdout, stderr=stderr, packages=packagelist) def remove_packages(module, names): installed = [] for name in names: if query_package(module, name): installed.append(name) if not installed: module.exit_json(changed=False, msg="package(s) already removed") names = " ".join(installed) if module.check_mode: cmd = "%s del --purge --simulate %s" % (APK_PATH, names) else: cmd = "%s del --purge %s" % (APK_PATH, names) rc, stdout, stderr = module.run_command(cmd, check_rc=False) packagelist = parse_for_packages(stdout) # Check to see if packages are still present because of dependencies for name in installed: if query_package(module, name): rc = 1 break if rc != 0: module.fail_json(msg="failed to remove %s package(s)" % (names), stdout=stdout, stderr=stderr, packages=packagelist) module.exit_json(changed=True, msg="removed %s package(s)" % (names), stdout=stdout, stderr=stderr, packages=packagelist) # ========================================== # Main control flow. def main(): module = AnsibleModule( argument_spec=dict( state=dict(default='present', choices=['present', 'installed', 'absent', 'removed', 'latest']), name=dict(type='list', elements='str'), repository=dict(type='list'), update_cache=dict(default='no', type='bool'), upgrade=dict(default='no', type='bool'), available=dict(default='no', type='bool'), ), required_one_of=[['name', 'update_cache', 'upgrade']], mutually_exclusive=[['name', 'upgrade']], supports_check_mode=True ) # Set LANG env since we parse stdout module.run_command_environ_update = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C', LC_CTYPE='C') global APK_PATH APK_PATH = module.get_bin_path('apk', required=True) p = module.params # add repositories to the APK_PATH if p['repository']: for r in p['repository']: APK_PATH = "%s --repository %s --repositories-file /dev/null" % (APK_PATH, r) # normalize the state parameter if p['state'] in ['present', 'installed']: p['state'] = 'present' if p['state'] in ['absent', 'removed']: p['state'] = 'absent' if p['update_cache']: update_package_db(module, not p['name'] and not p['upgrade']) if p['upgrade']: upgrade_packages(module, p['available']) if p['state'] in ['present', 'latest']: install_packages(module, p['name'], p['state']) elif p['state'] == 'absent': remove_packages(module, p['name']) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 25645, 11908, 699, 264, 66, 8143, 86, 665, 2859, 921, 5031, 14, 957, 15, 7862, 264, 66, 8143, 86, 30, 199, 3, 21311, 641, 299, 645, 1237, 334, 10881, 30736, 665, 2859, 921, 5031, 14, 957, 15, 4399, 30736, 6244, 437, 285, 265, 699, 979, 22985, 3624, 2412, 665, 65, 285, 265, 32, 15565, 13889, 14, 957, 18956, 199, 3, 436, 20932, 334, 14817, 29640, 644, 8148, 19470, 665, 569, 29640, 32, 1659, 4449, 14, 957, 18956, 4621, 14, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 31528, 199, 3612, 63, 1802, 26, 21612, 31528, 6117, 199, 1802, 26, 523, 446, 21612, 473, 8, 23582, 9, 6117, 367, 4580, 80, 1132, 10130, 14, 199, 2502, 26, 298, 1136, 11908, 699, 264, 66, 8143, 86, 8593, 7862, 264, 66, 8143, 86, 2924, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 1419, 26, 523, 2808, 26, 272, 1369, 26, 489, 446, 577, 4039, 10754, 12, 5305, 31792, 6701, 5124, 436, 1570, 9661, 370, 16602, 15810, 503, 3224, 16050, 6117, 334, 23145, 402, 17573, 3062, 9, 267, 340, 314, 5544, 4903, 2559, 365, 949, 8088, 2808, 687, 1263, 7611, 14, 272, 730, 26, 2155, 272, 849, 26, 283, 889, 7, 272, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 523, 536, 26, 272, 1369, 26, 489, 446, 437, 2559, 536, 12, 2839, 445, 8, 1421, 395, 503, 3663, 6117, 12, 2839, 445, 8, 1421, 12, 4681, 680, 272, 730, 26, 769, 272, 4008, 26, 620, 523, 7611, 26, 272, 1369, 26, 489, 446, 437, 2559, 7611, 503, 3663, 23737, 14, 267, 25059, 543, 314, 8793, 31528, 1414, 12, 642, 769, 911, 4278, 314, 2656, 23737, 7830, 2419, 4973, 968, 3062, 14, 272, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 523, 1174, 26, 272, 1369, 26, 489, 446, 19334, 314, 6387, 2559, 8, 83, 9, 1174, 14, 489, 446, 445, 8, 1881, 9, 15620, 314, 2559, 8, 83, 9, 365, 15, 1530, 3451, 14, 489, 446, 445, 8, 5575, 9, 15620, 314, 2559, 8, 83, 9, 365, 15, 1530, 9552, 14, 489, 446, 445, 8, 7410, 9, 15620, 314, 2559, 8, 83, 9, 365, 15, 1530, 3451, 436, 314, 8839, 1015, 8, 83, 680, 272, 849, 26, 3451, 272, 3415, 26, 359, 298, 1881, 401, 298, 5575, 401, 298, 7410, 2, 1622, 523, 1678, 63, 1637, 26, 272, 1369, 26, 489, 446, 6162, 7611, 10507, 14, 6855, 506, 1255, 543, 1163, 7124, 503, 641, 652, 1159, 5705, 14, 272, 730, 26, 2155, 272, 849, 26, 283, 889, 7, 523, 10754, 26, 272, 1369, 26, 489, 446, 4949, 4523, 1006, 4903, 6117, 370, 3932, 8839, 1015, 14, 272, 730, 26, 2155, 272, 849, 26, 283, 889, 7, 199, 5983, 26, 523, 446, 5522, 354, 2, 436, 298, 9375, 2, 787, 16108, 13914, 3530, 523, 446, 3979, 1202, 543, 282, 658, 3813, 1705, 1924, 2559, 911, 506, 7686, 7814, 3163, 12, 652, 365, 8298, 1655, 13402, 370, 986, 314, 769, 5370, 370, 314, 658, 354, 64, 945, 14, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 6162, 23737, 436, 3907, 298, 1421, 2, 2559, 199, 13, 31528, 26, 272, 536, 26, 3925, 272, 1678, 63, 1637, 26, 9456, 199, 199, 3, 6162, 23737, 436, 3907, 298, 1421, 2, 436, 298, 1700, 2, 6117, 199, 13, 31528, 26, 272, 536, 26, 3925, 12, 1700, 272, 1678, 63, 1637, 26, 9456, 199, 199, 3, 5852, 298, 1421, 2, 2559, 199, 13, 31528, 26, 272, 536, 26, 3925, 272, 1174, 26, 9552, 199, 199, 3, 5852, 298, 1421, 2, 436, 298, 1700, 2, 6117, 199, 13, 31528, 26, 272, 536, 26, 3925, 12, 1700, 272, 1174, 26, 9552, 199, 199, 3, 13276, 314, 2559, 298, 1421, 2, 199, 13, 31528, 26, 272, 536, 26, 3925, 272, 1174, 26, 3451, 199, 199, 3, 13276, 314, 6117, 298, 1421, 2, 436, 298, 1700, 2, 199, 13, 31528, 26, 272, 536, 26, 3925, 12, 1700, 272, 1174, 26, 3451, 199, 199, 3, 6162, 23737, 436, 1678, 2559, 298, 1421, 2, 370, 8839, 1015, 199, 13, 31528, 26, 272, 536, 26, 3925, 272, 1174, 26, 8839, 272, 1678, 63, 1637, 26, 9456, 199, 199, 3, 6162, 23737, 436, 1678, 6117, 298, 1421, 2, 436, 298, 1700, 2, 370, 8839, 5459, 199, 13, 31528, 26, 272, 536, 26, 3925, 12, 1700, 272, 1174, 26, 8839, 272, 1678, 63, 1637, 26, 9456, 199, 199, 3, 6162, 1006, 4903, 6117, 370, 314, 8839, 5459, 199, 13, 31528, 26, 272, 10754, 26, 9456, 199, 199, 3, 4949, 4523, 1182, 3350, 1182, 32498, 1182, 22199, 1006, 4903, 6117, 370, 314, 8839, 5459, 2808, 199, 13, 31528, 26, 272, 2808, 26, 9456, 272, 10754, 26, 9456, 199, 199, 3, 6162, 23737, 465, 282, 7396, 3650, 199, 13, 31528, 26, 272, 1678, 63, 1637, 26, 9456, 199, 199, 3, 13276, 2559, 687, 282, 2488, 7611, 199, 13, 31528, 26, 272, 536, 26, 3925, 272, 1174, 26, 8839, 272, 1678, 63, 1637, 26, 9456, 272, 7611, 26, 1455, 921, 5030, 13, 19, 14, 279, 7751, 352, 7226, 14, 1308, 15, 279, 80, 1132, 15, 5173, 15, 973, 199, 2344, 199, 199, 9677, 275, 1449, 199, 5154, 26, 272, 1369, 26, 282, 769, 402, 6117, 626, 1172, 2757, 2896, 272, 2138, 26, 1380, 6117, 1172, 2896, 272, 730, 26, 769, 272, 2690, 26, 788, 2491, 297, 283, 1848, 13, 2491, 418, 199, 2344, 199, 199, 646, 295, 199, 3, 3161, 859, 19484, 14, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6900, 12, 25645, 11908, 699, 264, 66, 8143, 86, 665, 2859, 921, 5031, 14, 957, 15, 7862, 264, 66, 8143, 86, 30, 199, 3, 21311, 641, 299, 645, 1237, 334, 10881, 30736, 665, 2859, 921, 5031, 14, 957, 15, 4399, 30736, 6244, 437, 285, 265, 699, 979, 22985, 3624, 2412, 665, 65, 285, 265, 32, 15565, 13889, 14, 957, 18956, 199, 3, 436, 20932, 334, 14817, 29640, 644, 8148, 19470, 665, 569, 29640, 32, 1659, 4449, 14, 957, 18956, 4621, 14, 199, 3, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 31528, 199, 3612, 63, 1802, 26, 21612, 31528, 6117, 199, 1802, 26, 523, 446, 21612, 473, 8, 23582, 9, 6117, 367, 4580, 80, 1132, 10130, 14, 199, 2502, 26, 298, 1136, 11908, 699, 264, 66, 8143, 86, 8593, 7862, 264, 66, 8143, 86, 2924, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 1419, 26, 523, 2808, 26, 272, 1369, 26, 489, 446, 577, 4039, 10754, 12, 5305, 31792, 6701, 5124, 436, 1570, 9661, 370, 16602, 15810, 503, 3224, 16050, 6117, 334, 23145, 402, 17573, 3062, 9, 267, 340, 314, 5544, 4903, 2559, 365, 949, 8088, 2808, 687, 1263, 7611, 14, 272, 730, 26, 2155, 272, 849, 26, 283, 889, 7, 272, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 523, 536, 26, 272, 1369, 26, 489, 446, 437, 2559, 536, 12, 2839, 445, 8, 1421, 395, 503, 3663, 6117, 12, 2839, 445, 8, 1421, 12, 4681, 680, 272, 730, 26, 769, 272, 4008, 26, 620, 523, 7611, 26, 272, 1369, 26, 489, 446, 437, 2559, 7611, 503, 3663, 23737, 14, 267, 25059, 543, 314, 8793, 31528, 1414, 12, 642, 769, 911, 4278, 314, 2656, 23737, 7830, 2419, 4973, 968, 3062, 14, 272, 1015, 63, 3270, 26, 298, 18, 14, 20, 2, 523, 1174, 26, 272, 1369, 26, 489, 446, 19334, 314, 6387, 2559, 8, 83, 9, 1174, 14, 489, 446, 445, 8, 1881, 9, 15620, 314, 2559, 8, 83, 9, 365, 15, 1530, 3451, 14, 489, 446, 445, 8, 5575, 9, 15620, 314, 2559, 8, 83, 9, 365, 15, 1530, 9552, 14, 489, 446, 445, 8, 7410, 9, 15620, 314, 2559, 8, 83, 9, 365, 15, 1530, 3451, 436, 314, 8839, 1015, 8, 83, 680, 272, 849, 26, 3451, 272, 3415, 26, 359, 298, 1881, 401, 298, 5575, 401, 298, 7410, 2, 1622, 523, 1678, 63, 1637, 26, 272, 1369, 26, 489, 446, 6162, 7611, 10507, 14, 6855, 506, 1255, 543, 1163, 7124, 503, 641, 652, 1159, 5705, 14, 272, 730, 26, 2155, 272, 849, 26, 283, 889, 7, 523, 10754, 26, 272, 1369, 26, 489, 446, 4949, 4523, 1006, 4903, 6117, 370, 3932, 8839, 1015, 14, 272, 730, 26, 2155, 272, 849, 26, 283, 889, 7, 199, 5983, 26, 523, 446, 5522, 354, 2, 436, 298, 9375, 2, 787, 16108, 13914, 3530, 523, 446, 3979, 1202, 543, 282, 658, 3813, 1705, 1924, 2559, 911, 506, 7686, 7814, 3163, 12, 652, 365, 8298, 1655, 13402, 370, 986, 314, 769, 5370, 370, 314, 658, 354, 64, 945, 14, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 6162, 23737, 436, 3907, 298, 1421, 2, 2559, 199, 13, 31528, 26, 272, 536, 26, 3925, 272, 1678, 63, 1637, 26, 9456, 199, 199, 3, 6162, 23737, 436, 3907, 298, 1421, 2, 436, 298, 1700, 2, 6117, 199, 13, 31528, 26, 272, 536, 26, 3925, 12, 1700, 272, 1678, 63, 1637, 26, 9456, 199, 199, 3, 5852, 298, 1421, 2, 2559, 199, 13, 31528, 26, 272, 536, 26, 3925, 272, 1174, 26, 9552, 199, 199, 3, 5852, 298, 1421, 2, 436, 298, 1700, 2, 6117, 199, 13, 31528, 26, 272, 536, 26, 3925, 12, 1700, 272, 1174, 26, 9552, 199, 199, 3, 13276, 314, 2559, 298, 1421, 2, 199, 13, 31528, 26, 272, 536, 26, 3925, 272, 1174, 26, 3451, 199, 199, 3, 13276, 314, 6117, 298, 1421, 2, 436, 298, 1700, 2, 199, 13, 31528, 26, 272, 536, 26, 3925, 12, 1700, 272, 1174, 26, 3451, 199, 199, 3, 6162, 23737, 436, 1678, 2559, 298, 1421, 2, 370, 8839, 1015, 199, 13, 31528, 26, 272, 536, 26, 3925, 272, 1174, 26, 8839, 272, 1678, 63, 1637, 26, 9456, 199, 199, 3, 6162, 23737, 436, 1678, 6117, 298, 1421, 2, 436, 298, 1700, 2, 370, 8839, 5459, 199, 13, 31528, 26, 272, 536, 26, 3925, 12, 1700, 272, 1174, 26, 8839, 272, 1678, 63, 1637, 26, 9456, 199, 199, 3, 6162, 1006, 4903, 6117, 370, 314, 8839, 5459, 199, 13, 31528, 26, 272, 10754, 26, 9456, 199, 199, 3, 4949, 4523, 1182, 3350, 1182, 32498, 1182, 22199, 1006, 4903, 6117, 370, 314, 8839, 5459, 2808, 199, 13, 31528, 26, 272, 2808, 26, 9456, 272, 10754, 26, 9456, 199, 199, 3, 6162, 23737, 465, 282, 7396, 3650, 199, 13, 31528, 26, 272, 1678, 63, 1637, 26, 9456, 199, 199, 3, 13276, 2559, 687, 282, 2488, 7611, 199, 13, 31528, 26, 272, 536, 26, 3925, 272, 1174, 26, 8839, 272, 1678, 63, 1637, 26, 9456, 272, 7611, 26, 1455, 921, 5030, 13, 19, 14, 279, 7751, 352, 7226, 14, 1308, 15, 279, 80, 1132, 15, 5173, 15, 973, 199, 2344, 199, 199, 9677, 275, 1449, 199, 5154, 26, 272, 1369, 26, 282, 769, 402, 6117, 626, 1172, 2757, 2896, 272, 2138, 26, 1380, 6117, 1172, 2896, 272, 730, 26, 769, 272, 2690, 26, 788, 2491, 297, 283, 1848, 13, 2491, 418, 199, 2344, 199, 199, 646, 295, 199, 3, 3161, 859, 19484, 14, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ZacariasBendeck/youtube-dl
youtube_dl/extractor/telebruxelles.py
150
2352
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor class TeleBruxellesIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?telebruxelles\.be/(news|sport|dernier-jt)/?(?P<id>[^/#?]+)' _TESTS = [{ 'url': 'http://www.telebruxelles.be/news/auditions-devant-parlement-francken-galant-tres-attendus/', 'md5': '59439e568c9ee42fb77588b2096b214f', 'info_dict': { 'id': '11942', 'display_id': 'auditions-devant-parlement-francken-galant-tres-attendus', 'ext': 'flv', 'title': 'Parlement : Francken et Galant répondent aux interpellations de l’opposition', 'description': 're:Les auditions des ministres se poursuivent*' }, 'params': { 'skip_download': 'requires rtmpdump' }, }, { 'url': 'http://www.telebruxelles.be/sport/basket-brussels-bat-mons-80-74/', 'md5': '181d3fbdcf20b909309e5aef5c6c6047', 'info_dict': { 'id': '10091', 'display_id': 'basket-brussels-bat-mons-80-74', 'ext': 'flv', 'title': 'Basket : le Brussels bat Mons 80-74', 'description': 're:^Ils l\u2019on fait ! En basket, le B*', }, 'params': { 'skip_download': 'requires rtmpdump' }, }] def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) article_id = self._html_search_regex( r"<article id=\"post-(\d+)\"", webpage, 'article ID') title = self._html_search_regex( r'<h1 class=\"entry-title\">(.*?)</h1>', webpage, 'title') description = self._og_search_description(webpage) rtmp_url = self._html_search_regex( r"file: \"(rtmp://\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5}/vod/mp4:\" \+ \"\w+\" \+ \".mp4)\"", webpage, 'RTMP url') rtmp_url = rtmp_url.replace("\" + \"", "") return { 'id': article_id, 'display_id': display_id, 'title': title, 'description': description, 'url': rtmp_url, 'ext': 'flv', 'rtmp_live': True # if rtmpdump is not called with "--live" argument, the download is blocked and can be completed }
unlicense
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 421, 199, 533, 23884, 12771, 2521, 352, 2978, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 15253, 3289, 2521, 352, 2978, 4537, 1235, 7985, 13224, 92, 3275, 92, 424, 78, 4446, 13, 26002, 2447, 31, 2229, 48, 28, 344, 13489, 12645, 31, 29716, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 15253, 3289, 2521, 352, 2978, 14, 1235, 15, 13224, 15, 3844, 3138, 13, 2374, 867, 13, 462, 968, 13, 70, 1312, 346, 287, 13, 27074, 867, 13, 84, 470, 13, 4867, 68, 527, 3678, 267, 283, 1064, 21, 356, 283, 15667, 1355, 69, 15085, 67, 25, 1024, 2260, 4675, 12710, 1299, 66, 1165, 2534, 66, 6886, 70, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 7119, 2260, 297, 288, 283, 2918, 63, 344, 356, 283, 3844, 3138, 13, 2374, 867, 13, 462, 968, 13, 70, 1312, 346, 287, 13, 27074, 867, 13, 84, 470, 13, 4867, 68, 527, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 1262, 968, 520, 481, 1312, 346, 287, 10844, 598, 279, 867, 519, 5741, 678, 1326, 11593, 1640, 28478, 6011, 477, 634, 21045, 411, 3124, 297, 288, 283, 1802, 356, 283, 264, 26, 44, 397, 10576, 3138, 18618, 1748, 631, 470, 542, 299, 16363, 1907, 782, 10223, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 283, 6537, 519, 2791, 2724, 7, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 15253, 3289, 2521, 352, 2978, 14, 1235, 15, 3275, 15, 18136, 13, 3289, 527, 261, 478, 13, 13475, 13, 2106, 83, 13, 1257, 13, 1342, 3678, 267, 283, 1064, 21, 356, 283, 12851, 68, 19, 17108, 2177, 1165, 66, 26578, 10556, 69, 21, 65, 2829, 21, 67, 22, 67, 22, 12931, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1960, 3328, 297, 288, 283, 2918, 63, 344, 356, 283, 18136, 13, 3289, 527, 261, 478, 13, 13475, 13, 2106, 83, 13, 1257, 13, 1342, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 34, 12351, 520, 1026, 699, 20791, 261, 478, 330, 292, 603, 4654, 5939, 13, 1342, 297, 288, 283, 1802, 356, 283, 264, 23497, 41, 478, 634, 60, 85, 14982, 265, 1433, 390, 8546, 3447, 22812, 12, 1026, 699, 7693, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 283, 6537, 519, 2791, 2724, 7, 267, 1660, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 2929, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 2929, 63, 344, 9, 398, 9772, 63, 344, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 17030, 6934, 1305, 8178, 1932, 13, 2961, 68, 13439, 5151, 9248, 12, 283, 6934, 2870, 358, 267, 2538, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 72, 17, 1021, 8178, 2373, 13, 1213, 60, 1743, 17140, 15939, 72, 17, 4206, 9248, 12, 283, 1213, 358, 267, 1369, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 9, 398, 519, 2791, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 2, 493, 26, 8441, 8, 29649, 921, 60, 68, 91, 17, 12, 19, 4988, 3134, 68, 91, 17, 12, 19, 4988, 3134, 68, 91, 17, 12, 19, 4988, 3134, 68, 91, 17, 12, 19, 93, 3427, 68, 91, 17, 12, 21, 5995, 86, 364, 15, 311, 20, 3427, 2, 971, 11, 971, 3212, 87, 11, 4451, 971, 11, 971, 1674, 311, 20, 2862, 5151, 288, 9248, 12, 283, 11876, 1658, 1166, 358, 267, 519, 2791, 63, 633, 275, 519, 2791, 63, 633, 14, 1814, 480, 4451, 435, 971, 5151, 6899, 398, 372, 469, 288, 283, 344, 356, 9772, 63, 344, 12, 288, 283, 2918, 63, 344, 356, 2929, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 633, 356, 519, 2791, 63, 633, 12, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 29649, 63, 6442, 356, 715, 221, 327, 340, 519, 2791, 2724, 365, 440, 2797, 543, 4320, 6442, 2, 1423, 12, 314, 5235, 365, 19697, 436, 883, 506, 9709, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 421, 199, 533, 23884, 12771, 2521, 352, 2978, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 15253, 3289, 2521, 352, 2978, 4537, 1235, 7985, 13224, 92, 3275, 92, 424, 78, 4446, 13, 26002, 2447, 31, 2229, 48, 28, 344, 13489, 12645, 31, 29716, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 15253, 3289, 2521, 352, 2978, 14, 1235, 15, 13224, 15, 3844, 3138, 13, 2374, 867, 13, 462, 968, 13, 70, 1312, 346, 287, 13, 27074, 867, 13, 84, 470, 13, 4867, 68, 527, 3678, 267, 283, 1064, 21, 356, 283, 15667, 1355, 69, 15085, 67, 25, 1024, 2260, 4675, 12710, 1299, 66, 1165, 2534, 66, 6886, 70, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 7119, 2260, 297, 288, 283, 2918, 63, 344, 356, 283, 3844, 3138, 13, 2374, 867, 13, 462, 968, 13, 70, 1312, 346, 287, 13, 27074, 867, 13, 84, 470, 13, 4867, 68, 527, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 1262, 968, 520, 481, 1312, 346, 287, 10844, 598, 279, 867, 519, 5741, 678, 1326, 11593, 1640, 28478, 6011, 477, 634, 21045, 411, 3124, 297, 288, 283, 1802, 356, 283, 264, 26, 44, 397, 10576, 3138, 18618, 1748, 631, 470, 542, 299, 16363, 1907, 782, 10223, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 283, 6537, 519, 2791, 2724, 7, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 15253, 3289, 2521, 352, 2978, 14, 1235, 15, 3275, 15, 18136, 13, 3289, 527, 261, 478, 13, 13475, 13, 2106, 83, 13, 1257, 13, 1342, 3678, 267, 283, 1064, 21, 356, 283, 12851, 68, 19, 17108, 2177, 1165, 66, 26578, 10556, 69, 21, 65, 2829, 21, 67, 22, 67, 22, 12931, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1960, 3328, 297, 288, 283, 2918, 63, 344, 356, 283, 18136, 13, 3289, 527, 261, 478, 13, 13475, 13, 2106, 83, 13, 1257, 13, 1342, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 34, 12351, 520, 1026, 699, 20791, 261, 478, 330, 292, 603, 4654, 5939, 13, 1342, 297, 288, 283, 1802, 356, 283, 264, 23497, 41, 478, 634, 60, 85, 14982, 265, 1433, 390, 8546, 3447, 22812, 12, 1026, 699, 7693, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 283, 6537, 519, 2791, 2724, 7, 267, 1660, 272, 14877, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 2929, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 2929, 63, 344, 9, 398, 9772, 63, 344, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 17030, 6934, 1305, 8178, 1932, 13, 2961, 68, 13439, 5151, 9248, 12, 283, 6934, 2870, 358, 267, 2538, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 7601, 72, 17, 1021, 8178, 2373, 13, 1213, 60, 1743, 17140, 15939, 72, 17, 4206, 9248, 12, 283, 1213, 358, 267, 1369, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 9, 398, 519, 2791, 63, 633, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 2, 493, 26, 8441, 8, 29649, 921, 60, 68, 91, 17, 12, 19, 4988, 3134, 68, 91, 17, 12, 19, 4988, 3134, 68, 91, 17, 12, 19, 4988, 3134, 68, 91, 17, 12, 19, 93, 3427, 68, 91, 17, 12, 21, 5995, 86, 364, 15, 311, 20, 3427, 2, 971, 11, 971, 3212, 87, 11, 4451, 971, 11, 971, 1674, 311, 20, 2862, 5151, 288, 9248, 12, 283, 11876, 1658, 1166, 358, 267, 519, 2791, 63, 633, 275, 519, 2791, 63, 633, 14, 1814, 480, 4451, 435, 971, 5151, 6899, 398, 372, 469, 288, 283, 344, 356, 9772, 63, 344, 12, 288, 283, 2918, 63, 344, 356, 2929, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 633, 356, 519, 2791, 63, 633, 12, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 29649, 63, 6442, 356, 715, 221, 327, 340, 519, 2791, 2724, 365, 440, 2797, 543, 4320, 6442, 2, 1423, 12, 314, 5235, 365, 19697, 436, 883, 506, 9709, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
super3/PyDev
Books/source/catanimation.py
7
1034
import pygame, sys from pygame.locals import * pygame.init() FPS = 30 # frames per second setting fpsClock = pygame.time.Clock() # set up the window DISPLAYSURF = pygame.display.set_mode((400, 300), 0, 32) pygame.display.set_caption('Animation') WHITE = (255, 255, 255) catImg = pygame.image.load('cat.png') catx = 10 caty = 10 direction = 'right' while True: # the main game loop DISPLAYSURF.fill(WHITE) if direction == 'right': catx += 5 if catx == 280: direction = 'down' elif direction == 'down': caty += 5 if caty == 220: direction = 'left' elif direction == 'left': catx -= 5 if catx == 10: direction = 'up' elif direction == 'up': caty -= 5 if caty == 10: direction = 'right' DISPLAYSURF.blit(catImg, (catx, caty)) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() pygame.display.update() fpsClock.tick(FPS)
mit
[ 646, 9193, 12, 984, 199, 504, 9193, 14, 9350, 492, 627, 199, 199, 22278, 14, 826, 342, 199, 199, 38, 5067, 275, 4233, 327, 11223, 1126, 3499, 4260, 199, 24709, 17387, 275, 9193, 14, 521, 14, 17387, 342, 199, 199, 3, 663, 1536, 314, 4353, 199, 20993, 51, 1230, 38, 275, 9193, 14, 2918, 14, 409, 63, 632, 1332, 5303, 12, 9601, 395, 378, 12, 4337, 9, 199, 22278, 14, 2918, 14, 409, 63, 13410, 360, 15957, 358, 199, 199, 18817, 275, 334, 2299, 12, 5450, 12, 5450, 9, 199, 3385, 27261, 275, 9193, 14, 1569, 14, 912, 360, 3385, 14, 4524, 358, 199, 3385, 88, 275, 1616, 199, 3385, 89, 275, 1616, 199, 6874, 275, 283, 1019, 7, 199, 199, 6710, 715, 26, 327, 314, 2446, 9219, 4438, 272, 7587, 11625, 51, 1230, 38, 14, 4498, 8, 18817, 9, 339, 340, 7581, 508, 283, 1019, 356, 267, 6230, 88, 847, 959, 267, 340, 6230, 88, 508, 499, 1257, 26, 288, 7581, 275, 283, 2110, 7, 272, 916, 7581, 508, 283, 2110, 356, 267, 6230, 89, 847, 959, 267, 340, 6230, 89, 508, 25647, 26, 288, 7581, 275, 283, 3039, 7, 272, 916, 7581, 508, 283, 3039, 356, 267, 6230, 88, 4862, 959, 267, 340, 6230, 88, 508, 1616, 26, 288, 7581, 275, 283, 384, 7, 272, 916, 7581, 508, 283, 384, 356, 267, 6230, 89, 4862, 959, 267, 340, 6230, 89, 508, 1616, 26, 288, 7581, 275, 283, 1019, 7, 339, 7587, 11625, 51, 1230, 38, 14, 15574, 8, 3385, 27261, 12, 334, 3385, 88, 12, 6230, 89, 430, 339, 367, 1566, 315, 9193, 14, 1430, 14, 362, 837, 267, 340, 1566, 14, 466, 508, 7813, 649, 26, 288, 9193, 14, 10589, 342, 288, 984, 14, 2224, 342, 339, 9193, 14, 2918, 14, 873, 342, 272, 289, 1190, 17387, 14, 8284, 8, 38, 5067, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 9193, 12, 984, 199, 504, 9193, 14, 9350, 492, 627, 199, 199, 22278, 14, 826, 342, 199, 199, 38, 5067, 275, 4233, 327, 11223, 1126, 3499, 4260, 199, 24709, 17387, 275, 9193, 14, 521, 14, 17387, 342, 199, 199, 3, 663, 1536, 314, 4353, 199, 20993, 51, 1230, 38, 275, 9193, 14, 2918, 14, 409, 63, 632, 1332, 5303, 12, 9601, 395, 378, 12, 4337, 9, 199, 22278, 14, 2918, 14, 409, 63, 13410, 360, 15957, 358, 199, 199, 18817, 275, 334, 2299, 12, 5450, 12, 5450, 9, 199, 3385, 27261, 275, 9193, 14, 1569, 14, 912, 360, 3385, 14, 4524, 358, 199, 3385, 88, 275, 1616, 199, 3385, 89, 275, 1616, 199, 6874, 275, 283, 1019, 7, 199, 199, 6710, 715, 26, 327, 314, 2446, 9219, 4438, 272, 7587, 11625, 51, 1230, 38, 14, 4498, 8, 18817, 9, 339, 340, 7581, 508, 283, 1019, 356, 267, 6230, 88, 847, 959, 267, 340, 6230, 88, 508, 499, 1257, 26, 288, 7581, 275, 283, 2110, 7, 272, 916, 7581, 508, 283, 2110, 356, 267, 6230, 89, 847, 959, 267, 340, 6230, 89, 508, 25647, 26, 288, 7581, 275, 283, 3039, 7, 272, 916, 7581, 508, 283, 3039, 356, 267, 6230, 88, 4862, 959, 267, 340, 6230, 88, 508, 1616, 26, 288, 7581, 275, 283, 384, 7, 272, 916, 7581, 508, 283, 384, 356, 267, 6230, 89, 4862, 959, 267, 340, 6230, 89, 508, 1616, 26, 288, 7581, 275, 283, 1019, 7, 339, 7587, 11625, 51, 1230, 38, 14, 15574, 8, 3385, 27261, 12, 334, 3385, 88, 12, 6230, 89, 430, 339, 367, 1566, 315, 9193, 14, 1430, 14, 362, 837, 267, 340, 1566, 14, 466, 508, 7813, 649, 26, 288, 9193, 14, 10589, 342, 288, 984, 14, 2224, 342, 339, 9193, 14, 2918, 14, 873, 342, 272, 289, 1190, 17387, 14, 8284, 8, 38, 5067, 9, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bakhtout/odoo-educ
openerp/modules/graph.py
260
7763
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # Copyright (C) 2010-2014 OpenERP s.a. (<http://openerp.com>). # # 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/>. # ############################################################################## """ Modules dependency graph. """ import os, sys, imp from os.path import join as opj import itertools import zipimport import openerp import openerp.osv as osv import openerp.tools as tools import openerp.tools.osutil as osutil from openerp.tools.safe_eval import safe_eval as eval from openerp.tools.translate import _ import zipfile import openerp.release as release import re import base64 from zipfile import PyZipFile, ZIP_DEFLATED from cStringIO import StringIO import logging _logger = logging.getLogger(__name__) class Graph(dict): """ Modules dependency graph. The graph is a mapping from module name to Nodes. """ def add_node(self, name, info): max_depth, father = 0, None for d in info['depends']: n = self.get(d) or Node(d, self, None) # lazy creation, do not use default value for get() if n.depth >= max_depth: father = n max_depth = n.depth if father: return father.add_child(name, info) else: return Node(name, self, info) def update_from_db(self, cr): if not len(self): return # update the graph with values from the database (if exist) ## First, we set the default values for each package in graph additional_data = dict((key, {'id': 0, 'state': 'uninstalled', 'dbdemo': False, 'installed_version': None}) for key in self.keys()) ## Then we get the values from the database cr.execute('SELECT name, id, state, demo AS dbdemo, latest_version AS installed_version' ' FROM ir_module_module' ' WHERE name IN %s',(tuple(additional_data),) ) ## and we update the default values with values from the database additional_data.update((x['name'], x) for x in cr.dictfetchall()) for package in self.values(): for k, v in additional_data[package.name].items(): setattr(package, k, v) def add_module(self, cr, module, force=None): self.add_modules(cr, [module], force) def add_modules(self, cr, module_list, force=None): if force is None: force = [] packages = [] len_graph = len(self) for module in module_list: # This will raise an exception if no/unreadable descriptor file. # NOTE The call to load_information_from_description_file is already # done by db.initialize, so it is possible to not do it again here. info = openerp.modules.module.load_information_from_description_file(module) if info and info['installable']: packages.append((module, info)) # TODO directly a dict, like in get_modules_with_version else: _logger.warning('module %s: not installable, skipped', module) dependencies = dict([(p, info['depends']) for p, info in packages]) current, later = set([p for p, info in packages]), set() while packages and current > later: package, info = packages[0] deps = info['depends'] # if all dependencies of 'package' are already in the graph, add 'package' in the graph if reduce(lambda x, y: x and y in self, deps, True): if not package in current: packages.pop(0) continue later.clear() current.remove(package) node = self.add_node(package, info) for kind in ('init', 'demo', 'update'): if package in tools.config[kind] or 'all' in tools.config[kind] or kind in force: setattr(node, kind, True) else: later.add(package) packages.append((package, info)) packages.pop(0) self.update_from_db(cr) for package in later: unmet_deps = filter(lambda p: p not in self, dependencies[package]) _logger.error('module %s: Unmet dependencies: %s', package, ', '.join(unmet_deps)) result = len(self) - len_graph if result != len(module_list): _logger.warning('Some modules were not loaded.') return result def __iter__(self): level = 0 done = set(self.keys()) while done: level_modules = sorted((name, module) for name, module in self.items() if module.depth==level) for name, module in level_modules: done.remove(name) yield module level += 1 def __str__(self): return '\n'.join(str(n) for n in self if n.depth == 0) class Node(object): """ One module in the modules dependency graph. Node acts as a per-module singleton. A node is constructed via Graph.add_module() or Graph.add_modules(). Some of its fields are from ir_module_module (setted by Graph.update_from_db()). """ def __new__(cls, name, graph, info): if name in graph: inst = graph[name] else: inst = object.__new__(cls) graph[name] = inst return inst def __init__(self, name, graph, info): self.name = name self.graph = graph self.info = info or getattr(self, 'info', {}) if not hasattr(self, 'children'): self.children = [] if not hasattr(self, 'depth'): self.depth = 0 @property def data(self): return self.info def add_child(self, name, info): node = Node(name, self.graph, info) node.depth = self.depth + 1 if node not in self.children: self.children.append(node) for attr in ('init', 'update', 'demo'): if hasattr(self, attr): setattr(node, attr, True) self.children.sort(lambda x, y: cmp(x.name, y.name)) return node def __setattr__(self, name, value): super(Node, self).__setattr__(name, value) if name in ('init', 'update', 'demo'): tools.config[name][self.name] = 1 for child in self.children: setattr(child, name, value) if name == 'depth': for child in self.children: setattr(child, name, value + 1) def __iter__(self): return itertools.chain(iter(self.children), *map(iter, self.children)) def __str__(self): return self._pprint() def _pprint(self, depth=0): s = '%s\n' % self.name for c in self.children: s += '%s`-> %s' % (' ' * depth, c._pprint(depth+1)) return s # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 259, 1898, 334, 35, 9, 7129, 13, 7280, 7653, 308, 14, 65, 14, 8642, 1014, 921, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 624, 18167, 5936, 3343, 14, 408, 199, 199, 646, 747, 12, 984, 12, 1742, 199, 504, 747, 14, 515, 492, 4263, 465, 1687, 74, 199, 646, 7975, 199, 646, 3482, 646, 199, 199, 646, 5166, 199, 199, 646, 5166, 14, 4795, 465, 9506, 199, 646, 5166, 14, 2537, 465, 7249, 199, 646, 5166, 14, 2537, 14, 736, 1974, 465, 747, 1974, 199, 504, 5166, 14, 2537, 14, 3489, 63, 2579, 492, 5048, 63, 2579, 465, 3468, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 646, 10392, 199, 646, 5166, 14, 3221, 465, 4683, 199, 199, 646, 295, 199, 646, 1300, 772, 199, 504, 10392, 492, 1611, 15016, 12, 18402, 63, 28506, 199, 504, 15073, 492, 5228, 199, 199, 646, 2050, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 11513, 8, 807, 304, 272, 408, 18167, 5936, 3343, 14, 339, 710, 3343, 365, 282, 4412, 687, 859, 536, 370, 23836, 14, 339, 408, 339, 347, 1050, 63, 932, 8, 277, 12, 536, 12, 2256, 304, 267, 1390, 63, 4631, 12, 1433, 728, 275, 378, 12, 488, 267, 367, 366, 315, 2256, 459, 8912, 2565, 288, 302, 275, 291, 14, 362, 8, 68, 9, 503, 5013, 8, 68, 12, 291, 12, 488, 9, 221, 327, 9617, 7143, 12, 886, 440, 675, 849, 574, 367, 664, 342, 288, 340, 302, 14, 4631, 2356, 1390, 63, 4631, 26, 355, 1433, 728, 275, 302, 355, 1390, 63, 4631, 275, 302, 14, 4631, 267, 340, 1433, 728, 26, 288, 372, 1433, 728, 14, 525, 63, 1739, 8, 354, 12, 2256, 9, 267, 587, 26, 288, 372, 5013, 8, 354, 12, 291, 12, 2256, 9, 339, 347, 1678, 63, 504, 63, 697, 8, 277, 12, 2467, 304, 267, 340, 440, 822, 8, 277, 304, 288, 372, 267, 327, 1678, 314, 3343, 543, 1338, 687, 314, 3050, 334, 692, 2187, 9, 267, 925, 7758, 12, 781, 663, 314, 849, 1338, 367, 1924, 2559, 315, 3343, 267, 4722, 63, 576, 275, 1211, 1332, 498, 12, 791, 344, 356, 378, 12, 283, 929, 356, 283, 324, 7657, 297, 283, 697, 8768, 356, 756, 12, 283, 7657, 63, 1023, 356, 488, 1552, 367, 790, 315, 291, 14, 1612, 1012, 267, 925, 9442, 781, 664, 314, 1338, 687, 314, 3050, 267, 2467, 14, 2526, 360, 4859, 536, 12, 1305, 12, 1174, 12, 14779, 4319, 1592, 8768, 12, 8839, 63, 1023, 4319, 4903, 63, 1023, 7, 673, 283, 221, 4442, 8190, 63, 578, 63, 578, 7, 673, 283, 6038, 536, 1621, 450, 83, 297, 8, 2960, 8, 8460, 63, 576, 16945, 673, 776, 398, 925, 436, 781, 1678, 314, 849, 1338, 543, 1338, 687, 314, 3050, 267, 4722, 63, 576, 14, 873, 1332, 88, 459, 354, 995, 671, 9, 367, 671, 315, 2467, 14, 807, 10174, 1012, 398, 367, 2559, 315, 291, 14, 1459, 837, 288, 367, 1022, 12, 373, 315, 4722, 63, 576, 59, 2491, 14, 354, 1055, 1744, 837, 355, 5371, 8, 2491, 12, 1022, 12, 373, 9, 339, 347, 1050, 63, 578, 8, 277, 12, 2467, 12, 859, 12, 3542, 29, 403, 304, 267, 291, 14, 525, 63, 3112, 8, 1556, 12, 359, 578, 467, 3542, 9, 339, 347, 1050, 63, 3112, 8, 277, 12, 2467, 12, 859, 63, 513, 12, 3542, 29, 403, 304, 267, 340, 3542, 365, 488, 26, 288, 3542, 275, 942, 267, 6117, 275, 942, 267, 822, 63, 2180, 275, 822, 8, 277, 9, 267, 367, 859, 315, 859, 63, 513, 26, 288, 327, 961, 911, 746, 376, 1919, 340, 949, 15, 324, 11875, 5872, 570, 14, 288, 327, 6944, 710, 1240, 370, 2248, 63, 11697, 63, 504, 63, 1802, 63, 493, 365, 2575, 288, 327, 4224, 701, 1592, 14, 8489, 12, 880, 652, 365, 3962, 370, 440, 886, 652, 4020, 2348, 14, 288, 2256, 275, 5166, 14, 3112, 14, 578, 14, 912, 63, 11697, 63, 504, 63, 1802, 63, 493, 8, 578, 9, 288, 340, 2256, 436, 2256, 459, 21762, 2565, 355, 6117, 14, 740, 1332, 578, 12, 2256, 430, 327, 3254, 5370, 282, 1211, 12, 2839, 315, 664, 63, 3112, 63, 1045, 63, 1023, 288, 587, 26, 355, 485, 2921, 14, 3764, 360, 578, 450, 83, 26, 440, 3907, 461, 12, 9645, 297, 859, 9, 398, 5124, 275, 1211, 7694, 80, 12, 2256, 459, 8912, 1105, 367, 299, 12, 2256, 315, 6117, 566, 267, 1453, 12, 2945, 275, 663, 779, 80, 367, 299, 12, 2256, 315, 6117, 2522, 663, 342, 398, 1830, 6117, 436, 1453, 690, 2945, 26, 288, 2559, 12, 2256, 275, 6117, 59, 16, 61, 288, 10140, 275, 2256, 459, 8912, 418, 953, 327, 340, 1006, 5124, 402, 283, 2491, 7, 787, 2575, 315, 314, 3343, 12, 1050, 283, 2491, 7, 315, 314, 3343, 288, 340, 7114, 8, 2734, 671, 12, 612, 26, 671, 436 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 259, 1898, 334, 35, 9, 7129, 13, 7280, 7653, 308, 14, 65, 14, 8642, 1014, 921, 11267, 14, 957, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 624, 18167, 5936, 3343, 14, 408, 199, 199, 646, 747, 12, 984, 12, 1742, 199, 504, 747, 14, 515, 492, 4263, 465, 1687, 74, 199, 646, 7975, 199, 646, 3482, 646, 199, 199, 646, 5166, 199, 199, 646, 5166, 14, 4795, 465, 9506, 199, 646, 5166, 14, 2537, 465, 7249, 199, 646, 5166, 14, 2537, 14, 736, 1974, 465, 747, 1974, 199, 504, 5166, 14, 2537, 14, 3489, 63, 2579, 492, 5048, 63, 2579, 465, 3468, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 646, 10392, 199, 646, 5166, 14, 3221, 465, 4683, 199, 199, 646, 295, 199, 646, 1300, 772, 199, 504, 10392, 492, 1611, 15016, 12, 18402, 63, 28506, 199, 504, 15073, 492, 5228, 199, 199, 646, 2050, 199, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 11513, 8, 807, 304, 272, 408, 18167, 5936, 3343, 14, 339, 710, 3343, 365, 282, 4412, 687, 859, 536, 370, 23836, 14, 339, 408, 339, 347, 1050, 63, 932, 8, 277, 12, 536, 12, 2256, 304, 267, 1390, 63, 4631, 12, 1433, 728, 275, 378, 12, 488, 267, 367, 366, 315, 2256, 459, 8912, 2565, 288, 302, 275, 291, 14, 362, 8, 68, 9, 503, 5013, 8, 68, 12, 291, 12, 488, 9, 221, 327, 9617, 7143, 12, 886, 440, 675, 849, 574, 367, 664, 342, 288, 340, 302, 14, 4631, 2356, 1390, 63, 4631, 26, 355, 1433, 728, 275, 302, 355, 1390, 63, 4631, 275, 302, 14, 4631, 267, 340, 1433, 728, 26, 288, 372, 1433, 728, 14, 525, 63, 1739, 8, 354, 12, 2256, 9, 267, 587, 26, 288, 372, 5013, 8, 354, 12, 291, 12, 2256, 9, 339, 347, 1678, 63, 504, 63, 697, 8, 277, 12, 2467, 304, 267, 340, 440, 822, 8, 277, 304, 288, 372, 267, 327, 1678, 314, 3343, 543, 1338, 687, 314, 3050, 334, 692, 2187, 9, 267, 925, 7758, 12, 781, 663, 314, 849, 1338, 367, 1924, 2559, 315, 3343, 267, 4722, 63, 576, 275, 1211, 1332, 498, 12, 791, 344, 356, 378, 12, 283, 929, 356, 283, 324, 7657, 297, 283, 697, 8768, 356, 756, 12, 283, 7657, 63, 1023, 356, 488, 1552, 367, 790, 315, 291, 14, 1612, 1012, 267, 925, 9442, 781, 664, 314, 1338, 687, 314, 3050, 267, 2467, 14, 2526, 360, 4859, 536, 12, 1305, 12, 1174, 12, 14779, 4319, 1592, 8768, 12, 8839, 63, 1023, 4319, 4903, 63, 1023, 7, 673, 283, 221, 4442, 8190, 63, 578, 63, 578, 7, 673, 283, 6038, 536, 1621, 450, 83, 297, 8, 2960, 8, 8460, 63, 576, 16945, 673, 776, 398, 925, 436, 781, 1678, 314, 849, 1338, 543, 1338, 687, 314, 3050, 267, 4722, 63, 576, 14, 873, 1332, 88, 459, 354, 995, 671, 9, 367, 671, 315, 2467, 14, 807, 10174, 1012, 398, 367, 2559, 315, 291, 14, 1459, 837, 288, 367, 1022, 12, 373, 315, 4722, 63, 576, 59, 2491, 14, 354, 1055, 1744, 837, 355, 5371, 8, 2491, 12, 1022, 12, 373, 9, 339, 347, 1050, 63, 578, 8, 277, 12, 2467, 12, 859, 12, 3542, 29, 403, 304, 267, 291, 14, 525, 63, 3112, 8, 1556, 12, 359, 578, 467, 3542, 9, 339, 347, 1050, 63, 3112, 8, 277, 12, 2467, 12, 859, 63, 513, 12, 3542, 29, 403, 304, 267, 340, 3542, 365, 488, 26, 288, 3542, 275, 942, 267, 6117, 275, 942, 267, 822, 63, 2180, 275, 822, 8, 277, 9, 267, 367, 859, 315, 859, 63, 513, 26, 288, 327, 961, 911, 746, 376, 1919, 340, 949, 15, 324, 11875, 5872, 570, 14, 288, 327, 6944, 710, 1240, 370, 2248, 63, 11697, 63, 504, 63, 1802, 63, 493, 365, 2575, 288, 327, 4224, 701, 1592, 14, 8489, 12, 880, 652, 365, 3962, 370, 440, 886, 652, 4020, 2348, 14, 288, 2256, 275, 5166, 14, 3112, 14, 578, 14, 912, 63, 11697, 63, 504, 63, 1802, 63, 493, 8, 578, 9, 288, 340, 2256, 436, 2256, 459, 21762, 2565, 355, 6117, 14, 740, 1332, 578, 12, 2256, 430, 327, 3254, 5370, 282, 1211, 12, 2839, 315, 664, 63, 3112, 63, 1045, 63, 1023, 288, 587, 26, 355, 485, 2921, 14, 3764, 360, 578, 450, 83, 26, 440, 3907, 461, 12, 9645, 297, 859, 9, 398, 5124, 275, 1211, 7694, 80, 12, 2256, 459, 8912, 1105, 367, 299, 12, 2256, 315, 6117, 566, 267, 1453, 12, 2945, 275, 663, 779, 80, 367, 299, 12, 2256, 315, 6117, 2522, 663, 342, 398, 1830, 6117, 436, 1453, 690, 2945, 26, 288, 2559, 12, 2256, 275, 6117, 59, 16, 61, 288, 10140, 275, 2256, 459, 8912, 418, 953, 327, 340, 1006, 5124, 402, 283, 2491, 7, 787, 2575, 315, 314, 3343, 12, 1050, 283, 2491, 7, 315, 314, 3343, 288, 340, 7114, 8, 2734, 671, 12, 612, 26, 671, 436, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
0x0mar/phpsploit
deps/SocksiPy-branch-1.02/socks.py
65
16177
"""SocksiPy - Python SOCKS module. Version 1.00 Copyright 2006 Dan-Haim. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of Dan Haim nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY DAN HAIM "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 DAN HAIM OR HIS 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, 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 DAMANGE. This module provides a standard socket-like interface for Python for tunneling connections through SOCKS proxies. """ """ Minor modifications made by Christopher Gilbert (http://motomastyle.com/) for use in PyLoris (http://pyloris.sourceforge.net/) Minor modifications made by Mario Vilas (http://breakingcode.wordpress.com/) mainly to merge bug fixes found in Sourceforge """ import socket import struct import sys PROXY_TYPE_SOCKS4 = 1 PROXY_TYPE_SOCKS5 = 2 PROXY_TYPE_HTTP = 3 _defaultproxy = None _orgsocket = socket.socket class ProxyError(Exception): pass class GeneralProxyError(ProxyError): pass class Socks5AuthError(ProxyError): pass class Socks5Error(ProxyError): pass class Socks4Error(ProxyError): pass class HTTPError(ProxyError): pass _generalerrors = ("success", "invalid data", "not connected", "not available", "bad proxy type", "bad input") _socks5errors = ("succeeded", "general SOCKS server failure", "connection not allowed by ruleset", "Network unreachable", "Host unreachable", "Connection refused", "TTL expired", "Command not supported", "Address type not supported", "Unknown error") _socks5autherrors = ("succeeded", "authentication is required", "all offered authentication methods were rejected", "unknown username or invalid password", "unknown error") _socks4errors = ("request granted", "request rejected or failed", "request rejected because SOCKS server cannot connect to identd on the client", "request rejected because the client program and identd report different user-ids", "unknown error") def setdefaultproxy(proxytype=None, addr=None, port=None, rdns=True, username=None, password=None): """setdefaultproxy(proxytype, addr[, port[, rdns[, username[, password]]]]) Sets a default proxy which all further socksocket objects will use, unless explicitly changed. """ global _defaultproxy _defaultproxy = (proxytype, addr, port, rdns, username, password) def wrapmodule(module): """wrapmodule(module) Attempts to replace a module's socket library with a SOCKS socket. Must set a default proxy using setdefaultproxy(...) first. This will only work on modules that import socket directly into the namespace; most of the Python Standard Library falls into this category. """ if _defaultproxy != None: module.socket.socket = socksocket else: raise GeneralProxyError((4, "no proxy specified")) class socksocket(socket.socket): """socksocket([family[, type[, proto]]]) -> socket object Open a SOCKS enabled socket. The parameters are the same as those of the standard socket init. In order for SOCKS to work, you must specify family=AF_INET, type=SOCK_STREAM and proto=0. """ def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None): _orgsocket.__init__(self, family, type, proto, _sock) if _defaultproxy != None: self.__proxy = _defaultproxy else: self.__proxy = (None, None, None, None, None, None) self.__proxysockname = None self.__proxypeername = None def __recvall(self, count): """__recvall(count) -> data Receive EXACTLY the number of bytes requested from the socket. Blocks until the required number of bytes have been received. """ data = self.recv(count) while len(data) < count: d = self.recv(count-len(data)) if not d: raise GeneralProxyError((0, "connection closed unexpectedly")) data = data + d return data def setproxy(self, proxytype=None, addr=None, port=None, rdns=True, username=None, password=None): """setproxy(proxytype, addr[, port[, rdns[, username[, password]]]]) Sets the proxy to be used. proxytype - The type of the proxy to be used. Three types are supported: PROXY_TYPE_SOCKS4 (including socks4a), PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP addr - The address of the server (IP or DNS). port - The port of the server. Defaults to 1080 for SOCKS servers and 8080 for HTTP proxy servers. rdns - Should DNS queries be preformed on the remote side (rather than the local side). The default is True. Note: This has no effect with SOCKS4 servers. username - Username to authenticate with to the server. The default is no authentication. password - Password to authenticate with to the server. Only relevant when username is also provided. """ self.__proxy = (proxytype, addr, port, rdns, username, password) def __negotiatesocks5(self, destaddr, destport): """__negotiatesocks5(self,destaddr,destport) Negotiates a connection through a SOCKS5 server. """ # First we'll send the authentication packages we support. if (self.__proxy[4]!=None) and (self.__proxy[5]!=None): # The username/password details were supplied to the # setproxy method so we support the USERNAME/PASSWORD # authentication (in addition to the standard none). self.sendall(struct.pack('BBBB', 0x05, 0x02, 0x00, 0x02)) else: # No username/password were entered, therefore we # only support connections with no authentication. self.sendall(struct.pack('BBB', 0x05, 0x01, 0x00)) # We'll receive the server's response to determine which # method was selected chosenauth = self.__recvall(2) if chosenauth[0:1] != chr(0x05).encode(): self.close() raise GeneralProxyError((1, _generalerrors[1])) # Check the chosen authentication method if chosenauth[1:2] == chr(0x00).encode(): # No authentication is required pass elif chosenauth[1:2] == chr(0x02).encode(): # Okay, we need to perform a basic username/password # authentication. self.sendall(chr(0x01).encode() + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5]) authstat = self.__recvall(2) if authstat[0:1] != chr(0x01).encode(): # Bad response self.close() raise GeneralProxyError((1, _generalerrors[1])) if authstat[1:2] != chr(0x00).encode(): # Authentication failed self.close() raise Socks5AuthError((3, _socks5autherrors[3])) # Authentication succeeded else: # Reaching here is always bad self.close() if chosenauth[1] == chr(0xFF).encode(): raise Socks5AuthError((2, _socks5autherrors[2])) else: raise GeneralProxyError((1, _generalerrors[1])) # Now we can request the actual connection req = struct.pack('BBB', 0x05, 0x01, 0x00) # If the given destination address is an IP address, we'll # use the IPv4 address request even if remote resolving was specified. try: ipaddr = socket.inet_aton(destaddr) req = req + chr(0x01).encode() + ipaddr except socket.error: # Well it's not an IP number, so it's probably a DNS name. if self.__proxy[3]: # Resolve remotely ipaddr = None req = req + chr(0x03).encode() + chr(len(destaddr)).encode() + destaddr else: # Resolve locally ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) req = req + chr(0x01).encode() + ipaddr req = req + struct.pack(">H", destport) self.sendall(req) # Get the response resp = self.__recvall(4) if resp[0:1] != chr(0x05).encode(): self.close() raise GeneralProxyError((1, _generalerrors[1])) elif resp[1:2] != chr(0x00).encode(): # Connection failed self.close() if ord(resp[1:2])<=8: raise Socks5Error((ord(resp[1:2]), _socks5errors[ord(resp[1:2])])) else: raise Socks5Error((9, _socks5errors[9])) # Get the bound address/port elif resp[3:4] == chr(0x01).encode(): boundaddr = self.__recvall(4) elif resp[3:4] == chr(0x03).encode(): resp = resp + self.recv(1) boundaddr = self.__recvall(ord(resp[4:5])) else: self.close() raise GeneralProxyError((1,_generalerrors[1])) boundport = struct.unpack(">H", self.__recvall(2))[0] self.__proxysockname = (boundaddr, boundport) if ipaddr != None: self.__proxypeername = (socket.inet_ntoa(ipaddr), destport) else: self.__proxypeername = (destaddr, destport) def getproxysockname(self): """getsockname() -> address info Returns the bound IP address and port number at the proxy. """ return self.__proxysockname def getproxypeername(self): """getproxypeername() -> address info Returns the IP and port number of the proxy. """ return _orgsocket.getpeername(self) def getpeername(self): """getpeername() -> address info Returns the IP address and port number of the destination machine (note: getproxypeername returns the proxy) """ return self.__proxypeername def __negotiatesocks4(self,destaddr,destport): """__negotiatesocks4(self,destaddr,destport) Negotiates a connection through a SOCKS4 server. """ # Check if the destination address provided is an IP address rmtrslv = False try: ipaddr = socket.inet_aton(destaddr) except socket.error: # It's a DNS name. Check where it should be resolved. if self.__proxy[3]: ipaddr = struct.pack("BBBB", 0x00, 0x00, 0x00, 0x01) rmtrslv = True else: ipaddr = socket.inet_aton(socket.gethostbyname(destaddr)) # Construct the request packet req = struct.pack(">BBH", 0x04, 0x01, destport) + ipaddr # The username parameter is considered userid for SOCKS4 if self.__proxy[4] != None: req = req + self.__proxy[4] req = req + chr(0x00).encode() # DNS name if remote resolving is required # NOTE: This is actually an extension to the SOCKS4 protocol # called SOCKS4A and may not be supported in all cases. if rmtrslv: req = req + destaddr + chr(0x00).encode() self.sendall(req) # Get the response from the server resp = self.__recvall(8) if resp[0:1] != chr(0x00).encode(): # Bad data self.close() raise GeneralProxyError((1,_generalerrors[1])) if resp[1:2] != chr(0x5A).encode(): # Server returned an error self.close() if ord(resp[1:2]) in (91, 92, 93): self.close() raise Socks4Error((ord(resp[1:2]), _socks4errors[ord(resp[1:2]) - 90])) else: raise Socks4Error((94, _socks4errors[4])) # Get the bound address/port self.__proxysockname = (socket.inet_ntoa(resp[4:]), struct.unpack(">H", resp[2:4])[0]) if rmtrslv != None: self.__proxypeername = (socket.inet_ntoa(ipaddr), destport) else: self.__proxypeername = (destaddr, destport) def __negotiatehttp(self, destaddr, destport): """__negotiatehttp(self,destaddr,destport) Negotiates a connection through an HTTP server. """ # If we need to resolve locally, we do this now if not self.__proxy[3]: addr = socket.gethostbyname(destaddr) else: addr = destaddr self.sendall(("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n").encode()) # We read the response until we get the string "\r\n\r\n" resp = self.recv(1) while resp.find("\r\n\r\n".encode()) == -1: resp = resp + self.recv(1) # We just need the first line to check if the connection # was successful statusline = resp.splitlines()[0].split(" ".encode(), 2) if statusline[0] not in ("HTTP/1.0".encode(), "HTTP/1.1".encode()): self.close() raise GeneralProxyError((1, _generalerrors[1])) try: statuscode = int(statusline[1]) except ValueError: self.close() raise GeneralProxyError((1, _generalerrors[1])) if statuscode != 200: self.close() raise HTTPError((statuscode, statusline[2])) self.__proxysockname = ("0.0.0.0", 0) self.__proxypeername = (addr, destport) def connect(self, destpair): """connect(self, despair) Connects to the specified destination through a proxy. destpar - A tuple of the IP/DNS address and the port number. (identical to socket's connect). To select the proxy server use setproxy(). """ # Do a minimal input check first if (not type(destpair) in (list,tuple)) or (len(destpair) < 2) or (type(destpair[0]) != type('')) or (type(destpair[1]) != int): raise GeneralProxyError((5, _generalerrors[5])) if self.__proxy[0] == PROXY_TYPE_SOCKS5: if self.__proxy[2] != None: portnum = self.__proxy[2] else: portnum = 1080 _orgsocket.connect(self, (self.__proxy[1], portnum)) self.__negotiatesocks5(destpair[0], destpair[1]) elif self.__proxy[0] == PROXY_TYPE_SOCKS4: if self.__proxy[2] != None: portnum = self.__proxy[2] else: portnum = 1080 _orgsocket.connect(self,(self.__proxy[1], portnum)) self.__negotiatesocks4(destpair[0], destpair[1]) elif self.__proxy[0] == PROXY_TYPE_HTTP: if self.__proxy[2] != None: portnum = self.__proxy[2] else: portnum = 8080 _orgsocket.connect(self,(self.__proxy[1], portnum)) self.__negotiatehttp(destpair[0], destpair[1]) elif self.__proxy[0] == None: _orgsocket.connect(self, (destpair[0], destpair[1])) else: raise GeneralProxyError((4, _generalerrors[4]))
gpl-3.0
[ 624, 51, 766, 338, 2713, 446, 2018, 26327, 51, 859, 14, 199, 3353, 413, 14, 383, 199, 199, 7384, 8315, 24747, 13, 15739, 1017, 14, 2900, 4481, 4644, 14, 199, 199, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 199, 1530, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 17, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 2043, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 18, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 2043, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 2043, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 19, 14, 11443, 314, 536, 402, 24747, 869, 65, 1017, 6590, 314, 1561, 402, 17049, 8417, 1443, 506, 1202, 2043, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 2043, 6791, 5313, 4983, 14, 272, 199, 24571, 4141, 2281, 7049, 6515, 577, 879, 16100, 1469, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 199, 55, 2007, 2563, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 199, 31461, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 199, 8193, 7000, 577, 879, 16100, 1469, 1549, 869, 1311, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 25205, 9678, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 13387, 1149, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 199, 726, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 2673, 2477, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 199, 3359, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 5179, 9011, 14, 421, 199, 2765, 859, 6571, 282, 4465, 2838, 13, 2930, 3217, 367, 2018, 199, 509, 21496, 316, 6947, 4012, 26327, 51, 14942, 14, 199, 199, 624, 199, 199, 624, 199, 199, 23094, 23070, 6326, 701, 2799, 322, 2379, 2523, 598, 382, 12504, 334, 1014, 921, 77, 3459, 391, 2487, 14, 957, 24793, 199, 509, 675, 315, 1611, 44, 269, 374, 334, 1014, 921, 647, 25339, 374, 14, 22943, 14, 846, 24793, 199, 199, 23094, 23070, 6326, 701, 603, 6936, 812, 382, 305, 334, 1014, 921, 4785, 316, 600, 14, 1027, 2915, 14, 957, 24793, 199, 973, 590, 370, 5389, 6519, 25079, 1911, 315, 5800, 16677, 199, 199, 624, 199, 199, 646, 2838, 199, 646, 2702, 199, 646, 984, 199, 199, 20026, 63, 2711, 63, 9469, 51, 20, 275, 413, 199, 20026, 63, 2711, 63, 9469, 51, 21, 275, 499, 199, 20026, 63, 2711, 63, 2856, 275, 650, 199, 199, 63, 885, 3280, 275, 488, 199, 63, 30146, 1539, 275, 2838, 14, 3450, 199, 199, 533, 12373, 547, 8, 1726, 304, 986, 199, 533, 1696, 4936, 547, 8, 4936, 547, 304, 986, 199, 533, 428, 27416, 21, 2817, 547, 8, 4936, 547, 304, 986, 199, 533, 428, 27416, 21, 547, 8, 4936, 547, 304, 986, 199, 533, 428, 27416, 20, 547, 8, 4936, 547, 304, 986, 199, 533, 15050, 8, 4936, 547, 304, 986, 199, 199, 63, 2038, 29706, 451, 83, 275, 1689, 3742, 401, 272, 298, 3197, 666, 401, 272, 298, 1397, 8539, 401, 272, 298, 1397, 2808, 401, 272, 298, 4087, 4566, 730, 401, 272, 298, 4087, 1324, 531, 199, 199, 63, 21234, 21, 2550, 275, 1689, 20003, 401, 272, 298, 10706, 26327, 51, 1654, 5988, 401, 272, 298, 2105, 440, 4370, 701, 2332, 409, 401, 272, 298, 4491, 625, 15837, 401, 272, 298, 4965, 625, 15837, 401, 272, 298, 3225, 2984, 2972, 401, 272, 298, 25567, 14721, 401, 272, 298, 3110, 440, 3748, 401, 272, 298, 1476, 730, 440, 3748, 401, 272, 298, 5912, 1125, 531, 199, 199, 63, 21234, 21, 1178, 2550, 275, 1689, 20003, 401, 272, 298, 11725, 365, 1415, 401, 272, 298, 452, 402, 22941, 6299, 3102, 4898, 18935, 401, 272, 298, 5187, 3434, 503, 3866, 2505, 401, 272, 298, 5187, 1125, 531, 199, 199, 63, 21234, 20, 2550, 275, 1689, 1069, 10009, 401, 272, 298, 1069, 18935, 503, 3405, 401, 272, 298, 1069, 18935, 2952, 26327, 51, 1654, 3913, 4907, 370, 12893, 68, 641, 314, 1890, 401, 272, 298, 1069, 18935, 2952, 314, 1890, 2240, 436, 12893, 68, 3622, 3365, 922, 13, 1580, 401, 272, 298, 5187, 1125, 531, 199, 199, 318, 29408, 3280, 8, 3280, 466, 29, 403, 12, 5552, 29, 403, 12, 1844, 29, 403, 12, 519, 5797, 29, 549, 12, 3434, 29, 403, 12, 2505, 29, 403, 304, 272, 408, 5486, 3280, 8, 3280, 466, 12, 5552, 14675, 1844, 14675, 519, 5797, 14675, 3434, 14675, 2505, 2677, 3934, 272, 10729, 282, 849, 4566, 1314, 1006, 9848, 6771, 3450, 2251, 911, 675, 12, 272, 7444, 7662, 2896, 14, 272, 408, 272, 2288, 485, 885, 3280, 272, 485, 885, 3280, 275, 334, 3280, 466, 12, 5552, 12, 1844, 12, 519, 5797, 12, 3434, 12, 2505, 9, 199, 199, 318, 4816, 578, 8, 578, 304, 272, 408, 3823, 578, 8, 578, 9, 272, 17413, 1086, 370, 3350, 282, 859, 1159, 2838, 3555, 543, 282, 26327, 51, 2838, 14, 9498, 663, 272, 282, 849, 4566, 1808, 29408, 3280, 20186, 1642, 14, 272, 961, 911, 1454, 1736, 641, 4621, 626, 492, 2838, 5370, 1901, 314, 3231, 27, 272, 4750, 402, 314, 2018, 9739, 11243, 26945, 1901, 642, 4637, 14, 272, 408, 272, 340, 485, 885, 3280, 1137, 488, 26, 267, 859, 14, 3450, 14, 3450, 275, 6771, 3450, 272, 587, 26, 267, 746, 1696, 4936, 547, 1332, 20, 12, 298, 889, 4566, 2013, 2237, 199, 199, 533, 6771, 3450, 8, 3450, 14, 3450, 304, 272, 408, 5096, 3450, 779, 6606, 14675, 730, 14675, 4104, 25724, 1035, 2838, 909, 272, 3232, 282, 26327, 51, 5223, 2838, 14, 710, 2633, 787, 314, 2011, 465, 272, 5204, 402, 314, 4465, 2838, 4205, 14, 1010, 1865, 367, 26327, 51, 370, 1736, 12, 272, 1265, 1471, 4165, 9614, 29, 5699, 63, 11367, 12, 730, 29, 9469, 63, 9484, 436, 4104, 29, 16, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 9614, 29, 3450, 14, 5699, 63 ]
[ 51, 766, 338, 2713, 446, 2018, 26327, 51, 859, 14, 199, 3353, 413, 14, 383, 199, 199, 7384, 8315, 24747, 13, 15739, 1017, 14, 2900, 4481, 4644, 14, 199, 199, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 199, 1530, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 17, 14, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 642, 2043, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 18, 14, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 2043, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 2043, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 19, 14, 11443, 314, 536, 402, 24747, 869, 65, 1017, 6590, 314, 1561, 402, 17049, 8417, 1443, 506, 1202, 2043, 370, 10692, 503, 10016, 7585, 7131, 687, 642, 2032, 1928, 2488, 2043, 6791, 5313, 4983, 14, 272, 199, 24571, 4141, 2281, 7049, 6515, 577, 879, 16100, 1469, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 199, 55, 2007, 2563, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 2990, 1634, 199, 31461, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 199, 8193, 7000, 577, 879, 16100, 1469, 1549, 869, 1311, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 25205, 9678, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 13387, 1149, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 199, 726, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 199, 2673, 2477, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 199, 3359, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 5179, 9011, 14, 421, 199, 2765, 859, 6571, 282, 4465, 2838, 13, 2930, 3217, 367, 2018, 199, 509, 21496, 316, 6947, 4012, 26327, 51, 14942, 14, 199, 199, 624, 199, 199, 624, 199, 199, 23094, 23070, 6326, 701, 2799, 322, 2379, 2523, 598, 382, 12504, 334, 1014, 921, 77, 3459, 391, 2487, 14, 957, 24793, 199, 509, 675, 315, 1611, 44, 269, 374, 334, 1014, 921, 647, 25339, 374, 14, 22943, 14, 846, 24793, 199, 199, 23094, 23070, 6326, 701, 603, 6936, 812, 382, 305, 334, 1014, 921, 4785, 316, 600, 14, 1027, 2915, 14, 957, 24793, 199, 973, 590, 370, 5389, 6519, 25079, 1911, 315, 5800, 16677, 199, 199, 624, 199, 199, 646, 2838, 199, 646, 2702, 199, 646, 984, 199, 199, 20026, 63, 2711, 63, 9469, 51, 20, 275, 413, 199, 20026, 63, 2711, 63, 9469, 51, 21, 275, 499, 199, 20026, 63, 2711, 63, 2856, 275, 650, 199, 199, 63, 885, 3280, 275, 488, 199, 63, 30146, 1539, 275, 2838, 14, 3450, 199, 199, 533, 12373, 547, 8, 1726, 304, 986, 199, 533, 1696, 4936, 547, 8, 4936, 547, 304, 986, 199, 533, 428, 27416, 21, 2817, 547, 8, 4936, 547, 304, 986, 199, 533, 428, 27416, 21, 547, 8, 4936, 547, 304, 986, 199, 533, 428, 27416, 20, 547, 8, 4936, 547, 304, 986, 199, 533, 15050, 8, 4936, 547, 304, 986, 199, 199, 63, 2038, 29706, 451, 83, 275, 1689, 3742, 401, 272, 298, 3197, 666, 401, 272, 298, 1397, 8539, 401, 272, 298, 1397, 2808, 401, 272, 298, 4087, 4566, 730, 401, 272, 298, 4087, 1324, 531, 199, 199, 63, 21234, 21, 2550, 275, 1689, 20003, 401, 272, 298, 10706, 26327, 51, 1654, 5988, 401, 272, 298, 2105, 440, 4370, 701, 2332, 409, 401, 272, 298, 4491, 625, 15837, 401, 272, 298, 4965, 625, 15837, 401, 272, 298, 3225, 2984, 2972, 401, 272, 298, 25567, 14721, 401, 272, 298, 3110, 440, 3748, 401, 272, 298, 1476, 730, 440, 3748, 401, 272, 298, 5912, 1125, 531, 199, 199, 63, 21234, 21, 1178, 2550, 275, 1689, 20003, 401, 272, 298, 11725, 365, 1415, 401, 272, 298, 452, 402, 22941, 6299, 3102, 4898, 18935, 401, 272, 298, 5187, 3434, 503, 3866, 2505, 401, 272, 298, 5187, 1125, 531, 199, 199, 63, 21234, 20, 2550, 275, 1689, 1069, 10009, 401, 272, 298, 1069, 18935, 503, 3405, 401, 272, 298, 1069, 18935, 2952, 26327, 51, 1654, 3913, 4907, 370, 12893, 68, 641, 314, 1890, 401, 272, 298, 1069, 18935, 2952, 314, 1890, 2240, 436, 12893, 68, 3622, 3365, 922, 13, 1580, 401, 272, 298, 5187, 1125, 531, 199, 199, 318, 29408, 3280, 8, 3280, 466, 29, 403, 12, 5552, 29, 403, 12, 1844, 29, 403, 12, 519, 5797, 29, 549, 12, 3434, 29, 403, 12, 2505, 29, 403, 304, 272, 408, 5486, 3280, 8, 3280, 466, 12, 5552, 14675, 1844, 14675, 519, 5797, 14675, 3434, 14675, 2505, 2677, 3934, 272, 10729, 282, 849, 4566, 1314, 1006, 9848, 6771, 3450, 2251, 911, 675, 12, 272, 7444, 7662, 2896, 14, 272, 408, 272, 2288, 485, 885, 3280, 272, 485, 885, 3280, 275, 334, 3280, 466, 12, 5552, 12, 1844, 12, 519, 5797, 12, 3434, 12, 2505, 9, 199, 199, 318, 4816, 578, 8, 578, 304, 272, 408, 3823, 578, 8, 578, 9, 272, 17413, 1086, 370, 3350, 282, 859, 1159, 2838, 3555, 543, 282, 26327, 51, 2838, 14, 9498, 663, 272, 282, 849, 4566, 1808, 29408, 3280, 20186, 1642, 14, 272, 961, 911, 1454, 1736, 641, 4621, 626, 492, 2838, 5370, 1901, 314, 3231, 27, 272, 4750, 402, 314, 2018, 9739, 11243, 26945, 1901, 642, 4637, 14, 272, 408, 272, 340, 485, 885, 3280, 1137, 488, 26, 267, 859, 14, 3450, 14, 3450, 275, 6771, 3450, 272, 587, 26, 267, 746, 1696, 4936, 547, 1332, 20, 12, 298, 889, 4566, 2013, 2237, 199, 199, 533, 6771, 3450, 8, 3450, 14, 3450, 304, 272, 408, 5096, 3450, 779, 6606, 14675, 730, 14675, 4104, 25724, 1035, 2838, 909, 272, 3232, 282, 26327, 51, 5223, 2838, 14, 710, 2633, 787, 314, 2011, 465, 272, 5204, 402, 314, 4465, 2838, 4205, 14, 1010, 1865, 367, 26327, 51, 370, 1736, 12, 272, 1265, 1471, 4165, 9614, 29, 5699, 63, 11367, 12, 730, 29, 9469, 63, 9484, 436, 4104, 29, 16, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 9614, 29, 3450, 14, 5699, 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,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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 ]
amith01994/intellij-community
python/testData/inspections/PyCompatibilityInspection/argumentsUnpackingGeneralizations.py
33
1128
def foo(*args, **kwargs): print(args, kwargs) foo(0, *[1], <warning descr="Python versions < 3.5 do not allow positional arguments after *expression">2</warning>, <warning descr="Python versions < 3.5 do not allow duplicate *expressions">*[3]</warning>, <warning descr="Python versions < 3.5 do not allow positional arguments after *expression">4</warning>, <warning descr="Python versions < 2.6 do not allow keyword arguments after *expression">a='a'</warning>, <warning descr="Python versions < 3.5 do not allow duplicate *expressions">*[6]</warning>, <warning descr="Python versions < 2.6 do not allow keyword arguments after *expression">b='b'</warning>, <warning descr="Python versions < 3.5 do not allow duplicate *expressions">*[7]</warning>, <warning descr="Python versions < 2.6 do not allow keyword arguments after *expression">c='c'</warning>, **{'d': 'd'}, <warning descr="Python versions < 2.6 do not allow keyword arguments after *expression">e='e'</warning>, <warning descr="Python versions < 3.5 do not allow duplicate **expressions">**{'f': 'f'}</warning>)
apache-2.0
[ 318, 3925, 2031, 589, 12, 1011, 958, 304, 272, 870, 8, 589, 12, 2074, 9, 421, 199, 1421, 8, 16, 12, 272, 627, 59, 17, 467, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 11333, 2368, 2410, 627, 5599, 1743, 18, 1108, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 9250, 627, 15264, 1743, 23033, 19, 61, 1108, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 11333, 2368, 2410, 627, 5599, 1743, 20, 1108, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 499, 14, 22, 886, 440, 2040, 4252, 2368, 2410, 627, 5599, 1743, 65, 534, 65, 29477, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 9250, 627, 15264, 1743, 23033, 22, 61, 1108, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 499, 14, 22, 886, 440, 2040, 4252, 2368, 2410, 627, 5599, 1743, 66, 534, 66, 29477, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 9250, 627, 15264, 1743, 23033, 23, 61, 1108, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 499, 14, 22, 886, 440, 2040, 4252, 2368, 2410, 627, 5599, 1743, 67, 534, 67, 29477, 3764, 6244, 272, 30653, 68, 356, 283, 68, 2267, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 499, 14, 22, 886, 440, 2040, 4252, 2368, 2410, 627, 5599, 1743, 69, 534, 69, 29477, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 9250, 1011, 15264, 1743, 538, 1445, 70, 356, 283, 70, 936, 1108, 3764, 18956, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 3925, 2031, 589, 12, 1011, 958, 304, 272, 870, 8, 589, 12, 2074, 9, 421, 199, 1421, 8, 16, 12, 272, 627, 59, 17, 467, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 11333, 2368, 2410, 627, 5599, 1743, 18, 1108, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 9250, 627, 15264, 1743, 23033, 19, 61, 1108, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 11333, 2368, 2410, 627, 5599, 1743, 20, 1108, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 499, 14, 22, 886, 440, 2040, 4252, 2368, 2410, 627, 5599, 1743, 65, 534, 65, 29477, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 9250, 627, 15264, 1743, 23033, 22, 61, 1108, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 499, 14, 22, 886, 440, 2040, 4252, 2368, 2410, 627, 5599, 1743, 66, 534, 66, 29477, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 9250, 627, 15264, 1743, 23033, 23, 61, 1108, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 499, 14, 22, 886, 440, 2040, 4252, 2368, 2410, 627, 5599, 1743, 67, 534, 67, 29477, 3764, 6244, 272, 30653, 68, 356, 283, 68, 2267, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 499, 14, 22, 886, 440, 2040, 4252, 2368, 2410, 627, 5599, 1743, 69, 534, 69, 29477, 3764, 6244, 272, 665, 3764, 16193, 628, 4718, 5459, 665, 650, 14, 21, 886, 440, 2040, 9250, 1011, 15264, 1743, 538, 1445, 70, 356, 283, 70, 936, 1108, 3764, 18956, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
opcode0x90/pyew
vstruct/defs/windows/win_6_1_i386/win32k.py
18
198521
# Version: 6.1 # Architecture: i386 import vstruct from vstruct.primitives import * ETW_THREAD_FLAG = v_enum() ETW_THREAD_FLAG.ETW_THREAD_FLAG_HAD_INPUT = 0 ETW_THREAD_FLAG.ETW_THREAD_FLAG_HAD_VISIBLE_WINDOWS = 1 ETW_THREAD_FLAG.ETW_THREAD_FLAG_HAS_NEW_INPUT = 2 ETW_THREAD_FLAG.ETW_THREAD_FLAG_MAX = 3 TOUCHSTATE = v_enum() TOUCHSTATE.TOUCHSTATE_INVALID = -1 TOUCHSTATE.TOUCHSTATE_NONE = 0 TOUCHSTATE.TOUCHSTATE_DOWN = 1 TOUCHSTATE.TOUCHSTATE_MOVE = 2 TOUCHSTATE.TOUCHSTATE_UPOUTOFRANGE = 3 TOUCHSTATE.TOUCHSTATE_INAIR = 4 TOUCHSTATE.TOUCHSTATE_INAIRMOVE = 5 TOUCHSTATE.TOUCHSTATE_INAIROUTOFRANGE = 6 TOUCHSTATE.TOUCHSTATE_COUNT = 7 WHEA_ERROR_SEVERITY = v_enum() WHEA_ERROR_SEVERITY.WheaErrSevRecoverable = 0 WHEA_ERROR_SEVERITY.WheaErrSevFatal = 1 WHEA_ERROR_SEVERITY.WheaErrSevCorrected = 2 WHEA_ERROR_SEVERITY.WheaErrSevInformational = 3 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED = v_enum() D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_UNINITIALIZED = 0 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_HD15 = 1 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_DVI = 2 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_HDMI = 3 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_HDMI2 = 4 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_SVIDEO_4PIN = 5 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_SVIDEO_7PIN = 6 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_RCA_COMPOSITE = 7 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_RCA_3COMPONENT = 8 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_BNC = 9 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_RF = 10 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_SDTVDONGLE = 11 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_INTERNAL = 12 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY_DEPRECATED.D3DKMDT_VOT_DEPRECATED_OTHER = 255 SM_STORAGE_MODIFIER = v_enum() SM_STORAGE_MODIFIER.SmStorageActual = 0 SM_STORAGE_MODIFIER.SmStorageNonActual = 1 DMM_MONITOR_PRESENCE_EVENT_TYPE = v_enum() DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_UNINITIALIZED = 0 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_ADDMONITOR = 1 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_REMOVEMONITOR = 2 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_DRIVERARRIVAL = 3 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_DRIVERQUERYREMOVE = 4 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_DRIVERREMOVECANCELLED = 5 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_DRIVERREMOVECOMPLETE = 6 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_DEVICENODEREADY = 7 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_EDIDCHANGE = 8 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_MONITORDISABLE = 9 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_MONITORENABLE = 10 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_ADAPTERADD = 11 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_ADAPTERREMOVAL = 12 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_INVALIDATION = 13 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_ADDSIMULATEDMONITOR = 1073741825 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_REMOVESIMULATEDMONITOR = 1073741826 DMM_MONITOR_PRESENCE_EVENT_TYPE.DMM_MPET_MAXVALID = 1073741826 REG_NOTIFY_CLASS = v_enum() REG_NOTIFY_CLASS.RegNtDeleteKey = 0 REG_NOTIFY_CLASS.RegNtPreDeleteKey = 0 REG_NOTIFY_CLASS.RegNtSetValueKey = 1 REG_NOTIFY_CLASS.RegNtPreSetValueKey = 1 REG_NOTIFY_CLASS.RegNtDeleteValueKey = 2 REG_NOTIFY_CLASS.RegNtPreDeleteValueKey = 2 REG_NOTIFY_CLASS.RegNtSetInformationKey = 3 REG_NOTIFY_CLASS.RegNtPreSetInformationKey = 3 REG_NOTIFY_CLASS.RegNtRenameKey = 4 REG_NOTIFY_CLASS.RegNtPreRenameKey = 4 REG_NOTIFY_CLASS.RegNtEnumerateKey = 5 REG_NOTIFY_CLASS.RegNtPreEnumerateKey = 5 REG_NOTIFY_CLASS.RegNtEnumerateValueKey = 6 REG_NOTIFY_CLASS.RegNtPreEnumerateValueKey = 6 REG_NOTIFY_CLASS.RegNtQueryKey = 7 REG_NOTIFY_CLASS.RegNtPreQueryKey = 7 REG_NOTIFY_CLASS.RegNtQueryValueKey = 8 REG_NOTIFY_CLASS.RegNtPreQueryValueKey = 8 REG_NOTIFY_CLASS.RegNtQueryMultipleValueKey = 9 REG_NOTIFY_CLASS.RegNtPreQueryMultipleValueKey = 9 REG_NOTIFY_CLASS.RegNtPreCreateKey = 10 REG_NOTIFY_CLASS.RegNtPostCreateKey = 11 REG_NOTIFY_CLASS.RegNtPreOpenKey = 12 REG_NOTIFY_CLASS.RegNtPostOpenKey = 13 REG_NOTIFY_CLASS.RegNtKeyHandleClose = 14 REG_NOTIFY_CLASS.RegNtPreKeyHandleClose = 14 REG_NOTIFY_CLASS.RegNtPostDeleteKey = 15 REG_NOTIFY_CLASS.RegNtPostSetValueKey = 16 REG_NOTIFY_CLASS.RegNtPostDeleteValueKey = 17 REG_NOTIFY_CLASS.RegNtPostSetInformationKey = 18 REG_NOTIFY_CLASS.RegNtPostRenameKey = 19 REG_NOTIFY_CLASS.RegNtPostEnumerateKey = 20 REG_NOTIFY_CLASS.RegNtPostEnumerateValueKey = 21 REG_NOTIFY_CLASS.RegNtPostQueryKey = 22 REG_NOTIFY_CLASS.RegNtPostQueryValueKey = 23 REG_NOTIFY_CLASS.RegNtPostQueryMultipleValueKey = 24 REG_NOTIFY_CLASS.RegNtPostKeyHandleClose = 25 REG_NOTIFY_CLASS.RegNtPreCreateKeyEx = 26 REG_NOTIFY_CLASS.RegNtPostCreateKeyEx = 27 REG_NOTIFY_CLASS.RegNtPreOpenKeyEx = 28 REG_NOTIFY_CLASS.RegNtPostOpenKeyEx = 29 REG_NOTIFY_CLASS.RegNtPreFlushKey = 30 REG_NOTIFY_CLASS.RegNtPostFlushKey = 31 REG_NOTIFY_CLASS.RegNtPreLoadKey = 32 REG_NOTIFY_CLASS.RegNtPostLoadKey = 33 REG_NOTIFY_CLASS.RegNtPreUnLoadKey = 34 REG_NOTIFY_CLASS.RegNtPostUnLoadKey = 35 REG_NOTIFY_CLASS.RegNtPreQueryKeySecurity = 36 REG_NOTIFY_CLASS.RegNtPostQueryKeySecurity = 37 REG_NOTIFY_CLASS.RegNtPreSetKeySecurity = 38 REG_NOTIFY_CLASS.RegNtPostSetKeySecurity = 39 REG_NOTIFY_CLASS.RegNtCallbackObjectContextCleanup = 40 REG_NOTIFY_CLASS.RegNtPreRestoreKey = 41 REG_NOTIFY_CLASS.RegNtPostRestoreKey = 42 REG_NOTIFY_CLASS.RegNtPreSaveKey = 43 REG_NOTIFY_CLASS.RegNtPostSaveKey = 44 REG_NOTIFY_CLASS.RegNtPreReplaceKey = 45 REG_NOTIFY_CLASS.RegNtPostReplaceKey = 46 REG_NOTIFY_CLASS.MaxRegNtNotifyClass = 47 DEVICE_RELATION_TYPE = v_enum() DEVICE_RELATION_TYPE.BusRelations = 0 DEVICE_RELATION_TYPE.EjectionRelations = 1 DEVICE_RELATION_TYPE.PowerRelations = 2 DEVICE_RELATION_TYPE.RemovalRelations = 3 DEVICE_RELATION_TYPE.TargetDeviceRelation = 4 DEVICE_RELATION_TYPE.SingleBusRelations = 5 DEVICE_RELATION_TYPE.TransportRelations = 6 D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_TYPE = v_enum() D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_TYPE.D3DKMDT_VPPMT_UNINITIALIZED = 0 D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_TYPE.D3DKMDT_VPPMT_NOPROTECTION = 1 D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_TYPE.D3DKMDT_VPPMT_MACROVISION_APSTRIGGER = 2 D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_TYPE.D3DKMDT_VPPMT_MACROVISION_FULLSUPPORT = 3 D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_TYPE.D3DKMDT_VPPMT_NOTSPECIFIED = 255 FILE_INFORMATION_CLASS = v_enum() FILE_INFORMATION_CLASS.FileDirectoryInformation = 1 FILE_INFORMATION_CLASS.FileFullDirectoryInformation = 2 FILE_INFORMATION_CLASS.FileBothDirectoryInformation = 3 FILE_INFORMATION_CLASS.FileBasicInformation = 4 FILE_INFORMATION_CLASS.FileStandardInformation = 5 FILE_INFORMATION_CLASS.FileInternalInformation = 6 FILE_INFORMATION_CLASS.FileEaInformation = 7 FILE_INFORMATION_CLASS.FileAccessInformation = 8 FILE_INFORMATION_CLASS.FileNameInformation = 9 FILE_INFORMATION_CLASS.FileRenameInformation = 10 FILE_INFORMATION_CLASS.FileLinkInformation = 11 FILE_INFORMATION_CLASS.FileNamesInformation = 12 FILE_INFORMATION_CLASS.FileDispositionInformation = 13 FILE_INFORMATION_CLASS.FilePositionInformation = 14 FILE_INFORMATION_CLASS.FileFullEaInformation = 15 FILE_INFORMATION_CLASS.FileModeInformation = 16 FILE_INFORMATION_CLASS.FileAlignmentInformation = 17 FILE_INFORMATION_CLASS.FileAllInformation = 18 FILE_INFORMATION_CLASS.FileAllocationInformation = 19 FILE_INFORMATION_CLASS.FileEndOfFileInformation = 20 FILE_INFORMATION_CLASS.FileAlternateNameInformation = 21 FILE_INFORMATION_CLASS.FileStreamInformation = 22 FILE_INFORMATION_CLASS.FilePipeInformation = 23 FILE_INFORMATION_CLASS.FilePipeLocalInformation = 24 FILE_INFORMATION_CLASS.FilePipeRemoteInformation = 25 FILE_INFORMATION_CLASS.FileMailslotQueryInformation = 26 FILE_INFORMATION_CLASS.FileMailslotSetInformation = 27 FILE_INFORMATION_CLASS.FileCompressionInformation = 28 FILE_INFORMATION_CLASS.FileObjectIdInformation = 29 FILE_INFORMATION_CLASS.FileCompletionInformation = 30 FILE_INFORMATION_CLASS.FileMoveClusterInformation = 31 FILE_INFORMATION_CLASS.FileQuotaInformation = 32 FILE_INFORMATION_CLASS.FileReparsePointInformation = 33 FILE_INFORMATION_CLASS.FileNetworkOpenInformation = 34 FILE_INFORMATION_CLASS.FileAttributeTagInformation = 35 FILE_INFORMATION_CLASS.FileTrackingInformation = 36 FILE_INFORMATION_CLASS.FileIdBothDirectoryInformation = 37 FILE_INFORMATION_CLASS.FileIdFullDirectoryInformation = 38 FILE_INFORMATION_CLASS.FileValidDataLengthInformation = 39 FILE_INFORMATION_CLASS.FileShortNameInformation = 40 FILE_INFORMATION_CLASS.FileIoCompletionNotificationInformation = 41 FILE_INFORMATION_CLASS.FileIoStatusBlockRangeInformation = 42 FILE_INFORMATION_CLASS.FileIoPriorityHintInformation = 43 FILE_INFORMATION_CLASS.FileSfioReserveInformation = 44 FILE_INFORMATION_CLASS.FileSfioVolumeInformation = 45 FILE_INFORMATION_CLASS.FileHardLinkInformation = 46 FILE_INFORMATION_CLASS.FileProcessIdsUsingFileInformation = 47 FILE_INFORMATION_CLASS.FileNormalizedNameInformation = 48 FILE_INFORMATION_CLASS.FileNetworkPhysicalNameInformation = 49 FILE_INFORMATION_CLASS.FileIdGlobalTxDirectoryInformation = 50 FILE_INFORMATION_CLASS.FileIsRemoteDeviceInformation = 51 FILE_INFORMATION_CLASS.FileAttributeCacheInformation = 52 FILE_INFORMATION_CLASS.FileNumaNodeInformation = 53 FILE_INFORMATION_CLASS.FileStandardLinkInformation = 54 FILE_INFORMATION_CLASS.FileRemoteProtocolInformation = 55 FILE_INFORMATION_CLASS.FileMaximumInformation = 56 BUS_QUERY_ID_TYPE = v_enum() BUS_QUERY_ID_TYPE.BusQueryDeviceID = 0 BUS_QUERY_ID_TYPE.BusQueryHardwareIDs = 1 BUS_QUERY_ID_TYPE.BusQueryCompatibleIDs = 2 BUS_QUERY_ID_TYPE.BusQueryInstanceID = 3 BUS_QUERY_ID_TYPE.BusQueryDeviceSerialNumber = 4 BUS_QUERY_ID_TYPE.BusQueryContainerID = 5 PROFILE_MAP = v_enum() PROFILE_MAP.PMAP_COLORS = 0 PROFILE_MAP.PMAP_CURSORS = 1 PROFILE_MAP.PMAP_WINDOWSM = 2 PROFILE_MAP.PMAP_WINDOWSU = 3 PROFILE_MAP.PMAP_DESKTOP = 4 PROFILE_MAP.PMAP_ICONS = 5 PROFILE_MAP.PMAP_FONTS = 6 PROFILE_MAP.PMAP_TRUETYPE = 7 PROFILE_MAP.PMAP_KBDLAYOUT = 8 PROFILE_MAP.PMAP_INPUT = 9 PROFILE_MAP.PMAP_SUBSYSTEMS = 10 PROFILE_MAP.PMAP_BEEP = 11 PROFILE_MAP.PMAP_MOUSE = 12 PROFILE_MAP.PMAP_KEYBOARD = 13 PROFILE_MAP.PMAP_STICKYKEYS = 14 PROFILE_MAP.PMAP_KEYBOARDRESPONSE = 15 PROFILE_MAP.PMAP_MOUSEKEYS = 16 PROFILE_MAP.PMAP_TOGGLEKEYS = 17 PROFILE_MAP.PMAP_TIMEOUT = 18 PROFILE_MAP.PMAP_SOUNDSENTRY = 19 PROFILE_MAP.PMAP_SHOWSOUNDS = 20 PROFILE_MAP.PMAP_AEDEBUG = 21 PROFILE_MAP.PMAP_NETWORK = 22 PROFILE_MAP.PMAP_METRICS = 23 PROFILE_MAP.PMAP_UKBDLAYOUT = 24 PROFILE_MAP.PMAP_UKBDLAYOUTTOGGLE = 25 PROFILE_MAP.PMAP_WINLOGON = 26 PROFILE_MAP.PMAP_KEYBOARDPREF = 27 PROFILE_MAP.PMAP_SCREENREADER = 28 PROFILE_MAP.PMAP_HIGHCONTRAST = 29 PROFILE_MAP.PMAP_IMECOMPAT = 30 PROFILE_MAP.PMAP_IMM = 31 PROFILE_MAP.PMAP_POOLLIMITS = 32 PROFILE_MAP.PMAP_COMPAT32 = 33 PROFILE_MAP.PMAP_SETUPPROGRAMNAMES = 34 PROFILE_MAP.PMAP_INPUTMETHOD = 35 PROFILE_MAP.PMAP_MOUCLASS_PARAMS = 36 PROFILE_MAP.PMAP_KBDCLASS_PARAMS = 37 PROFILE_MAP.PMAP_COMPUTERNAME = 38 PROFILE_MAP.PMAP_TS = 39 PROFILE_MAP.PMAP_TABLETPC = 40 PROFILE_MAP.PMAP_MEDIACENTER = 41 PROFILE_MAP.PMAP_TS_EXCLUDE_DESKTOP_VERSION = 42 PROFILE_MAP.PMAP_WOW64_COMPAT32 = 43 PROFILE_MAP.PMAP_WOW64_IMECOMPAT = 44 PROFILE_MAP.PMAP_SERVERR2 = 45 PROFILE_MAP.PMAP_STARTER = 46 PROFILE_MAP.PMAP_ACCESS = 47 PROFILE_MAP.PMAP_AUDIODESCRIPTION = 48 PROFILE_MAP.PMAP_CONTROL = 49 PROFILE_MAP.PMAP_LAST = 49 NT_PRODUCT_TYPE = v_enum() NT_PRODUCT_TYPE.NtProductWinNt = 1 NT_PRODUCT_TYPE.NtProductLanManNt = 2 NT_PRODUCT_TYPE.NtProductServer = 3 DMM_VIDPNCHANGE_TYPE = v_enum() DMM_VIDPNCHANGE_TYPE.DMM_CVR_UNINITIALIZED = 0 DMM_VIDPNCHANGE_TYPE.DMM_CVR_UPDATEMODALITY = 1 DMM_VIDPNCHANGE_TYPE.DMM_CVR_ADDPATH = 2 DMM_VIDPNCHANGE_TYPE.DMM_CVR_ADDPATHS = 3 DMM_VIDPNCHANGE_TYPE.DMM_CVR_REMOVEPATH = 4 DMM_VIDPNCHANGE_TYPE.DMM_CVR_REMOVEALLPATHS = 5 DEVICE_POWER_STATE = v_enum() DEVICE_POWER_STATE.PowerDeviceUnspecified = 0 DEVICE_POWER_STATE.PowerDeviceD0 = 1 DEVICE_POWER_STATE.PowerDeviceD1 = 2 DEVICE_POWER_STATE.PowerDeviceD2 = 3 DEVICE_POWER_STATE.PowerDeviceD3 = 4 DEVICE_POWER_STATE.PowerDeviceMaximum = 5 WHEA_ERROR_SOURCE_TYPE = v_enum() WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeMCE = 0 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeCMC = 1 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeCPE = 2 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeNMI = 3 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypePCIe = 4 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeGeneric = 5 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeINIT = 6 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeBOOT = 7 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeSCIGeneric = 8 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeIPFMCA = 9 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeIPFCMC = 10 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeIPFCPE = 11 WHEA_ERROR_SOURCE_TYPE.WheaErrSrcTypeMax = 12 DXGK_DIAG_CODE_POINT_TYPE = v_enum() DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_NONE = 0 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_RECOMMEND_FUNC_VIDPN = 1 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_OS_RECOMMENDED_VIDPN = 2 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_SDC_LOG_FAILURE = 3 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_SDC_INVALIDATE_ERROR = 4 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CDS_LOG_FAILURE = 5 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CDS_FAILURE_DB = 7 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_RETRIEVE_BTL = 8 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_RETRIEVE_DB = 9 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_QDC_LOG_FAILURE = 10 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_POWER_ON_GDI = 11 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_POWER_OFF_GDI = 12 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_POWER_ON_MONITOR = 13 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_POWER_OFF_MONITOR = 14 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_POWER_DIM_MONITOR = 15 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_POWER_UNDIM_MONITOR = 16 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_BML_BACKTRACK = 17 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_BML_CLOSEST_TARGET_MODE = 18 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_BML_NO_EXACT_SOURCE_MODE = 19 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_BML_NO_EXACT_TARGET_MODE = 20 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_BML_SOURCE_MODE_NOT_PINNED = 21 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_BML_TARGET_MODE_NOT_PINNED = 22 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_BML_RESTARTED = 23 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_TDR = 24 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_ACPI_EVENT_NOTIFICATION = 25 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CREATEMDEV_USE_DEFAULT_MODE = 26 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CONNECTED_SET_LOG_FAILURE = 27 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_INVALIDATE_DXGK_MODE_CACHE = 28 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_REBUILD_DXGK_MODE_CACHE = 29 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CREATEFUNVIDPN_RELAX_REFRESH_MATCH = 30 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CREATEFUNVIDPN_CCDBML_FAIL_VISTABML_SUCCESSED = 31 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_BML_BEST_SOURCE_MODE = 32 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_BML_BEST_TARGET_MODE = 33 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_ADD_DEVICE = 34 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_START_ADAPTER = 35 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_STOP_ADAPTER = 36 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CHILD_POLLING = 37 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CHILD_POLLING_TARGET = 38 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_INDICATE_CHILD_STATUS = 39 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_HANDLE_IRP = 40 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CHANGE_UNSUPPORTED_MONITOR_MODE_FLAG = 41 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_ACPI_NOTIFY_CALLBACK = 42 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_VIDEOPORTCALLOUT_EXCLUDE_EVICTALL_DISABLEGDI = 43 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_VIDEOPORTCALLOUT_EXCLUDE_EVICTALL_ENABLEGDI = 44 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_VIDEOPORTCALLOUT_EXCLUDE_MODESWITCH = 45 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_VIDEOPORTCALLOUT_SYNC_MONITOR_EVENT = 46 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_VIDEOPORTCALLOUT_PNP_NOTIFY_GDI = 47 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_VIDEOPORTCALLOUT_PNP_ENABLE_VGA = 48 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_VIDEOPORTCALLOUT_TDR_SWITCH_GDI = 49 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_VIDEOPORTCALLOUT_CDD_CREATE_DEVICE_FAILED = 50 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_VIDEOPORTCALLOUT_CDD_DEVICE_REMOVED = 51 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_VIDEOPORTCALLOUT_CDD_DRVASSERTMODE_TRUE_FAILED = 52 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_VIDEOPORTCALLOUT_CDD_RECREATE_DEVICE_FAILED = 53 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CDD_MAPSHADOWBUFFER_FAILED = 54 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_COMMIT_VIDPN_LOG_FAILURE = 55 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_DRIVER_RECOMMEND_LOG_FAILURE = 56 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_SDC_ENFORCED_CLONE_PATH_INVALID_SOURCE_IDX = 57 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_DRVPROBEANDCAPTURE_FAILED = 58 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_DXGKCDDENABLE_OPTIMIZED_MODE_CHANGE = 59 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_DXGKSETDISPLAYMODE_OPTIMIZED_MODE_CHANGE = 60 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_MON_DEPART_GETRECENTTOP_FAIL = 61 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_MON_ARRIVE_INC_ADD_FAIL = 62 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CCD_DATABASE_PERSIST = 63 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_CCD_DATABASE_PERSIST_NO_CONNECTIVITY_HASH = 64 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_MAX = 64 DXGK_DIAG_CODE_POINT_TYPE.DXGK_DIAG_CODE_POINT_TYPE_FORCE_UINT32 = -1 DMM_VIDPN_MONITOR_TYPE = v_enum() DMM_VIDPN_MONITOR_TYPE.DMM_VMT_UNINITIALIZED = 0 DMM_VIDPN_MONITOR_TYPE.DMM_VMT_PHYSICAL_MONITOR = 1 DMM_VIDPN_MONITOR_TYPE.DMM_VMT_BOOT_PERSISTENT_MONITOR = 2 DMM_VIDPN_MONITOR_TYPE.DMM_VMT_PERSISTENT_MONITOR = 3 DMM_VIDPN_MONITOR_TYPE.DMM_VMT_TEMPORARY_MONITOR = 4 DMM_VIDPN_MONITOR_TYPE.DMM_VMT_SIMULATED_MONITOR = 5 D3DDDI_VIDEO_SIGNAL_SCANLINE_ORDERING = v_enum() D3DDDI_VIDEO_SIGNAL_SCANLINE_ORDERING.D3DDDI_VSSLO_UNINITIALIZED = 0 D3DDDI_VIDEO_SIGNAL_SCANLINE_ORDERING.D3DDDI_VSSLO_PROGRESSIVE = 1 D3DDDI_VIDEO_SIGNAL_SCANLINE_ORDERING.D3DDDI_VSSLO_INTERLACED_UPPERFIELDFIRST = 2 D3DDDI_VIDEO_SIGNAL_SCANLINE_ORDERING.D3DDDI_VSSLO_INTERLACED_LOWERFIELDFIRST = 3 D3DDDI_VIDEO_SIGNAL_SCANLINE_ORDERING.D3DDDI_VSSLO_OTHER = 255 D3DKMDT_MONITOR_ORIENTATION = v_enum() D3DKMDT_MONITOR_ORIENTATION.D3DKMDT_MO_UNINITIALIZED = 0 D3DKMDT_MONITOR_ORIENTATION.D3DKMDT_MO_0DEG = 1 D3DKMDT_MONITOR_ORIENTATION.D3DKMDT_MO_90DEG = 2 D3DKMDT_MONITOR_ORIENTATION.D3DKMDT_MO_180DEG = 3 D3DKMDT_MONITOR_ORIENTATION.D3DKMDT_MO_270DEG = 4 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY = v_enum() D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY.D3DKMDT_VOT_UNINITIALIZED = -2 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY.D3DKMDT_VOT_OTHER = -1 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY.D3DKMDT_VOT_HD15 = 0 D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY.D3DKMDT_VOT_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enum() EVENT_TYPE.NotificationEvent = 0 EVENT_TYPE.SynchronizationEvent = 1 KSPIN_LOCK_QUEUE_NUMBER = v_enum() KSPIN_LOCK_QUEUE_NUMBER.LockQueueUnusedSpare0 = 0 KSPIN_LOCK_QUEUE_NUMBER.LockQueueExpansionLock = 1 KSPIN_LOCK_QUEUE_NUMBER.LockQueueUnusedSpare2 = 2 KSPIN_LOCK_QUEUE_NUMBER.LockQueueSystemSpaceLock = 3 KSPIN_LOCK_QUEUE_NUMBER.LockQueueVacbLock = 4 KSPIN_LOCK_QUEUE_NUMBER.LockQueueMasterLock = 5 KSPIN_LOCK_QUEUE_NUMBER.LockQueueNonPagedPoolLock = 6 KSPIN_LOCK_QUEUE_NUMBER.LockQueueIoCancelLock = 7 KSPIN_LOCK_QUEUE_NUMBER.LockQueueWorkQueueLock = 8 KSPIN_LOCK_QUEUE_NUMBER.LockQueueIoVpbLock = 9 KSPIN_LOCK_QUEUE_NUMBER.LockQueueIoDatabaseLock = 10 KSPIN_LOCK_QUEUE_NUMBER.LockQueueIoCompletionLock = 11 KSPIN_LOCK_QUEUE_NUMBER.LockQueueNtfsStructLock = 12 KSPIN_LOCK_QUEUE_NUMBER.LockQueueAfdWorkQueueLock = 13 KSPIN_LOCK_QUEUE_NUMBER.LockQueueBcbLock = 14 KSPIN_LOCK_QUEUE_NUMBER.LockQueueMmNonPagedPoolLock = 15 KSPIN_LOCK_QUEUE_NUMBER.LockQueueUnusedSpare16 = 16 KSPIN_LOCK_QUEUE_NUMBER.LockQueueMaximumLock = 17 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE = v_enum() D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_UNINITIALIZED = 0 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_PRIMARY = 1 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_SECONDARY = 2 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_TERTIARY = 3 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_QUATERNARY = 4 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_QUINARY = 5 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_SENARY = 6 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_SEPTENARY = 7 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_OCTONARY = 8 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_NONARY = 9 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_DENARY = 10 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_MAX = 32 D3DKMDT_VIDPN_PRESENT_PATH_IMPORTANCE.D3DKMDT_VPPI_NOTSPECIFIED = 255 FSINFOCLASS = v_enum() FSINFOCLASS.FileFsVolumeInformation = 1 FSINFOCLASS.FileFsLabelInformation = 2 FSINFOCLASS.FileFsSizeInformation = 3 FSINFOCLASS.FileFsDeviceInformation = 4 FSINFOCLASS.FileFsAttributeInformation = 5 FSINFOCLASS.FileFsControlInformation = 6 FSINFOCLASS.FileFsFullSizeInformation = 7 FSINFOCLASS.FileFsObjectIdInformation = 8 FSINFOCLASS.FileFsDriverPathInformation = 9 FSINFOCLASS.FileFsVolumeFlagsInformation = 10 FSINFOCLASS.FileFsMaximumInformation = 11 D3DKMT_QUERYSTATISTICS_QUEUE_PACKET_TYPE = v_enum() D3DKMT_QUERYSTATISTICS_QUEUE_PACKET_TYPE.D3DKMT_RenderCommandBuffer = 0 D3DKMT_QUERYSTATISTICS_QUEUE_PACKET_TYPE.D3DKMT_DeferredCommandBuffer = 1 D3DKMT_QUERYSTATISTICS_QUEUE_PACKET_TYPE.D3DKMT_SystemCommandBuffer = 2 D3DKMT_QUERYSTATISTICS_QUEUE_PACKET_TYPE.D3DKMT_MmIoFlipCommandBuffer = 3 D3DKMT_QUERYSTATISTICS_QUEUE_PACKET_TYPE.D3DKMT_WaitCommandBuffer = 4 D3DKMT_QUERYSTATISTICS_QUEUE_PACKET_TYPE.D3DKMT_SignalCommandBuffer = 5 D3DKMT_QUERYSTATISTICS_QUEUE_PACKET_TYPE.D3DKMT_DeviceCommandBuffer = 6 D3DKMT_QUERYSTATISTICS_QUEUE_PACKET_TYPE.D3DKMT_SoftwareCommandBuffer = 7 D3DKMT_QUERYSTATISTICS_QUEUE_PACKET_TYPE.D3DKMT_QueuePacketTypeMax = 8 _unnamed_15459 = v_enum() _unnamed_15459.DMM_DIAG_INFO_VISTA_BETA2_VERSION = 4097 _unnamed_15459.DMM_DIAG_INFO_VISTA_RC1_VERSION = 4098 _unnamed_15459.DMM_DIAG_INFO_VISTA_RTM_VERSION = 4099 _unnamed_15459.DMM_DIAG_INFO_WIN7_MQ_VERSION = 8192 _unnamed_15459.DMM_DIAG_INFO_WIN7_M3_VERSION = 8193 _unnamed_15459.DMM_DIAG_INFO_VERSION = 8193 D3DKMDT_VIDPN_PRESENT_PATH_CONTENT = v_enum() D3DKMDT_VIDPN_PRESENT_PATH_CONTENT.D3DKMDT_VPPC_UNINITIALIZED = 0 D3DKMDT_VIDPN_PRESENT_PATH_CONTENT.D3DKMDT_VPPC_GRAPHICS = 1 D3DKMDT_VIDPN_PRESENT_PATH_CONTENT.D3DKMDT_VPPC_VIDEO = 2 D3DKMDT_VIDPN_PRESENT_PATH_CONTENT.D3DKMDT_VPPC_NOTSPECIFIED = 255 THRESHOLD_SELECTOR = v_enum() THRESHOLD_SELECTOR.ThresholdMouse = 0 THRESHOLD_SELECTOR.ThresholdPen = 1 THRESHOLD_SELECTOR.ThresholdMouseDragOut = 2 THRESHOLD_SELECTOR.ThresholdPenDragOut = 3 THRESHOLD_SELECTOR.ThresholdMouseSideMove = 4 THRESHOLD_SELECTOR.ThresholdPenSideMove = 5 THRESHOLD_SELECTOR.ThresholdAlways = 6 THRESHOLD_SELECTOR.ThresholdLast = 7 POOL_TYPE = v_enum() POOL_TYPE.NonPagedPool = 0 POOL_TYPE.PagedPool = 1 POOL_TYPE.NonPagedPoolMustSucceed = 2 POOL_TYPE.DontUseThisType = 3 POOL_TYPE.NonPagedPoolCacheAligned = 4 POOL_TYPE.PagedPoolCacheAligned = 5 POOL_TYPE.NonPagedPoolCacheAlignedMustS = 6 POOL_TYPE.MaxPoolType = 7 POOL_TYPE.NonPagedPoolSession = 32 POOL_TYPE.PagedPoolSession = 33 POOL_TYPE.NonPagedPoolMustSucceedSession = 34 POOL_TYPE.DontUseThisTypeSession = 35 POOL_TYPE.NonPagedPoolCacheAlignedSession = 36 POOL_TYPE.PagedPoolCacheAlignedSession = 37 POOL_TYPE.NonPagedPoolCacheAlignedMustSSession = 38 DMM_CLIENT_TYPE = v_enum() DMM_CLIENT_TYPE.DMM_CT_UNINITIALIZED = 0 DMM_CLIENT_TYPE.DMM_CT_CDD_NOPATHDATA = 1 DMM_CLIENT_TYPE.DMM_CT_USERMODE = 2 DMM_CLIENT_TYPE.DMM_CT_CDD_PATHDATA = 3 DMM_CLIENT_TYPE.DMM_CT_DXGPORT = 4 D3DKMT_QUERYSTATISTICS_DMA_PACKET_TYPE = v_enum() D3DKMT_QUERYSTATISTICS_DMA_PACKET_TYPE.D3DKMT_ClientRenderBuffer = 0 D3DKMT_QUERYSTATISTICS_DMA_PACKET_TYPE.D3DKMT_ClientPagingBuffer = 1 D3DKMT_QUERYSTATISTICS_DMA_PACKET_TYPE.D3DKMT_SystemPagingBuffer = 2 D3DKMT_QUERYSTATISTICS_DMA_PACKET_TYPE.D3DKMT_SystemPreemptionBuffer = 3 D3DKMT_QUERYSTATISTICS_DMA_PACKET_TYPE.D3DKMT_DmaPacketTypeMax = 4 D3DKMDT_VIDEO_SIGNAL_STANDARD = v_enum() D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_UNINITIALIZED = 0 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_VESA_DMT = 1 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_VESA_GTF = 2 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_VESA_CVT = 3 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_IBM = 4 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_APPLE = 5 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_NTSC_M = 6 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_NTSC_J = 7 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_NTSC_443 = 8 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_B = 9 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_B1 = 10 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_G = 11 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_H = 12 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_I = 13 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_D = 14 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_N = 15 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_NC = 16 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_SECAM_B = 17 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_SECAM_D = 18 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_SECAM_G = 19 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_SECAM_H = 20 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_SECAM_K = 21 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_SECAM_K1 = 22 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_SECAM_L = 23 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_SECAM_L1 = 24 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_EIA_861 = 25 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_EIA_861A = 26 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_EIA_861B = 27 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_K = 28 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_K1 = 29 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_L = 30 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_PAL_M = 31 D3DKMDT_VIDEO_SIGNAL_STANDARD.D3DKMDT_VSS_OTHER = 255 D3DKMDT_MONITOR_FREQUENCY_RANGE_CONSTRAINT = v_enum() D3DKMDT_MONITOR_FREQUENCY_RANGE_CONSTRAINT.D3DKMDT_MFRC_UNINITIALIZED = 0 D3DKMDT_MONITOR_FREQUENCY_RANGE_CONSTRAINT.D3DKMDT_MFRC_ACTIVESIZE = 1 D3DKMDT_MONITOR_FREQUENCY_RANGE_CONSTRAINT.D3DKMDT_MFRC_MAXPIXELRATE = 2 WINDOW_ARRANGEMENT_COMMAND = v_enum() WINDOW_ARRANGEMENT_COMMAND.WARR_MOVE_FIRST = 10 WINDOW_ARRANGEMENT_COMMAND.WARR_RESTORE_UP = 10 WINDOW_ARRANGEMENT_COMMAND.WARR_RESTORE_DOWN = 11 WINDOW_ARRANGEMENT_COMMAND.WARR_VRESTORE_UP = 12 WINDOW_ARRANGEMENT_COMMAND.WARR_VRESTORE_DOWN = 13 WINDOW_ARRANGEMENT_COMMAND.WARR_VMAXIMIZE_RIGHT = 14 WINDOW_ARRANGEMENT_COMMAND.WARR_VMAXIMIZE_LEFT = 15 WINDOW_ARRANGEMENT_COMMAND.WARR_MOVE_NEXT_MONITOR_LEFT = 16 WINDOW_ARRANGEMENT_COMMAND.WARR_MOVE_NEXT_MONITOR_RIGHT = 17 WINDOW_ARRANGEMENT_COMMAND.WARR_MOVE_LAST = 18 OB_OPEN_REASON = v_enum() OB_OPEN_REASON.ObCreateHandle = 0 OB_OPEN_REASON.ObOpenHandle = 1 OB_OPEN_REASON.ObDuplicateHandle = 2 OB_OPEN_REASON.ObInheritHandle = 3 OB_OPEN_REASON.ObMaxOpenReason = 4 DMM_MODE_PRUNING_ALGORITHM = v_enum() DMM_MODE_PRUNING_ALGORITHM.DMM_MPA_UNINITIALIZED = 0 DMM_MODE_PRUNING_ALGORITHM.DMM_MPA_GDI = 1 DMM_MODE_PRUNING_ALGORITHM.DMM_MPA_VISTA = 2 DMM_MODE_PRUNING_ALGORITHM.DMM_MPA_GDI_VISTA_UNION = 3 DMM_MODE_PRUNING_ALGORITHM.DMM_MPA_MAXVALID = 3 MODE = v_enum() MODE.KernelMode = 0 MODE.UserMode = 1 MODE.MaximumMode = 2 POWER_STATE_TYPE = v_enum() POWER_STATE_TYPE.SystemPowerState = 0 POWER_STATE_TYPE.DevicePowerState = 1 IRQ_PRIORITY = v_enum() IRQ_PRIORITY.IrqPriorityUndefined = 0 IRQ_PRIORITY.IrqPriorityLow = 1 IRQ_PRIORITY.IrqPriorityNormal = 2 IRQ_PRIORITY.IrqPriorityHigh = 3 D3DKMT_QUERYSTATISTICS_ALLOCATION_PRIORITY_CLASS = v_enum() D3DKMT_QUERYSTATISTICS_ALLOCATION_PRIORITY_CLASS.D3DKMT_AllocationPriorityClassMinimum = 0 D3DKMT_QUERYSTATISTICS_ALLOCATION_PRIORITY_CLASS.D3DKMT_AllocationPriorityClassLow = 1 D3DKMT_QUERYSTATISTICS_ALLOCATION_PRIORITY_CLASS.D3DKMT_AllocationPriorityClassNormal = 2 D3DKMT_QUERYSTATISTICS_ALLOCATION_PRIORITY_CLASS.D3DKMT_AllocationPriorityClassHigh = 3 D3DKMT_QUERYSTATISTICS_ALLOCATION_PRIORITY_CLASS.D3DKMT_AllocationPriorityClassMaximum = 4 D3DKMT_QUERYSTATISTICS_ALLOCATION_PRIORITY_CLASS.D3DKMT_MaxAllocationPriorityClass = 5 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN = v_enum() D3DKMDT_MONITOR_CAPABILITIES_ORIGIN.D3DKMDT_MCO_UNINITIALIZED = 0 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN.D3DKMDT_MCO_DEFAULTMONITORPROFILE = 1 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN.D3DKMDT_MCO_MONITORDESCRIPTOR = 2 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN.D3DKMDT_MCO_MONITORDESCRIPTOR_REGISTRYOVERRIDE = 3 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN.D3DKMDT_MCO_SPECIFICCAP_REGISTRYOVERRIDE = 4 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN.D3DKMDT_MCO_DRIVER = 5 D3DKMDT_MONITOR_CAPABILITIES_ORIGIN.D3DKMDT_MCO_MAXVALID = 5 D3DKMDT_PIXEL_VALUE_ACCESS_MODE = v_enum() D3DKMDT_PIXEL_VALUE_ACCESS_MODE.D3DKMDT_PVAM_UNINITIALIZED = 0 D3DKMDT_PIXEL_VALUE_ACCESS_MODE.D3DKMDT_PVAM_DIRECT = 1 D3DKMDT_PIXEL_VALUE_ACCESS_MODE.D3DKMDT_PVAM_PRESETPALETTE = 2 D3DKMDT_PIXEL_VALUE_ACCESS_MODE.D3DKMDT_PVAM_SETTABLEPALETTE = 3 D3DKMDT_PIXEL_VALUE_ACCESS_MODE.D3DKMDT_PVAM_MAXVALID = 3 D3DKMDT_TEXT_RENDERING_FORMAT = v_enum() D3DKMDT_TEXT_RENDERING_FORMAT.D3DKMDT_TRF_UNINITIALIZED = 0 RTL_GENERIC_COMPARE_RESULTS = v_enum() RTL_GENERIC_COMPARE_RESULTS.GenericLessThan = 0 RTL_GENERIC_COMPARE_RESULTS.GenericGreaterThan = 1 RTL_GENERIC_COMPARE_RESULTS.GenericEqual = 2 SYSTEM_POWER_STATE = v_enum() SYSTEM_POWER_STATE.PowerSystemUnspecified = 0 SYSTEM_POWER_STATE.PowerSystemWorking = 1 SYSTEM_POWER_STATE.PowerSystemSleeping1 = 2 SYSTEM_POWER_STATE.PowerSystemSleeping2 = 3 SYSTEM_POWER_STATE.PowerSystemSleeping3 = 4 SYSTEM_POWER_STATE.PowerSystemHibernate = 5 SYSTEM_POWER_STATE.PowerSystemShutdown = 6 SYSTEM_POWER_STATE.PowerSystemMaximum = 7 D3DKMDT_VIDPN_SOURCE_MODE_TYPE = v_enum() D3DKMDT_VIDPN_SOURCE_MODE_TYPE.D3DKMDT_RMT_UNINITIALIZED = 0 D3DKMDT_VIDPN_SOURCE_MODE_TYPE.D3DKMDT_RMT_GRAPHICS = 1 D3DKMDT_VIDPN_SOURCE_MODE_TYPE.D3DKMDT_RMT_TEXT = 2 IO_ALLOCATION_ACTION = v_enum() IO_ALLOCATION_ACTION.KeepObject = 1 IO_ALLOCATION_ACTION.DeallocateObject = 2 IO_ALLOCATION_ACTION.DeallocateObjectKeepRegisters = 3 EXCEPTION_DISPOSITION = v_enum() EXCEPTION_DISPOSITION.ExceptionContinueExecution = 0 EXCEPTION_DISPOSITION.ExceptionContinueSearch = 1 EXCEPTION_DISPOSITION.ExceptionNestedException = 2 EXCEPTION_DISPOSITION.ExceptionCollidedUnwind = 3 D3DKMDT_VIDPN_PRESENT_PATH_SCALING = v_enum() D3DKMDT_VIDPN_PRESENT_PATH_SCALING.D3DKMDT_VPPS_UNINITIALIZED = 0 D3DKMDT_VIDPN_PRESENT_PATH_SCALING.D3DKMDT_VPPS_IDENTITY = 1 D3DKMDT_VIDPN_PRESENT_PATH_SCALING.D3DKMDT_VPPS_CENTERED = 2 D3DKMDT_VIDPN_PRESENT_PATH_SCALING.D3DKMDT_VPPS_STRETCHED = 3 D3DKMDT_VIDPN_PRESENT_PATH_SCALING.D3DKMDT_VPPS_ASPECTRATIOCENTEREDMAX = 4 D3DKMDT_VIDPN_PRESENT_PATH_SCALING.D3DKMDT_VPPS_CUSTOM = 5 D3DKMDT_VIDPN_PRESENT_PATH_SCALING.D3DKMDT_VPPS_RESERVED1 = 253 D3DKMDT_VIDPN_PRESENT_PATH_SCALING.D3DKMDT_VPPS_UNPINNED = 254 D3DKMDT_VIDPN_PRESENT_PATH_SCALING.D3DKMDT_VPPS_NOTSPECIFIED = 255 D3DDDI_GAMMARAMP_TYPE = v_enum() D3DDDI_GAMMARAMP_TYPE.D3DDDI_GAMMARAMP_UNINITIALIZED = 0 D3DDDI_GAMMARAMP_TYPE.D3DDDI_GAMMARAMP_DEFAULT = 1 D3DDDI_GAMMARAMP_TYPE.D3DDDI_GAMMARAMP_RGB256x3x16 = 2 D3DDDI_GAMMARAMP_TYPE.D3DDDI_GAMMARAMP_DXGI_1 = 3 SECURITY_OPERATION_CODE = v_enum() SECURITY_OPERATION_CODE.SetSecurityDescriptor = 0 SECURITY_OPERATION_CODE.QuerySecurityDescriptor = 1 SECURITY_OPERATION_CODE.DeleteSecurityDescriptor = 2 SECURITY_OPERATION_CODE.AssignSecurityDescriptor = 3 WHEA_ERROR_PACKET_DATA_FORMAT = v_enum() WHEA_ERROR_PACKET_DATA_FORMAT.WheaDataFormatIPFSalRecord = 0 WHEA_ERROR_PACKET_DATA_FORMAT.WheaDataFormatXPFMCA = 1 WHEA_ERROR_PACKET_DATA_FORMAT.WheaDataFormatMemory = 2 WHEA_ERROR_PACKET_DATA_FORMAT.WheaDataFormatPCIExpress = 3 WHEA_ERROR_PACKET_DATA_FORMAT.WheaDataFormatNMIPort = 4 WHEA_ERROR_PACKET_DATA_FORMAT.WheaDataFormatPCIXBus = 5 WHEA_ERROR_PACKET_DATA_FORMAT.WheaDataFormatPCIXDevice = 6 WHEA_ERROR_PACKET_DATA_FORMAT.WheaDataFormatGeneric = 7 WHEA_ERROR_PACKET_DATA_FORMAT.WheaDataFormatMax = 8 DISPLAYCONFIG_SCANLINE_ORDERING = v_enum() DISPLAYCONFIG_SCANLINE_ORDERING.DISPLAYCONFIG_SCANLINE_ORDERING_UNSPECIFIED = 0 DISPLAYCONFIG_SCANLINE_ORDERING.DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE = 1 DISPLAYCONFIG_SCANLINE_ORDERING.DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED = 2 DISPLAYCONFIG_SCANLINE_ORDERING.DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_UPPERFIELDFIRST = 2 DISPLAYCONFIG_SCANLINE_ORDERING.DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_LOWERFIELDFIRST = 3 DISPLAYCONFIG_SCANLINE_ORDERING.DISPLAYCONFIG_SCANLINE_ORDERING_FORCE_UINT32 = -1 TP_CALLBACK_PRIORITY = v_enum() TP_CALLBACK_PRIORITY.TP_CALLBACK_PRIORITY_HIGH = 0 TP_CALLBACK_PRIORITY.TP_CALLBACK_PRIORITY_NORMAL = 1 TP_CALLBACK_PRIORITY.TP_CALLBACK_PRIORITY_LOW = 2 TP_CALLBACK_PRIORITY.TP_CALLBACK_PRIORITY_INVALID = 3 SECURITY_IMPERSONATION_LEVEL = v_enum() SECURITY_IMPERSONATION_LEVEL.SecurityAnonymous = 0 SECURITY_IMPERSONATION_LEVEL.SecurityIdentification = 1 SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation = 2 SECURITY_IMPERSONATION_LEVEL.SecurityDelegation = 3 DEVICE_USAGE_NOTIFICATION_TYPE = v_enum() DEVICE_USAGE_NOTIFICATION_TYPE.DeviceUsageTypeUndefined = 0 DEVICE_USAGE_NOTIFICATION_TYPE.DeviceUsageTypePaging = 1 DEVICE_USAGE_NOTIFICATION_TYPE.DeviceUsageTypeHibernation = 2 DEVICE_USAGE_NOTIFICATION_TYPE.DeviceUsageTypeDumpFile = 3 D3DKMDT_COLOR_BASIS = v_enum() D3DKMDT_COLOR_BASIS.D3DKMDT_CB_UNINITIALIZED = 0 D3DKMDT_COLOR_BASIS.D3DKMDT_CB_INTENSITY = 1 D3DKMDT_COLOR_BASIS.D3DKMDT_CB_SRGB = 2 D3DKMDT_COLOR_BASIS.D3DKMDT_CB_SCRGB = 3 D3DKMDT_COLOR_BASIS.D3DKMDT_CB_YCBCR = 4 D3DKMDT_COLOR_BASIS.D3DKMDT_CB_YPBPR = 5 D3DKMDT_COLOR_BASIS.D3DKMDT_CB_MAXVALID = 5 DXGK_RECOMMENDFUNCTIONALVIDPN_REASON = v_enum() DXGK_RECOMMENDFUNCTIONALVIDPN_REASON.DXGK_RFVR_UNINITIALIZED = 0 DXGK_RECOMMENDFUNCTIONALVIDPN_REASON.DXGK_RFVR_HOTKEY = 1 DXGK_RECOMMENDFUNCTIONALVIDPN_REASON.DXGK_RFVR_USERMODE = 2 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT = v_enum() D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttempt = 0 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptSuccess = 1 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissNoCommand = 2 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissNotEnabled = 3 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissNextFence = 4 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissPagingCommand = 5 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissSplittedCommand = 6 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissFenceCommand = 7 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissRenderPendingFlip = 8 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissNotMakingProgress = 9 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissLessPriority = 10 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissRemainingQuantum = 11 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissRemainingPreemptionQuantum = 12 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissAlreadyPreempting = 13 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissGlobalBlock = 14 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptMissAlreadyRunning = 15 D3DKMT_QUERYRESULT_PREEMPTION_ATTEMPT_RESULT.D3DKMT_PreemptionAttemptStatisticsMax = 16 INTERFACE_TYPE = v_enum() INTERFACE_TYPE.InterfaceTypeUndefined = -1 INTERFACE_TYPE.Internal = 0 INTERFACE_TYPE.Isa = 1 INTERFACE_TYPE.Eisa = 2 INTERFACE_TYPE.MicroChannel = 3 INTERFACE_TYPE.TurboChannel = 4 INTERFACE_TYPE.PCIBus = 5 INTERFACE_TYPE.VMEBus = 6 INTERFACE_TYPE.NuBus = 7 INTERFACE_TYPE.PCMCIABus = 8 INTERFACE_TYPE.CBus = 9 INTERFACE_TYPE.MPIBus = 10 INTERFACE_TYPE.MPSABus = 11 INTERFACE_TYPE.ProcessorInternal = 12 INTERFACE_TYPE.InternalPowerBus = 13 INTERFACE_TYPE.PNPISABus = 14 INTERFACE_TYPE.PNPBus = 15 INTERFACE_TYPE.Vmcs = 16 INTERFACE_TYPE.MaximumInterfaceType = 17 ALTERNATIVE_ARCHITECTURE_TYPE = v_enum() ALTERNATIVE_ARCHITECTURE_TYPE.StandardDesign = 0 ALTERNATIVE_ARCHITECTURE_TYPE.NEC98x86 = 1 ALTERNATIVE_ARCHITECTURE_TYPE.EndAlternatives = 2 D3DKMDT_VIDPN_PRESENT_PATH_ROTATION = v_enum() D3DKMDT_VIDPN_PRESENT_PATH_ROTATION.D3DKMDT_VPPR_UNINITIALIZED = 0 D3DKMDT_VIDPN_PRESENT_PATH_ROTATION.D3DKMDT_VPPR_IDENTITY = 1 D3DKMDT_VIDPN_PRESENT_PATH_ROTATION.D3DKMDT_VPPR_ROTATE90 = 2 D3DKMDT_VIDPN_PRESENT_PATH_ROTATION.D3DKMDT_VPPR_ROTATE180 = 3 D3DKMDT_VIDPN_PRESENT_PATH_ROTATION.D3DKMDT_VPPR_ROTATE270 = 4 D3DKMDT_VIDPN_PRESENT_PATH_ROTATION.D3DKMDT_VPPR_UNPINNED = 254 D3DKMDT_VIDPN_PRESENT_PATH_ROTATION.D3DKMDT_VPPR_NOTSPECIFIED = 255 WHEA_ERROR_TYPE = v_enum() WHEA_ERROR_TYPE.WheaErrTypeProcessor = 0 WHEA_ERROR_TYPE.WheaErrTypeMemory = 1 WHEA_ERROR_TYPE.WheaErrTypePCIExpress = 2 WHEA_ERROR_TYPE.WheaErrTypeNMI = 3 WHEA_ERROR_TYPE.WheaErrTypePCIXBus = 4 WHEA_ERROR_TYPE.WheaErrTypePCIXDevice = 5 WHEA_ERROR_TYPE.WheaErrTypeGeneric = 6 DXGK_DIAG_TYPE = v_enum() DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_NONE = 0 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_SDC = 1 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_HPD = 2 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_DC_ORIGIN = 3 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_USER_CDS = 4 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_DRV_CDS = 5 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_CODE_POINT = 6 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_QDC = 7 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_MONITOR_MGR = 8 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_CONNECTEDSET_NOT_FOUND = 9 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_DISPDIAG_COLLECTED = 10 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_BML_PACKET = 11 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_BML_PACKET_EX = 12 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_COMMIT_VIDPN_FAILED = 13 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_DRIVER_RECOMMEND_VIDPN = 14 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_MAX = 14 DXGK_DIAG_TYPE.DXGK_DIAG_TYPE_FORCE_UINT32 = -1 ReplacesCorHdrNumericDefines = v_enum() ReplacesCorHdrNumericDefines.COMIMAGE_FLAGS_ILONLY = 1 ReplacesCorHdrNumericDefines.COMIMAGE_FLAGS_32BITREQUIRED = 2 ReplacesCorHdrNumericDefines.COMIMAGE_FLAGS_IL_LIBRARY = 4 ReplacesCorHdrNumericDefines.COMIMAGE_FLAGS_STRONGNAMESIGNED = 8 ReplacesCorHdrNumericDefines.COMIMAGE_FLAGS_NATIVE_ENTRYPOINT = 16 ReplacesCorHdrNumericDefines.COMIMAGE_FLAGS_TRACKDEBUGDATA = 65536 ReplacesCorHdrNumericDefines.COR_VERSION_MAJOR_V2 = 2 ReplacesCorHdrNumericDefines.COR_VERSION_MAJOR = 2 ReplacesCorHdrNumericDefines.COR_VERSION_MINOR = 0 ReplacesCorHdrNumericDefines.COR_DELETED_NAME_LENGTH = 8 ReplacesCorHdrNumericDefines.COR_VTABLEGAP_NAME_LENGTH = 8 ReplacesCorHdrNumericDefines.NATIVE_TYPE_MAX_CB = 1 ReplacesCorHdrNumericDefines.COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE = 255 ReplacesCorHdrNumericDefines.IMAGE_COR_MIH_METHODRVA = 1 ReplacesCorHdrNumericDefines.IMAGE_COR_MIH_EHRVA = 2 ReplacesCorHdrNumericDefines.IMAGE_COR_MIH_BASICBLOCK = 8 ReplacesCorHdrNumericDefines.COR_VTABLE_32BIT = 1 ReplacesCorHdrNumericDefines.COR_VTABLE_64BIT = 2 ReplacesCorHdrNumericDefines.COR_VTABLE_FROM_UNMANAGED = 4 ReplacesCorHdrNumericDefines.COR_VTABLE_FROM_UNMANAGED_RETAIN_APPDOMAIN = 8 ReplacesCorHdrNumericDefines.COR_VTABLE_CALL_MOST_DERIVED = 16 ReplacesCorHdrNumericDefines.IMAGE_COR_EATJ_THUNK_SIZE = 32 ReplacesCorHdrNumericDefines.MAX_CLASS_NAME = 1024 ReplacesCorHdrNumericDefines.MAX_PACKAGE_NAME = 1024 D3DKMDT_MODE_PREFERENCE = v_enum() D3DKMDT_MODE_PREFERENCE.D3DKMDT_MP_UNINITIALIZED = 0 D3DKMDT_MODE_PREFERENCE.D3DKMDT_MP_PREFERRED = 1 D3DKMDT_MODE_PREFERENCE.D3DKMDT_MP_NOTPREFERRED = 2 D3DKMDT_MODE_PREFERENCE.D3DKMDT_MP_MAXVALID = 2 EX_POOL_PRIORITY = v_enum() EX_POOL_PRIORITY.LowPoolPriority = 0 EX_POOL_PRIORITY.LowPoolPrioritySpecialPoolOverrun = 8 EX_POOL_PRIORITY.LowPoolPrioritySpecialPoolUnderrun = 9 EX_POOL_PRIORITY.NormalPoolPriority = 16 EX_POOL_PRIORITY.NormalPoolPrioritySpecialPoolOverrun = 24 EX_POOL_PRIORITY.NormalPoolPrioritySpecialPoolUnderrun = 25 EX_POOL_PRIORITY.HighPoolPriority = 32 EX_POOL_PRIORITY.HighPoolPrioritySpecialPoolOverrun = 40 EX_POOL_PRIORITY.HighPoolPrioritySpecialPoolUnderrun = 41 eTHRESHOLD_MARGIN_DIRECTION = v_enum() eTHRESHOLD_MARGIN_DIRECTION.ThresholdMarginTop = 0 eTHRESHOLD_MARGIN_DIRECTION.ThresholdMarginLeft = 1 eTHRESHOLD_MARGIN_DIRECTION.ThresholdMarginRight = 2 eTHRESHOLD_MARGIN_DIRECTION.ThresholdMarginBottom = 3 eTHRESHOLD_MARGIN_DIRECTION.ThresholdMarginMax = 4 MOVERECT_STYLE = v_enum() MOVERECT_STYLE.MoveRectKeepPositionAtCursor = 0 MOVERECT_STYLE.MoveRectMidTopAtCursor = 1 MOVERECT_STYLE.MoveRectKeepAspectRatioAtCursor = 2 MOVERECT_STYLE.MoveRectSidewiseKeepPositionAtCursor = 3 D3DDDIFORMAT = v_enum() D3DDDIFORMAT.D3DDDIFMT_UNKNOWN = 0 D3DDDIFORMAT.D3DDDIFMT_R8G8B8 = 20 D3DDDIFORMAT.D3DDDIFMT_A8R8G8B8 = 21 D3DDDIFORMAT.D3DDDIFMT_X8R8G8B8 = 22 D3DDDIFORMAT.D3DDDIFMT_R5G6B5 = 23 D3DDDIFORMAT.D3DDDIFMT_X1R5G5B5 = 24 D3DDDIFORMAT.D3DDDIFMT_A1R5G5B5 = 25 D3DDDIFORMAT.D3DDDIFMT_A4R4G4B4 = 26 D3DDDIFORMAT.D3DDDIFMT_R3G3B2 = 27 D3DDDIFORMAT.D3DDDIFMT_A8 = 28 D3DDDIFORMAT.D3DDDIFMT_A8R3G3B2 = 29 D3DDDIFORMAT.D3DDDIFMT_X4R4G4B4 = 30 D3DDDIFORMAT.D3DDDIFMT_A2B10G10R10 = 31 D3DDDIFORMAT.D3DDDIFMT_A8B8G8R8 = 32 D3DDDIFORMAT.D3DDDIFMT_X8B8G8R8 = 33 D3DDDIFORMAT.D3DDDIFMT_G16R16 = 34 D3DDDIFORMAT.D3DDDIFMT_A2R10G10B10 = 35 D3DDDIFORMAT.D3DDDIFMT_A16B16G16R16 = 36 D3DDDIFORMAT.D3DDDIFMT_A8P8 = 40 D3DDDIFORMAT.D3DDDIFMT_P8 = 41 D3DDDIFORMAT.D3DDDIFMT_L8 = 50 D3DDDIFORMAT.D3DDDIFMT_A8L8 = 51 D3DDDIFORMAT.D3DDDIFMT_A4L4 = 52 D3DDDIFORMAT.D3DDDIFMT_V8U8 = 60 D3DDDIFORMAT.D3DDDIFMT_L6V5U5 = 61 D3DDDIFORMAT.D3DDDIFMT_X8L8V8U8 = 62 D3DDDIFORMAT.D3DDDIFMT_Q8W8V8U8 = 63 D3DDDIFORMAT.D3DDDIFMT_V16U16 = 64 D3DDDIFORMAT.D3DDDIFMT_W11V11U10 = 65 D3DDDIFORMAT.D3DDDIFMT_A2W10V10U10 = 67 D3DDDIFORMAT.D3DDDIFMT_UYVY = 1498831189 D3DDDIFORMAT.D3DDDIFMT_R8G8_B8G8 = 1195525970 D3DDDIFORMAT.D3DDDIFMT_YUY2 = 844715353 D3DDDIFORMAT.D3DDDIFMT_G8R8_G8B8 = 1111970375 D3DDDIFORMAT.D3DDDIFMT_DXT1 = 827611204 D3DDDIFORMAT.D3DDDIFMT_DXT2 = 844388420 D3DDDIFORMAT.D3DDDIFMT_DXT3 = 861165636 D3DDDIFORMAT.D3DDDIFMT_DXT4 = 877942852 D3DDDIFORMAT.D3DDDIFMT_DXT5 = 894720068 D3DDDIFORMAT.D3DDDIFMT_D16_LOCKABLE = 70 D3DDDIFORMAT.D3DDDIFMT_D32 = 71 D3DDDIFORMAT.D3DDDIFMT_D15S1 = 73 D3DDDIFORMAT.D3DDDIFMT_D24S8 = 75 D3DDDIFORMAT.D3DDDIFMT_D24X8 = 77 D3DDDIFORMAT.D3DDDIFMT_D24X4S4 = 79 D3DDDIFORMAT.D3DDDIFMT_D16 = 80 D3DDDIFORMAT.D3DDDIFMT_D32F_LOCKABLE = 82 D3DDDIFORMAT.D3DDDIFMT_D24FS8 = 83 D3DDDIFORMAT.D3DDDIFMT_D32_LOCKABLE = 84 D3DDDIFORMAT.D3DDDIFMT_S8_LOCKABLE = 85 D3DDDIFORMAT.D3DDDIFMT_S1D15 = 72 D3DDDIFORMAT.D3DDDIFMT_S8D24 = 74 D3DDDIFORMAT.D3DDDIFMT_X8D24 = 76 D3DDDIFORMAT.D3DDDIFMT_X4S4D24 = 78 D3DDDIFORMAT.D3DDDIFMT_L16 = 81 D3DDDIFORMAT.D3DDDIFMT_VERTEXDATA = 100 D3DDDIFORMAT.D3DDDIFMT_INDEX16 = 101 D3DDDIFORMAT.D3DDDIFMT_INDEX32 = 102 D3DDDIFORMAT.D3DDDIFMT_Q16W16V16U16 = 110 D3DDDIFORMAT.D3DDDIFMT_MULTI2_ARGB8 = 827606349 D3DDDIFORMAT.D3DDDIFMT_R16F = 111 D3DDDIFORMAT.D3DDDIFMT_G16R16F = 112 D3DDDIFORMAT.D3DDDIFMT_A16B16G16R16F = 113 D3DDDIFORMAT.D3DDDIFMT_R32F = 114 D3DDDIFORMAT.D3DDDIFMT_G32R32F = 115 D3DDDIFORMAT.D3DDDIFMT_A32B32G32R32F = 116 D3DDDIFORMAT.D3DDDIFMT_CxV8U8 = 117 D3DDDIFORMAT.D3DDDIFMT_A1 = 118 D3DDDIFORMAT.D3DDDIFMT_A2B10G10R10_XR_BIAS = 119 D3DDDIFORMAT.D3DDDIFMT_DXVACOMPBUFFER_BASE = 150 D3DDDIFORMAT.D3DDDIFMT_PICTUREPARAMSDATA = 150 D3DDDIFORMAT.D3DDDIFMT_MACROBLOCKDATA = 151 D3DDDIFORMAT.D3DDDIFMT_RESIDUALDIFFERENCEDATA = 152 D3DDDIFORMAT.D3DDDIFMT_DEBLOCKINGDATA = 153 D3DDDIFORMAT.D3DDDIFMT_INVERSEQUANTIZATIONDATA = 154 D3DDDIFORMAT.D3DDDIFMT_SLICECONTROLDATA = 155 D3DDDIFORMAT.D3DDDIFMT_BITSTREAMDATA = 156 D3DDDIFORMAT.D3DDDIFMT_MOTIONVECTORBUFFER = 157 D3DDDIFORMAT.D3DDDIFMT_FILMGRAINBUFFER = 158 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED9 = 159 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED10 = 160 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED11 = 161 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED12 = 162 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED13 = 163 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED14 = 164 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED15 = 165 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED16 = 166 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED17 = 167 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED18 = 168 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED19 = 169 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED20 = 170 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED21 = 171 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED22 = 172 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED23 = 173 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED24 = 174 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED25 = 175 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED26 = 176 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED27 = 177 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED28 = 178 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED29 = 179 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED30 = 180 D3DDDIFORMAT.D3DDDIFMT_DXVA_RESERVED31 = 181 D3DDDIFORMAT.D3DDDIFMT_DXVACOMPBUFFER_MAX = 181 D3DDDIFORMAT.D3DDDIFMT_BINARYBUFFER = 199 D3DDDIFORMAT.D3DDDIFMT_FORCE_UINT = 2147483647 D3DKMDT_MONITOR_TIMING_TYPE = v_enum() D3DKMDT_MONITOR_TIMING_TYPE.D3DKMDT_MTT_UNINITIALIZED = 0 D3DKMDT_MONITOR_TIMING_TYPE.D3DKMDT_MTT_ESTABLISHED = 1 D3DKMDT_MONITOR_TIMING_TYPE.D3DKMDT_MTT_STANDARD = 2 D3DKMDT_MONITOR_TIMING_TYPE.D3DKMDT_MTT_EXTRASTANDARD = 3 D3DKMDT_MONITOR_TIMING_TYPE.D3DKMDT_MTT_DETAILED = 4 D3DKMDT_MONITOR_TIMING_TYPE.D3DKMDT_MTT_DEFAULTMONITORPROFILE = 5 D3DKMDT_MONITOR_TIMING_TYPE.D3DKMDT_MTT_DRIVER = 6 D3DKMDT_MONITOR_TIMING_TYPE.D3DKMDT_MTT_MAXVALID = 6 MEMORY_CACHING_TYPE_ORIG = v_enum() MEMORY_CACHING_TYPE_ORIG.MmFrameBufferCached = 2 DEVICE_TEXT_TYPE = v_enum() DEVICE_TEXT_TYPE.DeviceTextDescription = 0 DEVICE_TEXT_TYPE.DeviceTextLocationInformation = 1 POWER_ACTION = v_enum() POWER_ACTION.PowerActionNone = 0 POWER_ACTION.PowerActionReserved = 1 POWER_ACTION.PowerActionSleep = 2 POWER_ACTION.PowerActionHibernate = 3 POWER_ACTION.PowerActionShutdown = 4 POWER_ACTION.PowerActionShutdownReset = 5 POWER_ACTION.PowerActionShutdownOff = 6 POWER_ACTION.PowerActionWarmEject = 7 D3DKMDT_MONITOR_DESCRIPTOR_TYPE = v_enum() D3DKMDT_MONITOR_DESCRIPTOR_TYPE.D3DKMDT_MDT_UNINITIALIZED = 0 D3DKMDT_MONITOR_DESCRIPTOR_TYPE.D3DKMDT_MDT_VESA_EDID_V1_BASEBLOCK = 1 D3DKMDT_MONITOR_DESCRIPTOR_TYPE.D3DKMDT_MDT_VESA_EDID_V1_BLOCKMAP = 2 D3DKMDT_MONITOR_DESCRIPTOR_TYPE.D3DKMDT_MDT_OTHER = 255 SM_RANGE_TYPES = v_enum() SM_RANGE_TYPES.SmRangeSharedInfo = 0 SM_RANGE_TYPES.SmRangeNonSharedInfo = 1 SM_RANGE_TYPES.SmRangeBool = 2 WINDOWCOMPOSITIONATTRIB = v_enum() WINDOWCOMPOSITIONATTRIB.WCA_UNDEFINED = 0 WINDOWCOMPOSITIONATTRIB.WCA_NCRENDERING_ENABLED = 1 WINDOWCOMPOSITIONATTRIB.WCA_NCRENDERING_POLICY = 2 WINDOWCOMPOSITIONATTRIB.WCA_TRANSITIONS_FORCEDISABLED = 3 WINDOWCOMPOSITIONATTRIB.WCA_ALLOW_NCPAINT = 4 WINDOWCOMPOSITIONATTRIB.WCA_CAPTION_BUTTON_BOUNDS = 5 WINDOWCOMPOSITIONATTRIB.WCA_NONCLIENT_RTL_LAYOUT = 6 WINDOWCOMPOSITIONATTRIB.WCA_FORCE_ICONIC_REPRESENTATION = 7 WINDOWCOMPOSITIONATTRIB.WCA_FLIP3D_POLICY = 8 WINDOWCOMPOSITIONATTRIB.WCA_EXTENDED_FRAME_BOUNDS = 9 WINDOWCOMPOSITIONATTRIB.WCA_HAS_ICONIC_BITMAP = 10 WINDOWCOMPOSITIONATTRIB.WCA_THEME_ATTRIBUTES = 11 WINDOWCOMPOSITIONATTRIB.WCA_NCRENDERING_EXILED = 12 WINDOWCOMPOSITIONATTRIB.WCA_NCADORNMENTINFO = 13 WINDOWCOMPOSITIONATTRIB.WCA_EXCLUDED_FROM_LIVEPREVIEW = 14 WINDOWCOMPOSITIONATTRIB.WCA_VIDEO_OVERLAY_ACTIVE = 15 WINDOWCOMPOSITIONATTRIB.WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 16 WINDOWCOMPOSITIONATTRIB.WCA_DISALLOW_PEEK = 17 WINDOWCOMPOSITIONATTRIB.WCA_LAST = 18 class tagTOUCHINPUTINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.head = THROBJHEAD() self.dwcInputs = v_uint32() self.uFlags = v_uint32() self.TouchInput = vstruct.VArray([ tagTOUCHINPUT() for i in xrange(1) ]) class tagHOOK(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.head = THRDESKHEAD() self.phkNext = v_ptr32() self.iHook = v_uint32() self.offPfn = v_uint32() self.flags = v_uint32() self.ihmod = v_uint32() self.ptiHooked = v_ptr32() self.rpdesk = v_ptr32() self.nTimeout = v_uint32() class VK_TO_WCHAR_TABLE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pVkToWchars = v_ptr32() self.nModifications = v_uint8() self.cbSize = v_uint8() self._pad0008 = v_bytes(size=2) class D3DKMDT_2DREGION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.cx = v_uint32() self.cy = v_uint32() class DEADKEY(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.dwBoth = v_uint32() self.wchComposed = v_uint16() self.uFlags = v_uint16() class CURDIR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.DosPath = UNICODE_STRING() self.Handle = v_ptr32() class tagPROPLIST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.cEntries = v_uint32() self.iFirstFree = v_uint32() self.aprop = vstruct.VArray([ tagPROP() for i in xrange(1) ]) class tagDESKTOPINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pvDesktopBase = v_ptr32() self.pvDesktopLimit = v_ptr32() self.spwnd = v_ptr32() self.fsHooks = v_uint32() self.aphkStart = vstruct.VArray([ v_ptr32() for i in xrange(16) ]) self.spwndShell = v_ptr32() self.ppiShellProcess = v_ptr32() self.spwndBkGnd = v_ptr32() self.spwndTaskman = v_ptr32() self.spwndProgman = v_ptr32() self.pvwplShellHook = v_ptr32() self.cntMBox = v_uint32() self.spwndGestureEngine = v_ptr32() self.pvwplMessagePPHandler = v_ptr32() self.fComposited = v_uint32() class _unnamed_12849(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.PowerSequence = v_ptr32() class WHEA_ERROR_RECORD_SECTION_DESCRIPTOR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SectionOffset = v_uint32() self.SectionLength = v_uint32() self.Revision = WHEA_REVISION() self.ValidBits = WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_VALIDBITS() self.Reserved = v_uint8() self.Flags = WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_FLAGS() self.SectionType = GUID() self.FRUId = GUID() self.SectionSeverity = v_uint32() self.FRUText = vstruct.VArray([ v_uint8() for i in xrange(20) ]) class VK_TO_FUNCTION_TABLE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Vk = v_uint8() self.NLSFEProcType = v_uint8() self.NLSFEProcCurrent = v_uint8() self.NLSFEProcSwitch = v_uint8() self.NLSFEProc = vstruct.VArray([ VK_FUNCTION_PARAM() for i in xrange(8) ]) self.NLSFEProcAlt = vstruct.VArray([ VK_FUNCTION_PARAM() for i in xrange(8) ]) class tagTHREADINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pEThread = v_ptr32() self.RefCount = v_uint32() self.ptlW32 = v_ptr32() self.pgdiDcattr = v_ptr32() self.pgdiBrushAttr = v_ptr32() self.pUMPDObjs = v_ptr32() self.pUMPDHeap = v_ptr32() self.pUMPDObj = v_ptr32() self.GdiTmpTgoList = LIST_ENTRY() self.pRBRecursionCount = v_uint32() self.pNonRBRecursionCount = v_uint32() self.tlSpriteState = TLSPRITESTATE() self.pSpriteState = v_ptr32() self.pDevHTInfo = v_ptr32() self.ulDevHTInfoUniqueness = v_uint32() self.pdcoAA = v_ptr32() self.pdcoRender = v_ptr32() self.pdcoSrc = v_ptr32() self.bEnableEngUpdateDeviceSurface = v_uint8() self.bIncludeSprites = v_uint8() self._pad00ac = v_bytes(size=2) self.ulWindowSystemRendering = v_uint32() self.iVisRgnUniqueness = v_uint32() self.ptl = v_ptr32() self.ppi = v_ptr32() self.pq = v_ptr32() self.spklActive = v_ptr32() self.pcti = v_ptr32() self.rpdesk = v_ptr32() self.pDeskInfo = v_ptr32() self.ulClientDelta = v_uint32() self.pClientInfo = v_ptr32() self.TIF_flags = v_uint32() self.pstrAppName = v_ptr32() self.psmsSent = v_ptr32() self.psmsCurrent = v_ptr32() self.psmsReceiveList = v_ptr32() self.timeLast = v_uint32() self.idLast = v_uint32() self.exitCode = v_uint32() self.hdesk = v_ptr32() self.cPaintsReady = v_uint32() self.cTimersReady = v_uint32() self.pMenuState = v_ptr32() self.ptdb = v_ptr32() self.psiiList = v_ptr32() self.dwExpWinVer = v_uint32() self.dwCompatFlags = v_uint32() self.dwCompatFlags2 = v_uint32() self._pad0120 = v_bytes(size=4) self.pqAttach = v_ptr32() self.ptiSibling = v_ptr32() self.pmsd = v_ptr32() self.fsHooks = v_uint32() self.sphkCurrent = v_ptr32() self.lParamHkCurrent = v_uint32() self.wParamHkCurrent = v_uint32() self.pSBTrack = v_ptr32() self.hEventQueueClient = v_ptr32() self.pEventQueueServer = v_ptr32() self.PtiLink = LIST_ENTRY() self.iCursorLevel = v_uint32() self.ptLast = tagPOINT() self.ptLastReal = tagPOINT() self.spwndDefaultIme = v_ptr32() self.spDefaultImc = v_ptr32() self.hklPrev = v_ptr32() self.cEnterCount = v_uint32() self.mlPost = tagMLIST() self.fsChangeBitsRemoved = v_uint16() self.wchInjected = v_uint16() self.fsReserveKeys = v_uint32() self.apEvent = v_ptr32() self.amdesk = v_uint32() self.cWindows = v_uint32() self.cVisWindows = v_uint32() self.aphkStart = vstruct.VArray([ v_ptr32() for i in xrange(16) ]) self.cti = tagCLIENTTHREADINFO() self.hPrevHidData = v_ptr32() self.hTouchInputCurrent = v_ptr32() self.hGestureInfoCurrent = v_ptr32() self.MsgPPInfo = tagMSGPPINFO() self.cNestedStableVisRgn = v_uint32() self.readyHead = LIST_ENTRY() self.fSpecialInitialization = v_uint32() class _unnamed_12843(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.PowerState = v_uint32() class D3DKMDT_VIDEO_SIGNAL_INFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.VideoStandard = v_uint32() self.TotalSize = D3DKMDT_2DREGION() self.ActiveSize = D3DKMDT_2DREGION() self.VSyncFreq = D3DDDI_RATIONAL() self.HSyncFreq = D3DDDI_RATIONAL() self.PixelRate = v_uint32() self.ScanLineOrdering = v_uint32() class CM_PARTIAL_RESOURCE_LIST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Version = v_uint16() self.Revision = v_uint16() self.Count = v_uint32() self.PartialDescriptors = vstruct.VArray([ CM_PARTIAL_RESOURCE_DESCRIPTOR() for i in xrange(1) ]) class HGESTUREINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class DEVICE_CAPABILITIES(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Size = v_uint16() self.Version = v_uint16() self.DeviceD1 = v_uint32() self.Address = v_uint32() self.UINumber = v_uint32() self.DeviceState = vstruct.VArray([ DEVICE_POWER_STATE() for i in xrange(7) ]) self.SystemWake = v_uint32() self.DeviceWake = v_uint32() self.D1Latency = v_uint32() self.D2Latency = v_uint32() self.D3Latency = v_uint32() class TP_DIRECT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Callback = v_ptr32() self.NumaNode = v_uint32() self.IdealProcessor = v_uint8() self._pad000c = v_bytes(size=3) class tagMONITOR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.head = HEAD() self.pMonitorNext = v_ptr32() self.dwMONFlags = v_uint32() self.rcMonitorReal = tagRECT() self.rcWorkReal = tagRECT() self.hrgnMonitorReal = v_ptr32() self.Spare0 = v_uint16() self.cWndStack = v_uint16() self.hDev = v_ptr32() self.hDevReal = v_ptr32() self.DockTargets = vstruct.VArray([ v_uint32() for i in xrange(7) ]) self.Flink = v_ptr32() self.Blink = v_ptr32() class _unnamed_12410(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.UserApcRoutine = v_ptr32() self.UserApcContext = v_ptr32() class _unnamed_12558(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SecurityContext = v_ptr32() self.Options = v_uint32() self.FileAttributes = v_uint16() self.ShareAccess = v_uint16() self.EaLength = v_uint32() class _unnamed_12735(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint32() class KPROCESS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class DEVICE_OBJECT_POWER_EXTENSION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class tagTEXTMETRICW(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.tmHeight = v_uint32() self.tmAscent = v_uint32() self.tmDescent = v_uint32() self.tmInternalLeading = v_uint32() self.tmExternalLeading = v_uint32() self.tmAveCharWidth = v_uint32() self.tmMaxCharWidth = v_uint32() self.tmWeight = v_uint32() self.tmOverhang = v_uint32() self.tmDigitizedAspectX = v_uint32() self.tmDigitizedAspectY = v_uint32() self.tmFirstChar = v_uint16() self.tmLastChar = v_uint16() self.tmDefaultChar = v_uint16() self.tmBreakChar = v_uint16() self.tmItalic = v_uint8() self.tmUnderlined = v_uint8() self.tmStruckOut = v_uint8() self.tmPitchAndFamily = v_uint8() self.tmCharSet = v_uint8() self._pad003c = v_bytes(size=3) class WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_FLAGS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Primary = v_uint32() class TP_CALLBACK_ENVIRON_V3(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Version = v_uint32() self.Pool = v_ptr32() self.CleanupGroup = v_ptr32() self.CleanupGroupCancelCallback = v_ptr32() self.RaceDll = v_ptr32() self.ActivationContext = v_ptr32() self.FinalizationCallback = v_ptr32() self.u = _unnamed_11730() self.CallbackPriority = v_uint32() self.Size = v_uint32() class HDESK(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class RTL_ACTIVATION_CONTEXT_STACK_FRAME(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Previous = v_ptr32() self.ActivationContext = v_ptr32() self.Flags = v_uint32() class OBJECT_HANDLE_INFORMATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.HandleAttributes = v_uint32() self.GrantedAccess = v_uint32() class XSTATE_CONFIGURATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.EnabledFeatures = v_uint64() self.Size = v_uint32() self.OptimizedSave = v_uint32() self.Features = vstruct.VArray([ XSTATE_FEATURE() for i in xrange(64) ]) class RTL_AVL_TABLE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.BalancedRoot = RTL_BALANCED_LINKS() self.OrderedPointer = v_ptr32() self.WhichOrderedElement = v_uint32() self.NumberGenericTableElements = v_uint32() self.DepthOfTree = v_uint32() self.RestartKey = v_ptr32() self.DeleteCount = v_uint32() self.CompareRoutine = v_ptr32() self.AllocateRoutine = v_ptr32() self.FreeRoutine = v_ptr32() self.TableContext = v_ptr32() class tagHID_TLC_INFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.link = LIST_ENTRY() self.usUsagePage = v_uint16() self.usUsage = v_uint16() self.cDevices = v_uint32() self.cDirectRequest = v_uint32() self.cUsagePageRequest = v_uint32() self.cExcludeRequest = v_uint32() self.cExcludeOrphaned = v_uint32() class WHEA_ERROR_PACKET_V2(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Signature = v_uint32() self.Version = v_uint32() self.Length = v_uint32() self.Flags = WHEA_ERROR_PACKET_FLAGS() self.ErrorType = v_uint32() self.ErrorSeverity = v_uint32() self.ErrorSourceId = v_uint32() self.ErrorSourceType = v_uint32() self.NotifyType = GUID() self.Context = v_uint64() self.DataFormat = v_uint32() self.Reserved1 = v_uint32() self.DataOffset = v_uint32() self.DataLength = v_uint32() self.PshedDataOffset = v_uint32() self.PshedDataLength = v_uint32() class DXGK_DIAG_HEADER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint32() self.Size = v_uint32() self.LogTimestamp = v_uint64() self.ProcessName = vstruct.VArray([ v_uint8() for i in xrange(16) ]) self.ThreadId = v_uint64() self.Index = v_uint32() self.WdLogIdx = v_uint32() class DMM_VIDPNPATHANDTARGETMODESET_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.PathInfo = D3DKMDT_VIDPN_PRESENT_PATH() self.TargetModeSet = DMM_VIDPNTARGETMODESET_SERIALIZATION() class _unnamed_12744(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.InterfaceType = v_ptr32() self.Size = v_uint16() self.Version = v_uint16() self.Interface = v_ptr32() self.InterfaceSpecificData = v_ptr32() class VK_TO_WCHARS1(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.VirtualKey = v_uint8() self.Attributes = v_uint8() self.wch = vstruct.VArray([ v_uint16() for i in xrange(1) ]) class OWNER_ENTRY(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.OwnerThread = v_uint32() self.IoPriorityBoosted = v_uint32() class DEVOBJ_EXTENSION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint16() self.Size = v_uint16() self.DeviceObject = v_ptr32() self.PowerFlags = v_uint32() self.Dope = v_ptr32() self.ExtensionFlags = v_uint32() self.DeviceNode = v_ptr32() self.AttachedTo = v_ptr32() self.StartIoCount = v_uint32() self.StartIoKey = v_uint32() self.StartIoFlags = v_uint32() self.Vpb = v_ptr32() self.DependentList = LIST_ENTRY() self.ProviderList = LIST_ENTRY() class D3DKMDT_MONITOR_FREQUENCY_RANGE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Origin = v_uint32() self.RangeLimits = D3DKMDT_FREQUENCY_RANGE() self.ConstraintType = v_uint32() self.Constraint = _unnamed_13453() class tagQ(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.mlInput = tagMLIST() self.ptiSysLock = v_ptr32() self.idSysLock = v_uint32() self.idSysPeek = v_uint32() self.ptiMouse = v_ptr32() self.ptiKeyboard = v_ptr32() self.spwndCapture = v_ptr32() self.spwndFocus = v_ptr32() self.spwndActive = v_ptr32() self.spwndActivePrev = v_ptr32() self.codeCapture = v_uint32() self.msgDblClk = v_uint32() self.xbtnDblClk = v_uint16() self._pad003c = v_bytes(size=2) self.timeDblClk = v_uint32() self.hwndDblClk = v_ptr32() self.ptDblClk = tagPOINT() self.ptMouseMove = tagPOINT() self.afKeyRecentDown = vstruct.VArray([ v_uint8() for i in xrange(32) ]) self.afKeyState = vstruct.VArray([ v_uint8() for i in xrange(64) ]) self.caret = tagCARET() self.spcurCurrent = v_ptr32() self.iCursorLevel = v_uint32() self.QF_flags = v_uint32() self.cThreads = v_uint16() self.cLockCount = v_uint16() self.msgJournal = v_uint32() self.ExtraInfo = v_uint32() self.ulEtwReserved1 = v_uint32() class tagCLS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pclsNext = v_ptr32() self.atomClassName = v_uint16() self.atomNVClassName = v_uint16() self.fnid = v_uint16() self._pad000c = v_bytes(size=2) self.rpdeskParent = v_ptr32() self.pdce = v_ptr32() self.hTaskWow = v_uint16() self.CSF_flags = v_uint16() self.lpszClientAnsiMenuName = v_ptr32() self.lpszClientUnicodeMenuName = v_ptr32() self.spcpdFirst = v_ptr32() self.pclsBase = v_ptr32() self.pclsClone = v_ptr32() self.cWndReferenceCount = v_uint32() self.style = v_uint32() self.lpfnWndProc = v_ptr32() self.cbclsExtra = v_uint32() self.cbwndExtra = v_uint32() self.hModule = v_ptr32() self.spicn = v_ptr32() self.spcur = v_ptr32() self.hbrBackground = v_ptr32() self.lpszMenuName = v_ptr32() self.lpszAnsiClassName = v_ptr32() self.spicnSm = v_ptr32() class CALLPROCDATA(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.head = PROCDESKHEAD() self.spcpdNext = v_ptr32() self.pfnClientPrevious = v_uint32() self.wType = v_uint16() self._pad0020 = v_bytes(size=2) class WM_VALUES_STRINGS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pszName = v_ptr32() self.fInternal = v_uint8() self.fDefined = v_uint8() self._pad0008 = v_bytes(size=2) class _unnamed_16080(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Channel = v_uint32() self.Port = v_uint32() self.Reserved1 = v_uint32() class HIMC(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class _unnamed_16086(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Start = v_uint32() self.Length = v_uint32() self.Reserved = v_uint32() class LARGE_UNICODE_STRING(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.MaximumLength = v_uint32() self.Buffer = v_ptr32() class ACCESS_STATE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.OperationID = LUID() self.SecurityEvaluated = v_uint8() self.GenerateAudit = v_uint8() self.GenerateOnClose = v_uint8() self.PrivilegesAllocated = v_uint8() self.Flags = v_uint32() self.RemainingDesiredAccess = v_uint32() self.PreviouslyGrantedAccess = v_uint32() self.OriginalDesiredAccess = v_uint32() self.SubjectSecurityContext = SECURITY_SUBJECT_CONTEXT() self.SecurityDescriptor = v_ptr32() self.AuxData = v_ptr32() self.Privileges = _unnamed_13037() self.AuditPrivileges = v_uint8() self._pad0064 = v_bytes(size=3) self.ObjectName = UNICODE_STRING() self.ObjectTypeName = UNICODE_STRING() class TP_CALLBACK_INSTANCE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class tagRECT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.left = v_uint32() self.top = v_uint32() self.right = v_uint32() self.bottom = v_uint32() class GDI_TEB_BATCH(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Offset = v_uint32() self.HDC = v_uint32() self.Buffer = vstruct.VArray([ v_uint32() for i in xrange(310) ]) class _unnamed_16100(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Start = LARGE_INTEGER() self.Length64 = v_uint32() class ECP_LIST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class tagMENUSTATE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pGlobalPopupMenu = v_ptr32() self.fMenuStarted = v_uint32() self.ptMouseLast = tagPOINT() self.mnFocus = v_uint32() self.cmdLast = v_uint32() self.ptiMenuStateOwner = v_ptr32() self.dwLockCount = v_uint32() self.pmnsPrev = v_ptr32() self.ptButtonDown = tagPOINT() self.uButtonDownHitArea = v_uint32() self.uButtonDownIndex = v_uint32() self.vkButtonDown = v_uint32() self.uDraggingHitArea = v_uint32() self.uDraggingIndex = v_uint32() self.uDraggingFlags = v_uint32() self.hdcWndAni = v_ptr32() self.dwAniStartTime = v_uint32() self.ixAni = v_uint32() self.iyAni = v_uint32() self.cxAni = v_uint32() self.cyAni = v_uint32() self.hbmAni = v_ptr32() self.hdcAni = v_ptr32() class SECTION_OBJECT_POINTERS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.DataSectionObject = v_ptr32() self.SharedCacheMap = v_ptr32() self.ImageSectionObject = v_ptr32() class MDL(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Next = v_ptr32() self.Size = v_uint16() self.MdlFlags = v_uint16() self.Process = v_ptr32() self.MappedSystemVa = v_ptr32() self.StartVa = v_ptr32() self.ByteCount = v_uint32() self.ByteOffset = v_uint32() class tagMSGPPINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.dwIndexMsgPP = v_uint32() class VWPLELEMENT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.DataOrTag = v_uint32() self.pwnd = v_ptr32() class IO_TIMER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class VSC_VK(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Vsc = v_uint8() self._pad0002 = v_bytes(size=1) self.Vk = v_uint16() class WHEA_REVISION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.MinorRevision = v_uint8() self.MajorRevision = v_uint8() class MAGNIFICATION_INPUT_TRANSFORM(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.rcSource = tagRECT() self.rcScreen = tagRECT() self.ptiMagThreadInfo = v_ptr32() self.magFactorX = v_uint32() self.magFactorY = v_uint32() class TP_CLEANUP_GROUP(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class DMM_VIDPNPATHANDTARGETMODE_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.PathInfo = D3DKMDT_VIDPN_PRESENT_PATH() self.TargetMode = D3DKMDT_VIDPN_TARGET_MODE() class D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_SUPPORT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.NoProtection = v_uint32() class D3DDDI_DXGI_RGB(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Red = v_uint32() self.Green = v_uint32() self.Blue = v_uint32() class OBJECT_TYPE_INITIALIZER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint16() self.ObjectTypeFlags = v_uint8() self._pad0004 = v_bytes(size=1) self.ObjectTypeCode = v_uint32() self.InvalidAttributes = v_uint32() self.GenericMapping = GENERIC_MAPPING() self.ValidAccessMask = v_uint32() self.RetainAccess = v_uint32() self.PoolType = v_uint32() self.DefaultPagedPoolCharge = v_uint32() self.DefaultNonPagedPoolCharge = v_uint32() self.DumpProcedure = v_ptr32() self.OpenProcedure = v_ptr32() self.CloseProcedure = v_ptr32() self.DeleteProcedure = v_ptr32() self.ParseProcedure = v_ptr32() self.SecurityProcedure = v_ptr32() self.QueryNameProcedure = v_ptr32() self.OkayToCloseProcedure = v_ptr32() class MOVESIZEDATA(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.spwnd = v_ptr32() self.rcDrag = tagRECT() self.rcDragCursor = tagRECT() self.rcPreview = tagRECT() self.rcPreviewCursor = tagRECT() self.rcParent = tagRECT() self.ptMinTrack = tagPOINT() self.ptMaxTrack = tagPOINT() self.rcWindow = tagRECT() self.rcNormalStartCheckPt = tagRECT() self.dxMouse = v_uint32() self.dyMouse = v_uint32() self.cmd = v_uint32() self.impx = v_uint32() self.impy = v_uint32() self.ptRestore = tagPOINT() self.Flags = v_uint32() self.pStartMonitorCurrentHitTarget = v_ptr32() self.StartCurrentHitTarget = v_uint32() self.pMonitorCurrentHitTarget = v_ptr32() self.CurrentHitTarget = v_uint32() self.MoveRectStyle = v_uint32() self.ptHitWindowRelative = tagPOINT() self.ptStartHitWindowRelative = tagPOINT() self.ptLastTrack = tagPOINT() self.ulCountDragOutOfTopTarget = v_uint32() self.ulCountDragOutOfLeftRightTarget = v_uint32() self.ulCountSizeOutOfTopBottomTarget = v_uint32() class SCSI_REQUEST_BLOCK(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class _unnamed_16620(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length64 = v_uint32() self.Alignment64 = v_uint32() self.MinimumAddress = LARGE_INTEGER() self.MaximumAddress = LARGE_INTEGER() class TLSPRITESTATE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.bInsideDriverCall = v_uint8() self._pad0004 = v_bytes(size=3) self.flOriginalSurfFlags = v_uint32() self.iOriginalType = v_uint32() self.flSpriteSurfFlags = v_uint32() self.iSpriteType = v_uint32() self.flags = v_uint32() self.iType = v_uint32() self.pState = v_ptr32() self.pfnStrokeAndFillPath = v_ptr32() self.pfnStrokePath = v_ptr32() self.pfnFillPath = v_ptr32() self.pfnPaint = v_ptr32() self.pfnBitBlt = v_ptr32() self.pfnCopyBits = v_ptr32() self.pfnStretchBlt = v_ptr32() self.pfnTextOut = v_ptr32() self.pfnLineTo = v_ptr32() self.pfnTransparentBlt = v_ptr32() self.pfnAlphaBlend = v_ptr32() self.pfnPlgBlt = v_ptr32() self.pfnGradientFill = v_ptr32() self.pfnSaveScreenBits = v_ptr32() self.pfnStretchBltROP = v_ptr32() self.pfnDrawStream = v_ptr32() class _unnamed_15886(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pRgb256x3x16 = v_ptr32() class tagQMSG(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pqmsgNext = v_ptr32() self.pqmsgPrev = v_ptr32() self.msg = tagMSG() self.ExtraInfo = v_uint32() self.ptMouseReal = tagPOINT() self.dwQEvent = v_uint32() self.Wow64Message = v_uint32() self.pti = v_ptr32() self.MsgPPInfo = tagMSGPPINFO() class PAGED_LOOKASIDE_LIST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.L = GENERAL_LOOKASIDE() self.Lock__ObsoleteButDoNotDelete = FAST_MUTEX() class RTL_BITMAP(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SizeOfBitMap = v_uint32() self.Buffer = v_ptr32() class LARGE_INTEGER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.LowPart = v_uint32() self.HighPart = v_uint32() class HICON(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class NPAGED_LOOKASIDE_LIST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.L = GENERAL_LOOKASIDE() self.Lock__ObsoleteButDoNotDelete = v_uint32() self._pad0050 = v_bytes(size=4) class _unnamed_12830(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.InPath = v_uint8() self.Reserved = vstruct.VArray([ v_uint8() for i in xrange(3) ]) self.Type = v_uint32() class tagWin32PoolHead(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.size = v_uint32() self.pPrev = v_ptr32() self.pNext = v_ptr32() self.pTrace = v_ptr32() class _unnamed_12686(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.FsInformationClass = v_uint32() class VPB(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint16() self.Size = v_uint16() self.Flags = v_uint16() self.VolumeLabelLength = v_uint16() self.DeviceObject = v_ptr32() self.RealDevice = v_ptr32() self.SerialNumber = v_uint32() self.ReferenceCount = v_uint32() self.VolumeLabel = vstruct.VArray([ v_uint16() for i in xrange(32) ]) class _unnamed_12689(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.OutputBufferLength = v_uint32() self.InputBufferLength = v_uint32() self.FsControlCode = v_uint32() self.Type3InputBuffer = v_ptr32() class HEAD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.h = v_ptr32() self.cLockObj = v_uint32() class OBJECT_NAME_INFORMATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Name = UNICODE_STRING() class IO_RESOURCE_LIST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Version = v_uint16() self.Revision = v_uint16() self.Count = v_uint32() self.Descriptors = vstruct.VArray([ IO_RESOURCE_DESCRIPTOR() for i in xrange(1) ]) class KUSER_SHARED_DATA(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.TickCountLowDeprecated = v_uint32() self.TickCountMultiplier = v_uint32() self.InterruptTime = KSYSTEM_TIME() self.SystemTime = KSYSTEM_TIME() self.TimeZoneBias = KSYSTEM_TIME() self.ImageNumberLow = v_uint16() self.ImageNumberHigh = v_uint16() self.NtSystemRoot = vstruct.VArray([ v_uint16() for i in xrange(260) ]) self.MaxStackTraceDepth = v_uint32() self.CryptoExponent = v_uint32() self.TimeZoneId = v_uint32() self.LargePageMinimum = v_uint32() self.Reserved2 = vstruct.VArray([ v_uint32() for i in xrange(7) ]) self.NtProductType = v_uint32() self.ProductTypeIsValid = v_uint8() self._pad026c = v_bytes(size=3) self.NtMajorVersion = v_uint32() self.NtMinorVersion = v_uint32() self.ProcessorFeatures = vstruct.VArray([ v_uint8() for i in xrange(64) ]) self.Reserved1 = v_uint32() self.Reserved3 = v_uint32() self.TimeSlip = v_uint32() self.AlternativeArchitecture = v_uint32() self.AltArchitecturePad = vstruct.VArray([ v_uint32() for i in xrange(1) ]) self.SystemExpirationDate = LARGE_INTEGER() self.SuiteMask = v_uint32() self.KdDebuggerEnabled = v_uint8() self.NXSupportPolicy = v_uint8() self._pad02d8 = v_bytes(size=2) self.ActiveConsoleId = v_uint32() self.DismountCount = v_uint32() self.ComPlusPackage = v_uint32() self.LastSystemRITEventTickCount = v_uint32() self.NumberOfPhysicalPages = v_uint32() self.SafeBootMode = v_uint8() self.TscQpcData = v_uint8() self.TscQpcPad = vstruct.VArray([ v_uint8() for i in xrange(2) ]) self.SharedDataFlags = v_uint32() self.DataFlagsPad = vstruct.VArray([ v_uint32() for i in xrange(1) ]) self.TestRetInstruction = v_uint64() self.SystemCall = v_uint32() self.SystemCallReturn = v_uint32() self.SystemCallPad = vstruct.VArray([ v_uint64() for i in xrange(3) ]) self.TickCount = KSYSTEM_TIME() self.TickCountPad = vstruct.VArray([ v_uint32() for i in xrange(1) ]) self.Cookie = v_uint32() self.CookiePad = vstruct.VArray([ v_uint32() for i in xrange(1) ]) self.ConsoleSessionForegroundProcessId = v_uint64() self.Wow64SharedInformation = vstruct.VArray([ v_uint32() for i in xrange(16) ]) self.UserModeGlobalLogger = vstruct.VArray([ v_uint16() for i in xrange(16) ]) self.ImageFileExecutionOptions = v_uint32() self.LangGenerationCount = v_uint32() self.Reserved5 = v_uint64() self.InterruptTimeBias = v_uint64() self.TscQpcBias = v_uint64() self.ActiveProcessorCount = v_uint32() self.ActiveGroupCount = v_uint16() self.Reserved4 = v_uint16() self.AitSamplingValue = v_uint32() self.AppCompatFlag = v_uint32() self.SystemDllNativeRelocation = v_uint64() self.SystemDllWowRelocation = v_uint32() self.XStatePad = vstruct.VArray([ v_uint32() for i in xrange(1) ]) self.XState = XSTATE_CONFIGURATION() class SYSTEM_POWER_STATE_CONTEXT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Reserved1 = v_uint32() class _unnamed_12707(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SecurityInformation = v_uint32() self.SecurityDescriptor = v_ptr32() class _unnamed_12704(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SecurityInformation = v_uint32() self.Length = v_uint32() class IO_STATUS_BLOCK(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Status = v_uint32() self.Information = v_uint32() class PRIVILEGE_SET(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.PrivilegeCount = v_uint32() self.Control = v_uint32() self.Privilege = vstruct.VArray([ LUID_AND_ATTRIBUTES() for i in xrange(1) ]) class CM_RESOURCE_LIST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Count = v_uint32() self.List = vstruct.VArray([ CM_FULL_RESOURCE_DESCRIPTOR() for i in xrange(1) ]) class _unnamed_12666(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.FileInformationClass = v_uint32() self.FileObject = v_ptr32() self.ReplaceIfExists = v_uint8() self.AdvanceOnly = v_uint8() self._pad0010 = v_bytes(size=2) class EPROCESS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class _unnamed_12660(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.CompletionFilter = v_uint32() class _unnamed_12663(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.FileInformationClass = v_uint32() class tagPROFILEVALUEINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.dwValue = v_uint32() self.uSection = v_uint32() self.pwszKeyName = v_ptr32() class TP_TASK(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Callbacks = v_ptr32() self.NumaNode = v_uint32() self.IdealProcessor = v_uint8() self._pad000c = v_bytes(size=3) self.PostGuard = TP_NBQ_GUARD() self.NBQNode = v_ptr32() class TEB_ACTIVE_FRAME_CONTEXT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Flags = v_uint32() self.FrameName = v_ptr32() class PFNCLIENTWORKER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pfnButtonWndProc = v_ptr32() self.pfnComboBoxWndProc = v_ptr32() self.pfnComboListBoxProc = v_ptr32() self.pfnDialogWndProc = v_ptr32() self.pfnEditWndProc = v_ptr32() self.pfnListBoxWndProc = v_ptr32() self.pfnMDIClientWndProc = v_ptr32() self.pfnStaticWndProc = v_ptr32() self.pfnImeWndProc = v_ptr32() self.pfnGhostWndProc = v_ptr32() self.pfnCtfHookProc = v_ptr32() class DMM_COMMITVIDPNREQUESTSET_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.NumCommitVidPnRequests = v_uint8() self._pad0004 = v_bytes(size=3) self.CommitVidPnRequestOffset = vstruct.VArray([ v_uint32() for i in xrange(1) ]) class D3DKMDT_MONITOR_SOURCE_MODE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Id = v_uint32() self.VideoSignalInfo = D3DKMDT_VIDEO_SIGNAL_INFO() self.ColorBasis = v_uint32() self.ColorCoeffDynamicRanges = D3DKMDT_COLOR_COEFF_DYNAMIC_RANGES() self.Origin = v_uint32() self.Preference = v_uint32() class tagDISPLAYINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.hDev = v_ptr32() self.pmdev = v_ptr32() self.hDevInfo = v_ptr32() self.hdcScreen = v_ptr32() self.hdcBits = v_ptr32() self.hdcGray = v_ptr32() self.hbmGray = v_ptr32() self.cxGray = v_uint32() self.cyGray = v_uint32() self.pdceFirst = v_ptr32() self.pspbFirst = v_ptr32() self.cMonitors = v_uint32() self.pMonitorPrimary = v_ptr32() self.pMonitorFirst = v_ptr32() self.rcScreenReal = tagRECT() self.hrgnScreenReal = v_ptr32() self.dmLogPixels = v_uint16() self.BitCountMax = v_uint16() self.fDesktopIsRect = v_uint32() self.DockThresholdMax = v_uint32() self.SpatialListHead = KLIST_ENTRY() self.cFullScreen = v_uint16() self.Spare0 = v_uint16() class CM_PARTIAL_RESOURCE_DESCRIPTOR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint8() self.ShareDisposition = v_uint8() self.Flags = v_uint16() self.u = _unnamed_15793() class _unnamed_13381(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Graphics = D3DKMDT_GRAPHICS_RENDERING_FORMAT() class HRGN(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class OBJECT_ATTRIBUTES(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.RootDirectory = v_ptr32() self.ObjectName = v_ptr32() self.Attributes = v_uint32() self.SecurityDescriptor = v_ptr32() self.SecurityQualityOfService = v_ptr32() class _unnamed_16067(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Level = v_uint16() self.Group = v_uint16() self.Vector = v_uint32() self.Affinity = v_uint32() class CM_FULL_RESOURCE_DESCRIPTOR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.InterfaceType = v_uint32() self.BusNumber = v_uint32() self.PartialResourceList = CM_PARTIAL_RESOURCE_LIST() class _unnamed_16064(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Start = LARGE_INTEGER() self.Length = v_uint32() class FAST_IO_DISPATCH(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SizeOfFastIoDispatch = v_uint32() self.FastIoCheckIfPossible = v_ptr32() self.FastIoRead = v_ptr32() self.FastIoWrite = v_ptr32() self.FastIoQueryBasicInfo = v_ptr32() self.FastIoQueryStandardInfo = v_ptr32() self.FastIoLock = v_ptr32() self.FastIoUnlockSingle = v_ptr32() self.FastIoUnlockAll = v_ptr32() self.FastIoUnlockAllByKey = v_ptr32() self.FastIoDeviceControl = v_ptr32() self.AcquireFileForNtCreateSection = v_ptr32() self.ReleaseFileForNtCreateSection = v_ptr32() self.FastIoDetachDevice = v_ptr32() self.FastIoQueryNetworkOpenInfo = v_ptr32() self.AcquireForModWrite = v_ptr32() self.MdlRead = v_ptr32() self.MdlReadComplete = v_ptr32() self.PrepareMdlWrite = v_ptr32() self.MdlWriteComplete = v_ptr32() self.FastIoReadCompressed = v_ptr32() self.FastIoWriteCompressed = v_ptr32() self.MdlReadCompleteCompressed = v_ptr32() self.MdlWriteCompleteCompressed = v_ptr32() self.FastIoQueryOpen = v_ptr32() self.ReleaseForModWrite = v_ptr32() self.AcquireForCcFlush = v_ptr32() self.ReleaseForCcFlush = v_ptr32() class VSC_LPWSTR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.vsc = v_uint8() self._pad0004 = v_bytes(size=3) self.pwsz = v_ptr32() class _unnamed_12389(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.MasterIrp = v_ptr32() class KFLOATING_SAVE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ControlWord = v_uint32() self.StatusWord = v_uint32() self.ErrorOffset = v_uint32() self.ErrorSelector = v_uint32() self.DataOffset = v_uint32() self.DataSelector = v_uint32() self.Cr0NpxState = v_uint32() self.Spare1 = v_uint32() class RTL_DYNAMIC_HASH_TABLE_CONTEXT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ChainHead = v_ptr32() self.PrevLinkage = v_ptr32() self.Signature = v_uint32() class tagSBDATA(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.posMin = v_uint32() self.posMax = v_uint32() self.page = v_uint32() self.pos = v_uint32() class D3DDDI_GAMMA_RAMP_RGB256x3x16(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Red = vstruct.VArray([ v_uint16() for i in xrange(256) ]) self.Green = vstruct.VArray([ v_uint16() for i in xrange(256) ]) self.Blue = vstruct.VArray([ v_uint16() for i in xrange(256) ]) class tagUAHMENUPOPUPMETRICS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.rgcx = vstruct.VArray([ v_uint32() for i in xrange(4) ]) self.fUpdateMaxWidths = v_uint32() class THROBJHEAD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.h = v_ptr32() self.cLockObj = v_uint32() self.pti = v_ptr32() class DMM_VIDPNTARGETMODESET_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.NumModes = v_uint8() self._pad0004 = v_bytes(size=3) self.ModeSerialization = vstruct.VArray([ D3DKMDT_VIDPN_TARGET_MODE() for i in xrange(1) ]) class KSPECIAL_REGISTERS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Cr0 = v_uint32() self.Cr2 = v_uint32() self.Cr3 = v_uint32() self.Cr4 = v_uint32() self.KernelDr0 = v_uint32() self.KernelDr1 = v_uint32() self.KernelDr2 = v_uint32() self.KernelDr3 = v_uint32() self.KernelDr6 = v_uint32() self.KernelDr7 = v_uint32() self.Gdtr = DESCRIPTOR() self.Idtr = DESCRIPTOR() self.Tr = v_uint16() self.Ldtr = v_uint16() self.Reserved = vstruct.VArray([ v_uint32() for i in xrange(6) ]) class TP_NBQ_GUARD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.GuardLinks = LIST_ENTRY() self.Guards = vstruct.VArray([ v_ptr32() for i in xrange(2) ]) class RTL_CRITICAL_SECTION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.DebugInfo = v_ptr32() self.LockCount = v_uint32() self.RecursionCount = v_uint32() self.OwningThread = v_ptr32() self.LockSemaphore = v_ptr32() self.SpinCount = v_uint32() class KSYSTEM_TIME(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.LowPart = v_uint32() self.High1Time = v_uint32() self.High2Time = v_uint32() class tagTOUCHINPUT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.x = v_uint32() self.y = v_uint32() self.hSource = v_ptr32() self.dwID = v_uint32() self.dwFlags = v_uint32() self.dwMask = v_uint32() self.dwTime = v_uint32() self.dwExtraInfo = v_uint32() self.cxContact = v_uint32() self.cyContact = v_uint32() class WNDMSG(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.maxMsgs = v_uint32() self.abMsgs = v_ptr32() class D3DDDI_RATIONAL(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Numerator = v_uint32() self.Denominator = v_uint32() class LUID_AND_ATTRIBUTES(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Luid = LUID() self.Attributes = v_uint32() class tagSBTRACK(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.fHitOld = v_uint32() self.spwndTrack = v_ptr32() self.spwndSB = v_ptr32() self.spwndSBNotify = v_ptr32() self.rcTrack = tagRECT() self.xxxpfnSB = v_ptr32() self.cmdSB = v_uint32() self.hTimerSB = v_uint32() self.dpxThumb = v_uint32() self.pxOld = v_uint32() self.posOld = v_uint32() self.posNew = v_uint32() self.nBar = v_uint32() self.pSBCalc = v_ptr32() class KPROCESSOR_STATE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ContextFrame = CONTEXT() self.SpecialRegisters = KSPECIAL_REGISTERS() class KTHREAD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class HFONT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class tagDPISERVERINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.gclBorder = v_uint32() self.hCaptionFont = v_ptr32() self.hMsgFont = v_ptr32() self.cxMsgFontChar = v_uint32() self.cyMsgFontChar = v_uint32() self.wMaxBtnSize = v_uint32() class _unnamed_12876(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SystemContext = v_uint32() self.Type = v_uint32() self.State = POWER_STATE() self.ShutdownType = v_uint32() class HDC(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class CONTEXT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ContextFlags = v_uint32() self.Dr0 = v_uint32() self.Dr1 = v_uint32() self.Dr2 = v_uint32() self.Dr3 = v_uint32() self.Dr6 = v_uint32() self.Dr7 = v_uint32() self.FloatSave = FLOATING_SAVE_AREA() self.SegGs = v_uint32() self.SegFs = v_uint32() self.SegEs = v_uint32() self.SegDs = v_uint32() self.Edi = v_uint32() self.Esi = v_uint32() self.Ebx = v_uint32() self.Edx = v_uint32() self.Ecx = v_uint32() self.Eax = v_uint32() self.Ebp = v_uint32() self.Eip = v_uint32() self.SegCs = v_uint32() self.EFlags = v_uint32() self.Esp = v_uint32() self.SegSs = v_uint32() self.ExtendedRegisters = vstruct.VArray([ v_uint8() for i in xrange(512) ]) class AUX_ACCESS_DATA(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.PrivilegesUsed = v_ptr32() self.GenericMapping = GENERIC_MAPPING() self.AccessesToAudit = v_uint32() self.MaximumAuditMask = v_uint32() self.TransactionId = GUID() self.NewSecurityDescriptor = v_ptr32() self.ExistingSecurityDescriptor = v_ptr32() self.ParentSecurityDescriptor = v_ptr32() self.DeRefSecurityDescriptor = v_ptr32() self.SDLock = v_ptr32() self.AccessReasons = ACCESS_REASONS() class LIGATURE1(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.VirtualKey = v_uint8() self._pad0002 = v_bytes(size=1) self.ModificationNumber = v_uint16() self.wch = vstruct.VArray([ v_uint16() for i in xrange(1) ]) class _unnamed_12586(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SecurityContext = v_ptr32() self.Options = v_uint32() self.Reserved = v_uint16() self.ShareAccess = v_uint16() self.Parameters = v_ptr32() class D3DKMDT_VIDPN_PRESENT_PATH_SCALING_SUPPORT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Identity = v_uint32() class EVENT_DATA_DESCRIPTOR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Ptr = v_uint64() self.Size = v_uint32() self.Reserved = v_uint32() class IO_DRIVER_CREATE_CONTEXT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Size = v_uint16() self._pad0004 = v_bytes(size=2) self.ExtraCreateParameter = v_ptr32() self.DeviceObjectHint = v_ptr32() self.TxnParameters = v_ptr32() class D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.CopyProtectionType = v_uint32() self.APSTriggerBits = v_uint32() self.OEMCopyProtection = vstruct.VArray([ v_uint8() for i in xrange(256) ]) self.CopyProtectionSupport = D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION_SUPPORT() class HMONITOR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class EJOB(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class D3DKMDT_GAMMA_RAMP(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint32() self.DataSize = v_uint32() self.Data = _unnamed_15886() class VK_TO_BIT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Vk = v_uint8() self.ModBits = v_uint8() class MODIFIERS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pVkToBit = v_ptr32() self.wMaxModBits = v_uint16() self.ModNumber = vstruct.VArray([ v_uint8() for i in xrange(0) ]) self._pad0008 = v_bytes(size=2) class KAPC(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint8() self.SpareByte0 = v_uint8() self.Size = v_uint8() self.SpareByte1 = v_uint8() self.SpareLong0 = v_uint32() self.Thread = v_ptr32() self.ApcListEntry = LIST_ENTRY() self.KernelRoutine = v_ptr32() self.RundownRoutine = v_ptr32() self.NormalRoutine = v_ptr32() self.NormalContext = v_ptr32() self.SystemArgument1 = v_ptr32() self.SystemArgument2 = v_ptr32() self.ApcStateIndex = v_uint8() self.ApcMode = v_uint8() self.Inserted = v_uint8() self._pad0030 = v_bytes(size=1) class DMM_MONITOR_SOURCE_MODE_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Info = D3DKMDT_MONITOR_SOURCE_MODE() self.TimingType = v_uint32() class tagIMEINFOEX(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.hkl = v_ptr32() self.ImeInfo = tagIMEINFO() self.wszUIClass = vstruct.VArray([ v_uint16() for i in xrange(16) ]) self.fdwInitConvMode = v_uint32() self.fInitOpen = v_uint32() self.fLoadFlag = v_uint32() self.dwProdVersion = v_uint32() self.dwImeWinVersion = v_uint32() self.wszImeDescription = vstruct.VArray([ v_uint16() for i in xrange(50) ]) self.wszImeFile = vstruct.VArray([ v_uint16() for i in xrange(80) ]) self.fSysWow64Only = v_uint32() class tagWND(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.head = THRDESKHEAD() self.state = v_uint32() self.state2 = v_uint32() self.ExStyle = v_uint32() self.style = v_uint32() self.hModule = v_ptr32() self.hMod16 = v_uint16() self.fnid = v_uint16() self.spwndNext = v_ptr32() self.spwndPrev = v_ptr32() self.spwndParent = v_ptr32() self.spwndChild = v_ptr32() self.spwndOwner = v_ptr32() self.rcWindow = tagRECT() self.rcClient = tagRECT() self.lpfnWndProc = v_ptr32() self.pcls = v_ptr32() self.hrgnUpdate = v_ptr32() self.ppropList = v_ptr32() self.pSBInfo = v_ptr32() self.spmenuSys = v_ptr32() self.spmenu = v_ptr32() self.hrgnClip = v_ptr32() self.hrgnNewFrame = v_ptr32() self.strName = LARGE_UNICODE_STRING() self.cbwndExtra = v_uint32() self.spwndLastActive = v_ptr32() self.hImc = v_ptr32() self.dwUserData = v_uint32() self.pActCtx = v_ptr32() self.pTransform = v_ptr32() self.spwndClipboardListenerNext = v_ptr32() self.ExStyle2 = v_uint32() class XSTATE_FEATURE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Offset = v_uint32() self.Size = v_uint32() class _unnamed_12896(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Argument1 = v_ptr32() self.Argument2 = v_ptr32() self.Argument3 = v_ptr32() self.Argument4 = v_ptr32() class D3DDDI_GAMMA_RAMP_DXGI_1(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Scale = D3DDDI_DXGI_RGB() self.Offset = D3DDDI_DXGI_RGB() self.GammaCurve = vstruct.VArray([ D3DDDI_DXGI_RGB() for i in xrange(1025) ]) class WHEA_TIMESTAMP(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Seconds = v_uint64() class ACTIVATION_CONTEXT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class _unnamed_12891(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ProviderId = v_uint32() self.DataPath = v_ptr32() self.BufferSize = v_uint32() self.Buffer = v_ptr32() class tagUAHMENUITEMMETRICS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.rgsizeBar = vstruct.VArray([ tagSIZE() for i in xrange(2) ]) self._pad0020 = v_bytes(size=16) class KLIST_ENTRY(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Flink = v_ptr32() self.Blink = v_ptr32() class RTL_CRITICAL_SECTION_DEBUG(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint16() self.CreatorBackTraceIndex = v_uint16() self.CriticalSection = v_ptr32() self.ProcessLocksList = LIST_ENTRY() self.EntryCount = v_uint32() self.ContentionCount = v_uint32() self.Flags = v_uint32() self.CreatorBackTraceIndexHigh = v_uint16() self.SpareUSHORT = v_uint16() class DISPATCHER_HEADER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint8() self.TimerControlFlags = v_uint8() self.ThreadControlFlags = v_uint8() self.TimerMiscFlags = v_uint8() self.SignalState = v_uint32() self.WaitListHead = LIST_ENTRY() class HBITMAP(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class tagW32JOB(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pNext = v_ptr32() self.Job = v_ptr32() self.pAtomTable = v_ptr32() self.restrictions = v_uint32() self.uProcessCount = v_uint32() self.uMaxProcesses = v_uint32() self.ppiTable = v_ptr32() self.ughCrt = v_uint32() self.ughMax = v_uint32() self.pgh = v_ptr32() class ASSEMBLY_STORAGE_MAP(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class tagMBSTRING(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.szName = vstruct.VArray([ v_uint16() for i in xrange(15) ]) self._pad0020 = v_bytes(size=2) self.uID = v_uint32() self.uStr = v_uint32() class POWER_SEQUENCE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SequenceD1 = v_uint32() self.SequenceD2 = v_uint32() self.SequenceD3 = v_uint32() class DMM_MONITORDESCRIPTOR_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Id = v_uint32() self.Type = v_uint32() self.Origin = v_uint32() self.Data = vstruct.VArray([ v_uint8() for i in xrange(128) ]) class DESCRIPTOR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Pad = v_uint16() self.Limit = v_uint16() self.Base = v_uint32() class PROCDESKHEAD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.h = v_ptr32() self.cLockObj = v_uint32() self.hTaskWow = v_uint32() self.rpdesk = v_ptr32() self.pSelf = v_ptr32() class SM_VALUES_STRINGS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pszName = v_ptr32() self.ulValue = v_uint32() self.RangeType = v_uint32() self.StorageType = v_uint32() class HBRUSH(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class SECURITY_QUALITY_OF_SERVICE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.ImpersonationLevel = v_uint32() self.ContextTrackingMode = v_uint8() self.EffectiveOnly = v_uint8() self._pad000c = v_bytes(size=2) class _unnamed_12471(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Create = _unnamed_12558() class WHEA_ERROR_RECORD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Header = WHEA_ERROR_RECORD_HEADER() self.SectionDescriptor = vstruct.VArray([ WHEA_ERROR_RECORD_SECTION_DESCRIPTOR() for i in xrange(1) ]) class LUID(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.LowPart = v_uint32() self.HighPart = v_uint32() class tagDESKTOP(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.dwSessionId = v_uint32() self.pDeskInfo = v_ptr32() self.pDispInfo = v_ptr32() self.rpdeskNext = v_ptr32() self.rpwinstaParent = v_ptr32() self.dwDTFlags = v_uint32() self.dwDesktopId = v_uint32() self.spmenuSys = v_ptr32() self.spmenuDialogSys = v_ptr32() self.spmenuHScroll = v_ptr32() self.spmenuVScroll = v_ptr32() self.spwndForeground = v_ptr32() self.spwndTray = v_ptr32() self.spwndMessage = v_ptr32() self.spwndTooltip = v_ptr32() self.hsectionDesktop = v_ptr32() self.pheapDesktop = v_ptr32() self.ulHeapSize = v_uint32() self.cciConsole = CONSOLE_CARET_INFO() self.PtiList = LIST_ENTRY() self.spwndTrack = v_ptr32() self.htEx = v_uint32() self.rcMouseHover = tagRECT() self.dwMouseHoverTime = v_uint32() self.pMagInputTransform = v_ptr32() class tagPOOLRECORD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ExtraData = v_ptr32() self.size = v_uint32() self.trace = vstruct.VArray([ v_ptr32() for i in xrange(6) ]) class CLIENT_ID(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.UniqueProcess = v_ptr32() self.UniqueThread = v_ptr32() class OBJECT_DUMP_CONTROL(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Stream = v_ptr32() self.Detail = v_uint32() class _unnamed_15793(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Generic = _unnamed_16064() class _unnamed_16610(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length40 = v_uint32() self.Alignment40 = v_uint32() self.MinimumAddress = LARGE_INTEGER() self.MaximumAddress = LARGE_INTEGER() class _unnamed_16615(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length48 = v_uint32() self.Alignment48 = v_uint32() self.MinimumAddress = LARGE_INTEGER() self.MaximumAddress = LARGE_INTEGER() class tagSPB(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pspbNext = v_ptr32() self.spwnd = v_ptr32() self.hbm = v_ptr32() self.rc = tagRECT() self.hrgn = v_ptr32() self.flags = v_uint32() self.ulSaveId = v_uint32() class DMM_VIDPNSET_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.NumVidPns = v_uint8() self._pad0004 = v_bytes(size=3) self.VidPnOffset = vstruct.VArray([ v_uint32() for i in xrange(1) ]) class STRING(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint16() self.MaximumLength = v_uint16() self.Buffer = v_ptr32() class TP_POOL(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class tagPROP(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.hData = v_ptr32() self.atomKey = v_uint16() self.fs = v_uint16() class _unnamed_12822(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.DeviceTextType = v_uint32() self.LocaleId = v_uint32() class LIST_ENTRY32(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Flink = v_uint32() self.Blink = v_uint32() class SINGLE_LIST_ENTRY(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Next = v_ptr32() class KDEVICE_QUEUE_ENTRY(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.DeviceListEntry = LIST_ENTRY() self.SortKey = v_uint32() self.Inserted = v_uint8() self._pad0010 = v_bytes(size=3) class D3DKMDT_VIDPN_SOURCE_MODE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Id = v_uint32() self.Type = v_uint32() self.Format = _unnamed_13381() class _unnamed_12574(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SecurityContext = v_ptr32() self.Options = v_uint32() self.Reserved = v_uint16() self.ShareAccess = v_uint16() self.Parameters = v_ptr32() class tagCLIENTTHREADINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.CTIF_flags = v_uint32() self.fsChangeBits = v_uint16() self.fsWakeBits = v_uint16() self.fsWakeBitsJournal = v_uint16() self.fsWakeMask = v_uint16() self.tickLastMsgChecked = v_uint32() class tagKbdNlsLayer(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.OEMIdentifier = v_uint16() self.LayoutInformation = v_uint16() self.NumOfVkToF = v_uint32() self.pVkToF = v_ptr32() self.NumOfMouseVKey = v_uint32() self.pusMouseVKey = v_ptr32() class _unnamed_12654(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.FileName = v_ptr32() self.FileInformationClass = v_uint32() self.FileIndex = v_uint32() class KSPIN_LOCK_QUEUE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Next = v_ptr32() self.Lock = v_ptr32() class tagPROCESS_HID_TABLE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.link = LIST_ENTRY() self.InclusionList = LIST_ENTRY() self.UsagePageList = LIST_ENTRY() self.ExclusionList = LIST_ENTRY() self.spwndTargetMouse = v_ptr32() self.spwndTargetKbd = v_ptr32() self.nSinks = v_uint32() self.pLastRequest = v_ptr32() self.UsagePageLast = v_uint16() self.UsageLast = v_uint16() self.fRawMouse = v_uint32() class WHEA_ERROR_PACKET_FLAGS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.PreviousError = v_uint32() class IO_RESOURCE_DESCRIPTOR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Option = v_uint8() self.Type = v_uint8() self.ShareDisposition = v_uint8() self.Spare1 = v_uint8() self.Flags = v_uint16() self.Spare2 = v_uint16() self.u = _unnamed_16049() class EX_PUSH_LOCK_CACHE_AWARE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Locks = vstruct.VArray([ v_ptr32() for i in xrange(1) ]) class tagMLIST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pqmsgRead = v_ptr32() self.pqmsgWriteLast = v_ptr32() self.cMsgs = v_uint32() class DMM_MONITORDESCRIPTORSET_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.NumDescriptors = v_uint8() self._pad0004 = v_bytes(size=3) self.DescriptorSerialization = vstruct.VArray([ DMM_MONITORDESCRIPTOR_SERIALIZATION() for i in xrange(1) ]) class tagCLIP(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.fmt = v_uint32() self.hData = v_ptr32() self.fGlobalHandle = v_uint32() class tagSMS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.psmsNext = v_ptr32() self.psmsReceiveNext = v_ptr32() self.ptiSender = v_ptr32() self.ptiReceiver = v_ptr32() self.lpResultCallBack = v_ptr32() self.dwData = v_uint32() self.ptiCallBackSender = v_ptr32() self.lRet = v_uint32() self.tSent = v_uint32() self.flags = v_uint32() self.wParam = v_uint32() self.lParam = v_uint32() self.message = v_uint32() self.spwnd = v_ptr32() self.pvCapture = v_ptr32() class IMAGE_OPTIONAL_HEADER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Magic = v_uint16() self.MajorLinkerVersion = v_uint8() self.MinorLinkerVersion = v_uint8() self.SizeOfCode = v_uint32() self.SizeOfInitializedData = v_uint32() self.SizeOfUninitializedData = v_uint32() self.AddressOfEntryPoint = v_uint32() self.BaseOfCode = v_uint32() self.BaseOfData = v_uint32() self.ImageBase = v_uint32() self.SectionAlignment = v_uint32() self.FileAlignment = v_uint32() self.MajorOperatingSystemVersion = v_uint16() self.MinorOperatingSystemVersion = v_uint16() self.MajorImageVersion = v_uint16() self.MinorImageVersion = v_uint16() self.MajorSubsystemVersion = v_uint16() self.MinorSubsystemVersion = v_uint16() self.Win32VersionValue = v_uint32() self.SizeOfImage = v_uint32() self.SizeOfHeaders = v_uint32() self.CheckSum = v_uint32() self.Subsystem = v_uint16() self.DllCharacteristics = v_uint16() self.SizeOfStackReserve = v_uint32() self.SizeOfStackCommit = v_uint32() self.SizeOfHeapReserve = v_uint32() self.SizeOfHeapCommit = v_uint32() self.LoaderFlags = v_uint32() self.NumberOfRvaAndSizes = v_uint32() self.DataDirectory = vstruct.VArray([ IMAGE_DATA_DIRECTORY() for i in xrange(16) ]) class _unnamed_12786(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Capabilities = v_ptr32() class ETHREAD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class FAST_MUTEX(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Count = v_uint32() self.Owner = v_ptr32() self.Contention = v_uint32() self.Event = KEVENT() self.OldIrql = v_uint32() class WHEA_ERROR_RECORD_HEADER_VALIDBITS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.PlatformId = v_uint32() class D3DKMDT_VIDPN_PRESENT_PATH_TRANSFORMATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Scaling = v_uint32() self.ScalingSupport = D3DKMDT_VIDPN_PRESENT_PATH_SCALING_SUPPORT() self.Rotation = v_uint32() self.RotationSupport = D3DKMDT_VIDPN_PRESENT_PATH_ROTATION_SUPPORT() class KDEVICE_QUEUE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint16() self.Size = v_uint16() self.DeviceListHead = LIST_ENTRY() self.Lock = v_uint32() self.Busy = v_uint8() self._pad0014 = v_bytes(size=3) class CALLBACKWND(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.hwnd = v_ptr32() self.pwnd = v_ptr32() self.pActCtx = v_ptr32() class _unnamed_12395(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Overlay = _unnamed_12510() self._pad0030 = v_bytes(size=8) class IO_SECURITY_CONTEXT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SecurityQos = v_ptr32() self.AccessState = v_ptr32() self.DesiredAccess = v_uint32() self.FullCreateOptions = v_uint32() class tagSIZE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.cx = v_uint32() self.cy = v_uint32() class tagDESKTOPVIEW(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pdvNext = v_ptr32() self.pdesk = v_ptr32() self.ulClientDelta = v_uint32() class _unnamed_12392(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.AsynchronousParameters = _unnamed_12410() class PROCMARKHEAD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.h = v_ptr32() self.cLockObj = v_uint32() self.hTaskWow = v_uint32() self.ppi = v_ptr32() class INITIAL_PRIVILEGE_SET(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.PrivilegeCount = v_uint32() self.Control = v_uint32() self.Privilege = vstruct.VArray([ LUID_AND_ATTRIBUTES() for i in xrange(3) ]) class D3DKMDT_COLOR_COEFF_DYNAMIC_RANGES(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.FirstChannel = v_uint32() self.SecondChannel = v_uint32() self.ThirdChannel = v_uint32() self.FourthChannel = v_uint32() class WHEA_ERROR_RECORD_HEADER_FLAGS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Recovered = v_uint32() class _unnamed_15582(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Attrib = v_uint32() self.cbData = v_uint32() class _unnamed_15585(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Attrib = v_uint32() self.cbData = v_uint32() class D3DKMDT_FREQUENCY_RANGE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.MinVSyncFreq = D3DDDI_RATIONAL() self.MaxVSyncFreq = D3DDDI_RATIONAL() self.MinHSyncFreq = D3DDDI_RATIONAL() self.MaxHSyncFreq = D3DDDI_RATIONAL() class PFNCLIENT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pfnScrollBarWndProc = v_ptr32() self.pfnTitleWndProc = v_ptr32() self.pfnMenuWndProc = v_ptr32() self.pfnDesktopWndProc = v_ptr32() self.pfnDefWindowProc = v_ptr32() self.pfnMessageWindowProc = v_ptr32() self.pfnSwitchWindowProc = v_ptr32() self.pfnButtonWndProc = v_ptr32() self.pfnComboBoxWndProc = v_ptr32() self.pfnComboListBoxProc = v_ptr32() self.pfnDialogWndProc = v_ptr32() self.pfnEditWndProc = v_ptr32() self.pfnListBoxWndProc = v_ptr32() self.pfnMDIClientWndProc = v_ptr32() self.pfnStaticWndProc = v_ptr32() self.pfnImeWndProc = v_ptr32() self.pfnGhostWndProc = v_ptr32() self.pfnHkINLPCWPSTRUCT = v_ptr32() self.pfnHkINLPCWPRETSTRUCT = v_ptr32() self.pfnDispatchHook = v_ptr32() self.pfnDispatchDefWindowProc = v_ptr32() self.pfnDispatchMessage = v_ptr32() self.pfnMDIActivateDlgProc = v_ptr32() class ACTIVATION_CONTEXT_DATA(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class FILE_NETWORK_OPEN_INFORMATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.CreationTime = LARGE_INTEGER() self.LastAccessTime = LARGE_INTEGER() self.LastWriteTime = LARGE_INTEGER() self.ChangeTime = LARGE_INTEGER() self.AllocationSize = LARGE_INTEGER() self.EndOfFile = LARGE_INTEGER() self.FileAttributes = v_uint32() self._pad0038 = v_bytes(size=4) class TEB_ACTIVE_FRAME(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Flags = v_uint32() self.Previous = v_ptr32() self.Context = v_ptr32() class tagSVR_INSTANCE_INFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.head = THROBJHEAD() self.next = v_ptr32() self.nextInThisThread = v_ptr32() self.afCmd = v_uint32() self.spwndEvent = v_ptr32() self.pcii = v_ptr32() class RTL_DRIVE_LETTER_CURDIR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Flags = v_uint16() self.Length = v_uint16() self.TimeStamp = v_uint32() self.DosPath = STRING() class GENERAL_LOOKASIDE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ListHead = SLIST_HEADER() self.Depth = v_uint16() self.MaximumDepth = v_uint16() self.TotalAllocates = v_uint32() self.AllocateMisses = v_uint32() self.TotalFrees = v_uint32() self.FreeMisses = v_uint32() self.Type = v_uint32() self.Tag = v_uint32() self.Size = v_uint32() self.AllocateEx = v_ptr32() self.FreeEx = v_ptr32() self.ListEntry = LIST_ENTRY() self.LastTotalAllocates = v_uint32() self.LastAllocateMisses = v_uint32() self.Future = vstruct.VArray([ v_uint32() for i in xrange(2) ]) class VWPL(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.cPwnd = v_uint32() self.cElem = v_uint32() self.cThreshhold = v_uint32() self.fTagged = v_uint32() self.aElement = vstruct.VArray([ VWPLELEMENT() for i in xrange(0) ]) class KPRCB(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.MinorVersion = v_uint16() self.MajorVersion = v_uint16() self.CurrentThread = v_ptr32() self.NextThread = v_ptr32() self.IdleThread = v_ptr32() self.LegacyNumber = v_uint8() self.NestingLevel = v_uint8() self.BuildType = v_uint16() self.CpuType = v_uint8() self.CpuID = v_uint8() self.CpuStep = v_uint16() self.ProcessorState = KPROCESSOR_STATE() self.KernelReserved = vstruct.VArray([ v_uint32() for i in xrange(16) ]) self.HalReserved = vstruct.VArray([ v_uint32() for i in xrange(16) ]) self.CFlushSize = v_uint32() self.CoresPerPhysicalProcessor = v_uint8() self.LogicalProcessorsPerCore = v_uint8() self.PrcbPad0 = vstruct.VArray([ v_uint8() for i in xrange(2) ]) self.MHz = v_uint32() self.CpuVendor = v_uint8() self.GroupIndex = v_uint8() self.Group = v_uint16() self.GroupSetMember = v_uint32() self.Number = v_uint32() self.PrcbPad1 = vstruct.VArray([ v_uint8() for i in xrange(72) ]) self.LockQueue = vstruct.VArray([ KSPIN_LOCK_QUEUE() for i in xrange(17) ]) class ULARGE_INTEGER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.LowPart = v_uint32() self.HighPart = v_uint32() class tagCURSOR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.head = PROCMARKHEAD() self.pcurNext = v_ptr32() self.strName = UNICODE_STRING() self.atomModName = v_uint16() self.rt = v_uint16() self.CURSORF_flags = v_uint32() self.xHotspot = v_uint16() self.yHotspot = v_uint16() self.hbmMask = v_ptr32() self.hbmColor = v_ptr32() self.hbmAlpha = v_ptr32() self.rcBounds = tagRECT() self.hbmUserAlpha = v_ptr32() self.bpp = v_uint32() self.cx = v_uint32() self.cy = v_uint32() class tagDCE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pdceNext = v_ptr32() self.hdc = v_ptr32() self.pwndOrg = v_ptr32() self.pwndClip = v_ptr32() self.pwndRedirect = v_ptr32() self.hrgnClip = v_ptr32() self.hrgnClipPublic = v_ptr32() self.hrgnSavedVis = v_ptr32() self.DCX_flags = v_uint32() self.ptiOwner = v_ptr32() self.ppiOwner = v_ptr32() self.pMonitor = v_ptr32() class tagPROCESS_HID_REQUEST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.link = LIST_ENTRY() self.usUsagePage = v_uint16() self.usUsage = v_uint16() self.fSinkable = v_uint32() self.pTLCInfo = v_ptr32() self.spwndTarget = v_ptr32() class NAMED_PIPE_CREATE_PARAMETERS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.NamedPipeType = v_uint32() self.ReadMode = v_uint32() self.CompletionMode = v_uint32() self.MaximumInstances = v_uint32() self.InboundQuota = v_uint32() self.OutboundQuota = v_uint32() self.DefaultTimeout = LARGE_INTEGER() self.TimeoutSpecified = v_uint8() self._pad0028 = v_bytes(size=7) class NT_TIB(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ExceptionList = v_ptr32() self.StackBase = v_ptr32() self.StackLimit = v_ptr32() self.SubSystemTib = v_ptr32() self.FiberData = v_ptr32() self.ArbitraryUserPointer = v_ptr32() self.Self = v_ptr32() class POWER_STATE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SystemState = v_uint32() class UNICODE_STRING(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint16() self.MaximumLength = v_uint16() self.Buffer = v_ptr32() class DMM_MONITORSOURCEMODESET_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.NumModes = v_uint8() self._pad0004 = v_bytes(size=3) self.ModeSerialization = vstruct.VArray([ DMM_MONITOR_SOURCE_MODE_SERIALIZATION() for i in xrange(1) ]) class D3DKMDT_VIDPN_TARGET_MODE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Id = v_uint32() self.VideoSignalInfo = D3DKMDT_VIDEO_SIGNAL_INFO() self.Preference = v_uint32() class COMPRESSED_DATA_INFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.CompressionFormatAndEngine = v_uint16() self.CompressionUnitShift = v_uint8() self.ChunkShift = v_uint8() self.ClusterShift = v_uint8() self.Reserved = v_uint8() self.NumberOfChunks = v_uint16() self.CompressedChunkSizes = vstruct.VArray([ v_uint32() for i in xrange(1) ]) class tagWOWTHREADINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pwtiNext = v_ptr32() self.idTask = v_uint32() self.idWaitObject = v_uint32() self.idParentProcess = v_uint32() self.pIdleEvent = v_ptr32() class _unnamed_12593(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.Key = v_uint32() self.ByteOffset = LARGE_INTEGER() class PEB(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.InheritedAddressSpace = v_uint8() self.ReadImageFileExecOptions = v_uint8() self.BeingDebugged = v_uint8() self.BitField = v_uint8() self.Mutant = v_ptr32() self.ImageBaseAddress = v_ptr32() self.Ldr = v_ptr32() self.ProcessParameters = v_ptr32() self.SubSystemData = v_ptr32() self.ProcessHeap = v_ptr32() self.FastPebLock = v_ptr32() self.AtlThunkSListPtr = v_ptr32() self.IFEOKey = v_ptr32() self.CrossProcessFlags = v_uint32() self.KernelCallbackTable = v_ptr32() self.SystemReserved = vstruct.VArray([ v_uint32() for i in xrange(1) ]) self.AtlThunkSListPtr32 = v_uint32() self.ApiSetMap = v_ptr32() self.TlsExpansionCounter = v_uint32() self.TlsBitmap = v_ptr32() self.TlsBitmapBits = vstruct.VArray([ v_uint32() for i in xrange(2) ]) self.ReadOnlySharedMemoryBase = v_ptr32() self.HotpatchInformation = v_ptr32() self.ReadOnlyStaticServerData = v_ptr32() self.AnsiCodePageData = v_ptr32() self.OemCodePageData = v_ptr32() self.UnicodeCaseTableData = v_ptr32() self.NumberOfProcessors = v_uint32() self.NtGlobalFlag = v_uint32() self._pad0070 = v_bytes(size=4) self.CriticalSectionTimeout = LARGE_INTEGER() self.HeapSegmentReserve = v_uint32() self.HeapSegmentCommit = v_uint32() self.HeapDeCommitTotalFreeThreshold = v_uint32() self.HeapDeCommitFreeBlockThreshold = v_uint32() self.NumberOfHeaps = v_uint32() self.MaximumNumberOfHeaps = v_uint32() self.ProcessHeaps = v_ptr32() self.GdiSharedHandleTable = v_ptr32() self.ProcessStarterHelper = v_ptr32() self.GdiDCAttributeList = v_uint32() self.LoaderLock = v_ptr32() self.OSMajorVersion = v_uint32() self.OSMinorVersion = v_uint32() self.OSBuildNumber = v_uint16() self.OSCSDVersion = v_uint16() self.OSPlatformId = v_uint32() self.ImageSubsystem = v_uint32() self.ImageSubsystemMajorVersion = v_uint32() self.ImageSubsystemMinorVersion = v_uint32() self.ActiveProcessAffinityMask = v_uint32() self.GdiHandleBuffer = vstruct.VArray([ v_uint32() for i in xrange(34) ]) self.PostProcessInitRoutine = v_ptr32() self.TlsExpansionBitmap = v_ptr32() self.TlsExpansionBitmapBits = vstruct.VArray([ v_uint32() for i in xrange(32) ]) self.SessionId = v_uint32() self.AppCompatFlags = ULARGE_INTEGER() self.AppCompatFlagsUser = ULARGE_INTEGER() self.pShimData = v_ptr32() self.AppCompatInfo = v_ptr32() self.CSDVersion = UNICODE_STRING() self.ActivationContextData = v_ptr32() self.ProcessAssemblyStorageMap = v_ptr32() self.SystemDefaultActivationContextData = v_ptr32() self.SystemAssemblyStorageMap = v_ptr32() self.MinimumStackCommit = v_uint32() self.FlsCallback = v_ptr32() self.FlsListHead = LIST_ENTRY() self.FlsBitmap = v_ptr32() self.FlsBitmapBits = vstruct.VArray([ v_uint32() for i in xrange(4) ]) self.FlsHighIndex = v_uint32() self.WerRegistrationData = v_ptr32() self.WerShipAssertPtr = v_ptr32() self.pContextData = v_ptr32() self.pImageHeaderHash = v_ptr32() self.TracingFlags = v_uint32() self._pad0248 = v_bytes(size=4) class _unnamed_12817(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.IdType = v_uint32() class W32THREAD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pEThread = v_ptr32() self.RefCount = v_uint32() self.ptlW32 = v_ptr32() self.pgdiDcattr = v_ptr32() self.pgdiBrushAttr = v_ptr32() self.pUMPDObjs = v_ptr32() self.pUMPDHeap = v_ptr32() self.pUMPDObj = v_ptr32() self.GdiTmpTgoList = LIST_ENTRY() self.pRBRecursionCount = v_uint32() self.pNonRBRecursionCount = v_uint32() self.tlSpriteState = TLSPRITESTATE() self.pSpriteState = v_ptr32() self.pDevHTInfo = v_ptr32() self.ulDevHTInfoUniqueness = v_uint32() self.pdcoAA = v_ptr32() self.pdcoRender = v_ptr32() self.pdcoSrc = v_ptr32() self.bEnableEngUpdateDeviceSurface = v_uint8() self.bIncludeSprites = v_uint8() self._pad00ac = v_bytes(size=2) self.ulWindowSystemRendering = v_uint32() self.iVisRgnUniqueness = v_uint32() class KDPC(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint8() self.Importance = v_uint8() self.Number = v_uint16() self.DpcListEntry = LIST_ENTRY() self.DeferredRoutine = v_ptr32() self.DeferredContext = v_ptr32() self.SystemArgument1 = v_ptr32() self.SystemArgument2 = v_ptr32() self.DpcData = v_ptr32() class KEVENT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Header = DISPATCHER_HEADER() class KSEMAPHORE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Header = DISPATCHER_HEADER() self.Limit = v_uint32() class _unnamed_16581(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.Alignment = v_uint32() self.MinimumAddress = LARGE_INTEGER() self.MaximumAddress = LARGE_INTEGER() class OBJECT_TYPE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.TypeList = LIST_ENTRY() self.Name = UNICODE_STRING() self.DefaultObject = v_ptr32() self.Index = v_uint8() self._pad0018 = v_bytes(size=3) self.TotalNumberOfObjects = v_uint32() self.TotalNumberOfHandles = v_uint32() self.HighWaterNumberOfObjects = v_uint32() self.HighWaterNumberOfHandles = v_uint32() self.TypeInfo = OBJECT_TYPE_INITIALIZER() self.TypeLock = EX_PUSH_LOCK() self.Key = v_uint32() self.CallbackList = LIST_ENTRY() class tagIMEINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.dwPrivateDataSize = v_uint32() self.fdwProperty = v_uint32() self.fdwConversionCaps = v_uint32() self.fdwSentenceCaps = v_uint32() self.fdwUICaps = v_uint32() self.fdwSCSCaps = v_uint32() self.fdwSelectCaps = v_uint32() class DXGK_DIAG_CODE_POINT_PACKET(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Header = DXGK_DIAG_HEADER() self.CodePointType = v_uint32() self.Param1 = v_uint32() self.Param2 = v_uint32() self.Param3 = v_uint32() class W32PROCESS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Process = v_ptr32() self.RefCount = v_uint32() self.W32PF_Flags = v_uint32() self.InputIdleEvent = v_ptr32() self.StartCursorHideTime = v_uint32() self.NextStart = v_ptr32() self.pDCAttrList = v_ptr32() self.pBrushAttrList = v_ptr32() self.W32Pid = v_uint32() self.GDIHandleCount = v_uint32() self.GDIHandleCountPeak = v_uint32() self.UserHandleCount = v_uint32() self.UserHandleCountPeak = v_uint32() self.GDIPushLock = EX_PUSH_LOCK() self.GDIEngUserMemAllocTable = RTL_AVL_TABLE() self.GDIDcAttrFreeList = LIST_ENTRY() self.GDIBrushAttrFreeList = LIST_ENTRY() self.GDIW32PIDLockedBitmaps = LIST_ENTRY() self.hSecureGdiSharedHandleTable = v_ptr32() self.DxProcess = v_ptr32() class tagKBDFILE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.head = HEAD() self.pkfNext = v_ptr32() self.hBase = v_ptr32() self.pKbdTbl = v_ptr32() self.Size = v_uint32() self.pKbdNlsTbl = v_ptr32() self.awchDllName = vstruct.VArray([ v_uint16() for i in xrange(32) ]) class DMM_COMMITVIDPNREQUEST_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.AffectedVidPnSourceId = v_uint32() self.RequestDiagInfo = DMM_COMMITVIDPNREQUEST_DIAGINFO() self.VidPnSerialization = DMM_VIDPN_SERIALIZATION() class EXCEPTION_REGISTRATION_RECORD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Next = v_ptr32() self.Handler = v_ptr32() class FILE_BASIC_INFORMATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.CreationTime = LARGE_INTEGER() self.LastAccessTime = LARGE_INTEGER() self.LastWriteTime = LARGE_INTEGER() self.ChangeTime = LARGE_INTEGER() self.FileAttributes = v_uint32() self._pad0028 = v_bytes(size=4) class _unnamed_12887(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.AllocatedResources = v_ptr32() self.AllocatedResourcesTranslated = v_ptr32() class LIST_ENTRY(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Flink = v_ptr32() self.Blink = v_ptr32() class tagUSERSTARTUPINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.cb = v_uint32() self.dwX = v_uint32() self.dwY = v_uint32() self.dwXSize = v_uint32() self.dwYSize = v_uint32() self.dwFlags = v_uint32() self.wShowWindow = v_uint16() self.cbReserved2 = v_uint16() class tagHID_PAGEONLY_REQUEST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.link = LIST_ENTRY() self.usUsagePage = v_uint16() self._pad000c = v_bytes(size=2) self.cRefCount = v_uint32() class RTL_DYNAMIC_HASH_TABLE_ENUMERATOR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.HashEntry = RTL_DYNAMIC_HASH_TABLE_ENTRY() self.ChainHead = v_ptr32() self.BucketIndex = v_uint32() class tagWINDOWSTATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.dwSessionId = v_uint32() self.rpwinstaNext = v_ptr32() self.rpdeskList = v_ptr32() self.pTerm = v_ptr32() self.dwWSF_Flags = v_uint32() self.spklList = v_ptr32() self.ptiClipLock = v_ptr32() self.ptiDrawingClipboard = v_ptr32() self.spwndClipOpen = v_ptr32() self.spwndClipViewer = v_ptr32() self.spwndClipOwner = v_ptr32() self.pClipBase = v_ptr32() self.cNumClipFormats = v_uint32() self.iClipSerialNumber = v_uint32() self.iClipSequenceNumber = v_uint32() self.spwndClipboardListener = v_ptr32() self.pGlobalAtomTable = v_ptr32() self.luidEndSession = LUID() self.luidUser = LUID() self.psidUser = v_ptr32() class _unnamed_16049(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Port = _unnamed_16581() class DMM_VIDPNPATHSFROMSOURCE_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SourceMode = D3DKMDT_VIDPN_SOURCE_MODE() self.NumPathsFromSource = v_uint8() self._pad002c = v_bytes(size=3) self.PathAndTargetModeSerialization = vstruct.VArray([ DMM_VIDPNPATHANDTARGETMODE_SERIALIZATION() for i in xrange(1) ]) class GUID(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Data1 = v_uint32() self.Data2 = v_uint16() self.Data3 = v_uint16() self.Data4 = vstruct.VArray([ v_uint8() for i in xrange(8) ]) class D3DKMDT_GRAPHICS_RENDERING_FORMAT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.PrimSurfSize = D3DKMDT_2DREGION() self.VisibleRegionSize = D3DKMDT_2DREGION() self.Stride = v_uint32() self.PixelFormat = v_uint32() self.ColorBasis = v_uint32() self.PixelValueAccessMode = v_uint32() class GENERIC_MAPPING(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.GenericRead = v_uint32() self.GenericWrite = v_uint32() self.GenericExecute = v_uint32() self.GenericAll = v_uint32() class IRP(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint16() self.Size = v_uint16() self.MdlAddress = v_ptr32() self.Flags = v_uint32() self.AssociatedIrp = _unnamed_12389() self.ThreadListEntry = LIST_ENTRY() self.IoStatus = IO_STATUS_BLOCK() self.RequestorMode = v_uint8() self.PendingReturned = v_uint8() self.StackCount = v_uint8() self.CurrentLocation = v_uint8() self.Cancel = v_uint8() self.CancelIrql = v_uint8() self.ApcEnvironment = v_uint8() self.AllocationFlags = v_uint8() self.UserIosb = v_ptr32() self.UserEvent = v_ptr32() self.Overlay = _unnamed_12392() self.CancelRoutine = v_ptr32() self.UserBuffer = v_ptr32() self.Tail = _unnamed_12395() class _unnamed_11700(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.LowPart = v_uint32() self.HighPart = v_uint32() class DRIVER_OBJECT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint16() self.Size = v_uint16() self.DeviceObject = v_ptr32() self.Flags = v_uint32() self.DriverStart = v_ptr32() self.DriverSize = v_uint32() self.DriverSection = v_ptr32() self.DriverExtension = v_ptr32() self.DriverName = UNICODE_STRING() self.HardwareDatabase = v_ptr32() self.FastIoDispatch = v_ptr32() self.DriverInit = v_ptr32() self.DriverStartIo = v_ptr32() self.DriverUnload = v_ptr32() self.MajorFunction = vstruct.VArray([ v_ptr32() for i in xrange(28) ]) class MAILSLOT_CREATE_PARAMETERS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.MailslotQuota = v_uint32() self.MaximumMessageSize = v_uint32() self.ReadTimeout = LARGE_INTEGER() self.TimeoutSpecified = v_uint8() self._pad0018 = v_bytes(size=7) class DMM_VIDPN_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Size = v_uint32() self.NumActiveSources = v_uint8() self._pad0008 = v_bytes(size=3) self.PathsFromSourceSerializationOffsets = vstruct.VArray([ v_uint32() for i in xrange(1) ]) class _unnamed_16606(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Priority = v_uint32() self.Reserved1 = v_uint32() self.Reserved2 = v_uint32() class _unnamed_16601(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.MinBusNumber = v_uint32() self.MaxBusNumber = v_uint32() self.Reserved = v_uint32() class IO_COMPLETION_CONTEXT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Port = v_ptr32() self.Key = v_ptr32() class DRIVER_EXTENSION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.DriverObject = v_ptr32() self.AddDevice = v_ptr32() self.Count = v_uint32() self.ServiceKeyName = UNICODE_STRING() class _unnamed_16084(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Data = vstruct.VArray([ v_uint32() for i in xrange(3) ]) class DMM_COFUNCPATHSMODALITY_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.NumPathsFromSource = v_uint8() self._pad0004 = v_bytes(size=3) self.PathAndTargetModeSetOffset = vstruct.VArray([ v_uint32() for i in xrange(1) ]) class tagTDB(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ptdbNext = v_ptr32() self.nEvents = v_uint32() self.nPriority = v_uint32() self.pti = v_ptr32() self.pwti = v_ptr32() self.hTaskWow = v_uint16() self.TDB_Flags = v_uint16() class WHEA_PERSISTENCE_INFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Signature = v_uint64() class WHEA_ERROR_RECORD_SECTION_DESCRIPTOR_VALIDBITS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.FRUId = v_uint8() class tagWin32AllocStats(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.dwMaxMem = v_uint32() self.dwCrtMem = v_uint32() self.dwMaxAlloc = v_uint32() self.dwCrtAlloc = v_uint32() self.pHead = v_ptr32() class GENERAL_LOOKASIDE_POOL(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ListHead = SLIST_HEADER() self.Depth = v_uint16() self.MaximumDepth = v_uint16() self.TotalAllocates = v_uint32() self.AllocateMisses = v_uint32() self.TotalFrees = v_uint32() self.FreeMisses = v_uint32() self.Type = v_uint32() self.Tag = v_uint32() self.Size = v_uint32() self.AllocateEx = v_ptr32() self.FreeEx = v_ptr32() self.ListEntry = LIST_ENTRY() self.LastTotalAllocates = v_uint32() self.LastAllocateMisses = v_uint32() self.Future = vstruct.VArray([ v_uint32() for i in xrange(2) ]) class EXCEPTION_RECORD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ExceptionCode = v_uint32() self.ExceptionFlags = v_uint32() self.ExceptionRecord = v_ptr32() self.ExceptionAddress = v_ptr32() self.NumberParameters = v_uint32() self.ExceptionInformation = vstruct.VArray([ v_uint32() for i in xrange(15) ]) class HTOUCHINPUT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class PROCESSOR_NUMBER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Group = v_uint16() self.Number = v_uint8() self.Reserved = v_uint8() class IMAGE_FILE_HEADER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Machine = v_uint16() self.NumberOfSections = v_uint16() self.TimeDateStamp = v_uint32() self.PointerToSymbolTable = v_uint32() self.NumberOfSymbols = v_uint32() self.SizeOfOptionalHeader = v_uint16() self.Characteristics = v_uint16() class tagPROCESSINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Process = v_ptr32() self.RefCount = v_uint32() self.W32PF_Flags = v_uint32() self.InputIdleEvent = v_ptr32() self.StartCursorHideTime = v_uint32() self.NextStart = v_ptr32() self.pDCAttrList = v_ptr32() self.pBrushAttrList = v_ptr32() self.W32Pid = v_uint32() self.GDIHandleCount = v_uint32() self.GDIHandleCountPeak = v_uint32() self.UserHandleCount = v_uint32() self.UserHandleCountPeak = v_uint32() self.GDIPushLock = EX_PUSH_LOCK() self.GDIEngUserMemAllocTable = RTL_AVL_TABLE() self.GDIDcAttrFreeList = LIST_ENTRY() self.GDIBrushAttrFreeList = LIST_ENTRY() self.GDIW32PIDLockedBitmaps = LIST_ENTRY() self.hSecureGdiSharedHandleTable = v_ptr32() self.DxProcess = v_ptr32() self.ptiList = v_ptr32() self.ptiMainThread = v_ptr32() self.rpdeskStartup = v_ptr32() self.pclsPrivateList = v_ptr32() self.pclsPublicList = v_ptr32() self.pwpi = v_ptr32() self.ppiNext = v_ptr32() self.ppiNextRunning = v_ptr32() self.cThreads = v_uint32() self.hdeskStartup = v_ptr32() self.cSysExpunge = v_uint32() self.dwhmodLibLoadedMask = v_uint32() self.ahmodLibLoaded = vstruct.VArray([ v_ptr32() for i in xrange(32) ]) self.rpwinsta = v_ptr32() self.hwinsta = v_ptr32() self.amwinsta = v_uint32() self.dwHotkey = v_uint32() self.hMonitor = v_ptr32() self.pdvList = v_ptr32() self.iClipSerialNumber = v_uint32() self.bmHandleFlags = RTL_BITMAP() self.pCursorCache = v_ptr32() self.pClientBase = v_ptr32() self.dwLpkEntryPoints = v_uint32() self.pW32Job = v_ptr32() self.dwImeCompatFlags = v_uint32() self.luidSession = LUID() self.usi = tagUSERSTARTUPINFO() self.Flags = v_uint32() self.dwLayout = v_uint32() self.pHidTable = v_ptr32() self.dwRegisteredClasses = v_uint32() self.pvwplWndGCList = v_ptr32() class HKL(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class FLOATING_SAVE_AREA(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ControlWord = v_uint32() self.StatusWord = v_uint32() self.TagWord = v_uint32() self.ErrorOffset = v_uint32() self.ErrorSelector = v_uint32() self.DataOffset = v_uint32() self.DataSelector = v_uint32() self.RegisterArea = vstruct.VArray([ v_uint8() for i in xrange(80) ]) self.Cr0NpxState = v_uint32() class PEB_LDR_DATA(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint32() self.Initialized = v_uint8() self._pad0008 = v_bytes(size=3) self.SsHandle = v_ptr32() self.InLoadOrderModuleList = LIST_ENTRY() self.InMemoryOrderModuleList = LIST_ENTRY() self.InInitializationOrderModuleList = LIST_ENTRY() self.EntryInProgress = v_ptr32() self.ShutdownInProgress = v_uint8() self._pad002c = v_bytes(size=3) self.ShutdownThreadId = v_ptr32() class _unnamed_12724(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Srb = v_ptr32() class _unnamed_12720(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Vpb = v_ptr32() self.DeviceObject = v_ptr32() class DMM_MONITORFREQUENCYRANGESET_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.NumFrequencyRanges = v_uint8() self._pad0004 = v_bytes(size=3) self.FrequencyRangeSerialization = vstruct.VArray([ D3DKMDT_MONITOR_FREQUENCY_RANGE() for i in xrange(1) ]) class SECURITY_SUBJECT_CONTEXT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ClientToken = v_ptr32() self.ImpersonationLevel = v_uint32() self.PrimaryToken = v_ptr32() self.ProcessAuditId = v_ptr32() class DMM_MONITOR_SERIALIZATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Size = v_uint32() self.VideoPresentTargetId = v_uint32() self.Orientation = v_uint32() self.IsSimulatedMonitor = v_uint8() self.IsUsingDefaultProfile = v_uint8() self._pad0010 = v_bytes(size=2) self.ModePruningAlgorithm = v_uint32() self.MonitorPowerState = v_uint32() self.SourceModeSetOffset = v_uint32() self.FrequencyRangeSetOffset = v_uint32() self.DescriptorSetOffset = v_uint32() self.MonitorType = v_uint32() class tagKbdLayer(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pCharModifiers = v_ptr32() self.pVkToWcharTable = v_ptr32() self.pDeadKey = v_ptr32() self.pKeyNames = v_ptr32() self.pKeyNamesExt = v_ptr32() self.pKeyNamesDead = v_ptr32() self.pusVSCtoVK = v_ptr32() self.bMaxVSCtoVK = v_uint8() self._pad0020 = v_bytes(size=3) self.pVSCtoVK_E0 = v_ptr32() self.pVSCtoVK_E1 = v_ptr32() self.fLocaleFlags = v_uint32() self.nLgMax = v_uint8() self.cbLgEntry = v_uint8() self._pad0030 = v_bytes(size=2) self.pLigature = v_ptr32() self.dwType = v_uint32() self.dwSubType = v_uint32() class _unnamed_11687(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.LowPart = v_uint32() self.HighPart = v_uint32() class tagMSG(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.hwnd = v_ptr32() self.message = v_uint32() self.wParam = v_uint32() self.lParam = v_uint32() self.time = v_uint32() self.pt = tagPOINT() class HWND(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class INTERFACE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Size = v_uint16() self.Version = v_uint16() self.Context = v_ptr32() self.InterfaceReference = v_ptr32() self.InterfaceDereference = v_ptr32() class SLIST_HEADER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Alignment = v_uint64() class FILE_STANDARD_INFORMATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.AllocationSize = LARGE_INTEGER() self.EndOfFile = LARGE_INTEGER() self.NumberOfLinks = v_uint32() self.DeletePending = v_uint8() self.Directory = v_uint8() self._pad0018 = v_bytes(size=2) class _unnamed_13037(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.InitialPrivilegeSet = INITIAL_PRIVILEGE_SET() class IMAGE_DATA_DIRECTORY(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.VirtualAddress = v_uint32() self.Size = v_uint32() class FILE_OBJECT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint16() self.Size = v_uint16() self.DeviceObject = v_ptr32() self.Vpb = v_ptr32() self.FsContext = v_ptr32() self.FsContext2 = v_ptr32() self.SectionObjectPointer = v_ptr32() self.PrivateCacheMap = v_ptr32() self.FinalStatus = v_uint32() self.RelatedFileObject = v_ptr32() self.LockOperation = v_uint8() self.DeletePending = v_uint8() self.ReadAccess = v_uint8() self.WriteAccess = v_uint8() self.DeleteAccess = v_uint8() self.SharedRead = v_uint8() self.SharedWrite = v_uint8() self.SharedDelete = v_uint8() self.Flags = v_uint32() self.FileName = UNICODE_STRING() self.CurrentByteOffset = LARGE_INTEGER() self.Waiters = v_uint32() self.Busy = v_uint32() self.LastLock = v_ptr32() self.Lock = KEVENT() self.Event = KEVENT() self.CompletionContext = v_ptr32() self.IrpListLock = v_uint32() self.IrpList = LIST_ENTRY() self.FileObjectExtension = v_ptr32() class tagWOWPROCESSINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pwpiNext = v_ptr32() self.ptiScheduled = v_ptr32() self.ptdbHead = v_ptr32() self.lpfnWowExitTask = v_ptr32() self.pEventWowExec = v_ptr32() self.hEventWowExecClient = v_ptr32() self.nSendLock = v_uint32() self.nRecvLock = v_uint32() self.CSOwningThread = v_ptr32() self.CSLockCount = v_uint32() class tagMENU(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.head = PROCDESKHEAD() self.fFlags = v_uint32() self.iItem = v_uint32() self.cAlloced = v_uint32() self.cItems = v_uint32() self.cxMenu = v_uint32() self.cyMenu = v_uint32() self.cxTextAlign = v_uint32() self.spwndNotify = v_ptr32() self.rgItems = v_ptr32() self.pParentMenus = v_ptr32() self.dwContextHelpId = v_uint32() self.cyMax = v_uint32() self.dwMenuData = v_uint32() self.hbrBack = v_ptr32() self.iTop = v_uint32() self.iMaxTop = v_uint32() self.dwArrowsOn = v_uint32() self.umpm = tagUAHMENUPOPUPMETRICS() class ERESOURCE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.SystemResourcesList = LIST_ENTRY() self.OwnerTable = v_ptr32() self.ActiveCount = v_uint16() self.Flag = v_uint16() self.SharedWaiters = v_ptr32() self.ExclusiveWaiters = v_ptr32() self.OwnerEntry = OWNER_ENTRY() self.ActiveEntries = v_uint32() self.ContentionCount = v_uint32() self.NumberOfSharedWaiters = v_uint32() self.NumberOfExclusiveWaiters = v_uint32() self.Address = v_ptr32() self.SpinLock = v_uint32() class ACCESS_REASONS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Data = vstruct.VArray([ v_uint32() for i in xrange(32) ]) class THRDESKHEAD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.h = v_ptr32() self.cLockObj = v_uint32() self.pti = v_ptr32() self.rpdesk = v_ptr32() self.pSelf = v_ptr32() class _unnamed_16090(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.DataSize = v_uint32() self.Reserved1 = v_uint32() self.Reserved2 = v_uint32() class tagPOPUPMENU(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.fIsMenuBar = v_uint32() self.spwndNotify = v_ptr32() self.spwndPopupMenu = v_ptr32() self.spwndNextPopup = v_ptr32() self.spwndPrevPopup = v_ptr32() self.spmenu = v_ptr32() self.spmenuAlternate = v_ptr32() self.spwndActivePopup = v_ptr32() self.ppopupmenuRoot = v_ptr32() self.ppmDelayedFree = v_ptr32() self.posSelectedItem = v_uint32() self.posDropped = v_uint32() class TP_TASK_CALLBACKS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ExecuteCallback = v_ptr32() self.Unposted = v_ptr32() class _unnamed_16097(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Start = LARGE_INTEGER() self.Length48 = v_uint32() class _unnamed_16094(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Start = LARGE_INTEGER() self.Length40 = v_uint32() class RTL_BALANCED_LINKS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Parent = v_ptr32() self.LeftChild = v_ptr32() self.RightChild = v_ptr32() self.Balance = v_uint8() self.Reserved = vstruct.VArray([ v_uint8() for i in xrange(3) ]) class HANDLEENTRY(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.phead = v_ptr32() self.pOwner = v_ptr32() self.bType = v_uint8() self.bFlags = v_uint8() self.wUniq = v_uint16() class VK_FUNCTION_PARAM(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.NLSFEProcIndex = v_uint8() self._pad0004 = v_bytes(size=3) self.NLSFEProcParam = v_uint32() class EX_PUSH_LOCK(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Locked = v_uint32() class D3DMATRIX(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self._11 = v_uint32() self._12 = v_uint32() self._13 = v_uint32() self._14 = v_uint32() self._21 = v_uint32() self._22 = v_uint32() self._23 = v_uint32() self._24 = v_uint32() self._31 = v_uint32() self._32 = v_uint32() self._33 = v_uint32() self._34 = v_uint32() self._41 = v_uint32() self._42 = v_uint32() self._43 = v_uint32() self._44 = v_uint32() class _unnamed_13453(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ActiveSize = D3DKMDT_2DREGION() class CONSOLE_CARET_INFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.hwnd = v_ptr32() self.rc = tagRECT() class D3DKMDT_VIDPN_PRESENT_PATH_ROTATION_SUPPORT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Identity = v_uint32() class WHEA_ERROR_RECORD_HEADER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Signature = v_uint32() self.Revision = WHEA_REVISION() self.SignatureEnd = v_uint32() self.SectionCount = v_uint16() self.Severity = v_uint32() self.ValidBits = WHEA_ERROR_RECORD_HEADER_VALIDBITS() self.Length = v_uint32() self.Timestamp = WHEA_TIMESTAMP() self.PlatformId = GUID() self.PartitionId = GUID() self.CreatorId = GUID() self.NotifyType = GUID() self.RecordId = v_uint64() self.Flags = WHEA_ERROR_RECORD_HEADER_FLAGS() self.PersistenceInfo = WHEA_PERSISTENCE_INFO() self.Reserved = vstruct.VArray([ v_uint8() for i in xrange(12) ]) class EVENT_DESCRIPTOR(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Id = v_uint16() self.Version = v_uint8() self.Channel = v_uint8() self.Level = v_uint8() self.Opcode = v_uint8() self.Task = v_uint16() self.Keyword = v_uint64() class tagSBCALC(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.posMin = v_uint32() self.posMax = v_uint32() self.page = v_uint32() self.pos = v_uint32() self.pxTop = v_uint32() self.pxBottom = v_uint32() self.pxLeft = v_uint32() self.pxRight = v_uint32() self.cpxThumb = v_uint32() self.pxUpArrow = v_uint32() self.pxDownArrow = v_uint32() self.pxStart = v_uint32() self.pxThumbBottom = v_uint32() self.pxThumbTop = v_uint32() self.cpx = v_uint32() self.pxMin = v_uint32() class _unnamed_12451(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ListEntry = LIST_ENTRY() self._pad0028 = v_bytes(size=32) class tagSBINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.WSBflags = v_uint32() self.Horz = tagSBDATA() self.Vert = tagSBDATA() class FLS_CALLBACK_INFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class _unnamed_11733(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.LongFunction = v_uint32() class _unnamed_11730(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Flags = v_uint32() class LIST_ENTRY64(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Flink = v_uint64() self.Blink = v_uint64() class tagOEMBITMAPINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.x = v_uint32() self.y = v_uint32() self.cx = v_uint32() self.cy = v_uint32() class WAIT_CONTEXT_BLOCK(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.WaitQueueEntry = KDEVICE_QUEUE_ENTRY() self.DeviceRoutine = v_ptr32() self.DeviceContext = v_ptr32() self.NumberOfMapRegisters = v_uint32() self.DeviceObject = v_ptr32() self.CurrentIrp = v_ptr32() self.BufferChainingDpc = v_ptr32() class _unnamed_16072(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Group = v_uint16() self.MessageCount = v_uint16() self.Vector = v_uint32() self.Affinity = v_uint32() class ACTIVATION_CONTEXT_STACK(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ActiveFrame = v_ptr32() self.FrameListCache = LIST_ENTRY() self.Flags = v_uint32() self.NextCookieSequenceNumber = v_uint32() self.StackId = v_uint32() class tagITEM(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.fType = v_uint32() self.fState = v_uint32() self.wID = v_uint32() self.spSubMenu = v_ptr32() self.hbmpChecked = v_ptr32() self.hbmpUnchecked = v_ptr32() self.lpstr = v_ptr32() self.cch = v_uint32() self.dwItemData = v_uint32() self.xItem = v_uint32() self.yItem = v_uint32() self.cxItem = v_uint32() self.cyItem = v_uint32() self.dxTab = v_uint32() self.ulX = v_uint32() self.ulWidth = v_uint32() self.hbmp = v_ptr32() self.cxBmp = v_uint32() self.cyBmp = v_uint32() self.umim = tagUAHMENUITEMMETRICS() class LOOKASIDE_LIST_EX(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.L = GENERAL_LOOKASIDE_POOL() class TEB(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.NtTib = NT_TIB() self.EnvironmentPointer = v_ptr32() self.ClientId = CLIENT_ID() self.ActiveRpcHandle = v_ptr32() self.ThreadLocalStoragePointer = v_ptr32() self.ProcessEnvironmentBlock = v_ptr32() self.LastErrorValue = v_uint32() self.CountOfOwnedCriticalSections = v_uint32() self.CsrClientThread = v_ptr32() self.Win32ThreadInfo = v_ptr32() self.User32Reserved = vstruct.VArray([ v_uint32() for i in xrange(26) ]) self.UserReserved = vstruct.VArray([ v_uint32() for i in xrange(5) ]) self.WOW32Reserved = v_ptr32() self.CurrentLocale = v_uint32() self.FpSoftwareStatusRegister = v_uint32() self.SystemReserved1 = vstruct.VArray([ v_ptr32() for i in xrange(54) ]) self.ExceptionCode = v_uint32() self.ActivationContextStackPointer = v_ptr32() self.SpareBytes = vstruct.VArray([ v_uint8() for i in xrange(36) ]) self.TxFsContext = v_uint32() self.GdiTebBatch = GDI_TEB_BATCH() self.RealClientId = CLIENT_ID() self.GdiCachedProcessHandle = v_ptr32() self.GdiClientPID = v_uint32() self.GdiClientTID = v_uint32() self.GdiThreadLocalInfo = v_ptr32() self.Win32ClientInfo = vstruct.VArray([ v_uint32() for i in xrange(62) ]) self.glDispatchTable = vstruct.VArray([ v_ptr32() for i in xrange(233) ]) self.glReserved1 = vstruct.VArray([ v_uint32() for i in xrange(29) ]) self.glReserved2 = v_ptr32() self.glSectionInfo = v_ptr32() self.glSection = v_ptr32() self.glTable = v_ptr32() self.glCurrentRC = v_ptr32() self.glContext = v_ptr32() self.LastStatusValue = v_uint32() self.StaticUnicodeString = UNICODE_STRING() self.StaticUnicodeBuffer = vstruct.VArray([ v_uint16() for i in xrange(261) ]) self._pad0e0c = v_bytes(size=2) self.DeallocationStack = v_ptr32() self.TlsSlots = vstruct.VArray([ v_ptr32() for i in xrange(64) ]) self.TlsLinks = LIST_ENTRY() self.Vdm = v_ptr32() self.ReservedForNtRpc = v_ptr32() self.DbgSsReserved = vstruct.VArray([ v_ptr32() for i in xrange(2) ]) self.HardErrorMode = v_uint32() self.Instrumentation = vstruct.VArray([ v_ptr32() for i in xrange(9) ]) self.ActivityId = GUID() self.SubProcessTag = v_ptr32() self.EtwLocalData = v_ptr32() self.EtwTraceData = v_ptr32() self.WinSockData = v_ptr32() self.GdiBatchCount = v_uint32() self.CurrentIdealProcessor = PROCESSOR_NUMBER() self.GuaranteedStackBytes = v_uint32() self.ReservedForPerf = v_ptr32() self.ReservedForOle = v_ptr32() self.WaitingOnLoaderLock = v_uint32() self.SavedPriorityState = v_ptr32() self.SoftPatchPtr1 = v_uint32() self.ThreadPoolData = v_ptr32() self.TlsExpansionSlots = v_ptr32() self.MuiGeneration = v_uint32() self.IsImpersonating = v_uint32() self.NlsCache = v_ptr32() self.pShimData = v_ptr32() self.HeapVirtualAffinity = v_uint32() self.CurrentTransactionHandle = v_ptr32() self.ActiveFrame = v_ptr32() self.FlsData = v_ptr32() self.PreferredLanguages = v_ptr32() self.UserPrefLanguages = v_ptr32() self.MergedPrefLanguages = v_ptr32() self.MuiImpersonation = v_uint32() self.CrossTebFlags = v_uint16() self.SameTebFlags = v_uint16() self.TxnScopeEnterCallback = v_ptr32() self.TxnScopeExitCallback = v_ptr32() self.TxnScopeContext = v_ptr32() self.LockCount = v_uint32() self.SpareUlong0 = v_uint32() self.ResourceRetValue = v_ptr32() class tagWIN32HEAP(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) class DMM_COMMITVIDPNREQUEST_DIAGINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ClientType = v_uint32() self.ReclaimClonedTarget = v_uint8() self._pad0008 = v_bytes(size=3) self.ModeChangeRequestId = v_uint32() class IMAGE_DOS_HEADER(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.e_magic = v_uint16() self.e_cblp = v_uint16() self.e_cp = v_uint16() self.e_crlc = v_uint16() self.e_cparhdr = v_uint16() self.e_minalloc = v_uint16() self.e_maxalloc = v_uint16() self.e_ss = v_uint16() self.e_sp = v_uint16() self.e_csum = v_uint16() self.e_ip = v_uint16() self.e_cs = v_uint16() self.e_lfarlc = v_uint16() self.e_ovno = v_uint16() self.e_res = vstruct.VArray([ v_uint16() for i in xrange(4) ]) self.e_oemid = v_uint16() self.e_oeminfo = v_uint16() self.e_res2 = vstruct.VArray([ v_uint16() for i in xrange(10) ]) self.e_lfanew = v_uint32() class RTL_DYNAMIC_HASH_TABLE_ENTRY(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Linkage = LIST_ENTRY() self.Signature = v_uint32() class TXN_PARAMETER_BLOCK(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_uint16() self.TxFsContext = v_uint16() self.TransactionObject = v_ptr32() class QUAD(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.UseThisFieldToCopy = v_uint64() class _unnamed_12800(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.IoResourceRequirementList = v_ptr32() class _unnamed_12803(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.WhichSpace = v_uint32() self.Buffer = v_ptr32() self.Offset = v_uint32() self.Length = v_uint32() class RTL_DYNAMIC_HASH_TABLE(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Flags = v_uint32() self.Shift = v_uint32() self.TableSize = v_uint32() self.Pivot = v_uint32() self.DivisorMask = v_uint32() self.NumEntries = v_uint32() self.NonEmptyBuckets = v_uint32() self.NumEnumerators = v_uint32() self.Directory = v_ptr32() class _unnamed_12808(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Lock = v_uint8() class _unnamed_12694(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Length = v_ptr32() self.Key = v_uint32() self.ByteOffset = LARGE_INTEGER() class tagSERVERINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.dwSRVIFlags = v_uint32() self.cHandleEntries = v_uint32() self.mpFnidPfn = vstruct.VArray([ v_ptr32() for i in xrange(32) ]) self.aStoCidPfn = vstruct.VArray([ v_ptr32() for i in xrange(7) ]) self.mpFnid_serverCBWndProc = vstruct.VArray([ v_uint16() for i in xrange(31) ]) self._pad00e4 = v_bytes(size=2) self.apfnClientA = PFNCLIENT() self.apfnClientW = PFNCLIENT() self.apfnClientWorker = PFNCLIENTWORKER() self.cbHandleTable = v_uint32() self.atomSysClass = vstruct.VArray([ v_uint16() for i in xrange(25) ]) self._pad0200 = v_bytes(size=2) self.dwDefaultHeapBase = v_uint32() self.dwDefaultHeapSize = v_uint32() self.uiShellMsg = v_uint32() self.MBStrings = vstruct.VArray([ tagMBSTRING() for i in xrange(11) ]) self.atomIconSmProp = v_uint16() self.atomIconProp = v_uint16() self.atomContextHelpIdProp = v_uint16() self.atomFrostedWindowProp = v_uint16() self.acOemToAnsi = vstruct.VArray([ v_uint8() for i in xrange(256) ]) self.acAnsiToOem = vstruct.VArray([ v_uint8() for i in xrange(256) ]) self.dwInstalledEventHooks = v_uint32() self.aiSysMet = vstruct.VArray([ v_uint32() for i in xrange(97) ]) self.argbSystemUnmatched = vstruct.VArray([ v_uint32() for i in xrange(31) ]) self.argbSystem = vstruct.VArray([ v_uint32() for i in xrange(31) ]) self.ahbrSystem = vstruct.VArray([ v_ptr32() for i in xrange(31) ]) self.hbrGray = v_ptr32() self.ptCursor = tagPOINT() self.ptCursorReal = tagPOINT() self.dwLastRITEventTickCount = v_uint32() self.nEvents = v_uint32() self.dtScroll = v_uint32() self.dtLBSearch = v_uint32() self.dtCaretBlink = v_uint32() self.ucWheelScrollLines = v_uint32() self.ucWheelScrollChars = v_uint32() self.wMaxLeftOverlapChars = v_uint32() self.wMaxRightOverlapChars = v_uint32() self.cxSysFontChar = v_uint32() self.cySysFontChar = v_uint32() self.tmSysFont = tagTEXTMETRICW() self.dpiSystem = tagDPISERVERINFO() self.hIconSmWindows = v_ptr32() self.hIcoWindows = v_ptr32() self.dwKeyCache = v_uint32() self.dwAsyncKeyCache = v_uint32() self.cCaptures = v_uint32() self.oembmi = vstruct.VArray([ tagOEMBITMAPINFO() for i in xrange(93) ]) self.rcScreenReal = tagRECT() self.BitCount = v_uint16() self.dmLogPixels = v_uint16() self.Planes = v_uint8() self.BitsPixel = v_uint8() self._pad0f58 = v_bytes(size=2) self.PUSIFlags = v_uint32() self.uCaretWidth = v_uint32() self.UILangID = v_uint16() self._pad0f64 = v_bytes(size=2) self.dwLastSystemRITEventTickCountUpdate = v_uint32() self.adwDBGTAGFlags = vstruct.VArray([ v_uint32() for i in xrange(35) ]) self.dwTagCount = v_uint32() self.dwRIPFlags = v_uint32() class DEVICE_OBJECT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Type = v_uint16() self.Size = v_uint16() self.ReferenceCount = v_uint32() self.DriverObject = v_ptr32() self.NextDevice = v_ptr32() self.AttachedDevice = v_ptr32() self.CurrentIrp = v_ptr32() self.Timer = v_ptr32() self.Flags = v_uint32() self.Characteristics = v_uint32() self.Vpb = v_ptr32() self.DeviceExtension = v_ptr32() self.DeviceType = v_uint32() self.StackSize = v_uint8() self._pad0034 = v_bytes(size=3) self.Queue = _unnamed_12451() self.AlignmentRequirement = v_uint32() self.DeviceQueue = KDEVICE_QUEUE() self.Dpc = KDPC() self.ActiveThreadCount = v_uint32() self.SecurityDescriptor = v_ptr32() self.DeviceLock = KEVENT() self.SectorSize = v_uint16() self.Spare1 = v_uint16() self.DeviceObjectExtension = v_ptr32() self.Reserved = v_ptr32() class _unnamed_12699(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.OutputBufferLength = v_uint32() self.InputBufferLength = v_uint32() self.IoControlCode = v_uint32() self.Type3InputBuffer = v_ptr32() class _unnamed_12510(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.DeviceQueueEntry = KDEVICE_QUEUE_ENTRY() self.Thread = v_ptr32() self.AuxiliaryBuffer = v_ptr32() self.ListEntry = LIST_ENTRY() self.CurrentStackLocation = v_ptr32() self.OriginalFileObject = v_ptr32() class _unnamed_16591(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.MinimumVector = v_uint32() self.MaximumVector = v_uint32() self.AffinityPolicy = v_uint16() self.Group = v_uint16() self.PriorityPolicy = v_uint32() self.TargetedProcessors = v_uint32() class _unnamed_16598(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.MinimumChannel = v_uint32() self.MaximumChannel = v_uint32() class tagCLIENTINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.CI_flags = v_uint32() self.cSpins = v_uint32() self.dwExpWinVer = v_uint32() self.dwCompatFlags = v_uint32() self.dwCompatFlags2 = v_uint32() self.dwTIFlags = v_uint32() self.pDeskInfo = v_ptr32() self.ulClientDelta = v_uint32() self.phkCurrent = v_ptr32() self.fsHooks = v_uint32() self.CallbackWnd = CALLBACKWND() self.dwHookCurrent = v_uint32() self.cInDDEMLCallback = v_uint32() self.pClientThreadInfo = v_ptr32() self.dwHookData = v_uint32() self.dwKeyCache = v_uint32() self.afKeyState = vstruct.VArray([ v_uint8() for i in xrange(8) ]) self.dwAsyncKeyCache = v_uint32() self.afAsyncKeyState = vstruct.VArray([ v_uint8() for i in xrange(8) ]) self.afAsyncKeyStateRecentDown = vstruct.VArray([ v_uint8() for i in xrange(8) ]) self.hKL = v_ptr32() self.CodePage = v_uint16() self.achDbcsCF = vstruct.VArray([ v_uint8() for i in xrange(2) ]) self.msgDbcsCB = tagMSG() self.lpdwRegisteredClasses = v_ptr32() class HWINSTA(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.unused = v_uint32() class TL(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.next = v_ptr32() self.pobj = v_ptr32() self.pfnFree = v_ptr32() class IMAGE_NT_HEADERS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Signature = v_uint32() self.FileHeader = IMAGE_FILE_HEADER() self.OptionalHeader = IMAGE_OPTIONAL_HEADER() class IO_STACK_LOCATION(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.MajorFunction = v_uint8() self.MinorFunction = v_uint8() self.Flags = v_uint8() self.Control = v_uint8() self.Parameters = _unnamed_12471() self.DeviceObject = v_ptr32() self.FileObject = v_ptr32() self.CompletionRoutine = v_ptr32() self.Context = v_ptr32() class tagTERMINAL(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.dwTERMF_Flags = v_uint32() self.spwndDesktopOwner = v_ptr32() self.ptiDesktop = v_ptr32() self.pqDesktop = v_ptr32() self.dwNestedLevel = v_uint32() self.pEventTermInit = v_ptr32() self.rpdeskDestroy = v_ptr32() self.pEventInputReady = v_ptr32() class D3DKMDT_VIDPN_PRESENT_PATH(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.VidPnSourceId = v_uint32() self.VidPnTargetId = v_uint32() self.ImportanceOrdinal = v_uint32() self.ContentTransformation = D3DKMDT_VIDPN_PRESENT_PATH_TRANSFORMATION() self.VisibleFromActiveTLOffset = D3DKMDT_2DREGION() self.VisibleFromActiveBROffset = D3DKMDT_2DREGION() self.VidPnTargetColorBasis = v_uint32() self.VidPnTargetColorCoeffDynamicRanges = D3DKMDT_COLOR_COEFF_DYNAMIC_RANGES() self.Content = v_uint32() self.CopyProtection = D3DKMDT_VIDPN_PRESENT_PATH_COPYPROTECTION() self.GammaRamp = D3DKMDT_GAMMA_RAMP() class tagMENULIST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pNext = v_ptr32() self.pMenu = v_ptr32() class VK_VALUES_STRINGS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.pszMultiNames = v_ptr32() self.fReserved = v_uint8() self._pad0008 = v_bytes(size=3) class tagKL(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.head = HEAD() self.pklNext = v_ptr32() self.pklPrev = v_ptr32() self.dwKL_Flags = v_uint32() self.hkl = v_ptr32() self.spkf = v_ptr32() self.spkfPrimary = v_ptr32() self.dwFontSigs = v_uint32() self.iBaseCharset = v_uint32() self.CodePage = v_uint16() self.wchDiacritic = v_uint16() self.piiex = v_ptr32() self.uNumTbl = v_uint32() self.pspkfExtra = v_ptr32() self.dwLastKbdType = v_uint32() self.dwLastKbdSubType = v_uint32() self.dwKLID = v_uint32() class tagPOINT(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.x = v_uint32() self.y = v_uint32() class RTL_USER_PROCESS_PARAMETERS(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.MaximumLength = v_uint32() self.Length = v_uint32() self.Flags = v_uint32() self.DebugFlags = v_uint32() self.ConsoleHandle = v_ptr32() self.ConsoleFlags = v_uint32() self.StandardInput = v_ptr32() self.StandardOutput = v_ptr32() self.StandardError = v_ptr32() self.CurrentDirectory = CURDIR() self.DllPath = UNICODE_STRING() self.ImagePathName = UNICODE_STRING() self.CommandLine = UNICODE_STRING() self.Environment = v_ptr32() self.StartingX = v_uint32() self.StartingY = v_uint32() self.CountX = v_uint32() self.CountY = v_uint32() self.CountCharsX = v_uint32() self.CountCharsY = v_uint32() self.FillAttribute = v_uint32() self.WindowFlags = v_uint32() self.ShowWindowFlags = v_uint32() self.WindowTitle = UNICODE_STRING() self.DesktopInfo = UNICODE_STRING() self.ShellInfo = UNICODE_STRING() self.RuntimeData = UNICODE_STRING() self.CurrentDirectores = vstruct.VArray([ RTL_DRIVE_LETTER_CURDIR() for i in xrange(32) ]) self.EnvironmentSize = v_uint32() self.EnvironmentVersion = v_uint32() class _unnamed_16077(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.Raw = _unnamed_16072() class tagSHAREDINFO(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.psi = v_ptr32() self.aheList = v_ptr32() self.HeEntrySize = v_uint32() self.pDispInfo = v_ptr32() self.ulSharedDelta = v_uint32() self.awmControl = vstruct.VArray([ WNDMSG() for i in xrange(31) ]) self.DefWindowMsgs = WNDMSG() self.DefWindowSpecMsgs = WNDMSG() class tagIMC(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.head = THRDESKHEAD() self.pImcNext = v_ptr32() self.dwClientImcData = v_uint32() self.hImeWnd = v_ptr32() class IO_RESOURCE_REQUIREMENTS_LIST(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.ListSize = v_uint32() self.InterfaceType = v_uint32() self.BusNumber = v_uint32() self.SlotNumber = v_uint32() self.Reserved = vstruct.VArray([ v_uint32() for i in xrange(3) ]) self.AlternativeLists = v_uint32() self.List = vstruct.VArray([ IO_RESOURCE_LIST() for i in xrange(1) ]) class tagCARET(vstruct.VStruct): def __init__(self): vstruct.VStruct.__init__(self) self.spwnd = v_ptr32() self.fVisible = v_uint32() self.iHideLevel = v_uint32() self.x = v_uint32() self.y = v_uint32() self.cy = v_uint32() self.cx = v_uint32() self.hBitmap = v_ptr32() self.hTimer = v_uint32() self.tid = v_uint32() self.xOwnDc = v_uint32() self.yOwnDc = v_uint32() self.cxOwnDc = v_uint32() self.cyOwnDc = v_uint32()
gpl-2.0
[ 3, 3394, 26, 1227, 14, 17, 202, 199, 3, 19521, 10497, 26, 284, 8040, 202, 199, 646, 373, 1820, 202, 199, 504, 373, 1820, 14, 1359, 22337, 492, 627, 2999, 199, 775, 55, 63, 16103, 63, 3719, 275, 373, 63, 4869, 342, 202, 199, 775, 55, 63, 16103, 63, 3719, 14, 775, 55, 63, 16103, 63, 3719, 63, 40, 1554, 63, 7321, 275, 378, 202, 199, 775, 55, 63, 16103, 63, 3719, 14, 775, 55, 63, 16103, 63, 3719, 63, 40, 1554, 63, 31730, 63, 20509, 275, 413, 202, 199, 775, 55, 63, 16103, 63, 3719, 14, 775, 55, 63, 16103, 63, 3719, 63, 13533, 63, 11365, 63, 7321, 275, 499, 202, 199, 775, 55, 63, 16103, 63, 3719, 14, 775, 55, 63, 16103, 63, 3719, 63, 4283, 275, 650, 8065, 199, 2566, 53, 1244, 6689, 275, 373, 63, 4869, 342, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 9692, 275, 446, 17, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 9185, 275, 378, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 8819, 275, 413, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 16207, 275, 499, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 53, 1512, 934, 3359, 15167, 275, 650, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 568, 33, 3927, 275, 841, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 568, 33, 3927, 16207, 275, 959, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 568, 7730, 14999, 3359, 15167, 275, 1227, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 8760, 275, 1520, 8065, 199, 31588, 33, 63, 3170, 63, 899, 2111, 1922, 275, 373, 63, 4869, 342, 202, 199, 31588, 33, 63, 3170, 63, 899, 2111, 1922, 14, 55, 426, 65, 5432, 1513, 86, 497, 5899, 461, 275, 378, 202, 199, 31588, 33, 63, 3170, 63, 899, 2111, 1922, 14, 55, 426, 65, 5432, 1513, 86, 19507, 275, 413, 202, 199, 31588, 33, 63, 3170, 63, 899, 2111, 1922, 14, 55, 426, 65, 5432, 1513, 86, 8380, 7983, 275, 499, 202, 199, 31588, 33, 63, 3170, 63, 899, 2111, 1922, 14, 55, 426, 65, 5432, 1513, 86, 4935, 279, 275, 650, 8065, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 275, 373, 63, 4869, 342, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 1734, 13768, 18732, 275, 378, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 14903, 1046, 275, 413, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 6741, 41, 275, 499, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 14903, 10709, 275, 650, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 14903, 10709, 18, 275, 841, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 4985, 11259, 47, 63, 20, 30929, 275, 959, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 4985, 11259, 47, 63, 23, 30929, 275, 1227, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 50, 3263, 63, 11265, 1512, 7917, 275, 1520, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 50, 3263, 63, 19, 20360, 275, 1695, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 34, 6389, 275, 1749, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 11778, 275, 1616, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 3693, 12764, 36, 7770, 906, 275, 4119, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 17681, 275, 3144, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 18400, 275, 5450, 8065, 199, 4029, 63, 17467, 63, 16422, 29315, 275, 373, 63, 4869, 342, 202, 199, 4029, 63, 17467, 63, 16422, 29315, 14, 16782, 6408, 30141, 275, 378, 202, 199, 4029, 63, 17467, 63, 16422, 29315, 14, 16782, 6408, 6932, 30141, 275, 413, 8065, 199, 36, 3218, 63, 32387, 726, 63, 14956, 6013, 63, 8193, 63, 2711, 275, 373, 63, 4869, 342, 202, 199, 36, 3218, 63, 32387, 726, 63, 14956, 6013, 63, 8193, 63, 2711, 14, 36, 3218, 63, 1658, 775, 63, 1734, 13768, 18732, 275, 378, 202, 199, 36, 3218, 63, 32387, 726, 63, 14956, 6013, 63, 8193, 63, 2711, 14, 36, 3218, 63, 1658, 775, 63, 9732, 32387, 726, 275, 413, 202, 199, 36, 3218, 63, 32387 ]
[ 3394, 26, 1227, 14, 17, 202, 199, 3, 19521, 10497, 26, 284, 8040, 202, 199, 646, 373, 1820, 202, 199, 504, 373, 1820, 14, 1359, 22337, 492, 627, 2999, 199, 775, 55, 63, 16103, 63, 3719, 275, 373, 63, 4869, 342, 202, 199, 775, 55, 63, 16103, 63, 3719, 14, 775, 55, 63, 16103, 63, 3719, 63, 40, 1554, 63, 7321, 275, 378, 202, 199, 775, 55, 63, 16103, 63, 3719, 14, 775, 55, 63, 16103, 63, 3719, 63, 40, 1554, 63, 31730, 63, 20509, 275, 413, 202, 199, 775, 55, 63, 16103, 63, 3719, 14, 775, 55, 63, 16103, 63, 3719, 63, 13533, 63, 11365, 63, 7321, 275, 499, 202, 199, 775, 55, 63, 16103, 63, 3719, 14, 775, 55, 63, 16103, 63, 3719, 63, 4283, 275, 650, 8065, 199, 2566, 53, 1244, 6689, 275, 373, 63, 4869, 342, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 9692, 275, 446, 17, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 9185, 275, 378, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 8819, 275, 413, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 16207, 275, 499, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 53, 1512, 934, 3359, 15167, 275, 650, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 568, 33, 3927, 275, 841, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 568, 33, 3927, 16207, 275, 959, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 568, 7730, 14999, 3359, 15167, 275, 1227, 202, 199, 2566, 53, 1244, 6689, 14, 2566, 53, 1244, 6689, 63, 8760, 275, 1520, 8065, 199, 31588, 33, 63, 3170, 63, 899, 2111, 1922, 275, 373, 63, 4869, 342, 202, 199, 31588, 33, 63, 3170, 63, 899, 2111, 1922, 14, 55, 426, 65, 5432, 1513, 86, 497, 5899, 461, 275, 378, 202, 199, 31588, 33, 63, 3170, 63, 899, 2111, 1922, 14, 55, 426, 65, 5432, 1513, 86, 19507, 275, 413, 202, 199, 31588, 33, 63, 3170, 63, 899, 2111, 1922, 14, 55, 426, 65, 5432, 1513, 86, 8380, 7983, 275, 499, 202, 199, 31588, 33, 63, 3170, 63, 899, 2111, 1922, 14, 55, 426, 65, 5432, 1513, 86, 4935, 279, 275, 650, 8065, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 275, 373, 63, 4869, 342, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 1734, 13768, 18732, 275, 378, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 14903, 1046, 275, 413, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 6741, 41, 275, 499, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 14903, 10709, 275, 650, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 14903, 10709, 18, 275, 841, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 4985, 11259, 47, 63, 20, 30929, 275, 959, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 4985, 11259, 47, 63, 23, 30929, 275, 1227, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 50, 3263, 63, 11265, 1512, 7917, 275, 1520, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 50, 3263, 63, 19, 20360, 275, 1695, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 34, 6389, 275, 1749, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 11778, 275, 1616, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 3693, 12764, 36, 7770, 906, 275, 4119, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 17681, 275, 3144, 202, 199, 36, 19, 10892, 5127, 52, 63, 20142, 63, 8414, 63, 3727, 1244, 31798, 57, 63, 25832, 14, 36, 19, 10892, 5127, 52, 63, 54, 1387, 63, 25832, 63, 18400, 275, 5450, 8065, 199, 4029, 63, 17467, 63, 16422, 29315, 275, 373, 63, 4869, 342, 202, 199, 4029, 63, 17467, 63, 16422, 29315, 14, 16782, 6408, 30141, 275, 378, 202, 199, 4029, 63, 17467, 63, 16422, 29315, 14, 16782, 6408, 6932, 30141, 275, 413, 8065, 199, 36, 3218, 63, 32387, 726, 63, 14956, 6013, 63, 8193, 63, 2711, 275, 373, 63, 4869, 342, 202, 199, 36, 3218, 63, 32387, 726, 63, 14956, 6013, 63, 8193, 63, 2711, 14, 36, 3218, 63, 1658, 775, 63, 1734, 13768, 18732, 275, 378, 202, 199, 36, 3218, 63, 32387, 726, 63, 14956, 6013, 63, 8193, 63, 2711, 14, 36, 3218, 63, 1658, 775, 63, 9732, 32387, 726, 275, 413, 202, 199, 36, 3218, 63, 32387, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
enthought/pikos
pikos/recorders/abstract_recorder.py
1
1322
# -*- coding: utf-8 -*- #------------------------------------------------------------------------------ # Package: Pikos toolkit # File: recorders/abstract_recorder.py # License: LICENSE.TXT # # Copyright (c) 2012, Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ import abc class RecorderError(Exception): pass class AbstractRecorder(object): """ Abstract recorder class. A recorder is reposnible for storing the record data that are provided by the monitor or profiler. The records are expected to be nametuple-like classes. """ __metaclass__ = abc.ABCMeta @abc.abstractmethod def prepare(self, record): """ Perform any setup required before the recorder is used. Parameters ---------- record : NamedTuple The record class that is going to be used. """ @abc.abstractmethod def finalize(self): """ Perform any tasks to finalize and clean up when the recording has completed. """ @abc.abstractmethod def record(self, data): """ Record a measurement. Parameters ---------- data : NamedTuple An instance of the record class that is going to be used. """
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 20974, 199, 3, 221, 15665, 26, 510, 3258, 736, 4744, 6065, 199, 3, 221, 3814, 26, 295, 989, 7735, 15, 6198, 63, 27733, 14, 647, 199, 3, 221, 844, 26, 5113, 14, 17715, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 6029, 12, 3447, 273, 20816, 12, 3277, 14, 199, 3, 221, 2900, 4481, 4644, 14, 199, 20974, 199, 646, 13022, 421, 199, 533, 799, 16940, 547, 8, 1726, 304, 272, 986, 421, 199, 533, 11836, 497, 16940, 8, 785, 304, 272, 408, 11836, 295, 16940, 1021, 14, 339, 437, 295, 16940, 365, 20416, 78, 7247, 367, 16915, 314, 2777, 666, 626, 787, 2741, 701, 272, 314, 8372, 503, 23173, 14, 710, 5767, 787, 1420, 370, 506, 536, 2960, 13, 2930, 272, 3992, 14, 339, 408, 339, 636, 6577, 363, 275, 13022, 14, 22254, 339, 768, 3175, 14, 10315, 272, 347, 9275, 8, 277, 12, 2777, 304, 267, 408, 14795, 1263, 3272, 1415, 2544, 314, 295, 16940, 365, 1202, 14, 398, 3897, 267, 4143, 267, 2777, 520, 16198, 7075, 288, 710, 2777, 1021, 626, 365, 9995, 370, 506, 1202, 14, 398, 408, 339, 768, 3175, 14, 10315, 272, 347, 17284, 8, 277, 304, 267, 408, 14795, 1263, 6527, 370, 17284, 436, 3633, 1536, 1380, 314, 20952, 267, 965, 9709, 14, 398, 408, 339, 768, 3175, 14, 10315, 272, 347, 2777, 8, 277, 12, 666, 304, 267, 408, 12651, 282, 18216, 14, 398, 3897, 267, 4143, 267, 666, 520, 16198, 7075, 288, 1626, 1256, 402, 314, 2777, 1021, 626, 365, 9995, 370, 506, 1202, 14, 398, 408, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 20974, 199, 3, 221, 15665, 26, 510, 3258, 736, 4744, 6065, 199, 3, 221, 3814, 26, 295, 989, 7735, 15, 6198, 63, 27733, 14, 647, 199, 3, 221, 844, 26, 5113, 14, 17715, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 6029, 12, 3447, 273, 20816, 12, 3277, 14, 199, 3, 221, 2900, 4481, 4644, 14, 199, 20974, 199, 646, 13022, 421, 199, 533, 799, 16940, 547, 8, 1726, 304, 272, 986, 421, 199, 533, 11836, 497, 16940, 8, 785, 304, 272, 408, 11836, 295, 16940, 1021, 14, 339, 437, 295, 16940, 365, 20416, 78, 7247, 367, 16915, 314, 2777, 666, 626, 787, 2741, 701, 272, 314, 8372, 503, 23173, 14, 710, 5767, 787, 1420, 370, 506, 536, 2960, 13, 2930, 272, 3992, 14, 339, 408, 339, 636, 6577, 363, 275, 13022, 14, 22254, 339, 768, 3175, 14, 10315, 272, 347, 9275, 8, 277, 12, 2777, 304, 267, 408, 14795, 1263, 3272, 1415, 2544, 314, 295, 16940, 365, 1202, 14, 398, 3897, 267, 4143, 267, 2777, 520, 16198, 7075, 288, 710, 2777, 1021, 626, 365, 9995, 370, 506, 1202, 14, 398, 408, 339, 768, 3175, 14, 10315, 272, 347, 17284, 8, 277, 304, 267, 408, 14795, 1263, 6527, 370, 17284, 436, 3633, 1536, 1380, 314, 20952, 267, 965, 9709, 14, 398, 408, 339, 768, 3175, 14, 10315, 272, 347, 2777, 8, 277, 12, 666, 304, 267, 408, 12651, 282, 18216, 14, 398, 3897, 267, 4143, 267, 666, 520, 16198, 7075, 288, 1626, 1256, 402, 314, 2777, 1021, 626, 365, 9995, 370, 506, 1202, 14, 398, 408, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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ventilation unit. For more details about this component, please refer to the documentation at https://home-assistant.io/components/sensor.comfoconnect/ """ import logging from homeassistant.components.comfoconnect import ( DOMAIN, ComfoConnectBridge, ATTR_CURRENT_TEMPERATURE, ATTR_CURRENT_HUMIDITY, ATTR_OUTSIDE_TEMPERATURE, ATTR_OUTSIDE_HUMIDITY, ATTR_AIR_FLOW_SUPPLY, ATTR_AIR_FLOW_EXHAUST, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED) from homeassistant.const import ( CONF_RESOURCES, TEMP_CELSIUS, STATE_UNKNOWN) from homeassistant.helpers.dispatcher import dispatcher_connect from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) DEPENDENCIES = ['comfoconnect'] SENSOR_TYPES = {} def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the ComfoConnect fan platform.""" from pycomfoconnect import ( SENSOR_TEMPERATURE_EXTRACT, SENSOR_HUMIDITY_EXTRACT, SENSOR_TEMPERATURE_OUTDOOR, SENSOR_HUMIDITY_OUTDOOR, SENSOR_FAN_SUPPLY_FLOW, SENSOR_FAN_EXHAUST_FLOW) global SENSOR_TYPES SENSOR_TYPES = { ATTR_CURRENT_TEMPERATURE: [ 'Inside Temperature', TEMP_CELSIUS, 'mdi:thermometer', SENSOR_TEMPERATURE_EXTRACT ], ATTR_CURRENT_HUMIDITY: [ 'Inside Humidity', '%', 'mdi:water-percent', SENSOR_HUMIDITY_EXTRACT ], ATTR_OUTSIDE_TEMPERATURE: [ 'Outside Temperature', TEMP_CELSIUS, 'mdi:thermometer', SENSOR_TEMPERATURE_OUTDOOR ], ATTR_OUTSIDE_HUMIDITY: [ 'Outside Humidity', '%', 'mdi:water-percent', SENSOR_HUMIDITY_OUTDOOR ], ATTR_AIR_FLOW_SUPPLY: [ 'Supply airflow', 'm³/h', 'mdi:air-conditioner', SENSOR_FAN_SUPPLY_FLOW ], ATTR_AIR_FLOW_EXHAUST: [ 'Exhaust airflow', 'm³/h', 'mdi:air-conditioner', SENSOR_FAN_EXHAUST_FLOW ], } ccb = hass.data[DOMAIN] sensors = [] for resource in config[CONF_RESOURCES]: sensor_type = resource.lower() if sensor_type not in SENSOR_TYPES: _LOGGER.warning("Sensor type: %s is not a valid sensor.", sensor_type) continue sensors.append( ComfoConnectSensor( hass, name="%s %s" % (ccb.name, SENSOR_TYPES[sensor_type][0]), ccb=ccb, sensor_type=sensor_type ) ) add_devices(sensors, True) class ComfoConnectSensor(Entity): """Representation of a ComfoConnect sensor.""" def __init__(self, hass, name, ccb: ComfoConnectBridge, sensor_type): """Initialize the ComfoConnect sensor.""" self._ccb = ccb self._sensor_type = sensor_type self._sensor_id = SENSOR_TYPES[self._sensor_type][3] self._name = name # Register the requested sensor self._ccb.comfoconnect.register_sensor(self._sensor_id) def _handle_update(var): if var == self._sensor_id: _LOGGER.debug('Dispatcher update for %s.', var) self.schedule_update_ha_state() # Register for dispatcher updates dispatcher_connect( hass, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED, _handle_update) @property def state(self): """Return the state of the entity.""" try: return self._ccb.data[self._sensor_id] except KeyError: return STATE_UNKNOWN @property def name(self): """Return the name of the sensor.""" return self._name @property def icon(self): """Return the icon to use in the frontend, if any.""" return SENSOR_TYPES[self._sensor_type][2] @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return SENSOR_TYPES[self._sensor_type][1]
apache-2.0
[ 624, 199, 10397, 370, 3304, 282, 3107, 69, 6164, 424, 5429, 545, 28948, 1413, 13595, 15, 24223, 15, 6683, 373, 287, 280, 2212, 4137, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 3931, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 8956, 14, 957, 545, 2242, 15, 199, 624, 199, 646, 2050, 199, 199, 504, 8846, 14, 4608, 14, 957, 545, 2242, 492, 334, 272, 15265, 12, 5429, 545, 8631, 14491, 12, 10762, 63, 14211, 63, 12510, 32559, 12, 272, 10762, 63, 14211, 63, 40, 2639, 998, 1922, 12, 10762, 63, 1877, 28035, 63, 12510, 32559, 12, 272, 10762, 63, 1877, 28035, 63, 40, 2639, 998, 1922, 12, 10762, 63, 33, 3927, 63, 17114, 63, 7380, 31370, 12, 272, 10762, 63, 33, 3927, 63, 17114, 63, 1438, 6294, 7698, 12, 24360, 63, 11265, 3230, 14657, 63, 10383, 63, 28467, 30487, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 6392, 63, 3830, 11237, 16734, 12, 24314, 63, 21595, 2684, 1668, 12, 11377, 63, 11588, 9, 199, 504, 8846, 14, 7546, 14, 14913, 492, 17475, 63, 2242, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 25743, 9415, 2563, 275, 788, 957, 545, 2242, 418, 199, 199, 24151, 63, 7893, 275, 1052, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 5429, 545, 8631, 13758, 4298, 1041, 272, 687, 1134, 957, 545, 2242, 492, 334, 267, 428, 17850, 63, 12510, 32559, 63, 30335, 12, 428, 17850, 63, 40, 2639, 998, 1922, 63, 30335, 12, 267, 428, 17850, 63, 12510, 32559, 63, 1877, 1649, 726, 12, 428, 17850, 63, 40, 2639, 998, 1922, 63, 1877, 1649, 726, 12, 267, 428, 17850, 63, 29091, 63, 7380, 31370, 63, 17114, 12, 428, 17850, 63, 29091, 63, 1438, 6294, 7698, 63, 17114, 9, 339, 2288, 428, 17850, 63, 7893, 272, 428, 17850, 63, 7893, 275, 469, 267, 10762, 63, 14211, 63, 12510, 32559, 26, 359, 288, 283, 607, 2441, 12540, 7899, 297, 288, 24314, 63, 21595, 2684, 1668, 12, 288, 283, 20208, 26, 728, 573, 10011, 297, 288, 428, 17850, 63, 12510, 32559, 63, 30335, 267, 2156, 267, 10762, 63, 14211, 63, 40, 2639, 998, 1922, 26, 359, 288, 283, 607, 2441, 869, 21704, 297, 288, 1543, 297, 288, 283, 20208, 26, 17217, 13, 7045, 297, 288, 428, 17850, 63, 40, 2639, 998, 1922, 63, 30335, 267, 2156, 267, 10762, 63, 1877, 28035, 63, 12510, 32559, 26, 359, 288, 283, 2204, 2441, 12540, 7899, 297, 288, 24314, 63, 21595, 2684, 1668, 12, 288, 283, 20208, 26, 728, 573, 10011, 297, 288, 428, 17850, 63, 12510, 32559, 63, 1877, 1649, 726, 267, 2156, 267, 10762, 63, 1877, 28035, 63, 40, 2639, 998, 1922, 26, 359, 288, 283, 2204, 2441, 869, 21704, 297, 288, 1543, 297, 288, 283, 20208, 26, 17217, 13, 7045, 297, 288, 428, 17850, 63, 40, 2639, 998, 1922, 63, 1877, 1649, 726, 267, 2156, 267, 10762, 63, 33, 3927, 63, 17114, 63, 7380, 31370, 26, 359, 288, 283, 17127, 590, 16321, 297, 288, 283, 77, 127, 112, 15, 72, 297, 288, 283, 20208, 26, 8387, 13, 5394, 281, 297, 288, 428, 17850, 63, 29091, 63, 7380, 31370, 63, 17114, 267, 2156, 267, 10762, 63, 33, 3927, 63, 17114, 63, 1438, 6294, 7698, 26, 359, 288, 283, 920, 2411, 833, 16321, 297, 288, 283, 77, 127, 112, 15, 72, 297, 288, 283, 20208, 26, 8387, 13, 5394, 281, 297, 288, 428, 17850, 63, 29091, 63, 1438, 6294, 7698, 63, 17114, 267, 2156, 272, 789, 339, 286, 2894, 275, 6298, 14, 576, 59, 7378, 61, 339, 19678, 275, 942, 272, 367, 2073, 315, 1101, 59, 3103, 63, 3830, 11237, 16734, 2189, 267, 8778, 63, 466, 275, 2073, 14, 2325, 342, 398, 340, 8778, 63, 466, 440, 315, 428, 17850, 63, 7893, 26, 288, 485, 10186, 14, 3764, 480, 10160, 730, 26, 450, 83, 365, 440, 282, 1686, 8778, 4765, 1169, 8778, 63, 466, 9, 288, 1980, 398, 19678, 14, 740, 8, 288, 5429, 545, 8631, 10160, 8, 355, 6298, 12, 355, 536, 5961, 83, 450, 83, 2, 450, 334, 32594, 14, 354, 12, 428, 17850, 63, 7893, 59, 8956, 63, 466, 1527, 16, 2522, 355, 286, 2894, 29, 32594, 12, 355, 8778, 63, 466, 29, 8956, 63, 466, 288, 776, 267, 776, 339, 1050, 63, 6410, 8, 22675, 12, 715, 9, 421, 199, 533, 5429, 545, 8631, 10160, 8, 7302, 304, 272, 408, 20609, 402, 282, 5429, 545, 8631, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 6298, 12, 536, 12, 286, 2894, 26, 5429, 545, 8631, 14491, 12, 8778, 63, 466, 304, 267, 408, 9345, 314, 5429, 545, 8631, 8778, 1041, 267, 291, 423, 32594, 275, 286, 2894, 267, 291, 423, 8956, 63, 466, 275, 8778, 63, 466, 267, 291, 423, 8956, 63, 344, 275, 428, 17850, 63, 7893, 59, 277, 423, 8956, 63, 466, 1527, 19, 61, 267, 291, 423, 354, 275, 536, 398, 327, 11828, 314, 5839, 8778, 267, 291, 423, 32594, 14, 957, 545, 2242, 14, 2683, 63, 8956, 8, 277, 423, 8956, 63, 344, 9, 398, 347, 485, 2479, 63, 873, 8, 1391, 304, 288, 340, 2729, 508, 291, 423, 8956, 63, 344, 26, 355, 485, 10186, 14, 1757, 360, 15461, 1678, 367, 450, 83, 3130, 2729, 9, 355, 291, 14, 7211, 63, 873, 63, 2411, 63, 929, 342, 398, 327, 11828, 367, 17475, 7029, 267, 17475, 63, 2242, 8, 288, 6298, 12, 24360, 63, 11265, 3230, 14657, 63, 10383, 63, 28467, 30487, 12, 485, 2479, 63, 873, 9, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 402, 314, 4642, 1041, 267, 862, 26, 288, 372, 291, 423, 32594, 14, 576, 59, 277, 423, 8956, 63, 344, 61, 267, 871, 4067, 26, 288, 372, 11377, 63, 11588, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 8778, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 7016, 8, 277, 304, 267, 408, 1767, 314, 7016, 370, 675, 315 ]
[ 199, 10397, 370, 3304, 282, 3107, 69, 6164, 424, 5429, 545, 28948, 1413, 13595, 15, 24223, 15, 6683, 373, 287, 280, 2212, 4137, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 3931, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 8956, 14, 957, 545, 2242, 15, 199, 624, 199, 646, 2050, 199, 199, 504, 8846, 14, 4608, 14, 957, 545, 2242, 492, 334, 272, 15265, 12, 5429, 545, 8631, 14491, 12, 10762, 63, 14211, 63, 12510, 32559, 12, 272, 10762, 63, 14211, 63, 40, 2639, 998, 1922, 12, 10762, 63, 1877, 28035, 63, 12510, 32559, 12, 272, 10762, 63, 1877, 28035, 63, 40, 2639, 998, 1922, 12, 10762, 63, 33, 3927, 63, 17114, 63, 7380, 31370, 12, 272, 10762, 63, 33, 3927, 63, 17114, 63, 1438, 6294, 7698, 12, 24360, 63, 11265, 3230, 14657, 63, 10383, 63, 28467, 30487, 9, 199, 504, 8846, 14, 1297, 492, 334, 272, 6392, 63, 3830, 11237, 16734, 12, 24314, 63, 21595, 2684, 1668, 12, 11377, 63, 11588, 9, 199, 504, 8846, 14, 7546, 14, 14913, 492, 17475, 63, 2242, 199, 504, 8846, 14, 7546, 14, 4502, 492, 17680, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 25743, 9415, 2563, 275, 788, 957, 545, 2242, 418, 199, 199, 24151, 63, 7893, 275, 1052, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 5429, 545, 8631, 13758, 4298, 1041, 272, 687, 1134, 957, 545, 2242, 492, 334, 267, 428, 17850, 63, 12510, 32559, 63, 30335, 12, 428, 17850, 63, 40, 2639, 998, 1922, 63, 30335, 12, 267, 428, 17850, 63, 12510, 32559, 63, 1877, 1649, 726, 12, 428, 17850, 63, 40, 2639, 998, 1922, 63, 1877, 1649, 726, 12, 267, 428, 17850, 63, 29091, 63, 7380, 31370, 63, 17114, 12, 428, 17850, 63, 29091, 63, 1438, 6294, 7698, 63, 17114, 9, 339, 2288, 428, 17850, 63, 7893, 272, 428, 17850, 63, 7893, 275, 469, 267, 10762, 63, 14211, 63, 12510, 32559, 26, 359, 288, 283, 607, 2441, 12540, 7899, 297, 288, 24314, 63, 21595, 2684, 1668, 12, 288, 283, 20208, 26, 728, 573, 10011, 297, 288, 428, 17850, 63, 12510, 32559, 63, 30335, 267, 2156, 267, 10762, 63, 14211, 63, 40, 2639, 998, 1922, 26, 359, 288, 283, 607, 2441, 869, 21704, 297, 288, 1543, 297, 288, 283, 20208, 26, 17217, 13, 7045, 297, 288, 428, 17850, 63, 40, 2639, 998, 1922, 63, 30335, 267, 2156, 267, 10762, 63, 1877, 28035, 63, 12510, 32559, 26, 359, 288, 283, 2204, 2441, 12540, 7899, 297, 288, 24314, 63, 21595, 2684, 1668, 12, 288, 283, 20208, 26, 728, 573, 10011, 297, 288, 428, 17850, 63, 12510, 32559, 63, 1877, 1649, 726, 267, 2156, 267, 10762, 63, 1877, 28035, 63, 40, 2639, 998, 1922, 26, 359, 288, 283, 2204, 2441, 869, 21704, 297, 288, 1543, 297, 288, 283, 20208, 26, 17217, 13, 7045, 297, 288, 428, 17850, 63, 40, 2639, 998, 1922, 63, 1877, 1649, 726, 267, 2156, 267, 10762, 63, 33, 3927, 63, 17114, 63, 7380, 31370, 26, 359, 288, 283, 17127, 590, 16321, 297, 288, 283, 77, 127, 112, 15, 72, 297, 288, 283, 20208, 26, 8387, 13, 5394, 281, 297, 288, 428, 17850, 63, 29091, 63, 7380, 31370, 63, 17114, 267, 2156, 267, 10762, 63, 33, 3927, 63, 17114, 63, 1438, 6294, 7698, 26, 359, 288, 283, 920, 2411, 833, 16321, 297, 288, 283, 77, 127, 112, 15, 72, 297, 288, 283, 20208, 26, 8387, 13, 5394, 281, 297, 288, 428, 17850, 63, 29091, 63, 1438, 6294, 7698, 63, 17114, 267, 2156, 272, 789, 339, 286, 2894, 275, 6298, 14, 576, 59, 7378, 61, 339, 19678, 275, 942, 272, 367, 2073, 315, 1101, 59, 3103, 63, 3830, 11237, 16734, 2189, 267, 8778, 63, 466, 275, 2073, 14, 2325, 342, 398, 340, 8778, 63, 466, 440, 315, 428, 17850, 63, 7893, 26, 288, 485, 10186, 14, 3764, 480, 10160, 730, 26, 450, 83, 365, 440, 282, 1686, 8778, 4765, 1169, 8778, 63, 466, 9, 288, 1980, 398, 19678, 14, 740, 8, 288, 5429, 545, 8631, 10160, 8, 355, 6298, 12, 355, 536, 5961, 83, 450, 83, 2, 450, 334, 32594, 14, 354, 12, 428, 17850, 63, 7893, 59, 8956, 63, 466, 1527, 16, 2522, 355, 286, 2894, 29, 32594, 12, 355, 8778, 63, 466, 29, 8956, 63, 466, 288, 776, 267, 776, 339, 1050, 63, 6410, 8, 22675, 12, 715, 9, 421, 199, 533, 5429, 545, 8631, 10160, 8, 7302, 304, 272, 408, 20609, 402, 282, 5429, 545, 8631, 8778, 1041, 339, 347, 636, 826, 721, 277, 12, 6298, 12, 536, 12, 286, 2894, 26, 5429, 545, 8631, 14491, 12, 8778, 63, 466, 304, 267, 408, 9345, 314, 5429, 545, 8631, 8778, 1041, 267, 291, 423, 32594, 275, 286, 2894, 267, 291, 423, 8956, 63, 466, 275, 8778, 63, 466, 267, 291, 423, 8956, 63, 344, 275, 428, 17850, 63, 7893, 59, 277, 423, 8956, 63, 466, 1527, 19, 61, 267, 291, 423, 354, 275, 536, 398, 327, 11828, 314, 5839, 8778, 267, 291, 423, 32594, 14, 957, 545, 2242, 14, 2683, 63, 8956, 8, 277, 423, 8956, 63, 344, 9, 398, 347, 485, 2479, 63, 873, 8, 1391, 304, 288, 340, 2729, 508, 291, 423, 8956, 63, 344, 26, 355, 485, 10186, 14, 1757, 360, 15461, 1678, 367, 450, 83, 3130, 2729, 9, 355, 291, 14, 7211, 63, 873, 63, 2411, 63, 929, 342, 398, 327, 11828, 367, 17475, 7029, 267, 17475, 63, 2242, 8, 288, 6298, 12, 24360, 63, 11265, 3230, 14657, 63, 10383, 63, 28467, 30487, 12, 485, 2479, 63, 873, 9, 339, 768, 1829, 272, 347, 1174, 8, 277, 304, 267, 408, 1767, 314, 1174, 402, 314, 4642, 1041, 267, 862, 26, 288, 372, 291, 423, 32594, 14, 576, 59, 277, 423, 8956, 63, 344, 61, 267, 871, 4067, 26, 288, 372, 11377, 63, 11588, 339, 768, 1829, 272, 347, 536, 8, 277, 304, 267, 408, 1767, 314, 536, 402, 314, 8778, 1041, 267, 372, 291, 423, 354, 339, 768, 1829, 272, 347, 7016, 8, 277, 304, 267, 408, 1767, 314, 7016, 370, 675, 315, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
mpetyx/pychatbot
SemanticWebApproach/RoboWriter/allegrordf-1.0.1/franz/miniclient/request.py
1
6234
import StringIO, pycurl, urllib, cjson, locale from threading import Lock class Pool: def __init__(self, create): self.create = create self.lock = Lock() self.pool = [] def get(self): self.lock.acquire() try: if len(self.pool): return self.pool.pop() else: return self.create() finally: self.lock.release() def put(self, value): self.lock.acquire() try: self.pool.append(value) finally: self.lock.release() curlPool = Pool(pycurl.Curl) class RequestError(Exception): def __init__(self, status, message): print status, message self.status = status self.message = message def __str__(self): return "Server returned %s: %s" % (self.status, self.message) def urlenc(**args): buf = [] def enc(name, val): buf.append(urllib.quote(name) + "=" + urllib.quote(val)) def encval(name, val): if val is None: pass elif isinstance(val, bool): enc(name, (val and "true") or "false") elif isinstance(val, int): enc(name, "%d" % val) elif isinstance(val, float): enc(name, "%g" % val) elif isinstance(val, list) or isinstance(val, tuple): for elt in val: encval(name, elt) elif isinstance(val, basestring): enc(name, val.encode("utf-8")) else: enc(name, unicode(val).encode("utf-8")) for name, val in args.iteritems(): encval(name, val) return "&".join(buf) def makeRequest(obj, method, url, body=None, accept="*/*", contentType=None, callback=None, errCallback=None): curl = curlPool.get() if obj: if obj.user and obj.password: curl.setopt(pycurl.USERPWD, "%s:%s" % (obj.user, obj.password)) curl.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC) if url.startswith("/"): url = obj.url + url postbody = method == "POST" or method == "PUT" curl.setopt(pycurl.POSTFIELDS, "") if body: if postbody: curl.setopt(pycurl.POSTFIELDS, body) else: url = url + "?" + body curl.setopt(pycurl.POST, (postbody and 1) or 0) curl.setopt(pycurl.CUSTOMREQUEST, method) curl.setopt(pycurl.URL, url) # The "Expect:" is there to suppress "Expect: 100-continue" # behaviour that is the default in libcurl when posting large # bodies. headers = ["Connection: keep-alive", "Accept: " + accept, "Expect:"] if contentType and postbody: headers.append("Content-Type: " + contentType) if callback: headers.append("Connection: close") curl.setopt(pycurl.HTTPHEADER, headers) curl.setopt(pycurl.ENCODING, "") # which means 'any encoding that curl supports' if callback: status = [None] error = [] def headerfunc(string): if status[0] is None: status[0] = locale.atoi(string.split(" ")[1]) return len(string) def writefunc(string): if status[0] == 200: callback(string) else: error.append(string.decode("utf-8")) curl.setopt(pycurl.WRITEFUNCTION, writefunc) curl.setopt(pycurl.HEADERFUNCTION, headerfunc) curl.perform() if status[0] != 200: errCallback(curl.getinfo(pycurl.RESPONSE_CODE), "".join(error)) else: buf = StringIO.StringIO() curl.setopt(pycurl.WRITEFUNCTION, buf.write) curl.perform() response = buf.getvalue().decode("utf-8") buf.close() result = (curl.getinfo(pycurl.RESPONSE_CODE), response) curlPool.put(curl) return result def jsonRequest(obj, method, url, body=None, contentType="application/x-www-form-urlencoded", rowreader=None, accept="application/json"): if rowreader is None: status, body = makeRequest(obj, method, url, body, accept, contentType) if (status == 200): if accept in ('application/json', 'text/integer', "application/x-quints+json"): body = cjson.decode(body) return body else: raise RequestError(status, body) else: def raiseErr(status, message): raise RequestError(status, message) makeRequest(obj, method, url, body, accept, contentType, callback=rowreader.process, errCallback=raiseErr) def nullRequest(obj, method, url, body=None, contentType="application/x-www-form-urlencoded"): status, body = makeRequest(obj, method, url, body, "application/json", contentType) if (status < 200 or status > 204): raise RequestError(status, body) class RowReader: def __init__(self, callback): self.hasNames = None self.names = None self.skipNextBracket = False self.callback = callback self.backlog = None def process(self, string): if self.hasNames is None: self.hasNames = string[0] == "{" if not self.hasNames: self.skipNextBracket = True ln = len(string) if self.backlog: string = self.backlog + string pos = [0] def useArray(arr): if self.hasNames: if self.names: self.callback(arr, self.names) else: self.names = arr self.skipNextBracket = True else: self.callback(arr, None) def takeArrayAt(start): scanned = start + 1 while True: end = string.find("]", scanned) if end == -1: return False try: useArray(cjson.decode(string[start : end + 1].decode("utf-8"))) pos[0] = end + 1 return True except cjson.DecodeError: scanned = end + 1 while True: start = string.find("[", pos[0]) if self.skipNextBracket: self.skipNextBracket = False pos[0] = start + 1 elif start == -1 or not takeArrayAt(start): break if pos[0] == 0: self.backlog = string return ln else: self.backlog = None return pos[0]
apache-2.0
[ 646, 5228, 12, 1134, 17096, 12, 4011, 12, 286, 1001, 12, 5867, 199, 199, 504, 5796, 492, 15536, 199, 199, 533, 15553, 26, 272, 347, 636, 826, 721, 277, 12, 1218, 304, 267, 291, 14, 981, 275, 1218, 267, 291, 14, 831, 275, 15536, 342, 267, 291, 14, 2293, 275, 942, 272, 347, 664, 8, 277, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 862, 26, 288, 340, 822, 8, 277, 14, 2293, 304, 372, 291, 14, 2293, 14, 1935, 342, 288, 587, 26, 372, 291, 14, 981, 342, 267, 3753, 26, 288, 291, 14, 831, 14, 3221, 342, 272, 347, 5324, 8, 277, 12, 574, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 862, 26, 288, 291, 14, 2293, 14, 740, 8, 585, 9, 267, 3753, 26, 288, 291, 14, 831, 14, 3221, 342, 199, 199, 17096, 5453, 275, 15553, 8, 11357, 633, 14, 35, 633, 9, 199, 199, 533, 4784, 547, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 2004, 12, 1245, 304, 267, 870, 2004, 12, 1245, 267, 291, 14, 1205, 275, 2004, 267, 291, 14, 1188, 275, 1245, 272, 347, 636, 495, 721, 277, 304, 267, 372, 298, 3120, 2138, 450, 83, 26, 450, 83, 2, 450, 334, 277, 14, 1205, 12, 291, 14, 1188, 9, 199, 199, 318, 7629, 552, 67, 3682, 589, 304, 272, 4123, 275, 942, 272, 347, 12011, 8, 354, 12, 1139, 304, 267, 4123, 14, 740, 8, 4078, 14, 3513, 8, 354, 9, 435, 22250, 435, 4011, 14, 3513, 8, 637, 430, 272, 347, 12011, 637, 8, 354, 12, 1139, 304, 267, 340, 1139, 365, 488, 26, 986, 267, 916, 1228, 8, 637, 12, 2155, 304, 12011, 8, 354, 12, 334, 637, 436, 298, 2052, 531, 503, 298, 3910, 531, 267, 916, 1228, 8, 637, 12, 1109, 304, 12011, 8, 354, 12, 2071, 68, 2, 450, 1139, 9, 267, 916, 1228, 8, 637, 12, 2069, 304, 12011, 8, 354, 12, 2071, 71, 2, 450, 1139, 9, 267, 916, 1228, 8, 637, 12, 769, 9, 503, 1228, 8, 637, 12, 2008, 304, 288, 367, 18409, 315, 1139, 26, 12011, 637, 8, 354, 12, 18409, 9, 267, 916, 1228, 8, 637, 12, 7116, 304, 288, 12011, 8, 354, 12, 1139, 14, 2143, 480, 1624, 13, 24, 2237, 267, 587, 26, 288, 12011, 8, 354, 12, 2649, 8, 637, 680, 2143, 480, 1624, 13, 24, 2237, 272, 367, 536, 12, 1139, 315, 1249, 14, 4611, 837, 267, 12011, 637, 8, 354, 12, 1139, 9, 272, 372, 11746, 1674, 904, 8, 1436, 9, 199, 199, 318, 1852, 2017, 8, 1113, 12, 1083, 12, 1166, 12, 2396, 29, 403, 12, 4729, 32103, 6331, 401, 1564, 804, 29, 403, 12, 3233, 29, 403, 12, 2329, 2806, 29, 403, 304, 272, 26145, 275, 26145, 5453, 14, 362, 342, 272, 340, 1559, 26, 267, 340, 1559, 14, 751, 436, 1559, 14, 2060, 26, 288, 26145, 14, 29852, 8, 11357, 633, 14, 3791, 10780, 36, 12, 2071, 83, 2689, 83, 2, 450, 334, 1113, 14, 751, 12, 1559, 14, 2060, 430, 288, 26145, 14, 29852, 8, 11357, 633, 14, 2856, 5580, 12, 1134, 17096, 14, 2856, 5580, 63, 27271, 9, 267, 340, 1166, 14, 2460, 4769, 2349, 1166, 275, 1559, 14, 633, 435, 1166, 339, 2963, 2030, 275, 1083, 508, 298, 4030, 2, 503, 1083, 508, 298, 4013, 2, 272, 26145, 14, 29852, 8, 11357, 633, 14, 4030, 12767, 12, 6899, 272, 340, 2396, 26, 267, 340, 2963, 2030, 26, 288, 26145, 14, 29852, 8, 11357, 633, 14, 4030, 12767, 12, 2396, 9, 267, 587, 26, 288, 1166, 275, 1166, 435, 29325, 435, 2396, 339, 26145, 14, 29852, 8, 11357, 633, 14, 4030, 12, 334, 1932, 2030, 436, 413, 9, 503, 378, 9, 272, 26145, 14, 29852, 8, 11357, 633, 14, 20519, 6780, 12, 1083, 9, 272, 26145, 14, 29852, 8, 11357, 633, 14, 2632, 12, 1166, 9, 339, 327, 710, 298, 13495, 5424, 365, 2337, 370, 15678, 298, 13495, 26, 2948, 13, 6958, 2, 272, 327, 13942, 626, 365, 314, 849, 315, 1973, 17096, 1380, 25386, 7031, 272, 327, 1234, 18245, 14, 272, 2323, 275, 2097, 3225, 26, 4215, 13, 9631, 401, 298, 8422, 26, 298, 435, 4729, 12, 298, 13495, 26, 937, 272, 340, 1564, 804, 436, 2963, 2030, 26, 2323, 14, 740, 480, 2714, 13, 804, 26, 298, 435, 1564, 804, 9, 272, 340, 3233, 26, 2323, 14, 740, 480, 3225, 26, 4002, 531, 272, 26145, 14, 29852, 8, 11357, 633, 14, 2856, 7311, 12, 2323, 9, 272, 26145, 14, 29852, 8, 11357, 633, 14, 16314, 12, 6899, 327, 1314, 4910, 283, 1629, 2644, 626, 26145, 5171, 7, 339, 340, 3233, 26, 267, 2004, 275, 359, 403, 61, 267, 1125, 275, 942, 267, 347, 1406, 1532, 8, 875, 304, 288, 340, 2004, 59, 16, 61, 365, 488, 26, 355, 2004, 59, 16, 61, 275, 5867, 14, 11318, 73, 8, 875, 14, 1294, 480, 298, 2788, 17, 566, 288, 372, 822, 8, 875, 9, 267, 347, 2218, 1532, 8, 875, 304, 288, 340, 2004, 59, 16, 61, 508, 1926, 26, 3233, 8, 875, 9, 288, 587, 26, 1125, 14, 740, 8, 875, 14, 2708, 480, 1624, 13, 24, 2237, 267, 26145, 14, 29852, 8, 11357, 633, 14, 10387, 15476, 12, 2218, 1532, 9, 267, 26145, 14, 29852, 8, 11357, 633, 14, 7311, 15476, 12, 1406, 1532, 9, 267, 26145, 14, 15795, 342, 267, 340, 2004, 59, 16, 61, 1137, 1926, 26, 288, 2329, 2806, 8, 17096, 14, 32286, 8, 11357, 633, 14, 12801, 63, 6012, 395, 10587, 904, 8, 705, 430, 272, 587, 26, 267, 4123, 275, 5228, 14, 6424, 342, 267, 26145, 14, 29852, 8, 11357, 633, 14, 10387, 15476, 12, 4123, 14, 952, 9, 267, 26145, 14, 15795, 342, 267, 1177, 275, 4123, 14, 7150, 1252, 2708, 480, 1624, 13, 24, 531, 267, 4123, 14, 1600, 342, 267, 754, 275, 334, 17096, 14, 32286, 8, 11357, 633, 14, 12801, 63, 6012, 395, 1177, 9, 267, 26145, 5453, 14, 524, 8, 17096, 9, 267, 372, 754, 199, 199, 318, 2022, 2017, 8, 1113, 12, 1083, 12, 1166, 12, 2396, 29, 403, 12, 1564, 804, 628, 3578, 15, 88, 13, 1544, 13, 964, 13, 21886, 401, 1962, 5503 ]
[ 5228, 12, 1134, 17096, 12, 4011, 12, 286, 1001, 12, 5867, 199, 199, 504, 5796, 492, 15536, 199, 199, 533, 15553, 26, 272, 347, 636, 826, 721, 277, 12, 1218, 304, 267, 291, 14, 981, 275, 1218, 267, 291, 14, 831, 275, 15536, 342, 267, 291, 14, 2293, 275, 942, 272, 347, 664, 8, 277, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 862, 26, 288, 340, 822, 8, 277, 14, 2293, 304, 372, 291, 14, 2293, 14, 1935, 342, 288, 587, 26, 372, 291, 14, 981, 342, 267, 3753, 26, 288, 291, 14, 831, 14, 3221, 342, 272, 347, 5324, 8, 277, 12, 574, 304, 267, 291, 14, 831, 14, 8174, 342, 267, 862, 26, 288, 291, 14, 2293, 14, 740, 8, 585, 9, 267, 3753, 26, 288, 291, 14, 831, 14, 3221, 342, 199, 199, 17096, 5453, 275, 15553, 8, 11357, 633, 14, 35, 633, 9, 199, 199, 533, 4784, 547, 8, 1726, 304, 272, 347, 636, 826, 721, 277, 12, 2004, 12, 1245, 304, 267, 870, 2004, 12, 1245, 267, 291, 14, 1205, 275, 2004, 267, 291, 14, 1188, 275, 1245, 272, 347, 636, 495, 721, 277, 304, 267, 372, 298, 3120, 2138, 450, 83, 26, 450, 83, 2, 450, 334, 277, 14, 1205, 12, 291, 14, 1188, 9, 199, 199, 318, 7629, 552, 67, 3682, 589, 304, 272, 4123, 275, 942, 272, 347, 12011, 8, 354, 12, 1139, 304, 267, 4123, 14, 740, 8, 4078, 14, 3513, 8, 354, 9, 435, 22250, 435, 4011, 14, 3513, 8, 637, 430, 272, 347, 12011, 637, 8, 354, 12, 1139, 304, 267, 340, 1139, 365, 488, 26, 986, 267, 916, 1228, 8, 637, 12, 2155, 304, 12011, 8, 354, 12, 334, 637, 436, 298, 2052, 531, 503, 298, 3910, 531, 267, 916, 1228, 8, 637, 12, 1109, 304, 12011, 8, 354, 12, 2071, 68, 2, 450, 1139, 9, 267, 916, 1228, 8, 637, 12, 2069, 304, 12011, 8, 354, 12, 2071, 71, 2, 450, 1139, 9, 267, 916, 1228, 8, 637, 12, 769, 9, 503, 1228, 8, 637, 12, 2008, 304, 288, 367, 18409, 315, 1139, 26, 12011, 637, 8, 354, 12, 18409, 9, 267, 916, 1228, 8, 637, 12, 7116, 304, 288, 12011, 8, 354, 12, 1139, 14, 2143, 480, 1624, 13, 24, 2237, 267, 587, 26, 288, 12011, 8, 354, 12, 2649, 8, 637, 680, 2143, 480, 1624, 13, 24, 2237, 272, 367, 536, 12, 1139, 315, 1249, 14, 4611, 837, 267, 12011, 637, 8, 354, 12, 1139, 9, 272, 372, 11746, 1674, 904, 8, 1436, 9, 199, 199, 318, 1852, 2017, 8, 1113, 12, 1083, 12, 1166, 12, 2396, 29, 403, 12, 4729, 32103, 6331, 401, 1564, 804, 29, 403, 12, 3233, 29, 403, 12, 2329, 2806, 29, 403, 304, 272, 26145, 275, 26145, 5453, 14, 362, 342, 272, 340, 1559, 26, 267, 340, 1559, 14, 751, 436, 1559, 14, 2060, 26, 288, 26145, 14, 29852, 8, 11357, 633, 14, 3791, 10780, 36, 12, 2071, 83, 2689, 83, 2, 450, 334, 1113, 14, 751, 12, 1559, 14, 2060, 430, 288, 26145, 14, 29852, 8, 11357, 633, 14, 2856, 5580, 12, 1134, 17096, 14, 2856, 5580, 63, 27271, 9, 267, 340, 1166, 14, 2460, 4769, 2349, 1166, 275, 1559, 14, 633, 435, 1166, 339, 2963, 2030, 275, 1083, 508, 298, 4030, 2, 503, 1083, 508, 298, 4013, 2, 272, 26145, 14, 29852, 8, 11357, 633, 14, 4030, 12767, 12, 6899, 272, 340, 2396, 26, 267, 340, 2963, 2030, 26, 288, 26145, 14, 29852, 8, 11357, 633, 14, 4030, 12767, 12, 2396, 9, 267, 587, 26, 288, 1166, 275, 1166, 435, 29325, 435, 2396, 339, 26145, 14, 29852, 8, 11357, 633, 14, 4030, 12, 334, 1932, 2030, 436, 413, 9, 503, 378, 9, 272, 26145, 14, 29852, 8, 11357, 633, 14, 20519, 6780, 12, 1083, 9, 272, 26145, 14, 29852, 8, 11357, 633, 14, 2632, 12, 1166, 9, 339, 327, 710, 298, 13495, 5424, 365, 2337, 370, 15678, 298, 13495, 26, 2948, 13, 6958, 2, 272, 327, 13942, 626, 365, 314, 849, 315, 1973, 17096, 1380, 25386, 7031, 272, 327, 1234, 18245, 14, 272, 2323, 275, 2097, 3225, 26, 4215, 13, 9631, 401, 298, 8422, 26, 298, 435, 4729, 12, 298, 13495, 26, 937, 272, 340, 1564, 804, 436, 2963, 2030, 26, 2323, 14, 740, 480, 2714, 13, 804, 26, 298, 435, 1564, 804, 9, 272, 340, 3233, 26, 2323, 14, 740, 480, 3225, 26, 4002, 531, 272, 26145, 14, 29852, 8, 11357, 633, 14, 2856, 7311, 12, 2323, 9, 272, 26145, 14, 29852, 8, 11357, 633, 14, 16314, 12, 6899, 327, 1314, 4910, 283, 1629, 2644, 626, 26145, 5171, 7, 339, 340, 3233, 26, 267, 2004, 275, 359, 403, 61, 267, 1125, 275, 942, 267, 347, 1406, 1532, 8, 875, 304, 288, 340, 2004, 59, 16, 61, 365, 488, 26, 355, 2004, 59, 16, 61, 275, 5867, 14, 11318, 73, 8, 875, 14, 1294, 480, 298, 2788, 17, 566, 288, 372, 822, 8, 875, 9, 267, 347, 2218, 1532, 8, 875, 304, 288, 340, 2004, 59, 16, 61, 508, 1926, 26, 3233, 8, 875, 9, 288, 587, 26, 1125, 14, 740, 8, 875, 14, 2708, 480, 1624, 13, 24, 2237, 267, 26145, 14, 29852, 8, 11357, 633, 14, 10387, 15476, 12, 2218, 1532, 9, 267, 26145, 14, 29852, 8, 11357, 633, 14, 7311, 15476, 12, 1406, 1532, 9, 267, 26145, 14, 15795, 342, 267, 340, 2004, 59, 16, 61, 1137, 1926, 26, 288, 2329, 2806, 8, 17096, 14, 32286, 8, 11357, 633, 14, 12801, 63, 6012, 395, 10587, 904, 8, 705, 430, 272, 587, 26, 267, 4123, 275, 5228, 14, 6424, 342, 267, 26145, 14, 29852, 8, 11357, 633, 14, 10387, 15476, 12, 4123, 14, 952, 9, 267, 26145, 14, 15795, 342, 267, 1177, 275, 4123, 14, 7150, 1252, 2708, 480, 1624, 13, 24, 531, 267, 4123, 14, 1600, 342, 267, 754, 275, 334, 17096, 14, 32286, 8, 11357, 633, 14, 12801, 63, 6012, 395, 1177, 9, 267, 26145, 5453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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 ]
aubreystarktoller/django-babik-card-primitives
setup.py
1
1665
import sys from setuptools import setup from setuptools.command.test import test as TestCommand class PyTest(TestCommand): user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] def initialize_options(self): TestCommand.initialize_options(self) self.pytest_args = [] def finalize_options(self): TestCommand.finalize_options(self) self.test_args = [] self.test_suite = True def run_tests(self): import pytest errno = pytest.main(self.pytest_args) sys.exit(errno) setup( name="django-babik-card-primitives", version="0.1.0", description="Basic functionallity for handling credit card information", author="Aubrey Stark-Toller", author_email="aubrey@deepearth.uk", license="BSD", include_package_data=True, classifiers=[ "Development Status :: 3 - Alpha", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", ], keywords="project django", packages=["babik_card_primitives"], install_requires = ["django>=1.8,<1.10"], tests_require = ["pytest", "pytest-django", "pytest-cov", 'testfixtures'], cmdclass = {'test': PyTest} )
bsd-3-clause
[ 646, 984, 199, 504, 9116, 492, 3272, 199, 504, 9116, 14, 1531, 14, 396, 492, 511, 465, 1379, 3110, 199, 199, 533, 1611, 774, 8, 774, 3110, 304, 272, 922, 63, 1419, 275, 4274, 4462, 13, 589, 4009, 283, 65, 297, 298, 14517, 370, 986, 370, 1134, 14, 396, 11323, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 1379, 3110, 14, 8489, 63, 1419, 8, 277, 9, 267, 291, 14, 4462, 63, 589, 275, 942, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 1379, 3110, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 396, 63, 589, 275, 942, 267, 291, 14, 396, 63, 5768, 275, 715, 339, 347, 1255, 63, 2219, 8, 277, 304, 267, 492, 4613, 267, 7554, 275, 4613, 14, 973, 8, 277, 14, 4462, 63, 589, 9, 267, 984, 14, 2224, 8, 7931, 9, 199, 199, 2758, 8, 272, 536, 628, 1176, 13, 26118, 3258, 13, 5841, 13, 1359, 22337, 401, 272, 1015, 628, 16, 14, 17, 14, 16, 401, 272, 1369, 628, 6845, 22380, 5075, 367, 7252, 16630, 12564, 2556, 401, 272, 4132, 628, 33, 456, 17885, 1933, 1096, 13, 52, 393, 1435, 401, 272, 4132, 63, 2123, 628, 65, 456, 17885, 32, 11192, 16343, 273, 14, 3210, 401, 272, 4190, 628, 15400, 401, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 19137, 1524, 267, 298, 23753, 9795, 3800, 650, 446, 32657, 401, 267, 298, 16442, 3800, 5634, 401, 267, 298, 23910, 23975, 3800, 23493, 401, 267, 298, 3761, 3800, 25718, 26330, 3800, 6289, 844, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 18, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 21, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 24425, 3800, 25654, 401, 272, 2156, 272, 7681, 628, 1715, 1639, 401, 272, 6117, 6270, 26118, 3258, 63, 5841, 63, 1359, 22337, 2255, 272, 3907, 63, 6537, 275, 2097, 1176, 8119, 17, 14, 24, 30027, 17, 14, 709, 2255, 272, 2295, 63, 4365, 275, 2097, 4462, 401, 298, 4462, 13, 1176, 401, 298, 4462, 13, 8695, 401, 283, 396, 8769, 995, 272, 2088, 533, 275, 791, 396, 356, 1611, 774, 93, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 984, 199, 504, 9116, 492, 3272, 199, 504, 9116, 14, 1531, 14, 396, 492, 511, 465, 1379, 3110, 199, 199, 533, 1611, 774, 8, 774, 3110, 304, 272, 922, 63, 1419, 275, 4274, 4462, 13, 589, 4009, 283, 65, 297, 298, 14517, 370, 986, 370, 1134, 14, 396, 11323, 339, 347, 8265, 63, 1419, 8, 277, 304, 267, 1379, 3110, 14, 8489, 63, 1419, 8, 277, 9, 267, 291, 14, 4462, 63, 589, 275, 942, 339, 347, 17284, 63, 1419, 8, 277, 304, 267, 1379, 3110, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 396, 63, 589, 275, 942, 267, 291, 14, 396, 63, 5768, 275, 715, 339, 347, 1255, 63, 2219, 8, 277, 304, 267, 492, 4613, 267, 7554, 275, 4613, 14, 973, 8, 277, 14, 4462, 63, 589, 9, 267, 984, 14, 2224, 8, 7931, 9, 199, 199, 2758, 8, 272, 536, 628, 1176, 13, 26118, 3258, 13, 5841, 13, 1359, 22337, 401, 272, 1015, 628, 16, 14, 17, 14, 16, 401, 272, 1369, 628, 6845, 22380, 5075, 367, 7252, 16630, 12564, 2556, 401, 272, 4132, 628, 33, 456, 17885, 1933, 1096, 13, 52, 393, 1435, 401, 272, 4132, 63, 2123, 628, 65, 456, 17885, 32, 11192, 16343, 273, 14, 3210, 401, 272, 4190, 628, 15400, 401, 272, 2387, 63, 2491, 63, 576, 29, 549, 12, 272, 19137, 1524, 267, 298, 23753, 9795, 3800, 650, 446, 32657, 401, 267, 298, 16442, 3800, 5634, 401, 267, 298, 23910, 23975, 3800, 23493, 401, 267, 298, 3761, 3800, 25718, 26330, 3800, 6289, 844, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 18, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 650, 14, 21, 401, 267, 298, 11411, 8466, 3800, 2018, 3800, 24425, 3800, 25654, 401, 272, 2156, 272, 7681, 628, 1715, 1639, 401, 272, 6117, 6270, 26118, 3258, 63, 5841, 63, 1359, 22337, 2255, 272, 3907, 63, 6537, 275, 2097, 1176, 8119, 17, 14, 24, 30027, 17, 14, 709, 2255, 272, 2295, 63, 4365, 275, 2097, 4462, 401, 298, 4462, 13, 1176, 401, 298, 4462, 13, 8695, 401, 283, 396, 8769, 995, 272, 2088, 533, 275, 791, 396, 356, 1611, 774, 93, 199, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
simonkrogmann/planets
gui/object_3D.py
1
4105
# -*- coding: cp1252 -*- import vector import time class Planet3D: """ein 3D-Objekt für das graphics-Modul, dass mit einem Planeten verbunden ist""" def __init__(self, Parent, Planet): self.Parent = Parent self.Planet = Planet self.Planet.Register(self) self.Positions = [Planet["position"].Tuple()] self.Trace = [] self.Color = Planet["color"] self.TraceState = -1 self.Drawing = self.Parent.Canvas.create_oval(-5, -5, -6, -6, fill = Planet["color"], outline = "") self.Redraw() def ResetTrace(self): """löscht die bisher gezeichnete Spur des Planeten""" for Line in self.Trace: self.Parent.Canvas.delete(Line.Drawing) self.Parent.Drawings.remove(Line) self.Trace = [] self.TraceState = -1 self.Positions = [self.Positions[-1]] def Redraw(self): """zeichnet den Planeten neu""" C = self.Parent.DisplayPosition(self.Positions[-1]) if C: Diameter = self.Parent.DisplayDiameter(self.Positions[-1], self.Planet["diameter"]) Coordinates = (C[0] - Diameter, C[1] - Diameter, C[0] + Diameter, C[1] + Diameter) self.Parent.Canvas.coords(self.Drawing, Coordinates) else: self.Parent.Canvas.coords(self.Drawing, -5, -5, -6, -6) def Update(self, Tag, Value): """ändert die Zeichnung des Planeten entsprechend der Daten. Mögliche Daten sind die Planetenattribute.""" if Tag == "position": if type(Value) == tuple: Tuple = Value else: Tuple = Value.Tuple() if self.Planet["trace"] and self.Planet.Parent.Trace: # fasst jeweils 5 Linien für die Spur zusammen self.TraceState = (self.TraceState + 1) % 5 if not self.TraceState: self.Trace.append(Line3D(self.Parent, self.Positions[-1], Tuple, self.Color)) self.Parent.Drawings.append(self.Trace[-1]) self.Positions.append(Tuple) else: self.Positions[-1] = Tuple self.Trace[-1].End = Tuple self.Trace[-1].Redraw() else: self.Positions = [Tuple] self.Redraw() elif Tag == "diameter": self.Redraw() elif Tag == "color": self.SetColor(Value) elif Tag == "trace" and not Value: self.ResetTrace() def SetColor(self, Color): """ändert die Planetenfarbe""" self.Color = Color self.Parent.Canvas.itemconfig(self.Drawing, fill = Color) def Delete(self): """entfernt den Planeten aus der Zeichnung""" for Line in self.Trace: self.Parent.Canvas.delete(Line.Drawing) self.Parent.Drawings.remove(Line) self.Parent.Canvas.delete(self.Drawing) self.Planet.Deregister(self) def MidPoint(self): """gibt den Mittelpunkt des Planeten zurück""" return self.Positions[-1] class Line3D: """eine 3D-Linie für das graphics-Modul""" def __init__(self, Parent, Begin, End, Color): self.Parent = Parent self.Begin = Begin self.End = End self.OnScreen = False self.Drawing = self.Parent.Canvas.create_line(-5, -5, -5, -5, fill = Color) self.Redraw() def Redraw(self): """zeichnet die Linie neu""" Coordinates = self.Parent.LineDisplayCoordinates(self.Begin, self.End) if Coordinates != (-5,-5,-5,-5): self.Parent.Canvas.coords(self.Drawing, Coordinates) self.OnScreen = True elif self.OnScreen: self.OnScreen = False self.Parent.Canvas.coords(self.Drawing, Coordinates) def MidPoint(self): """gibt den Mittelpunkt der Linie zurück""" return ((self.Begin[0] + self.End[0])/ 2, (self.Begin[1] + self.End[1])/ 2, (self.Begin[2] + self.End[2])/ 2)
mit
[ 3, 1882, 2803, 26, 7667, 19364, 1882, 199, 646, 5477, 199, 646, 900, 199, 199, 533, 32427, 386, 19, 36, 26, 272, 408, 69, 262, 650, 36, 13, 5665, 5711, 84, 289, 17709, 82, 366, 305, 24348, 13, 9871, 348, 12, 366, 405, 30714, 325, 1132, 77, 510, 24064, 724, 16041, 324, 848, 284, 270, 624, 272, 347, 636, 826, 721, 277, 12, 16396, 12, 32427, 386, 304, 267, 291, 14, 6652, 275, 16396, 267, 291, 14, 13375, 386, 275, 32427, 386, 267, 291, 14, 13375, 386, 14, 7099, 8, 277, 9, 267, 291, 14, 32650, 275, 359, 13375, 386, 905, 3124, 4140, 7075, 5106, 267, 291, 14, 3921, 275, 942, 267, 291, 14, 4117, 275, 32427, 386, 905, 2326, 937, 267, 291, 14, 3921, 2223, 275, 446, 17, 267, 291, 14, 9654, 316, 275, 291, 14, 6652, 14, 15174, 14, 981, 63, 79, 637, 2801, 21, 12, 446, 21, 12, 446, 22, 12, 446, 22, 12, 5554, 275, 32427, 386, 905, 2326, 2255, 10028, 17964, 275, 6899, 267, 291, 14, 10858, 1773, 342, 339, 347, 15510, 3921, 8, 277, 304, 267, 408, 76, 14614, 15820, 84, 18833, 330, 2453, 281, 2312, 806, 1158, 685, 266, 428, 6653, 18618, 510, 24064, 724, 624, 267, 367, 7030, 315, 291, 14, 3921, 26, 288, 291, 14, 6652, 14, 15174, 14, 1807, 8, 3049, 14, 9654, 316, 9, 288, 291, 14, 6652, 14, 9654, 780, 14, 2168, 8, 3049, 9, 267, 291, 14, 3921, 275, 942, 267, 291, 14, 3921, 2223, 275, 446, 17, 267, 291, 14, 32650, 275, 359, 277, 14, 32650, 1988, 17, 2677, 339, 347, 9572, 1773, 8, 277, 304, 267, 408, 806, 1158, 846, 5376, 510, 24064, 724, 1279, 85, 624, 267, 445, 275, 291, 14, 6652, 14, 7687, 5625, 8, 277, 14, 32650, 1988, 17, 566, 267, 340, 445, 26, 288, 3757, 1787, 275, 291, 14, 6652, 14, 7687, 1341, 1787, 8, 277, 14, 32650, 1988, 17, 467, 291, 14, 13375, 386, 905, 328, 1787, 3135, 288, 25334, 2335, 275, 334, 35, 59, 16, 61, 446, 3757, 1787, 12, 445, 59, 17, 61, 446, 3757, 1787, 12, 445, 59, 16, 61, 435, 3757, 1787, 12, 445, 59, 17, 61, 435, 3757, 1787, 9, 288, 291, 14, 6652, 14, 15174, 14, 8032, 8, 277, 14, 9654, 316, 12, 25334, 2335, 9, 267, 587, 26, 288, 291, 14, 6652, 14, 15174, 14, 8032, 8, 277, 14, 9654, 316, 12, 446, 21, 12, 446, 21, 12, 446, 22, 12, 446, 22, 9, 339, 347, 6162, 8, 277, 12, 8053, 12, 1594, 304, 267, 408, 13733, 78, 424, 84, 18833, 3107, 69, 1158, 78, 10335, 18618, 510, 24064, 724, 15992, 83, 657, 335, 500, 16921, 6148, 78, 14, 199, 45, 14614, 71, 317, 595, 6148, 78, 308, 688, 18833, 510, 24064, 724, 3215, 1041, 267, 340, 8053, 508, 298, 3124, 582, 288, 340, 730, 8, 1110, 9, 508, 2008, 26, 355, 11634, 275, 1594, 288, 587, 26, 355, 11634, 275, 1594, 14, 7075, 342, 288, 340, 291, 14, 13375, 386, 905, 3446, 937, 436, 291, 14, 13375, 386, 14, 6652, 14, 3921, 26, 355, 327, 289, 305, 270, 1335, 546, 69, 17841, 959, 491, 2730, 287, 289, 17709, 82, 18833, 428, 6653, 1315, 527, 455, 1410, 355, 291, 14, 3921, 2223, 275, 334, 277, 14, 3921, 2223, 435, 413, 9, 450, 959, 355, 340, 440, 291, 14, 3921, 2223, 26, 490, 291, 14, 3921, 14, 740, 8, 3049, 19, 36, 8, 277, 14, 6652, 12, 291, 14, 32650, 1988, 17, 467, 11634, 12, 291, 14, 4117, 430, 490, 291, 14, 6652, 14, 9654, 780, 14, 740, 8, 277, 14, 3921, 1988, 17, 566, 490, 291, 14, 32650, 14, 740, 8, 7075, 9, 355, 587, 26, 490, 291, 14, 32650, 1988, 17, 61, 275, 11634, 490, 291, 14, 3921, 1988, 17, 1055, 3005, 275, 11634, 490, 291, 14, 3921, 1988, 17, 1055, 10858, 1773, 342, 288, 587, 26, 355, 291, 14, 32650, 275, 359, 7075, 61, 288, 291, 14, 10858, 1773, 342, 267, 916, 8053, 508, 298, 328, 1787, 582, 288, 291, 14, 10858, 1773, 342, 267, 916, 8053, 508, 298, 2326, 582, 288, 291, 14, 1084, 4117, 8, 1110, 9, 267, 916, 8053, 508, 298, 3446, 2, 436, 440, 1594, 26, 288, 291, 14, 9637, 3921, 342, 339, 347, 2494, 4117, 8, 277, 12, 11581, 304, 267, 408, 13733, 78, 424, 84, 18833, 510, 24064, 724, 15315, 1235, 624, 267, 291, 14, 4117, 275, 11581, 267, 291, 14, 6652, 14, 15174, 14, 1053, 888, 8, 277, 14, 9654, 316, 12, 5554, 275, 11581, 9, 339, 347, 8496, 8, 277, 304, 267, 408, 484, 2412, 343, 5376, 510, 24064, 724, 282, 527, 16921, 3107, 69, 1158, 78, 10335, 624, 267, 367, 7030, 315, 291, 14, 3921, 26, 288, 291, 14, 6652, 14, 15174, 14, 1807, 8, 3049, 14, 9654, 316, 9, 288, 291, 14, 6652, 14, 9654, 780, 14, 2168, 8, 3049, 9, 267, 291, 14, 6652, 14, 15174, 14, 1807, 8, 277, 14, 9654, 316, 9, 267, 291, 14, 13375, 386, 14, 872, 2683, 8, 277, 9, 339, 347, 603, 344, 3428, 8, 277, 304, 267, 408, 71, 1892, 84, 5376, 603, 390, 266, 10343, 1778, 84, 18618, 510, 24064, 724, 1315, 300, 17709, 346, 624, 267, 372, 291, 14, 32650, 1988, 17, 61, 199, 199, 533, 7030, 19, 36, 26, 272, 408, 69, 1132, 650, 36, 13, 27889, 1873, 289, 17709, 82, 366, 305, 24348, 13, 9871, 348, 624, 272, 347, 636, 826, 721, 277, 12, 16396, 12, 25754, 12, 9599, 12, 11581, 304, 267, 291, 14, 6652, 275, 16396, 267, 291, 14, 5595, 275, 25754, 267, 291, 14, 3005, 275, 9599, 267, 291, 14, 3314, 9616, 275, 756, 398, 291, 14, 9654, 316, 275, 291, 14, 6652, 14, 15174, 14, 981, 63, 604, 2801, 21, 12, 446, 21, 12, 446, 21, 12, 446, 21, 12, 5554, 275, 11581, 9, 267, 291, 14, 10858, 1773, 342, 339, 347, 9572, 1773, 8, 277, 304, 267, 408, 806, 1158, 846, 18833, 29730, 1873, 1279, 85, 624, 267, 25334, 2335, 275, 291, 14, 6652, 14, 3049, 7687, 13940, 2335, 8, 277, 14, 5595, 12, 291, 14, 3005, 9, 267, 340, 25334, 2335, 1137, 5868, 21, 3057, 21, 3057 ]
[ 1882, 2803, 26, 7667, 19364, 1882, 199, 646, 5477, 199, 646, 900, 199, 199, 533, 32427, 386, 19, 36, 26, 272, 408, 69, 262, 650, 36, 13, 5665, 5711, 84, 289, 17709, 82, 366, 305, 24348, 13, 9871, 348, 12, 366, 405, 30714, 325, 1132, 77, 510, 24064, 724, 16041, 324, 848, 284, 270, 624, 272, 347, 636, 826, 721, 277, 12, 16396, 12, 32427, 386, 304, 267, 291, 14, 6652, 275, 16396, 267, 291, 14, 13375, 386, 275, 32427, 386, 267, 291, 14, 13375, 386, 14, 7099, 8, 277, 9, 267, 291, 14, 32650, 275, 359, 13375, 386, 905, 3124, 4140, 7075, 5106, 267, 291, 14, 3921, 275, 942, 267, 291, 14, 4117, 275, 32427, 386, 905, 2326, 937, 267, 291, 14, 3921, 2223, 275, 446, 17, 267, 291, 14, 9654, 316, 275, 291, 14, 6652, 14, 15174, 14, 981, 63, 79, 637, 2801, 21, 12, 446, 21, 12, 446, 22, 12, 446, 22, 12, 5554, 275, 32427, 386, 905, 2326, 2255, 10028, 17964, 275, 6899, 267, 291, 14, 10858, 1773, 342, 339, 347, 15510, 3921, 8, 277, 304, 267, 408, 76, 14614, 15820, 84, 18833, 330, 2453, 281, 2312, 806, 1158, 685, 266, 428, 6653, 18618, 510, 24064, 724, 624, 267, 367, 7030, 315, 291, 14, 3921, 26, 288, 291, 14, 6652, 14, 15174, 14, 1807, 8, 3049, 14, 9654, 316, 9, 288, 291, 14, 6652, 14, 9654, 780, 14, 2168, 8, 3049, 9, 267, 291, 14, 3921, 275, 942, 267, 291, 14, 3921, 2223, 275, 446, 17, 267, 291, 14, 32650, 275, 359, 277, 14, 32650, 1988, 17, 2677, 339, 347, 9572, 1773, 8, 277, 304, 267, 408, 806, 1158, 846, 5376, 510, 24064, 724, 1279, 85, 624, 267, 445, 275, 291, 14, 6652, 14, 7687, 5625, 8, 277, 14, 32650, 1988, 17, 566, 267, 340, 445, 26, 288, 3757, 1787, 275, 291, 14, 6652, 14, 7687, 1341, 1787, 8, 277, 14, 32650, 1988, 17, 467, 291, 14, 13375, 386, 905, 328, 1787, 3135, 288, 25334, 2335, 275, 334, 35, 59, 16, 61, 446, 3757, 1787, 12, 445, 59, 17, 61, 446, 3757, 1787, 12, 445, 59, 16, 61, 435, 3757, 1787, 12, 445, 59, 17, 61, 435, 3757, 1787, 9, 288, 291, 14, 6652, 14, 15174, 14, 8032, 8, 277, 14, 9654, 316, 12, 25334, 2335, 9, 267, 587, 26, 288, 291, 14, 6652, 14, 15174, 14, 8032, 8, 277, 14, 9654, 316, 12, 446, 21, 12, 446, 21, 12, 446, 22, 12, 446, 22, 9, 339, 347, 6162, 8, 277, 12, 8053, 12, 1594, 304, 267, 408, 13733, 78, 424, 84, 18833, 3107, 69, 1158, 78, 10335, 18618, 510, 24064, 724, 15992, 83, 657, 335, 500, 16921, 6148, 78, 14, 199, 45, 14614, 71, 317, 595, 6148, 78, 308, 688, 18833, 510, 24064, 724, 3215, 1041, 267, 340, 8053, 508, 298, 3124, 582, 288, 340, 730, 8, 1110, 9, 508, 2008, 26, 355, 11634, 275, 1594, 288, 587, 26, 355, 11634, 275, 1594, 14, 7075, 342, 288, 340, 291, 14, 13375, 386, 905, 3446, 937, 436, 291, 14, 13375, 386, 14, 6652, 14, 3921, 26, 355, 327, 289, 305, 270, 1335, 546, 69, 17841, 959, 491, 2730, 287, 289, 17709, 82, 18833, 428, 6653, 1315, 527, 455, 1410, 355, 291, 14, 3921, 2223, 275, 334, 277, 14, 3921, 2223, 435, 413, 9, 450, 959, 355, 340, 440, 291, 14, 3921, 2223, 26, 490, 291, 14, 3921, 14, 740, 8, 3049, 19, 36, 8, 277, 14, 6652, 12, 291, 14, 32650, 1988, 17, 467, 11634, 12, 291, 14, 4117, 430, 490, 291, 14, 6652, 14, 9654, 780, 14, 740, 8, 277, 14, 3921, 1988, 17, 566, 490, 291, 14, 32650, 14, 740, 8, 7075, 9, 355, 587, 26, 490, 291, 14, 32650, 1988, 17, 61, 275, 11634, 490, 291, 14, 3921, 1988, 17, 1055, 3005, 275, 11634, 490, 291, 14, 3921, 1988, 17, 1055, 10858, 1773, 342, 288, 587, 26, 355, 291, 14, 32650, 275, 359, 7075, 61, 288, 291, 14, 10858, 1773, 342, 267, 916, 8053, 508, 298, 328, 1787, 582, 288, 291, 14, 10858, 1773, 342, 267, 916, 8053, 508, 298, 2326, 582, 288, 291, 14, 1084, 4117, 8, 1110, 9, 267, 916, 8053, 508, 298, 3446, 2, 436, 440, 1594, 26, 288, 291, 14, 9637, 3921, 342, 339, 347, 2494, 4117, 8, 277, 12, 11581, 304, 267, 408, 13733, 78, 424, 84, 18833, 510, 24064, 724, 15315, 1235, 624, 267, 291, 14, 4117, 275, 11581, 267, 291, 14, 6652, 14, 15174, 14, 1053, 888, 8, 277, 14, 9654, 316, 12, 5554, 275, 11581, 9, 339, 347, 8496, 8, 277, 304, 267, 408, 484, 2412, 343, 5376, 510, 24064, 724, 282, 527, 16921, 3107, 69, 1158, 78, 10335, 624, 267, 367, 7030, 315, 291, 14, 3921, 26, 288, 291, 14, 6652, 14, 15174, 14, 1807, 8, 3049, 14, 9654, 316, 9, 288, 291, 14, 6652, 14, 9654, 780, 14, 2168, 8, 3049, 9, 267, 291, 14, 6652, 14, 15174, 14, 1807, 8, 277, 14, 9654, 316, 9, 267, 291, 14, 13375, 386, 14, 872, 2683, 8, 277, 9, 339, 347, 603, 344, 3428, 8, 277, 304, 267, 408, 71, 1892, 84, 5376, 603, 390, 266, 10343, 1778, 84, 18618, 510, 24064, 724, 1315, 300, 17709, 346, 624, 267, 372, 291, 14, 32650, 1988, 17, 61, 199, 199, 533, 7030, 19, 36, 26, 272, 408, 69, 1132, 650, 36, 13, 27889, 1873, 289, 17709, 82, 366, 305, 24348, 13, 9871, 348, 624, 272, 347, 636, 826, 721, 277, 12, 16396, 12, 25754, 12, 9599, 12, 11581, 304, 267, 291, 14, 6652, 275, 16396, 267, 291, 14, 5595, 275, 25754, 267, 291, 14, 3005, 275, 9599, 267, 291, 14, 3314, 9616, 275, 756, 398, 291, 14, 9654, 316, 275, 291, 14, 6652, 14, 15174, 14, 981, 63, 604, 2801, 21, 12, 446, 21, 12, 446, 21, 12, 446, 21, 12, 5554, 275, 11581, 9, 267, 291, 14, 10858, 1773, 342, 339, 347, 9572, 1773, 8, 277, 304, 267, 408, 806, 1158, 846, 18833, 29730, 1873, 1279, 85, 624, 267, 25334, 2335, 275, 291, 14, 6652, 14, 3049, 7687, 13940, 2335, 8, 277, 14, 5595, 12, 291, 14, 3005, 9, 267, 340, 25334, 2335, 1137, 5868, 21, 3057, 21, 3057, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Novasoft-India/OperERP-AM-Motors
openerp/tools/sql.py
455
1173
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 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/>. # ############################################################################## def drop_view_if_exists(cr, viewname): cr.execute("DROP view IF EXISTS %s CASCADE" % (viewname,)) cr.commit() # 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, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 318, 5978, 63, 1345, 63, 692, 63, 2444, 8, 1556, 12, 2455, 354, 304, 272, 2467, 14, 2526, 480, 14764, 2455, 8036, 23875, 450, 83, 27751, 9947, 2, 450, 334, 1345, 354, 4641, 272, 2467, 14, 3543, 342, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 318, 5978, 63, 1345, 63, 692, 63, 2444, 8, 1556, 12, 2455, 354, 304, 272, 2467, 14, 2526, 480, 14764, 2455, 8036, 23875, 450, 83, 27751, 9947, 2, 450, 334, 1345, 354, 4641, 272, 2467, 14, 3543, 342, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
sebastien-j/gensim
gensim/corpora/mmcorpus.py
85
1588
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (C) 2010 Radim Rehurek <radimrehurek@seznam.cz> # Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl.html """ Corpus in the Matrix Market format. """ import logging from gensim import interfaces, matutils from gensim.corpora import IndexedCorpus logger = logging.getLogger('gensim.corpora.mmcorpus') class MmCorpus(matutils.MmReader, IndexedCorpus): """ Corpus in the Matrix Market format. """ def __init__(self, fname): # avoid calling super(), too confusing IndexedCorpus.__init__(self, fname) matutils.MmReader.__init__(self, fname) def __iter__(self): """ Interpret a matrix in Matrix Market format as a streamed gensim corpus (yielding one document at a time). """ for doc_id, doc in super(MmCorpus, self).__iter__(): yield doc # get rid of doc id, return the sparse vector only @staticmethod def save_corpus(fname, corpus, id2word=None, progress_cnt=1000, metadata=False): """ Save a corpus in the Matrix Market format to disk. This function is automatically called by `MmCorpus.serialize`; don't call it directly, call `serialize` instead. """ logger.info("storing corpus in Matrix Market format to %s" % fname) num_terms = len(id2word) if id2word is not None else None return matutils.MmWriter.write_corpus(fname, corpus, num_terms=num_terms, index=True, progress_cnt=progress_cnt, metadata=metadata) # endclass MmCorpus
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 3898, 3572, 799, 72, 608, 75, 665, 345, 3572, 264, 72, 608, 75, 32, 261, 90, 17811, 14, 16823, 30, 199, 3, 3909, 1334, 314, 1664, 32426, 373, 18, 14, 17, 446, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 421, 199, 624, 199, 26424, 315, 314, 8449, 7173, 386, 1475, 14, 199, 624, 421, 199, 646, 2050, 199, 199, 504, 3805, 5206, 492, 8386, 12, 2530, 1208, 199, 504, 3805, 5206, 14, 20504, 65, 492, 26437, 26424, 421, 199, 2921, 275, 2050, 14, 5572, 360, 2268, 5206, 14, 20504, 65, 14, 596, 16780, 358, 421, 199, 533, 603, 77, 26424, 8, 569, 1208, 14, 28171, 5929, 12, 26437, 26424, 304, 272, 408, 272, 7499, 8843, 315, 314, 8449, 7173, 386, 1475, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 6748, 304, 267, 327, 5126, 6358, 1613, 1062, 4634, 3743, 4941, 267, 26437, 26424, 855, 826, 721, 277, 12, 6748, 9, 267, 2530, 1208, 14, 28171, 5929, 855, 826, 721, 277, 12, 6748, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 408, 267, 6551, 25133, 282, 3634, 315, 8449, 7173, 386, 1475, 465, 282, 410, 19308, 68, 3805, 5206, 16831, 267, 334, 11481, 316, 1373, 2213, 737, 282, 900, 680, 267, 408, 267, 367, 1382, 63, 344, 12, 1382, 315, 1613, 8, 28171, 26424, 12, 291, 2843, 1661, 721, 304, 288, 1995, 1382, 221, 327, 664, 16146, 402, 1382, 1305, 12, 372, 314, 5178, 5477, 1454, 339, 768, 4639, 272, 347, 3354, 63, 16780, 8, 5252, 12, 16831, 12, 1305, 18, 1027, 29, 403, 12, 6696, 63, 6507, 29, 5279, 12, 3341, 29, 797, 304, 267, 408, 267, 11063, 282, 16831, 315, 314, 8449, 7173, 386, 1475, 370, 4543, 14, 398, 961, 805, 365, 5847, 2797, 701, 658, 28171, 26424, 14, 3549, 64, 27, 2793, 1133, 267, 1240, 652, 5370, 12, 1240, 658, 3549, 64, 3140, 14, 267, 408, 267, 2512, 14, 815, 480, 270, 6854, 16831, 315, 8449, 7173, 386, 1475, 370, 450, 83, 2, 450, 6748, 9, 267, 1967, 63, 9187, 275, 822, 8, 344, 18, 1027, 9, 340, 1305, 18, 1027, 365, 440, 488, 587, 488, 267, 372, 2530, 1208, 14, 28171, 6261, 14, 952, 63, 16780, 8, 5252, 12, 16831, 12, 1967, 63, 9187, 29, 1507, 63, 9187, 12, 1478, 29, 549, 12, 6696, 63, 6507, 29, 5734, 63, 6507, 12, 3341, 29, 2343, 9, 199, 199, 3, 1284, 533, 603, 77, 26424, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 3898, 3572, 799, 72, 608, 75, 665, 345, 3572, 264, 72, 608, 75, 32, 261, 90, 17811, 14, 16823, 30, 199, 3, 3909, 1334, 314, 1664, 32426, 373, 18, 14, 17, 446, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 421, 199, 624, 199, 26424, 315, 314, 8449, 7173, 386, 1475, 14, 199, 624, 421, 199, 646, 2050, 199, 199, 504, 3805, 5206, 492, 8386, 12, 2530, 1208, 199, 504, 3805, 5206, 14, 20504, 65, 492, 26437, 26424, 421, 199, 2921, 275, 2050, 14, 5572, 360, 2268, 5206, 14, 20504, 65, 14, 596, 16780, 358, 421, 199, 533, 603, 77, 26424, 8, 569, 1208, 14, 28171, 5929, 12, 26437, 26424, 304, 272, 408, 272, 7499, 8843, 315, 314, 8449, 7173, 386, 1475, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 6748, 304, 267, 327, 5126, 6358, 1613, 1062, 4634, 3743, 4941, 267, 26437, 26424, 855, 826, 721, 277, 12, 6748, 9, 267, 2530, 1208, 14, 28171, 5929, 855, 826, 721, 277, 12, 6748, 9, 339, 347, 636, 1661, 721, 277, 304, 267, 408, 267, 6551, 25133, 282, 3634, 315, 8449, 7173, 386, 1475, 465, 282, 410, 19308, 68, 3805, 5206, 16831, 267, 334, 11481, 316, 1373, 2213, 737, 282, 900, 680, 267, 408, 267, 367, 1382, 63, 344, 12, 1382, 315, 1613, 8, 28171, 26424, 12, 291, 2843, 1661, 721, 304, 288, 1995, 1382, 221, 327, 664, 16146, 402, 1382, 1305, 12, 372, 314, 5178, 5477, 1454, 339, 768, 4639, 272, 347, 3354, 63, 16780, 8, 5252, 12, 16831, 12, 1305, 18, 1027, 29, 403, 12, 6696, 63, 6507, 29, 5279, 12, 3341, 29, 797, 304, 267, 408, 267, 11063, 282, 16831, 315, 314, 8449, 7173, 386, 1475, 370, 4543, 14, 398, 961, 805, 365, 5847, 2797, 701, 658, 28171, 26424, 14, 3549, 64, 27, 2793, 1133, 267, 1240, 652, 5370, 12, 1240, 658, 3549, 64, 3140, 14, 267, 408, 267, 2512, 14, 815, 480, 270, 6854, 16831, 315, 8449, 7173, 386, 1475, 370, 450, 83, 2, 450, 6748, 9, 267, 1967, 63, 9187, 275, 822, 8, 344, 18, 1027, 9, 340, 1305, 18, 1027, 365, 440, 488, 587, 488, 267, 372, 2530, 1208, 14, 28171, 6261, 14, 952, 63, 16780, 8, 5252, 12, 16831, 12, 1967, 63, 9187, 29, 1507, 63, 9187, 12, 1478, 29, 549, 12, 6696, 63, 6507, 29, 5734, 63, 6507, 12, 3341, 29, 2343, 9, 199, 199, 3, 1284, 533, 603, 77, 26424, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
allenlavoie/tensorflow
tensorflow/python/kernel_tests/sparse_reorder_op_test.py
94
5261
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for SparseReorder.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.python.framework import dtypes from tensorflow.python.framework import sparse_tensor from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import sparse_ops import tensorflow.python.ops.sparse_grad # pylint: disable=unused-import from tensorflow.python.platform import test class SparseReorderTest(test.TestCase): def _SparseTensorPlaceholder(self): return sparse_tensor.SparseTensor( array_ops.placeholder(dtypes.int64), array_ops.placeholder(dtypes.float64), array_ops.placeholder(dtypes.int64)) def _SparseTensorValue_5x6(self, permutation): ind = np.array([[0, 0], [1, 0], [1, 3], [1, 4], [3, 2], [3, 3]]).astype(np.int64) val = np.array([0, 10, 13, 14, 32, 33]).astype(np.float64) ind = ind[permutation] val = val[permutation] shape = np.array([5, 6]).astype(np.int64) return sparse_tensor.SparseTensorValue(ind, val, shape) def testStaticShapeInfoPreserved(self): sp_input = sparse_tensor.SparseTensor.from_value( self._SparseTensorValue_5x6(np.arange(6))) self.assertAllEqual((5, 6), sp_input.get_shape()) sp_output = sparse_ops.sparse_reorder(sp_input) self.assertAllEqual((5, 6), sp_output.get_shape()) def testAlreadyInOrder(self): with self.test_session(use_gpu=False) as sess: input_val = self._SparseTensorValue_5x6(np.arange(6)) sp_output = sparse_ops.sparse_reorder(input_val) output_val = sess.run(sp_output) self.assertAllEqual(output_val.indices, input_val.indices) self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, input_val.dense_shape) def testFeedAlreadyInOrder(self): with self.test_session(use_gpu=False) as sess: sp_input = self._SparseTensorPlaceholder() input_val = self._SparseTensorValue_5x6(np.arange(6)) sp_output = sparse_ops.sparse_reorder(sp_input) output_val = sess.run(sp_output, {sp_input: input_val}) self.assertAllEqual(output_val.indices, input_val.indices) self.assertAllEqual(output_val.values, input_val.values) self.assertAllEqual(output_val.dense_shape, input_val.dense_shape) def testOutOfOrder(self): expected_output_val = self._SparseTensorValue_5x6(np.arange(6)) with self.test_session(use_gpu=False) as sess: for _ in range(5): # To test various random permutations input_val = self._SparseTensorValue_5x6(np.random.permutation(6)) sp_output = sparse_ops.sparse_reorder(input_val) output_val = sess.run(sp_output) self.assertAllEqual(output_val.indices, expected_output_val.indices) self.assertAllEqual(output_val.values, expected_output_val.values) self.assertAllEqual(output_val.dense_shape, expected_output_val.dense_shape) def testFeedOutOfOrder(self): expected_output_val = self._SparseTensorValue_5x6(np.arange(6)) with self.test_session(use_gpu=False) as sess: for _ in range(5): # To test various random permutations sp_input = self._SparseTensorPlaceholder() input_val = self._SparseTensorValue_5x6(np.random.permutation(6)) sp_output = sparse_ops.sparse_reorder(sp_input) output_val = sess.run(sp_output, {sp_input: input_val}) self.assertAllEqual(output_val.indices, expected_output_val.indices) self.assertAllEqual(output_val.values, expected_output_val.values) self.assertAllEqual(output_val.dense_shape, expected_output_val.dense_shape) def testGradients(self): with self.test_session(use_gpu=False): for _ in range(5): # To test various random permutations input_val = self._SparseTensorValue_5x6(np.random.permutation(6)) sp_input = sparse_tensor.SparseTensor(input_val.indices, input_val.values, input_val.dense_shape) sp_output = sparse_ops.sparse_reorder(sp_input) err = gradient_checker.compute_gradient_error( sp_input.values, input_val.values.shape, sp_output.values, input_val.values.shape, x_init_value=input_val.values) self.assertLess(err, 1e-11) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 14531, 497, 1648, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 5178, 63, 3128, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6709, 63, 6743, 199, 504, 3228, 14, 1548, 14, 1483, 492, 5178, 63, 1483, 199, 646, 3228, 14, 1548, 14, 1483, 14, 4421, 63, 6017, 221, 327, 4287, 26, 3507, 29, 8618, 13, 646, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 14531, 497, 1648, 774, 8, 396, 14, 1746, 304, 819, 347, 485, 12079, 20185, 8, 277, 304, 272, 372, 5178, 63, 3128, 14, 12079, 8, 267, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 442, 772, 395, 267, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 772, 395, 267, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 442, 772, 430, 819, 347, 485, 12079, 1110, 63, 21, 88, 22, 8, 277, 12, 22966, 304, 272, 7654, 275, 980, 14, 1144, 4038, 16, 12, 378, 467, 359, 17, 12, 378, 467, 359, 17, 12, 650, 467, 359, 17, 12, 841, 467, 359, 19, 12, 499, 467, 490, 359, 19, 12, 650, 3934, 14, 6041, 8, 1590, 14, 442, 772, 9, 272, 1139, 275, 980, 14, 1144, 779, 16, 12, 1616, 12, 4944, 12, 4329, 12, 4337, 12, 9404, 6575, 6041, 8, 1590, 14, 1609, 772, 9, 339, 7654, 275, 7654, 59, 23832, 61, 272, 1139, 275, 1139, 59, 23832, 61, 339, 2215, 275, 980, 14, 1144, 779, 21, 12, 1227, 6575, 6041, 8, 1590, 14, 442, 772, 9, 272, 372, 5178, 63, 3128, 14, 12079, 1110, 8, 688, 12, 1139, 12, 2215, 9, 819, 347, 511, 9278, 7238, 2354, 2398, 2485, 8, 277, 304, 272, 2249, 63, 1210, 275, 5178, 63, 3128, 14, 12079, 14, 504, 63, 585, 8, 267, 291, 423, 12079, 1110, 63, 21, 88, 22, 8, 1590, 14, 5605, 8, 22, 1724, 272, 291, 14, 7069, 1332, 21, 12, 1227, 395, 2249, 63, 1210, 14, 362, 63, 1392, 1012, 272, 2249, 63, 1199, 275, 5178, 63, 1483, 14, 4421, 63, 29463, 8, 681, 63, 1210, 9, 272, 291, 14, 7069, 1332, 21, 12, 1227, 395, 2249, 63, 1199, 14, 362, 63, 1392, 1012, 819, 347, 511, 16760, 607, 4738, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 797, 9, 465, 4043, 26, 489, 1324, 63, 637, 275, 291, 423, 12079, 1110, 63, 21, 88, 22, 8, 1590, 14, 5605, 8, 22, 430, 489, 2249, 63, 1199, 275, 5178, 63, 1483, 14, 4421, 63, 29463, 8, 1210, 63, 637, 9, 2541, 1072, 63, 637, 275, 4043, 14, 1065, 8, 681, 63, 1199, 9, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 4108, 12, 1324, 63, 637, 14, 4108, 9, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 1459, 12, 1324, 63, 637, 14, 1459, 9, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 7253, 63, 1392, 12, 1324, 63, 637, 14, 7253, 63, 1392, 9, 819, 347, 511, 7658, 16760, 607, 4738, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 797, 9, 465, 4043, 26, 489, 2249, 63, 1210, 275, 291, 423, 12079, 20185, 342, 489, 1324, 63, 637, 275, 291, 423, 12079, 1110, 63, 21, 88, 22, 8, 1590, 14, 5605, 8, 22, 430, 489, 2249, 63, 1199, 275, 5178, 63, 1483, 14, 4421, 63, 29463, 8, 681, 63, 1210, 9, 2541, 1072, 63, 637, 275, 4043, 14, 1065, 8, 681, 63, 1199, 12, 469, 681, 63, 1210, 26, 1324, 63, 637, 1552, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 4108, 12, 1324, 63, 637, 14, 4108, 9, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 1459, 12, 1324, 63, 637, 14, 1459, 9, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 7253, 63, 1392, 12, 1324, 63, 637, 14, 7253, 63, 1392, 9, 819, 347, 511, 21383, 4738, 8, 277, 304, 272, 1420, 63, 1199, 63, 637, 275, 291, 423, 12079, 1110, 63, 21, 88, 22, 8, 1590, 14, 5605, 8, 22, 430, 272, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 797, 9, 465, 4043, 26, 489, 367, 485, 315, 1425, 8, 21, 304, 221, 327, 4005, 511, 7750, 2196, 26899, 267, 1324, 63, 637, 275, 291, 423, 12079, 1110, 63, 21, 88, 22, 8, 1590, 14, 2355, 14, 23832, 8, 22, 430, 267, 2249, 63, 1199, 275, 5178, 63, 1483, 14, 4421, 63, 29463, 8, 1210, 63, 637, 9, 398, 1072, 63, 637, 275, 4043, 14, 1065, 8, 681, 63, 1199, 9, 267, 291, 14, 7069, 8, 1199, 63, 637, 14, 4108, 12, 1420, 63, 1199, 63, 637, 14, 4108, 9, 267, 291, 14, 7069, 8, 1199, 63, 637, 14, 1459, 12, 1420, 63, 1199, 63, 637, 14, 1459, 9, 267, 291, 14, 7069, 8, 1199, 63, 637, 14, 7253, 63, 1392, 12, 1169, 1420, 63, 1199, 63, 637, 14, 7253, 63, 1392, 9, 819, 347, 511, 7658, 21383, 4738, 8, 277, 304 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 14531, 497, 1648, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 5178, 63, 3128, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6709, 63, 6743, 199, 504, 3228, 14, 1548, 14, 1483, 492, 5178, 63, 1483, 199, 646, 3228, 14, 1548, 14, 1483, 14, 4421, 63, 6017, 221, 327, 4287, 26, 3507, 29, 8618, 13, 646, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 14531, 497, 1648, 774, 8, 396, 14, 1746, 304, 819, 347, 485, 12079, 20185, 8, 277, 304, 272, 372, 5178, 63, 3128, 14, 12079, 8, 267, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 442, 772, 395, 267, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 1609, 772, 395, 267, 1625, 63, 1483, 14, 6199, 8, 5717, 14, 442, 772, 430, 819, 347, 485, 12079, 1110, 63, 21, 88, 22, 8, 277, 12, 22966, 304, 272, 7654, 275, 980, 14, 1144, 4038, 16, 12, 378, 467, 359, 17, 12, 378, 467, 359, 17, 12, 650, 467, 359, 17, 12, 841, 467, 359, 19, 12, 499, 467, 490, 359, 19, 12, 650, 3934, 14, 6041, 8, 1590, 14, 442, 772, 9, 272, 1139, 275, 980, 14, 1144, 779, 16, 12, 1616, 12, 4944, 12, 4329, 12, 4337, 12, 9404, 6575, 6041, 8, 1590, 14, 1609, 772, 9, 339, 7654, 275, 7654, 59, 23832, 61, 272, 1139, 275, 1139, 59, 23832, 61, 339, 2215, 275, 980, 14, 1144, 779, 21, 12, 1227, 6575, 6041, 8, 1590, 14, 442, 772, 9, 272, 372, 5178, 63, 3128, 14, 12079, 1110, 8, 688, 12, 1139, 12, 2215, 9, 819, 347, 511, 9278, 7238, 2354, 2398, 2485, 8, 277, 304, 272, 2249, 63, 1210, 275, 5178, 63, 3128, 14, 12079, 14, 504, 63, 585, 8, 267, 291, 423, 12079, 1110, 63, 21, 88, 22, 8, 1590, 14, 5605, 8, 22, 1724, 272, 291, 14, 7069, 1332, 21, 12, 1227, 395, 2249, 63, 1210, 14, 362, 63, 1392, 1012, 272, 2249, 63, 1199, 275, 5178, 63, 1483, 14, 4421, 63, 29463, 8, 681, 63, 1210, 9, 272, 291, 14, 7069, 1332, 21, 12, 1227, 395, 2249, 63, 1199, 14, 362, 63, 1392, 1012, 819, 347, 511, 16760, 607, 4738, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 797, 9, 465, 4043, 26, 489, 1324, 63, 637, 275, 291, 423, 12079, 1110, 63, 21, 88, 22, 8, 1590, 14, 5605, 8, 22, 430, 489, 2249, 63, 1199, 275, 5178, 63, 1483, 14, 4421, 63, 29463, 8, 1210, 63, 637, 9, 2541, 1072, 63, 637, 275, 4043, 14, 1065, 8, 681, 63, 1199, 9, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 4108, 12, 1324, 63, 637, 14, 4108, 9, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 1459, 12, 1324, 63, 637, 14, 1459, 9, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 7253, 63, 1392, 12, 1324, 63, 637, 14, 7253, 63, 1392, 9, 819, 347, 511, 7658, 16760, 607, 4738, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 797, 9, 465, 4043, 26, 489, 2249, 63, 1210, 275, 291, 423, 12079, 20185, 342, 489, 1324, 63, 637, 275, 291, 423, 12079, 1110, 63, 21, 88, 22, 8, 1590, 14, 5605, 8, 22, 430, 489, 2249, 63, 1199, 275, 5178, 63, 1483, 14, 4421, 63, 29463, 8, 681, 63, 1210, 9, 2541, 1072, 63, 637, 275, 4043, 14, 1065, 8, 681, 63, 1199, 12, 469, 681, 63, 1210, 26, 1324, 63, 637, 1552, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 4108, 12, 1324, 63, 637, 14, 4108, 9, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 1459, 12, 1324, 63, 637, 14, 1459, 9, 489, 291, 14, 7069, 8, 1199, 63, 637, 14, 7253, 63, 1392, 12, 1324, 63, 637, 14, 7253, 63, 1392, 9, 819, 347, 511, 21383, 4738, 8, 277, 304, 272, 1420, 63, 1199, 63, 637, 275, 291, 423, 12079, 1110, 63, 21, 88, 22, 8, 1590, 14, 5605, 8, 22, 430, 272, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 797, 9, 465, 4043, 26, 489, 367, 485, 315, 1425, 8, 21, 304, 221, 327, 4005, 511, 7750, 2196, 26899, 267, 1324, 63, 637, 275, 291, 423, 12079, 1110, 63, 21, 88, 22, 8, 1590, 14, 2355, 14, 23832, 8, 22, 430, 267, 2249, 63, 1199, 275, 5178, 63, 1483, 14, 4421, 63, 29463, 8, 1210, 63, 637, 9, 398, 1072, 63, 637, 275, 4043, 14, 1065, 8, 681, 63, 1199, 9, 267, 291, 14, 7069, 8, 1199, 63, 637, 14, 4108, 12, 1420, 63, 1199, 63, 637, 14, 4108, 9, 267, 291, 14, 7069, 8, 1199, 63, 637, 14, 1459, 12, 1420, 63, 1199, 63, 637, 14, 1459, 9, 267, 291, 14, 7069, 8, 1199, 63, 637, 14, 7253, 63, 1392, 12, 1169, 1420, 63, 1199, 63, 637, 14, 7253, 63, 1392, 9, 819, 347, 511, 7658, 21383, 4738, 8, 277, 304, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
nfedera/rg3-youtube-dl
youtube_dl/extractor/googleplus.py
38
2568
# coding: utf-8 from __future__ import unicode_literals import re import codecs from .common import InfoExtractor from ..utils import unified_strdate class GooglePlusIE(InfoExtractor): IE_DESC = 'Google Plus' _VALID_URL = r'https://plus\.google\.com/(?:[^/]+/)*?posts/(?P<id>\w+)' IE_NAME = 'plus.google' _TEST = { 'url': 'https://plus.google.com/u/0/108897254135232129896/posts/ZButuJc6CtH', 'info_dict': { 'id': 'ZButuJc6CtH', 'ext': 'flv', 'title': '嘆きの天使 降臨', 'upload_date': '20120613', 'uploader': '井上ヨシマサ', } } def _real_extract(self, url): video_id = self._match_id(url) # Step 1, Retrieve post webpage to extract further information webpage = self._download_webpage(url, video_id, 'Downloading entry webpage') title = self._og_search_description(webpage).splitlines()[0] upload_date = unified_strdate(self._html_search_regex( r'''(?x)<a.+?class="o-U-s\s[^"]+"\s+style="display:\s*none"\s*> ([0-9]{4}-[0-9]{2}-[0-9]{2})</a>''', webpage, 'upload date', fatal=False, flags=re.VERBOSE)) uploader = self._html_search_regex( r'rel="author".*?>(.*?)</a>', webpage, 'uploader', fatal=False) # Step 2, Simulate clicking the image box to launch video DOMAIN = 'https://plus.google.com/' video_page = self._search_regex( r'<a href="((?:%s)?photos/.*?)"' % re.escape(DOMAIN), webpage, 'video page URL') if not video_page.startswith(DOMAIN): video_page = DOMAIN + video_page webpage = self._download_webpage(video_page, video_id, 'Downloading video page') def unicode_escape(s): decoder = codecs.getdecoder('unicode_escape') return re.sub( r'\\u[0-9a-fA-F]{4,}', lambda m: decoder(m.group(0))[0], s) # Extract video links all sizes formats = [{ 'url': unicode_escape(video_url), 'ext': 'flv', 'width': int(width), 'height': int(height), } for width, height, video_url in re.findall( r'\d+,(\d+),(\d+),"(https?://[^.]+\.googleusercontent.com.*?)"', webpage)] self._sort_formats(formats) return { 'id': video_id, 'title': title, 'uploader': uploader, 'upload_date': upload_date, 'formats': formats, }
unlicense
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 646, 6010, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 25344, 63, 495, 602, 421, 199, 533, 4475, 25800, 4332, 8, 18283, 304, 272, 15292, 63, 15119, 275, 283, 13266, 7497, 527, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 921, 6666, 4537, 3098, 4537, 957, 32576, 26285, 15, 3342, 31, 18084, 9448, 48, 28, 344, 3072, 87, 29600, 272, 15292, 63, 2339, 275, 283, 6666, 14, 3098, 7, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 2859, 921, 6666, 14, 3098, 14, 957, 15, 85, 15, 16, 15, 709, 1299, 2576, 8306, 969, 2528, 708, 7263, 12031, 15, 18084, 15, 58, 28543, 85, 42, 67, 22, 35, 84, 40, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 58, 28543, 85, 42, 67, 22, 35, 84, 40, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 162, 247, 229, 4197, 236, 14741, 11546, 103, 28446, 10469, 248, 236, 27345, 102, 297, 288, 283, 5064, 63, 602, 356, 283, 1797, 11089, 969, 297, 288, 283, 13671, 356, 283, 6923, 244, 22661, 5692, 102, 5573, 116, 5692, 253, 5573, 114, 297, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 327, 13382, 413, 12, 13939, 2963, 9248, 370, 5536, 9848, 2556, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 12, 283, 18085, 2397, 9248, 358, 398, 2538, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 680, 7644, 3430, 16, 61, 267, 5802, 63, 602, 275, 25344, 63, 495, 602, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 2344, 2229, 88, 21528, 65, 11198, 533, 628, 79, 13, 53, 13, 83, 60, 83, 25153, 25789, 83, 11, 2487, 628, 2918, 3427, 83, 10, 3592, 3212, 83, 10, 30, 490, 7287, 16, 13, 25, 8194, 20, 17063, 59, 16, 13, 25, 8194, 18, 17063, 59, 16, 13, 25, 8194, 18, 1552, 1108, 65, 30, 18108, 288, 9248, 12, 283, 5064, 1434, 297, 14294, 29, 797, 12, 3285, 29, 264, 14, 16075, 430, 267, 25257, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 3984, 76, 628, 2502, 1674, 15279, 13661, 6697, 15939, 65, 4206, 9248, 12, 283, 13671, 297, 14294, 29, 797, 9, 398, 327, 13382, 499, 12, 10751, 5434, 8968, 316, 314, 1834, 5689, 370, 10623, 3991, 267, 15265, 275, 283, 2859, 921, 6666, 14, 3098, 14, 957, 4805, 267, 3991, 63, 1606, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7601, 65, 4369, 628, 17304, 2689, 83, 5547, 25211, 15, 6697, 2924, 7, 450, 295, 14, 3765, 8, 7378, 395, 288, 9248, 12, 283, 3722, 2034, 2851, 358, 267, 340, 440, 3991, 63, 1606, 14, 2460, 8, 7378, 304, 288, 3991, 63, 1606, 275, 15265, 435, 3991, 63, 1606, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 3722, 63, 1606, 12, 3991, 63, 344, 12, 283, 18085, 3991, 2034, 358, 398, 347, 2649, 63, 3765, 8, 83, 304, 288, 10334, 275, 6010, 14, 362, 8813, 360, 2975, 63, 3765, 358, 288, 372, 295, 14, 954, 8, 355, 519, 8124, 85, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 20, 12, 7293, 355, 2400, 333, 26, 10334, 8, 77, 14, 923, 8, 16, 11515, 16, 467, 355, 308, 9, 398, 327, 12892, 3991, 6220, 1006, 10627, 267, 6752, 275, 8910, 288, 283, 633, 356, 2649, 63, 3765, 8, 3722, 63, 633, 395, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 2063, 356, 1109, 8, 2063, 395, 288, 283, 3333, 356, 1109, 8, 3333, 395, 267, 789, 367, 3462, 12, 4569, 12, 3991, 63, 633, 315, 295, 14, 6452, 8, 288, 519, 1154, 68, 28061, 2961, 68, 11, 395, 2961, 68, 11, 395, 26507, 2859, 14144, 4735, 32455, 4537, 3098, 751, 1317, 14, 957, 6697, 32691, 9248, 1874, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 13671, 356, 25257, 12, 288, 283, 5064, 63, 602, 356, 5802, 63, 602, 12, 288, 283, 6321, 356, 6752, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 646, 6010, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 25344, 63, 495, 602, 421, 199, 533, 4475, 25800, 4332, 8, 18283, 304, 272, 15292, 63, 15119, 275, 283, 13266, 7497, 527, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 921, 6666, 4537, 3098, 4537, 957, 32576, 26285, 15, 3342, 31, 18084, 9448, 48, 28, 344, 3072, 87, 29600, 272, 15292, 63, 2339, 275, 283, 6666, 14, 3098, 7, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 2859, 921, 6666, 14, 3098, 14, 957, 15, 85, 15, 16, 15, 709, 1299, 2576, 8306, 969, 2528, 708, 7263, 12031, 15, 18084, 15, 58, 28543, 85, 42, 67, 22, 35, 84, 40, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 58, 28543, 85, 42, 67, 22, 35, 84, 40, 297, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 1213, 356, 283, 162, 247, 229, 4197, 236, 14741, 11546, 103, 28446, 10469, 248, 236, 27345, 102, 297, 288, 283, 5064, 63, 602, 356, 283, 1797, 11089, 969, 297, 288, 283, 13671, 356, 283, 6923, 244, 22661, 5692, 102, 5573, 116, 5692, 253, 5573, 114, 297, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 327, 13382, 413, 12, 13939, 2963, 9248, 370, 5536, 9848, 2556, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 12, 283, 18085, 2397, 9248, 358, 398, 2538, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 680, 7644, 3430, 16, 61, 267, 5802, 63, 602, 275, 25344, 63, 495, 602, 8, 277, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 2344, 2229, 88, 21528, 65, 11198, 533, 628, 79, 13, 53, 13, 83, 60, 83, 25153, 25789, 83, 11, 2487, 628, 2918, 3427, 83, 10, 3592, 3212, 83, 10, 30, 490, 7287, 16, 13, 25, 8194, 20, 17063, 59, 16, 13, 25, 8194, 18, 17063, 59, 16, 13, 25, 8194, 18, 1552, 1108, 65, 30, 18108, 288, 9248, 12, 283, 5064, 1434, 297, 14294, 29, 797, 12, 3285, 29, 264, 14, 16075, 430, 267, 25257, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 288, 519, 3984, 76, 628, 2502, 1674, 15279, 13661, 6697, 15939, 65, 4206, 9248, 12, 283, 13671, 297, 14294, 29, 797, 9, 398, 327, 13382, 499, 12, 10751, 5434, 8968, 316, 314, 1834, 5689, 370, 10623, 3991, 267, 15265, 275, 283, 2859, 921, 6666, 14, 3098, 14, 957, 4805, 267, 3991, 63, 1606, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7601, 65, 4369, 628, 17304, 2689, 83, 5547, 25211, 15, 6697, 2924, 7, 450, 295, 14, 3765, 8, 7378, 395, 288, 9248, 12, 283, 3722, 2034, 2851, 358, 267, 340, 440, 3991, 63, 1606, 14, 2460, 8, 7378, 304, 288, 3991, 63, 1606, 275, 15265, 435, 3991, 63, 1606, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 3722, 63, 1606, 12, 3991, 63, 344, 12, 283, 18085, 3991, 2034, 358, 398, 347, 2649, 63, 3765, 8, 83, 304, 288, 10334, 275, 6010, 14, 362, 8813, 360, 2975, 63, 3765, 358, 288, 372, 295, 14, 954, 8, 355, 519, 8124, 85, 59, 16, 13, 25, 65, 13, 13753, 13, 38, 8194, 20, 12, 7293, 355, 2400, 333, 26, 10334, 8, 77, 14, 923, 8, 16, 11515, 16, 467, 355, 308, 9, 398, 327, 12892, 3991, 6220, 1006, 10627, 267, 6752, 275, 8910, 288, 283, 633, 356, 2649, 63, 3765, 8, 3722, 63, 633, 395, 288, 283, 832, 356, 283, 22753, 297, 288, 283, 2063, 356, 1109, 8, 2063, 395, 288, 283, 3333, 356, 1109, 8, 3333, 395, 267, 789, 367, 3462, 12, 4569, 12, 3991, 63, 633, 315, 295, 14, 6452, 8, 288, 519, 1154, 68, 28061, 2961, 68, 11, 395, 2961, 68, 11, 395, 26507, 2859, 14144, 4735, 32455, 4537, 3098, 751, 1317, 14, 957, 6697, 32691, 9248, 1874, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 13671, 356, 25257, 12, 288, 283, 5064, 63, 602, 356, 5802, 63, 602, 12, 288, 283, 6321, 356, 6752, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pombredanne/teamwork
exts/w2/static/Brython2.0.0-20140209-164925/Lib/sys.py
92
3227
# hack to return special attributes from _sys import * from javascript import JSObject has_local_storage=__BRYTHON__.has_local_storage has_json=__BRYTHON__.has_json argv = ['__main__'] base_exec_prefix = __BRYTHON__.brython_path base_prefix = __BRYTHON__.brython_path builtin_module_names=__BRYTHON__.builtin_module_names byteorder='little' def exc_info(): exc = __BRYTHON__.exception_stack[-1] return (exc.__class__,exc,exc.traceback) exec_prefix = __BRYTHON__.brython_path executable = __BRYTHON__.brython_path+'/brython.js' def exit(i=None): raise SystemExit('') class flag_class: def __init__(self): self.debug=0 self.inspect=0 self.interactive=0 self.optimize=0 self.dont_write_bytecode=0 self.no_user_site=0 self.no_site=0 self.ignore_environment=0 self.verbose=0 self.bytes_warning=0 self.quiet=0 self.hash_randomization=1 flags=flag_class() def getfilesystemencoding(*args,**kw): """getfilesystemencoding() -> string Return the encoding used to convert Unicode filenames in operating system filenames.""" return 'utf-8' maxsize=2147483647 maxunicode=1114111 path = __BRYTHON__.path path_hooks = list(JSObject(__BRYTHON__.path_hooks)) platform="brython" prefix = __BRYTHON__.brython_path version = '.'.join(str(x) for x in __BRYTHON__.version_info[:3]) #todo, put in a 'real' date, etc version += " (default, Feb 29 2013, 00:00:00) \n[Javascript 1.5]" hexversion = 0x03000000 # python 3.0 class __version_info(object): def __init__(self, version_info): self.version_info = version_info self.major = version_info[0] self.minor = version_info[1] self.micro = version_info[2] self.releaselevel = version_info[3] self.serial = version_info[4] def __getitem__(self, index): if isinstance(self.version_info[index], list): return tuple(self.version_info[index]) return self.version_info[index] def hexversion(self): try: return '0%d0%d0%d' % (self.major, self.minor, self.micro) finally: #probably some invalid char in minor (rc, etc) return '0%d0000' % (self.major) def __str__(self): _s="sys.version(major=%d, minor=%d, micro=%d, releaselevel='%s', serial=%d)" return _s % (self.major, self.minor, self.micro, self.releaselevel, self.serial) #return str(self.version_info) #eventually this needs to be the real python version such as 3.0, 3.1, etc version_info=__version_info(__BRYTHON__.version_info) class _implementation: def __init__(self): self.name='brython' self.version = __version_info(__BRYTHON__.implementation) self.hexversion = self.version.hexversion() self.cache_tag=None def __repr__(self): return "namespace(name='%s' version=%s hexversion='%s')" % (self.name, self.version, self.hexversion) def __str__(self): return "namespace(name='%s' version=%s hexversion='%s')" % (self.name, self.version, self.hexversion) implementation=_implementation() warnoptions=[] #delete objects not in python sys module namespace del JSObject del _implementation
gpl-2.0
[ 3, 11176, 370, 372, 4539, 3004, 199, 504, 485, 1274, 492, 627, 199, 504, 18910, 492, 18001, 1692, 199, 199, 1989, 63, 1832, 63, 3494, 18971, 34, 5782, 8472, 4343, 1989, 63, 1832, 63, 3494, 199, 1989, 63, 1001, 18971, 34, 5782, 8472, 4343, 1989, 63, 1001, 199, 199, 3020, 275, 14050, 973, 17501, 199, 199, 1095, 63, 1628, 63, 1861, 275, 636, 34, 5782, 8472, 4343, 66, 23196, 63, 515, 199, 199, 1095, 63, 1861, 275, 636, 34, 5782, 8472, 4343, 66, 23196, 63, 515, 199, 199, 5351, 63, 578, 63, 1247, 18971, 34, 5782, 8472, 4343, 5351, 63, 578, 63, 1247, 199, 199, 19415, 534, 10182, 7, 199, 199, 318, 3178, 63, 815, 837, 272, 3178, 275, 636, 34, 5782, 8472, 4343, 1971, 63, 2340, 1988, 17, 61, 272, 372, 334, 2804, 855, 533, 3108, 2804, 12, 2804, 14, 6894, 9, 1362, 199, 1628, 63, 1861, 275, 636, 34, 5782, 8472, 4343, 66, 23196, 63, 515, 199, 199, 5904, 275, 636, 34, 5782, 8472, 4343, 66, 23196, 63, 515, 23164, 66, 23196, 14, 3596, 7, 199, 199, 318, 4458, 8, 73, 29, 403, 304, 272, 746, 14838, 8355, 199, 199, 533, 3305, 63, 533, 26, 523, 347, 636, 826, 721, 277, 304, 489, 291, 14, 1757, 29, 16, 489, 291, 14, 10955, 29, 16, 489, 291, 14, 13543, 29, 16, 489, 291, 14, 13416, 29, 16, 489, 291, 14, 18671, 63, 952, 63, 19812, 29, 16, 489, 291, 14, 889, 63, 751, 63, 2124, 29, 16, 489, 291, 14, 889, 63, 2124, 29, 16, 489, 291, 14, 4247, 63, 5418, 29, 16, 489, 291, 14, 3832, 29, 16, 489, 291, 14, 2394, 63, 3764, 29, 16, 489, 291, 14, 10243, 29, 16, 489, 291, 14, 2227, 63, 2355, 2072, 29, 17, 199, 199, 2469, 29, 4173, 63, 533, 342, 199, 199, 318, 664, 493, 32255, 2031, 589, 12663, 829, 304, 272, 408, 23462, 32255, 342, 1035, 1059, 14821, 1432, 314, 2644, 1202, 370, 3957, 6140, 6203, 315, 272, 17406, 2656, 6203, 1041, 272, 372, 283, 1624, 13, 24, 7, 1362, 199, 13634, 29, 22519, 8557, 199, 199, 988, 2975, 29, 845, 1079, 6673, 199, 199, 515, 275, 636, 34, 5782, 8472, 4343, 515, 199, 199, 515, 63, 7922, 275, 769, 8, 11378, 1692, 3460, 34, 5782, 8472, 4343, 515, 63, 7922, 430, 199, 199, 3246, 628, 66, 23196, 2, 199, 199, 1861, 275, 636, 34, 5782, 8472, 4343, 66, 23196, 63, 515, 199, 199, 1023, 275, 15671, 904, 8, 495, 8, 88, 9, 367, 671, 315, 636, 34, 5782, 8472, 4343, 1023, 63, 815, 1491, 19, 566, 199, 3, 11396, 12, 5324, 315, 282, 283, 3093, 7, 1434, 12, 5423, 199, 1023, 847, 298, 334, 885, 12, 21141, 7349, 6171, 12, 8733, 26, 383, 26, 383, 9, 971, 78, 59, 31708, 413, 14, 21, 8480, 199, 4097, 1023, 275, 378, 88, 1644, 3273, 257, 327, 2366, 650, 14, 16, 199, 199, 533, 636, 1023, 63, 815, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1015, 63, 815, 304, 267, 291, 14, 1023, 63, 815, 275, 1015, 63, 815, 267, 291, 14, 8452, 275, 1015, 63, 815, 59, 16, 61, 267, 291, 14, 11067, 275, 1015, 63, 815, 59, 17, 61, 267, 291, 14, 6453, 275, 1015, 63, 815, 59, 18, 61, 267, 291, 14, 3221, 1896, 275, 1015, 63, 815, 59, 19, 61, 267, 291, 14, 2171, 275, 1015, 63, 815, 59, 20, 61, 339, 347, 636, 6095, 721, 277, 12, 1478, 304, 267, 340, 1228, 8, 277, 14, 1023, 63, 815, 59, 1080, 467, 769, 304, 1779, 372, 2008, 8, 277, 14, 1023, 63, 815, 59, 1080, 566, 267, 372, 291, 14, 1023, 63, 815, 59, 1080, 61, 339, 347, 6318, 1023, 8, 277, 304, 267, 862, 26, 881, 372, 283, 16, 5, 68, 16, 5, 68, 16, 5, 68, 7, 450, 334, 277, 14, 8452, 12, 291, 14, 11067, 12, 291, 14, 6453, 9, 267, 3753, 26, 221, 327, 6101, 6665, 2005, 3866, 1495, 315, 12612, 334, 1195, 12, 5423, 9, 881, 372, 283, 16, 5, 68, 993, 7, 450, 334, 277, 14, 8452, 9, 339, 347, 636, 495, 721, 277, 304, 267, 485, 83, 628, 1274, 14, 1023, 8, 8452, 2458, 68, 12, 12612, 2458, 68, 12, 9967, 2458, 68, 12, 4683, 1896, 9569, 83, 297, 3012, 2458, 68, 2924, 267, 372, 485, 83, 450, 334, 277, 14, 8452, 12, 291, 14, 11067, 12, 291, 14, 6453, 12, 221, 2151, 291, 14, 3221, 1896, 12, 291, 14, 2171, 9, 267, 327, 1107, 620, 8, 277, 14, 1023, 63, 815, 9, 199, 199, 3, 1430, 3163, 642, 4839, 370, 506, 314, 3363, 2366, 1015, 4066, 465, 650, 14, 16, 12, 650, 14, 17, 12, 5423, 199, 1023, 63, 815, 18971, 1023, 63, 815, 3460, 34, 5782, 8472, 4343, 1023, 63, 815, 9, 199, 199, 533, 485, 12236, 26, 523, 347, 636, 826, 721, 277, 304, 489, 291, 14, 354, 534, 66, 23196, 7, 489, 291, 14, 1023, 275, 636, 1023, 63, 815, 3460, 34, 5782, 8472, 4343, 12236, 9, 489, 291, 14, 4097, 1023, 275, 291, 14, 1023, 14, 4097, 1023, 342, 489, 291, 14, 1637, 63, 1450, 29, 403, 819, 347, 636, 2722, 721, 277, 304, 489, 372, 298, 3251, 8, 354, 9569, 83, 7, 1015, 2458, 83, 6318, 1023, 9569, 83, 19124, 450, 334, 277, 14, 354, 12, 291, 14, 1023, 12, 291, 14, 4097, 1023, 9, 819, 347, 636, 495, 721, 277, 304, 489, 372, 298, 3251, 8, 354, 9569, 83, 7, 1015, 2458, 83, 6318, 1023, 9569, 83, 19124, 450, 334, 277, 14, 354, 12, 291, 14, 1023, 12, 291, 14, 4097, 1023, 9, 199, 199, 12236, 3699, 12236, 342, 199, 199, 4050, 1419, 9811, 199, 199, 3, 1807, 2251, 440, 315, 2366, 984, 859, 3231, 199, 2264, 18001, 1692, 199, 2264, 485, 12236, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11176, 370, 372, 4539, 3004, 199, 504, 485, 1274, 492, 627, 199, 504, 18910, 492, 18001, 1692, 199, 199, 1989, 63, 1832, 63, 3494, 18971, 34, 5782, 8472, 4343, 1989, 63, 1832, 63, 3494, 199, 1989, 63, 1001, 18971, 34, 5782, 8472, 4343, 1989, 63, 1001, 199, 199, 3020, 275, 14050, 973, 17501, 199, 199, 1095, 63, 1628, 63, 1861, 275, 636, 34, 5782, 8472, 4343, 66, 23196, 63, 515, 199, 199, 1095, 63, 1861, 275, 636, 34, 5782, 8472, 4343, 66, 23196, 63, 515, 199, 199, 5351, 63, 578, 63, 1247, 18971, 34, 5782, 8472, 4343, 5351, 63, 578, 63, 1247, 199, 199, 19415, 534, 10182, 7, 199, 199, 318, 3178, 63, 815, 837, 272, 3178, 275, 636, 34, 5782, 8472, 4343, 1971, 63, 2340, 1988, 17, 61, 272, 372, 334, 2804, 855, 533, 3108, 2804, 12, 2804, 14, 6894, 9, 1362, 199, 1628, 63, 1861, 275, 636, 34, 5782, 8472, 4343, 66, 23196, 63, 515, 199, 199, 5904, 275, 636, 34, 5782, 8472, 4343, 66, 23196, 63, 515, 23164, 66, 23196, 14, 3596, 7, 199, 199, 318, 4458, 8, 73, 29, 403, 304, 272, 746, 14838, 8355, 199, 199, 533, 3305, 63, 533, 26, 523, 347, 636, 826, 721, 277, 304, 489, 291, 14, 1757, 29, 16, 489, 291, 14, 10955, 29, 16, 489, 291, 14, 13543, 29, 16, 489, 291, 14, 13416, 29, 16, 489, 291, 14, 18671, 63, 952, 63, 19812, 29, 16, 489, 291, 14, 889, 63, 751, 63, 2124, 29, 16, 489, 291, 14, 889, 63, 2124, 29, 16, 489, 291, 14, 4247, 63, 5418, 29, 16, 489, 291, 14, 3832, 29, 16, 489, 291, 14, 2394, 63, 3764, 29, 16, 489, 291, 14, 10243, 29, 16, 489, 291, 14, 2227, 63, 2355, 2072, 29, 17, 199, 199, 2469, 29, 4173, 63, 533, 342, 199, 199, 318, 664, 493, 32255, 2031, 589, 12663, 829, 304, 272, 408, 23462, 32255, 342, 1035, 1059, 14821, 1432, 314, 2644, 1202, 370, 3957, 6140, 6203, 315, 272, 17406, 2656, 6203, 1041, 272, 372, 283, 1624, 13, 24, 7, 1362, 199, 13634, 29, 22519, 8557, 199, 199, 988, 2975, 29, 845, 1079, 6673, 199, 199, 515, 275, 636, 34, 5782, 8472, 4343, 515, 199, 199, 515, 63, 7922, 275, 769, 8, 11378, 1692, 3460, 34, 5782, 8472, 4343, 515, 63, 7922, 430, 199, 199, 3246, 628, 66, 23196, 2, 199, 199, 1861, 275, 636, 34, 5782, 8472, 4343, 66, 23196, 63, 515, 199, 199, 1023, 275, 15671, 904, 8, 495, 8, 88, 9, 367, 671, 315, 636, 34, 5782, 8472, 4343, 1023, 63, 815, 1491, 19, 566, 199, 3, 11396, 12, 5324, 315, 282, 283, 3093, 7, 1434, 12, 5423, 199, 1023, 847, 298, 334, 885, 12, 21141, 7349, 6171, 12, 8733, 26, 383, 26, 383, 9, 971, 78, 59, 31708, 413, 14, 21, 8480, 199, 4097, 1023, 275, 378, 88, 1644, 3273, 257, 327, 2366, 650, 14, 16, 199, 199, 533, 636, 1023, 63, 815, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1015, 63, 815, 304, 267, 291, 14, 1023, 63, 815, 275, 1015, 63, 815, 267, 291, 14, 8452, 275, 1015, 63, 815, 59, 16, 61, 267, 291, 14, 11067, 275, 1015, 63, 815, 59, 17, 61, 267, 291, 14, 6453, 275, 1015, 63, 815, 59, 18, 61, 267, 291, 14, 3221, 1896, 275, 1015, 63, 815, 59, 19, 61, 267, 291, 14, 2171, 275, 1015, 63, 815, 59, 20, 61, 339, 347, 636, 6095, 721, 277, 12, 1478, 304, 267, 340, 1228, 8, 277, 14, 1023, 63, 815, 59, 1080, 467, 769, 304, 1779, 372, 2008, 8, 277, 14, 1023, 63, 815, 59, 1080, 566, 267, 372, 291, 14, 1023, 63, 815, 59, 1080, 61, 339, 347, 6318, 1023, 8, 277, 304, 267, 862, 26, 881, 372, 283, 16, 5, 68, 16, 5, 68, 16, 5, 68, 7, 450, 334, 277, 14, 8452, 12, 291, 14, 11067, 12, 291, 14, 6453, 9, 267, 3753, 26, 221, 327, 6101, 6665, 2005, 3866, 1495, 315, 12612, 334, 1195, 12, 5423, 9, 881, 372, 283, 16, 5, 68, 993, 7, 450, 334, 277, 14, 8452, 9, 339, 347, 636, 495, 721, 277, 304, 267, 485, 83, 628, 1274, 14, 1023, 8, 8452, 2458, 68, 12, 12612, 2458, 68, 12, 9967, 2458, 68, 12, 4683, 1896, 9569, 83, 297, 3012, 2458, 68, 2924, 267, 372, 485, 83, 450, 334, 277, 14, 8452, 12, 291, 14, 11067, 12, 291, 14, 6453, 12, 221, 2151, 291, 14, 3221, 1896, 12, 291, 14, 2171, 9, 267, 327, 1107, 620, 8, 277, 14, 1023, 63, 815, 9, 199, 199, 3, 1430, 3163, 642, 4839, 370, 506, 314, 3363, 2366, 1015, 4066, 465, 650, 14, 16, 12, 650, 14, 17, 12, 5423, 199, 1023, 63, 815, 18971, 1023, 63, 815, 3460, 34, 5782, 8472, 4343, 1023, 63, 815, 9, 199, 199, 533, 485, 12236, 26, 523, 347, 636, 826, 721, 277, 304, 489, 291, 14, 354, 534, 66, 23196, 7, 489, 291, 14, 1023, 275, 636, 1023, 63, 815, 3460, 34, 5782, 8472, 4343, 12236, 9, 489, 291, 14, 4097, 1023, 275, 291, 14, 1023, 14, 4097, 1023, 342, 489, 291, 14, 1637, 63, 1450, 29, 403, 819, 347, 636, 2722, 721, 277, 304, 489, 372, 298, 3251, 8, 354, 9569, 83, 7, 1015, 2458, 83, 6318, 1023, 9569, 83, 19124, 450, 334, 277, 14, 354, 12, 291, 14, 1023, 12, 291, 14, 4097, 1023, 9, 819, 347, 636, 495, 721, 277, 304, 489, 372, 298, 3251, 8, 354, 9569, 83, 7, 1015, 2458, 83, 6318, 1023, 9569, 83, 19124, 450, 334, 277, 14, 354, 12, 291, 14, 1023, 12, 291, 14, 4097, 1023, 9, 199, 199, 12236, 3699, 12236, 342, 199, 199, 4050, 1419, 9811, 199, 199, 3, 1807, 2251, 440, 315, 2366, 984, 859, 3231, 199, 2264, 18001, 1692, 199, 2264, 485, 12236, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 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 ]
Fireblend/chromium-crosswalk
chrome/common/extensions/docs/server2/host_file_system_provider.py
16
4861
# Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from caching_file_system import CachingFileSystem from gitiles_file_system import GitilesFileSystem from local_file_system import LocalFileSystem from offline_file_system import OfflineFileSystem from third_party.json_schema_compiler.memoize import memoize class HostFileSystemProvider(object): '''Provides host file systems ("host" meaning the file system that hosts the server's source code and templates) tracking master, or any branch. File system instances are memoized to maintain the in-memory caches across multiple callers. ''' def __init__(self, object_store_creator, pinned_commit=None, default_master_instance=None, offline=False, constructor_for_test=None, cache_only=False): ''' |object_store_creator| Provides caches for file systems that need one. |pinned_commit| If not None, the commit at which a 'master' file system will be created. If None, 'master' file systems will use HEAD. |default_master_instance| If not None, 'master' file systems provided by this class without a specific commit will return |default_master_instance| instead. |offline| If True all provided file systems will be wrapped in an OfflineFileSystem. |constructor_for_test| Provides a custom constructor rather than creating GitilesFileSystems. |cache_only| If True, all provided file systems will be cache-only, meaning that cache misses will result in errors rather than cache updates. ''' self._object_store_creator = object_store_creator self._pinned_commit = pinned_commit self._default_master_instance = default_master_instance self._offline = offline self._constructor_for_test = constructor_for_test self._cache_only = cache_only @memoize def GetMaster(self, commit=None): '''Gets a file system tracking 'master'. Use this method rather than GetBranch('master') because the behaviour is subtly different; 'master' can be pinned to a specific commit (|pinned_commit| in constructor) and can have have its default instance overridden (|default_master_instance| in the constructor). |commit| if non-None determines a specific commit to pin the host file system at, though it will be ignored if it's newer than |pinned_commit|. If None then |commit| will track |pinned_commit| if is has been set, or just HEAD (which might change during server runtime!). ''' if commit is None: if self._default_master_instance is not None: return self._default_master_instance return self._Create('master', commit=self._pinned_commit) return self._Create('master', commit=commit) @memoize def GetBranch(self, branch): '''Gets a file system tracking |branch|, for example '1150' - anything other than 'master', which must be constructed via the GetMaster() method. Note: Unlike GetMaster this function doesn't take a |commit| argument since we assume that branches hardly ever change, while master frequently changes. ''' assert isinstance(branch, basestring), 'Branch %s must be a string' % branch assert branch != 'master', ( 'Cannot specify branch=\'master\', use GetMaster()') return self._Create(branch) def _Create(self, branch, commit=None): '''Creates Gitiles file systems (or if in a test, potentially whatever |self._constructor_for_test specifies). Wraps the resulting file system in an Offline file system if the offline flag is set, and finally wraps it in a Caching file system. ''' if self._constructor_for_test is not None: file_system = self._constructor_for_test(branch=branch, commit=commit) else: file_system = GitilesFileSystem.Create(branch=branch, commit=commit) if self._offline: file_system = OfflineFileSystem(file_system) return CachingFileSystem(file_system, self._object_store_creator, fail_on_miss=self._cache_only) @staticmethod def ForLocal(object_store_creator, **optargs): '''Used in creating a server instance on localhost. ''' return HostFileSystemProvider( object_store_creator, constructor_for_test=lambda **_: LocalFileSystem.Create(), **optargs) @staticmethod def ForTest(file_system, object_store_creator, **optargs): '''Used in creating a test server instance. The HostFileSystemProvider returned here will always return |file_system| when its Create() method is called. ''' return HostFileSystemProvider( object_store_creator, constructor_for_test=lambda **_: file_system, **optargs)
bsd-3-clause
[ 3, 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 504, 13627, 63, 493, 63, 2253, 492, 445, 23302, 17521, 199, 504, 486, 5277, 2978, 63, 493, 63, 2253, 492, 598, 5277, 2978, 17521, 199, 504, 2257, 63, 493, 63, 2253, 492, 10111, 17521, 199, 504, 26302, 63, 493, 63, 2253, 492, 28856, 604, 17521, 199, 504, 10919, 63, 7522, 14, 1001, 63, 3629, 63, 5772, 14, 11979, 794, 492, 11955, 794, 421, 199, 533, 10891, 17521, 6663, 8, 785, 304, 523, 1449, 17473, 1591, 570, 10460, 1689, 1102, 2, 11150, 314, 570, 2656, 626, 7057, 314, 523, 1654, 1159, 1350, 1233, 436, 7009, 9, 15161, 5288, 12, 503, 1263, 5246, 14, 819, 3814, 2656, 4454, 787, 11955, 1759, 370, 11075, 314, 315, 13, 4844, 18014, 9371, 523, 3663, 24194, 14, 523, 1449, 523, 347, 636, 826, 721, 277, 12, 2049, 909, 63, 1617, 63, 9986, 12, 2049, 10713, 7439, 63, 3543, 29, 403, 12, 2049, 849, 63, 4133, 63, 842, 29, 403, 12, 2049, 26302, 29, 797, 12, 2049, 3787, 63, 509, 63, 396, 29, 403, 12, 2049, 2581, 63, 2118, 29, 797, 304, 272, 1449, 272, 1204, 785, 63, 1617, 63, 9986, 92, 489, 21552, 18014, 367, 570, 10460, 626, 1929, 1373, 14, 272, 1204, 7751, 7439, 63, 3543, 92, 489, 982, 440, 488, 12, 314, 5532, 737, 1314, 282, 283, 4133, 7, 570, 2656, 911, 506, 2737, 14, 489, 982, 488, 12, 283, 4133, 7, 570, 10460, 911, 675, 13053, 14, 272, 1204, 885, 63, 4133, 63, 842, 92, 489, 982, 440, 488, 12, 283, 4133, 7, 570, 10460, 2741, 701, 642, 1021, 1928, 282, 489, 2488, 5532, 911, 372, 1204, 885, 63, 4133, 63, 842, 92, 3140, 14, 272, 1204, 18430, 92, 489, 982, 715, 1006, 2741, 570, 10460, 911, 506, 8072, 315, 376, 28856, 604, 17521, 14, 272, 1204, 1880, 63, 509, 63, 396, 92, 489, 21552, 282, 3537, 3787, 7830, 2419, 6425, 598, 5277, 2978, 17521, 83, 14, 272, 1204, 1637, 63, 2118, 92, 489, 982, 715, 12, 1006, 2741, 570, 10460, 911, 506, 2581, 13, 2118, 12, 11150, 626, 2581, 489, 3201, 874, 911, 754, 315, 2552, 7830, 2419, 2581, 7029, 14, 272, 1449, 272, 291, 423, 785, 63, 1617, 63, 9986, 275, 909, 63, 1617, 63, 9986, 272, 291, 423, 7751, 7439, 63, 3543, 275, 10713, 7439, 63, 3543, 272, 291, 423, 885, 63, 4133, 63, 842, 275, 849, 63, 4133, 63, 842, 272, 291, 423, 18430, 275, 26302, 272, 291, 423, 1880, 63, 509, 63, 396, 275, 3787, 63, 509, 63, 396, 272, 291, 423, 1637, 63, 2118, 275, 2581, 63, 2118, 819, 768, 11979, 794, 523, 347, 2372, 12288, 8, 277, 12, 5532, 29, 403, 304, 272, 1449, 14426, 282, 570, 2656, 15161, 283, 4133, 1370, 3645, 642, 1083, 7830, 2419, 272, 2372, 12526, 360, 4133, 358, 2952, 314, 13942, 365, 1007, 84, 590, 3365, 27, 283, 4133, 7, 883, 272, 506, 10713, 7439, 370, 282, 2488, 5532, 334, 92, 7751, 7439, 63, 3543, 92, 315, 3787, 9, 436, 883, 1172, 272, 1172, 2399, 849, 1256, 10087, 334, 92, 885, 63, 4133, 63, 842, 92, 315, 314, 272, 3787, 680, 339, 1204, 3543, 92, 340, 2222, 13, 403, 16756, 282, 2488, 5532, 370, 10713, 314, 1591, 570, 272, 2656, 737, 12, 10617, 652, 911, 506, 5525, 340, 652, 1159, 15666, 2419, 1204, 7751, 7439, 63, 3543, 18257, 272, 982, 488, 2066, 1204, 3543, 92, 911, 4426, 1204, 7751, 7439, 63, 3543, 92, 340, 365, 965, 2757, 272, 663, 12, 503, 2951, 13053, 334, 6777, 5594, 1570, 5309, 1654, 8836, 1, 680, 272, 1449, 272, 340, 5532, 365, 488, 26, 489, 340, 291, 423, 885, 63, 4133, 63, 842, 365, 440, 488, 26, 267, 372, 291, 423, 885, 63, 4133, 63, 842, 489, 372, 291, 423, 2499, 360, 4133, 297, 5532, 29, 277, 423, 7751, 7439, 63, 3543, 9, 272, 372, 291, 423, 2499, 360, 4133, 297, 5532, 29, 3543, 9, 819, 768, 11979, 794, 523, 347, 2372, 12526, 8, 277, 12, 5246, 304, 272, 1449, 14426, 282, 570, 2656, 15161, 1204, 4694, 18712, 367, 2893, 283, 845, 1400, 7, 446, 7003, 1163, 272, 2419, 283, 4133, 297, 1314, 1471, 506, 14701, 4799, 314, 2372, 12288, 342, 1083, 14, 339, 3390, 26, 25059, 2372, 12288, 642, 805, 3181, 1133, 5452, 282, 1204, 3543, 92, 1423, 272, 3967, 781, 5534, 626, 17347, 7508, 590, 14433, 1570, 12, 1830, 5288, 28914, 590, 272, 4493, 14, 272, 1449, 272, 702, 1228, 8, 4694, 12, 7116, 395, 283, 12526, 450, 83, 1471, 506, 282, 1059, 7, 450, 5246, 272, 702, 5246, 1137, 283, 4133, 297, 334, 267, 283, 6612, 4165, 5246, 25641, 4133, 22458, 675, 2372, 12288, 19004, 272, 372, 291, 423, 2499, 8, 4694, 9, 819, 347, 485, 2499, 8, 277, 12, 5246, 12, 5532, 29, 403, 304, 272, 1449, 10607, 598, 5277, 2978, 570, 10460, 334, 269, 340, 315, 282, 511, 12, 18994, 15685, 272, 1204, 277, 423, 1880, 63, 509, 63, 396, 9314, 680, 644, 8146, 314, 9183, 570, 2656, 315, 272, 376, 28856, 604, 570, 2656, 340, 314, 26302, 3305, 365, 663, 12, 436, 3753, 14018, 652, 315, 272, 282, 445, 23302, 570, 2656, 14, 272, 1449, 272, 340, 291, 423, 1880, 63, 509, 63, 396, 365, 440, 488, 26, 489, 570, 63, 2253, 275, 291, 423, 1880, 63, 509, 63, 396, 8, 4694, 29, 4694, 12, 5532, 29, 3543, 9, 272, 587, 26, 489, 570, 63, 2253, 275, 598, 5277, 2978, 17521, 14, 2499, 8, 4694, 29, 4694, 12, 5532, 29, 3543, 9, 272, 340, 291, 423, 18430, 26, 489, 570, 63, 2253, 275, 28856, 604, 17521, 8, 493, 63, 2253, 9, 272, 372, 445, 23302, 17521, 8, 493, 63, 2253, 12, 291, 423, 785, 63, 1617, 63, 9986, 12, 267, 2449, 63, 265, 63, 18420, 29, 277, 423, 1637, 63, 2118, 9, 819, 768, 4639, 523, 347, 2104, 5339, 8, 785, 63, 1617, 63, 9986, 12, 1011, 2992, 589, 304, 272, 1449, 9167, 315, 6425, 282, 1654, 1256, 641, 11667, 14, 272, 1449, 272 ]
[ 1898, 6171, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 504, 13627, 63, 493, 63, 2253, 492, 445, 23302, 17521, 199, 504, 486, 5277, 2978, 63, 493, 63, 2253, 492, 598, 5277, 2978, 17521, 199, 504, 2257, 63, 493, 63, 2253, 492, 10111, 17521, 199, 504, 26302, 63, 493, 63, 2253, 492, 28856, 604, 17521, 199, 504, 10919, 63, 7522, 14, 1001, 63, 3629, 63, 5772, 14, 11979, 794, 492, 11955, 794, 421, 199, 533, 10891, 17521, 6663, 8, 785, 304, 523, 1449, 17473, 1591, 570, 10460, 1689, 1102, 2, 11150, 314, 570, 2656, 626, 7057, 314, 523, 1654, 1159, 1350, 1233, 436, 7009, 9, 15161, 5288, 12, 503, 1263, 5246, 14, 819, 3814, 2656, 4454, 787, 11955, 1759, 370, 11075, 314, 315, 13, 4844, 18014, 9371, 523, 3663, 24194, 14, 523, 1449, 523, 347, 636, 826, 721, 277, 12, 2049, 909, 63, 1617, 63, 9986, 12, 2049, 10713, 7439, 63, 3543, 29, 403, 12, 2049, 849, 63, 4133, 63, 842, 29, 403, 12, 2049, 26302, 29, 797, 12, 2049, 3787, 63, 509, 63, 396, 29, 403, 12, 2049, 2581, 63, 2118, 29, 797, 304, 272, 1449, 272, 1204, 785, 63, 1617, 63, 9986, 92, 489, 21552, 18014, 367, 570, 10460, 626, 1929, 1373, 14, 272, 1204, 7751, 7439, 63, 3543, 92, 489, 982, 440, 488, 12, 314, 5532, 737, 1314, 282, 283, 4133, 7, 570, 2656, 911, 506, 2737, 14, 489, 982, 488, 12, 283, 4133, 7, 570, 10460, 911, 675, 13053, 14, 272, 1204, 885, 63, 4133, 63, 842, 92, 489, 982, 440, 488, 12, 283, 4133, 7, 570, 10460, 2741, 701, 642, 1021, 1928, 282, 489, 2488, 5532, 911, 372, 1204, 885, 63, 4133, 63, 842, 92, 3140, 14, 272, 1204, 18430, 92, 489, 982, 715, 1006, 2741, 570, 10460, 911, 506, 8072, 315, 376, 28856, 604, 17521, 14, 272, 1204, 1880, 63, 509, 63, 396, 92, 489, 21552, 282, 3537, 3787, 7830, 2419, 6425, 598, 5277, 2978, 17521, 83, 14, 272, 1204, 1637, 63, 2118, 92, 489, 982, 715, 12, 1006, 2741, 570, 10460, 911, 506, 2581, 13, 2118, 12, 11150, 626, 2581, 489, 3201, 874, 911, 754, 315, 2552, 7830, 2419, 2581, 7029, 14, 272, 1449, 272, 291, 423, 785, 63, 1617, 63, 9986, 275, 909, 63, 1617, 63, 9986, 272, 291, 423, 7751, 7439, 63, 3543, 275, 10713, 7439, 63, 3543, 272, 291, 423, 885, 63, 4133, 63, 842, 275, 849, 63, 4133, 63, 842, 272, 291, 423, 18430, 275, 26302, 272, 291, 423, 1880, 63, 509, 63, 396, 275, 3787, 63, 509, 63, 396, 272, 291, 423, 1637, 63, 2118, 275, 2581, 63, 2118, 819, 768, 11979, 794, 523, 347, 2372, 12288, 8, 277, 12, 5532, 29, 403, 304, 272, 1449, 14426, 282, 570, 2656, 15161, 283, 4133, 1370, 3645, 642, 1083, 7830, 2419, 272, 2372, 12526, 360, 4133, 358, 2952, 314, 13942, 365, 1007, 84, 590, 3365, 27, 283, 4133, 7, 883, 272, 506, 10713, 7439, 370, 282, 2488, 5532, 334, 92, 7751, 7439, 63, 3543, 92, 315, 3787, 9, 436, 883, 1172, 272, 1172, 2399, 849, 1256, 10087, 334, 92, 885, 63, 4133, 63, 842, 92, 315, 314, 272, 3787, 680, 339, 1204, 3543, 92, 340, 2222, 13, 403, 16756, 282, 2488, 5532, 370, 10713, 314, 1591, 570, 272, 2656, 737, 12, 10617, 652, 911, 506, 5525, 340, 652, 1159, 15666, 2419, 1204, 7751, 7439, 63, 3543, 18257, 272, 982, 488, 2066, 1204, 3543, 92, 911, 4426, 1204, 7751, 7439, 63, 3543, 92, 340, 365, 965, 2757, 272, 663, 12, 503, 2951, 13053, 334, 6777, 5594, 1570, 5309, 1654, 8836, 1, 680, 272, 1449, 272, 340, 5532, 365, 488, 26, 489, 340, 291, 423, 885, 63, 4133, 63, 842, 365, 440, 488, 26, 267, 372, 291, 423, 885, 63, 4133, 63, 842, 489, 372, 291, 423, 2499, 360, 4133, 297, 5532, 29, 277, 423, 7751, 7439, 63, 3543, 9, 272, 372, 291, 423, 2499, 360, 4133, 297, 5532, 29, 3543, 9, 819, 768, 11979, 794, 523, 347, 2372, 12526, 8, 277, 12, 5246, 304, 272, 1449, 14426, 282, 570, 2656, 15161, 1204, 4694, 18712, 367, 2893, 283, 845, 1400, 7, 446, 7003, 1163, 272, 2419, 283, 4133, 297, 1314, 1471, 506, 14701, 4799, 314, 2372, 12288, 342, 1083, 14, 339, 3390, 26, 25059, 2372, 12288, 642, 805, 3181, 1133, 5452, 282, 1204, 3543, 92, 1423, 272, 3967, 781, 5534, 626, 17347, 7508, 590, 14433, 1570, 12, 1830, 5288, 28914, 590, 272, 4493, 14, 272, 1449, 272, 702, 1228, 8, 4694, 12, 7116, 395, 283, 12526, 450, 83, 1471, 506, 282, 1059, 7, 450, 5246, 272, 702, 5246, 1137, 283, 4133, 297, 334, 267, 283, 6612, 4165, 5246, 25641, 4133, 22458, 675, 2372, 12288, 19004, 272, 372, 291, 423, 2499, 8, 4694, 9, 819, 347, 485, 2499, 8, 277, 12, 5246, 12, 5532, 29, 403, 304, 272, 1449, 10607, 598, 5277, 2978, 570, 10460, 334, 269, 340, 315, 282, 511, 12, 18994, 15685, 272, 1204, 277, 423, 1880, 63, 509, 63, 396, 9314, 680, 644, 8146, 314, 9183, 570, 2656, 315, 272, 376, 28856, 604, 570, 2656, 340, 314, 26302, 3305, 365, 663, 12, 436, 3753, 14018, 652, 315, 272, 282, 445, 23302, 570, 2656, 14, 272, 1449, 272, 340, 291, 423, 1880, 63, 509, 63, 396, 365, 440, 488, 26, 489, 570, 63, 2253, 275, 291, 423, 1880, 63, 509, 63, 396, 8, 4694, 29, 4694, 12, 5532, 29, 3543, 9, 272, 587, 26, 489, 570, 63, 2253, 275, 598, 5277, 2978, 17521, 14, 2499, 8, 4694, 29, 4694, 12, 5532, 29, 3543, 9, 272, 340, 291, 423, 18430, 26, 489, 570, 63, 2253, 275, 28856, 604, 17521, 8, 493, 63, 2253, 9, 272, 372, 445, 23302, 17521, 8, 493, 63, 2253, 12, 291, 423, 785, 63, 1617, 63, 9986, 12, 267, 2449, 63, 265, 63, 18420, 29, 277, 423, 1637, 63, 2118, 9, 819, 768, 4639, 523, 347, 2104, 5339, 8, 785, 63, 1617, 63, 9986, 12, 1011, 2992, 589, 304, 272, 1449, 9167, 315, 6425, 282, 1654, 1256, 641, 11667, 14, 272, 1449, 272, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
cs564/heron
third_party/setuptools/pkg_resources.py
11
101160
""" Package resource API -------------------- A resource is a logical file contained within a package, or a logical subdirectory thereof. The package resource API expects resource names to have their path parts separated with ``/``, *not* whatever the local path separator is. Do not use os.path operations to manipulate resource names being passed into the API. The package resource API is designed to work with normal filesystem packages, .egg files, and unpacked .egg files. It can also work in a limited way with .zip files and with custom PEP 302 loaders that support the ``get_data()`` method. """ import sys import os import time import re import imp import zipfile import zipimport import warnings import stat import functools import pkgutil import token import symbol import operator import platform from pkgutil import get_importer try: from urlparse import urlparse, urlunparse except ImportError: from urllib.parse import urlparse, urlunparse try: frozenset except NameError: from sets import ImmutableSet as frozenset try: basestring next = lambda o: o.next() from cStringIO import StringIO as BytesIO except NameError: basestring = str from io import BytesIO def execfile(fn, globs=None, locs=None): if globs is None: globs = globals() if locs is None: locs = globs exec(compile(open(fn).read(), fn, 'exec'), globs, locs) # capture these to bypass sandboxing from os import utime try: from os import mkdir, rename, unlink WRITE_SUPPORT = True except ImportError: # no write support, probably under GAE WRITE_SUPPORT = False from os import open as os_open from os.path import isdir, split # Avoid try/except due to potential problems with delayed import mechanisms. if sys.version_info >= (3, 3) and sys.implementation.name == "cpython": import importlib._bootstrap as importlib_bootstrap else: importlib_bootstrap = None try: import parser except ImportError: pass def _bypass_ensure_directory(name, mode=0o777): # Sandbox-bypassing version of ensure_directory() if not WRITE_SUPPORT: raise IOError('"os.mkdir" not supported on this platform.') dirname, filename = split(name) if dirname and filename and not isdir(dirname): _bypass_ensure_directory(dirname) mkdir(dirname, mode) _state_vars = {} def _declare_state(vartype, **kw): globals().update(kw) _state_vars.update(dict.fromkeys(kw, vartype)) def __getstate__(): state = {} g = globals() for k, v in _state_vars.items(): state[k] = g['_sget_'+v](g[k]) return state def __setstate__(state): g = globals() for k, v in state.items(): g['_sset_'+_state_vars[k]](k, g[k], v) return state def _sget_dict(val): return val.copy() def _sset_dict(key, ob, state): ob.clear() ob.update(state) def _sget_object(val): return val.__getstate__() def _sset_object(key, ob, state): ob.__setstate__(state) _sget_none = _sset_none = lambda *args: None def get_supported_platform(): """Return this platform's maximum compatible version. distutils.util.get_platform() normally reports the minimum version of Mac OS X that would be required to *use* extensions produced by distutils. But what we want when checking compatibility is to know the version of Mac OS X that we are *running*. To allow usage of packages that explicitly require a newer version of Mac OS X, we must also know the current version of the OS. If this condition occurs for any other platform with a version in its platform strings, this function should be extended accordingly. """ plat = get_build_platform() m = macosVersionString.match(plat) if m is not None and sys.platform == "darwin": try: plat = 'macosx-%s-%s' % ('.'.join(_macosx_vers()[:2]), m.group(3)) except ValueError: # not Mac OS X pass return plat __all__ = [ # Basic resource access and distribution/entry point discovery 'require', 'run_script', 'get_provider', 'get_distribution', 'load_entry_point', 'get_entry_map', 'get_entry_info', 'iter_entry_points', 'resource_string', 'resource_stream', 'resource_filename', 'resource_listdir', 'resource_exists', 'resource_isdir', # Environmental control 'declare_namespace', 'working_set', 'add_activation_listener', 'find_distributions', 'set_extraction_path', 'cleanup_resources', 'get_default_cache', # Primary implementation classes 'Environment', 'WorkingSet', 'ResourceManager', 'Distribution', 'Requirement', 'EntryPoint', # Exceptions 'ResolutionError', 'VersionConflict', 'DistributionNotFound', 'UnknownExtra', 'ExtractionError', # Parsing functions and string utilities 'parse_requirements', 'parse_version', 'safe_name', 'safe_version', 'get_platform', 'compatible_platforms', 'yield_lines', 'split_sections', 'safe_extra', 'to_filename', 'invalid_marker', 'evaluate_marker', # filesystem utilities 'ensure_directory', 'normalize_path', # Distribution "precedence" constants 'EGG_DIST', 'BINARY_DIST', 'SOURCE_DIST', 'CHECKOUT_DIST', 'DEVELOP_DIST', # "Provider" interfaces, implementations, and registration/lookup APIs 'IMetadataProvider', 'IResourceProvider', 'FileMetadata', 'PathMetadata', 'EggMetadata', 'EmptyProvider', 'empty_provider', 'NullProvider', 'EggProvider', 'DefaultProvider', 'ZipProvider', 'register_finder', 'register_namespace_handler', 'register_loader_type', 'fixup_namespace_packages', 'get_importer', # Deprecated/backward compatibility only 'run_main', 'AvailableDistributions', ] class ResolutionError(Exception): """Abstract base for dependency resolution errors""" def __repr__(self): return self.__class__.__name__+repr(self.args) class VersionConflict(ResolutionError): """An already-installed version conflicts with the requested version""" class DistributionNotFound(ResolutionError): """A requested distribution was not found""" class UnknownExtra(ResolutionError): """Distribution doesn't have an "extra feature" of the given name""" _provider_factories = {} PY_MAJOR = sys.version[:3] EGG_DIST = 3 BINARY_DIST = 2 SOURCE_DIST = 1 CHECKOUT_DIST = 0 DEVELOP_DIST = -1 def register_loader_type(loader_type, provider_factory): """Register `provider_factory` to make providers for `loader_type` `loader_type` is the type or class of a PEP 302 ``module.__loader__``, and `provider_factory` is a function that, passed a *module* object, returns an ``IResourceProvider`` for that module. """ _provider_factories[loader_type] = provider_factory def get_provider(moduleOrReq): """Return an IResourceProvider for the named module or requirement""" if isinstance(moduleOrReq, Requirement): return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0] try: module = sys.modules[moduleOrReq] except KeyError: __import__(moduleOrReq) module = sys.modules[moduleOrReq] loader = getattr(module, '__loader__', None) return _find_adapter(_provider_factories, loader)(module) def _macosx_vers(_cache=[]): if not _cache: import platform version = platform.mac_ver()[0] # fallback for MacPorts if version == '': import plistlib plist = '/System/Library/CoreServices/SystemVersion.plist' if os.path.exists(plist): if hasattr(plistlib, 'readPlist'): plist_content = plistlib.readPlist(plist) if 'ProductVersion' in plist_content: version = plist_content['ProductVersion'] _cache.append(version.split('.')) return _cache[0] def _macosx_arch(machine): return {'PowerPC': 'ppc', 'Power_Macintosh': 'ppc'}.get(machine, machine) def get_build_platform(): """Return this platform's string for platform-specific distributions XXX Currently this is the same as ``distutils.util.get_platform()``, but it needs some hacks for Linux and Mac OS X. """ try: # Python 2.7 or >=3.2 from sysconfig import get_platform except ImportError: from distutils.util import get_platform plat = get_platform() if sys.platform == "darwin" and not plat.startswith('macosx-'): try: version = _macosx_vers() machine = os.uname()[4].replace(" ", "_") return "macosx-%d.%d-%s" % (int(version[0]), int(version[1]), _macosx_arch(machine)) except ValueError: # if someone is running a non-Mac darwin system, this will fall # through to the default implementation pass return plat macosVersionString = re.compile(r"macosx-(\d+)\.(\d+)-(.*)") darwinVersionString = re.compile(r"darwin-(\d+)\.(\d+)\.(\d+)-(.*)") # XXX backward compat get_platform = get_build_platform def compatible_platforms(provided, required): """Can code for the `provided` platform run on the `required` platform? Returns true if either platform is ``None``, or the platforms are equal. XXX Needs compatibility checks for Linux and other unixy OSes. """ if provided is None or required is None or provided==required: # easy case return True # Mac OS X special cases reqMac = macosVersionString.match(required) if reqMac: provMac = macosVersionString.match(provided) # is this a Mac package? if not provMac: # this is backwards compatibility for packages built before # setuptools 0.6. All packages built after this point will # use the new macosx designation. provDarwin = darwinVersionString.match(provided) if provDarwin: dversion = int(provDarwin.group(1)) macosversion = "%s.%s" % (reqMac.group(1), reqMac.group(2)) if dversion == 7 and macosversion >= "10.3" or \ dversion == 8 and macosversion >= "10.4": #import warnings #warnings.warn("Mac eggs should be rebuilt to " # "use the macosx designation instead of darwin.", # category=DeprecationWarning) return True return False # egg isn't macosx or legacy darwin # are they the same major version and machine type? if provMac.group(1) != reqMac.group(1) or \ provMac.group(3) != reqMac.group(3): return False # is the required OS major update >= the provided one? if int(provMac.group(2)) > int(reqMac.group(2)): return False return True # XXX Linux and other platforms' special cases should go here return False def run_script(dist_spec, script_name): """Locate distribution `dist_spec` and run its `script_name` script""" ns = sys._getframe(1).f_globals name = ns['__name__'] ns.clear() ns['__name__'] = name require(dist_spec)[0].run_script(script_name, ns) # backward compatibility run_main = run_script def get_distribution(dist): """Return a current distribution object for a Requirement or string""" if isinstance(dist, basestring): dist = Requirement.parse(dist) if isinstance(dist, Requirement): dist = get_provider(dist) if not isinstance(dist, Distribution): raise TypeError("Expected string, Requirement, or Distribution", dist) return dist def load_entry_point(dist, group, name): """Return `name` entry point of `group` for `dist` or raise ImportError""" return get_distribution(dist).load_entry_point(group, name) def get_entry_map(dist, group=None): """Return the entry point map for `group`, or the full entry map""" return get_distribution(dist).get_entry_map(group) def get_entry_info(dist, group, name): """Return the EntryPoint object for `group`+`name`, or ``None``""" return get_distribution(dist).get_entry_info(group, name) class IMetadataProvider: def has_metadata(name): """Does the package's distribution contain the named metadata?""" def get_metadata(name): """The named metadata resource as a string""" def get_metadata_lines(name): """Yield named metadata resource as list of non-blank non-comment lines Leading and trailing whitespace is stripped from each line, and lines with ``#`` as the first non-blank character are omitted.""" def metadata_isdir(name): """Is the named metadata a directory? (like ``os.path.isdir()``)""" def metadata_listdir(name): """List of metadata names in the directory (like ``os.listdir()``)""" def run_script(script_name, namespace): """Execute the named script in the supplied namespace dictionary""" class IResourceProvider(IMetadataProvider): """An object that provides access to package resources""" def get_resource_filename(manager, resource_name): """Return a true filesystem path for `resource_name` `manager` must be an ``IResourceManager``""" def get_resource_stream(manager, resource_name): """Return a readable file-like object for `resource_name` `manager` must be an ``IResourceManager``""" def get_resource_string(manager, resource_name): """Return a string containing the contents of `resource_name` `manager` must be an ``IResourceManager``""" def has_resource(resource_name): """Does the package contain the named resource?""" def resource_isdir(resource_name): """Is the named resource a directory? (like ``os.path.isdir()``)""" def resource_listdir(resource_name): """List of resource names in the directory (like ``os.listdir()``)""" class WorkingSet(object): """A collection of active distributions on sys.path (or a similar list)""" def __init__(self, entries=None): """Create working set from list of path entries (default=sys.path)""" self.entries = [] self.entry_keys = {} self.by_key = {} self.callbacks = [] if entries is None: entries = sys.path for entry in entries: self.add_entry(entry) @classmethod def _build_master(cls): """ Prepare the master working set. """ ws = cls() try: from __main__ import __requires__ except ImportError: # The main program does not list any requirements return ws # ensure the requirements are met try: ws.require(__requires__) except VersionConflict: return cls._build_from_requirements(__requires__) return ws @classmethod def _build_from_requirements(cls, req_spec): """ Build a working set from a requirement spec. Rewrites sys.path. """ # try it without defaults already on sys.path # by starting with an empty path ws = cls([]) reqs = parse_requirements(req_spec) dists = ws.resolve(reqs, Environment()) for dist in dists: ws.add(dist) # add any missing entries from sys.path for entry in sys.path: if entry not in ws.entries: ws.add_entry(entry) # then copy back to sys.path sys.path[:] = ws.entries return ws def add_entry(self, entry): """Add a path item to ``.entries``, finding any distributions on it ``find_distributions(entry, True)`` is used to find distributions corresponding to the path entry, and they are added. `entry` is always appended to ``.entries``, even if it is already present. (This is because ``sys.path`` can contain the same value more than once, and the ``.entries`` of the ``sys.path`` WorkingSet should always equal ``sys.path``.) """ self.entry_keys.setdefault(entry, []) self.entries.append(entry) for dist in find_distributions(entry, True): self.add(dist, entry, False) def __contains__(self, dist): """True if `dist` is the active distribution for its project""" return self.by_key.get(dist.key) == dist def find(self, req): """Find a distribution matching requirement `req` If there is an active distribution for the requested project, this returns it as long as it meets the version requirement specified by `req`. But, if there is an active distribution for the project and it does *not* meet the `req` requirement, ``VersionConflict`` is raised. If there is no active distribution for the requested project, ``None`` is returned. """ dist = self.by_key.get(req.key) if dist is not None and dist not in req: # XXX add more info raise VersionConflict(dist, req) else: return dist def iter_entry_points(self, group, name=None): """Yield entry point objects from `group` matching `name` If `name` is None, yields all entry points in `group` from all distributions in the working set, otherwise only ones matching both `group` and `name` are yielded (in distribution order). """ for dist in self: entries = dist.get_entry_map(group) if name is None: for ep in entries.values(): yield ep elif name in entries: yield entries[name] def run_script(self, requires, script_name): """Locate distribution for `requires` and run `script_name` script""" ns = sys._getframe(1).f_globals name = ns['__name__'] ns.clear() ns['__name__'] = name self.require(requires)[0].run_script(script_name, ns) def __iter__(self): """Yield distributions for non-duplicate projects in the working set The yield order is the order in which the items' path entries were added to the working set. """ seen = {} for item in self.entries: if item not in self.entry_keys: # workaround a cache issue continue for key in self.entry_keys[item]: if key not in seen: seen[key]=1 yield self.by_key[key] def add(self, dist, entry=None, insert=True, replace=False): """Add `dist` to working set, associated with `entry` If `entry` is unspecified, it defaults to the ``.location`` of `dist`. On exit from this routine, `entry` is added to the end of the working set's ``.entries`` (if it wasn't already present). `dist` is only added to the working set if it's for a project that doesn't already have a distribution in the set, unless `replace=True`. If it's added, any callbacks registered with the ``subscribe()`` method will be called. """ if insert: dist.insert_on(self.entries, entry) if entry is None: entry = dist.location keys = self.entry_keys.setdefault(entry,[]) keys2 = self.entry_keys.setdefault(dist.location,[]) if not replace and dist.key in self.by_key: # ignore hidden distros return self.by_key[dist.key] = dist if dist.key not in keys: keys.append(dist.key) if dist.key not in keys2: keys2.append(dist.key) self._added_new(dist) def resolve(self, requirements, env=None, installer=None, replace_conflicting=False): """List all distributions needed to (recursively) meet `requirements` `requirements` must be a sequence of ``Requirement`` objects. `env`, if supplied, should be an ``Environment`` instance. If not supplied, it defaults to all distributions available within any entry or distribution in the working set. `installer`, if supplied, will be invoked with each requirement that cannot be met by an already-installed distribution; it should return a ``Distribution`` or ``None``. Unless `replace_conflicting=True`, raises a VersionConflict exception if any requirements are found on the path that have the correct name but the wrong version. Otherwise, if an `installer` is supplied it will be invoked to obtain the correct version of the requirement and activate it. """ # set up the stack requirements = list(requirements)[::-1] # set of processed requirements processed = {} # key -> dist best = {} to_activate = [] while requirements: # process dependencies breadth-first req = requirements.pop(0) if req in processed: # Ignore cyclic or redundant dependencies continue dist = best.get(req.key) if dist is None: # Find the best distribution and add it to the map dist = self.by_key.get(req.key) if dist is None or (dist not in req and replace_conflicting): ws = self if env is None: if dist is None: env = Environment(self.entries) else: # Use an empty environment and workingset to avoid # any further conflicts with the conflicting # distribution env = Environment([]) ws = WorkingSet([]) dist = best[req.key] = env.best_match(req, ws, installer) if dist is None: #msg = ("The '%s' distribution was not found on this " # "system, and is required by this application.") #raise DistributionNotFound(msg % req) # unfortunately, zc.buildout uses a str(err) # to get the name of the distribution here.. raise DistributionNotFound(req) to_activate.append(dist) if dist not in req: # Oops, the "best" so far conflicts with a dependency raise VersionConflict(dist, req) # XXX put more info here requirements.extend(dist.requires(req.extras)[::-1]) processed[req] = True # return list of distros to activate return to_activate def find_plugins(self, plugin_env, full_env=None, installer=None, fallback=True): """Find all activatable distributions in `plugin_env` Example usage:: distributions, errors = working_set.find_plugins( Environment(plugin_dirlist) ) map(working_set.add, distributions) # add plugins+libs to sys.path print 'Could not load', errors # display errors The `plugin_env` should be an ``Environment`` instance that contains only distributions that are in the project's "plugin directory" or directories. The `full_env`, if supplied, should be an ``Environment`` contains all currently-available distributions. If `full_env` is not supplied, one is created automatically from the ``WorkingSet`` this method is called on, which will typically mean that every directory on ``sys.path`` will be scanned for distributions. `installer` is a standard installer callback as used by the ``resolve()`` method. The `fallback` flag indicates whether we should attempt to resolve older versions of a plugin if the newest version cannot be resolved. This method returns a 2-tuple: (`distributions`, `error_info`), where `distributions` is a list of the distributions found in `plugin_env` that were loadable, along with any other distributions that are needed to resolve their dependencies. `error_info` is a dictionary mapping unloadable plugin distributions to an exception instance describing the error that occurred. Usually this will be a ``DistributionNotFound`` or ``VersionConflict`` instance. """ plugin_projects = list(plugin_env) # scan project names in alphabetic order plugin_projects.sort() error_info = {} distributions = {} if full_env is None: env = Environment(self.entries) env += plugin_env else: env = full_env + plugin_env shadow_set = self.__class__([]) # put all our entries in shadow_set list(map(shadow_set.add, self)) for project_name in plugin_projects: for dist in plugin_env[project_name]: req = [dist.as_requirement()] try: resolvees = shadow_set.resolve(req, env, installer) except ResolutionError: v = sys.exc_info()[1] # save error info error_info[dist] = v if fallback: # try the next older version of project continue else: # give up on this project, keep going break else: list(map(shadow_set.add, resolvees)) distributions.update(dict.fromkeys(resolvees)) # success, no need to try any more versions of this project break distributions = list(distributions) distributions.sort() return distributions, error_info def require(self, *requirements): """Ensure that distributions matching `requirements` are activated `requirements` must be a string or a (possibly-nested) sequence thereof, specifying the distributions and versions required. The return value is a sequence of the distributions that needed to be activated to fulfill the requirements; all relevant distributions are included, even if they were already activated in this working set. """ needed = self.resolve(parse_requirements(requirements)) for dist in needed: self.add(dist) return needed def subscribe(self, callback): """Invoke `callback` for all distributions (including existing ones)""" if callback in self.callbacks: return self.callbacks.append(callback) for dist in self: callback(dist) def _added_new(self, dist): for callback in self.callbacks: callback(dist) def __getstate__(self): return ( self.entries[:], self.entry_keys.copy(), self.by_key.copy(), self.callbacks[:] ) def __setstate__(self, e_k_b_c): entries, keys, by_key, callbacks = e_k_b_c self.entries = entries[:] self.entry_keys = keys.copy() self.by_key = by_key.copy() self.callbacks = callbacks[:] class Environment(object): """Searchable snapshot of distributions on a search path""" def __init__(self, search_path=None, platform=get_supported_platform(), python=PY_MAJOR): """Snapshot distributions available on a search path Any distributions found on `search_path` are added to the environment. `search_path` should be a sequence of ``sys.path`` items. If not supplied, ``sys.path`` is used. `platform` is an optional string specifying the name of the platform that platform-specific distributions must be compatible with. If unspecified, it defaults to the current platform. `python` is an optional string naming the desired version of Python (e.g. ``'3.3'``); it defaults to the current version. You may explicitly set `platform` (and/or `python`) to ``None`` if you wish to map *all* distributions, not just those compatible with the running platform or Python version. """ self._distmap = {} self.platform = platform self.python = python self.scan(search_path) def can_add(self, dist): """Is distribution `dist` acceptable for this environment? The distribution must match the platform and python version requirements specified when this environment was created, or False is returned. """ return (self.python is None or dist.py_version is None or dist.py_version==self.python) \ and compatible_platforms(dist.platform, self.platform) def remove(self, dist): """Remove `dist` from the environment""" self._distmap[dist.key].remove(dist) def scan(self, search_path=None): """Scan `search_path` for distributions usable in this environment Any distributions found are added to the environment. `search_path` should be a sequence of ``sys.path`` items. If not supplied, ``sys.path`` is used. Only distributions conforming to the platform/python version defined at initialization are added. """ if search_path is None: search_path = sys.path for item in search_path: for dist in find_distributions(item): self.add(dist) def __getitem__(self, project_name): """Return a newest-to-oldest list of distributions for `project_name` Uses case-insensitive `project_name` comparison, assuming all the project's distributions use their project's name converted to all lowercase as their key. """ distribution_key = project_name.lower() return self._distmap.get(distribution_key, []) def add(self, dist): """Add `dist` if we ``can_add()`` it and it has not already been added """ if self.can_add(dist) and dist.has_version(): dists = self._distmap.setdefault(dist.key, []) if dist not in dists: dists.append(dist) dists.sort(key=operator.attrgetter('hashcmp'), reverse=True) def best_match(self, req, working_set, installer=None): """Find distribution best matching `req` and usable on `working_set` This calls the ``find(req)`` method of the `working_set` to see if a suitable distribution is already active. (This may raise ``VersionConflict`` if an unsuitable version of the project is already active in the specified `working_set`.) If a suitable distribution isn't active, this method returns the newest distribution in the environment that meets the ``Requirement`` in `req`. If no suitable distribution is found, and `installer` is supplied, then the result of calling the environment's ``obtain(req, installer)`` method will be returned. """ dist = working_set.find(req) if dist is not None: return dist for dist in self[req.key]: if dist in req: return dist # try to download/install return self.obtain(req, installer) def obtain(self, requirement, installer=None): """Obtain a distribution matching `requirement` (e.g. via download) Obtain a distro that matches requirement (e.g. via download). In the base ``Environment`` class, this routine just returns ``installer(requirement)``, unless `installer` is None, in which case None is returned instead. This method is a hook that allows subclasses to attempt other ways of obtaining a distribution before falling back to the `installer` argument.""" if installer is not None: return installer(requirement) def __iter__(self): """Yield the unique project names of the available distributions""" for key in self._distmap.keys(): if self[key]: yield key def __iadd__(self, other): """In-place addition of a distribution or environment""" if isinstance(other, Distribution): self.add(other) elif isinstance(other, Environment): for project in other: for dist in other[project]: self.add(dist) else: raise TypeError("Can't add %r to environment" % (other,)) return self def __add__(self, other): """Add an environment or distribution to an environment""" new = self.__class__([], platform=None, python=None) for env in self, other: new += env return new # XXX backward compatibility AvailableDistributions = Environment class ExtractionError(RuntimeError): """An error occurred extracting a resource The following attributes are available from instances of this exception: manager The resource manager that raised this exception cache_path The base directory for resource extraction original_error The exception instance that caused extraction to fail """ class ResourceManager: """Manage resource extraction and packages""" extraction_path = None def __init__(self): self.cached_files = {} def resource_exists(self, package_or_requirement, resource_name): """Does the named resource exist?""" return get_provider(package_or_requirement).has_resource(resource_name) def resource_isdir(self, package_or_requirement, resource_name): """Is the named resource an existing directory?""" return get_provider(package_or_requirement).resource_isdir( resource_name ) def resource_filename(self, package_or_requirement, resource_name): """Return a true filesystem path for specified resource""" return get_provider(package_or_requirement).get_resource_filename( self, resource_name ) def resource_stream(self, package_or_requirement, resource_name): """Return a readable file-like object for specified resource""" return get_provider(package_or_requirement).get_resource_stream( self, resource_name ) def resource_string(self, package_or_requirement, resource_name): """Return specified resource as a string""" return get_provider(package_or_requirement).get_resource_string( self, resource_name ) def resource_listdir(self, package_or_requirement, resource_name): """List the contents of the named resource directory""" return get_provider(package_or_requirement).resource_listdir( resource_name ) def extraction_error(self): """Give an error message for problems extracting file(s)""" old_exc = sys.exc_info()[1] cache_path = self.extraction_path or get_default_cache() err = ExtractionError("""Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: %s The Python egg cache directory is currently set to: %s Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory. """ % (old_exc, cache_path) ) err.manager = self err.cache_path = cache_path err.original_error = old_exc raise err def get_cache_path(self, archive_name, names=()): """Return absolute location in cache for `archive_name` and `names` The parent directory of the resulting path will be created if it does not already exist. `archive_name` should be the base filename of the enclosing egg (which may not be the name of the enclosing zipfile!), including its ".egg" extension. `names`, if provided, should be a sequence of path name parts "under" the egg's extraction location. This method should only be called by resource providers that need to obtain an extraction location, and only for names they intend to extract, as it tracks the generated names for possible cleanup later. """ extract_path = self.extraction_path or get_default_cache() target_path = os.path.join(extract_path, archive_name+'-tmp', *names) try: _bypass_ensure_directory(target_path) except: self.extraction_error() self._warn_unsafe_extraction_path(extract_path) self.cached_files[target_path] = 1 return target_path @staticmethod def _warn_unsafe_extraction_path(path): """ If the default extraction path is overridden and set to an insecure location, such as /tmp, it opens up an opportunity for an attacker to replace an extracted file with an unauthorized payload. Warn the user if a known insecure location is used. See Distribute #375 for more details. """ if os.name == 'nt' and not path.startswith(os.environ['windir']): # On Windows, permissions are generally restrictive by default # and temp directories are not writable by other users, so # bypass the warning. return mode = os.stat(path).st_mode if mode & stat.S_IWOTH or mode & stat.S_IWGRP: msg = ("%s is writable by group/others and vulnerable to attack " "when " "used with get_resource_filename. Consider a more secure " "location (set with .set_extraction_path or the " "PYTHON_EGG_CACHE environment variable)." % path) warnings.warn(msg, UserWarning) def postprocess(self, tempname, filename): """Perform any platform-specific postprocessing of `tempname` This is where Mac header rewrites should be done; other platforms don't have anything special they should do. Resource providers should call this method ONLY after successfully extracting a compressed resource. They must NOT call it on resources that are already in the filesystem. `tempname` is the current (temporary) name of the file, and `filename` is the name it will be renamed to by the caller after this routine returns. """ if os.name == 'posix': # Make the resource executable mode = ((os.stat(tempname).st_mode) | 0o555) & 0o7777 os.chmod(tempname, mode) def set_extraction_path(self, path): """Set the base path where resources will be extracted to, if needed. If you do not call this routine before any extractions take place, the path defaults to the return value of ``get_default_cache()``. (Which is based on the ``PYTHON_EGG_CACHE`` environment variable, with various platform-specific fallbacks. See that routine's documentation for more details.) Resources are extracted to subdirectories of this path based upon information given by the ``IResourceProvider``. You may set this to a temporary directory, but then you must call ``cleanup_resources()`` to delete the extracted files when done. There is no guarantee that ``cleanup_resources()`` will be able to remove all extracted files. (Note: you may not change the extraction path for a given resource manager once resources have been extracted, unless you first call ``cleanup_resources()``.) """ if self.cached_files: raise ValueError( "Can't change extraction path, files already extracted" ) self.extraction_path = path def cleanup_resources(self, force=False): """ Delete all extracted resource files and directories, returning a list of the file and directory names that could not be successfully removed. This function does not have any concurrency protection, so it should generally only be called when the extraction path is a temporary directory exclusive to a single process. This method is not automatically called; you must call it explicitly or register it as an ``atexit`` function if you wish to ensure cleanup of a temporary directory used for extractions. """ # XXX def get_default_cache(): """Determine the default cache location This returns the ``PYTHON_EGG_CACHE`` environment variable, if set. Otherwise, on Windows, it returns a "Python-Eggs" subdirectory of the "Application Data" directory. On all other systems, it's "~/.python-eggs". """ try: return os.environ['PYTHON_EGG_CACHE'] except KeyError: pass if os.name!='nt': return os.path.expanduser('~/.python-eggs') # XXX this may be locale-specific! app_data = 'Application Data' app_homes = [ # best option, should be locale-safe (('APPDATA',), None), (('USERPROFILE',), app_data), (('HOMEDRIVE','HOMEPATH'), app_data), (('HOMEPATH',), app_data), (('HOME',), None), # 95/98/ME (('WINDIR',), app_data), ] for keys, subdir in app_homes: dirname = '' for key in keys: if key in os.environ: dirname = os.path.join(dirname, os.environ[key]) else: break else: if subdir: dirname = os.path.join(dirname, subdir) return os.path.join(dirname, 'Python-Eggs') else: raise RuntimeError( "Please set the PYTHON_EGG_CACHE enviroment variable" ) def safe_name(name): """Convert an arbitrary string to a standard distribution name Any runs of non-alphanumeric/. characters are replaced with a single '-'. """ return re.sub('[^A-Za-z0-9.]+', '-', name) def safe_version(version): """Convert an arbitrary string to a standard version string Spaces become dots, and all other non-alphanumeric characters become dashes, with runs of multiple dashes condensed to a single dash. """ version = version.replace(' ','.') return re.sub('[^A-Za-z0-9.]+', '-', version) def safe_extra(extra): """Convert an arbitrary string to a standard 'extra' name Any runs of non-alphanumeric characters are replaced with a single '_', and the result is always lowercased. """ return re.sub('[^A-Za-z0-9.]+', '_', extra).lower() def to_filename(name): """Convert a project or version name to its filename-escaped form Any '-' characters are currently replaced with '_'. """ return name.replace('-','_') class MarkerEvaluation(object): values = { 'os_name': lambda: os.name, 'sys_platform': lambda: sys.platform, 'python_full_version': platform.python_version, 'python_version': lambda: platform.python_version()[:3], 'platform_version': platform.version, 'platform_machine': platform.machine, 'python_implementation': platform.python_implementation, } @classmethod def is_invalid_marker(cls, text): """ Validate text as a PEP 426 environment marker; return an exception if invalid or False otherwise. """ try: cls.evaluate_marker(text) except SyntaxError: return cls.normalize_exception(sys.exc_info()[1]) return False @staticmethod def normalize_exception(exc): """ Given a SyntaxError from a marker evaluation, normalize the error message: - Remove indications of filename and line number. - Replace platform-specific error messages with standard error messages. """ subs = { 'unexpected EOF while parsing': 'invalid syntax', 'parenthesis is never closed': 'invalid syntax', } exc.filename = None exc.lineno = None exc.msg = subs.get(exc.msg, exc.msg) return exc @classmethod def and_test(cls, nodelist): # MUST NOT short-circuit evaluation, or invalid syntax can be skipped! items = [ cls.interpret(nodelist[i]) for i in range(1, len(nodelist), 2) ] return functools.reduce(operator.and_, items) @classmethod def test(cls, nodelist): # MUST NOT short-circuit evaluation, or invalid syntax can be skipped! items = [ cls.interpret(nodelist[i]) for i in range(1, len(nodelist), 2) ] return functools.reduce(operator.or_, items) @classmethod def atom(cls, nodelist): t = nodelist[1][0] if t == token.LPAR: if nodelist[2][0] == token.RPAR: raise SyntaxError("Empty parentheses") return cls.interpret(nodelist[2]) msg = "Language feature not supported in environment markers" raise SyntaxError(msg) @classmethod def comparison(cls, nodelist): if len(nodelist) > 4: msg = "Chained comparison not allowed in environment markers" raise SyntaxError(msg) comp = nodelist[2][1] cop = comp[1] if comp[0] == token.NAME: if len(nodelist[2]) == 3: if cop == 'not': cop = 'not in' else: cop = 'is not' try: cop = cls.get_op(cop) except KeyError: msg = repr(cop) + " operator not allowed in environment markers" raise SyntaxError(msg) return cop(cls.evaluate(nodelist[1]), cls.evaluate(nodelist[3])) @classmethod def get_op(cls, op): ops = { symbol.test: cls.test, symbol.and_test: cls.and_test, symbol.atom: cls.atom, symbol.comparison: cls.comparison, 'not in': lambda x, y: x not in y, 'in': lambda x, y: x in y, '==': operator.eq, '!=': operator.ne, } if hasattr(symbol, 'or_test'): ops[symbol.or_test] = cls.test return ops[op] @classmethod def evaluate_marker(cls, text, extra=None): """ Evaluate a PEP 426 environment marker on CPython 2.4+. Return a boolean indicating the marker result in this environment. Raise SyntaxError if marker is invalid. This implementation uses the 'parser' module, which is not implemented on Jython and has been superseded by the 'ast' module in Python 2.6 and later. """ return cls.interpret(parser.expr(text).totuple(1)[1]) @classmethod def _markerlib_evaluate(cls, text): """ Evaluate a PEP 426 environment marker using markerlib. Return a boolean indicating the marker result in this environment. Raise SyntaxError if marker is invalid. """ import _markerlib # markerlib implements Metadata 1.2 (PEP 345) environment markers. # Translate the variables to Metadata 2.0 (PEP 426). env = _markerlib.default_environment() for key in env.keys(): new_key = key.replace('.', '_') env[new_key] = env.pop(key) try: result = _markerlib.interpret(text, env) except NameError: e = sys.exc_info()[1] raise SyntaxError(e.args[0]) return result if 'parser' not in globals(): # Fall back to less-complete _markerlib implementation if 'parser' module # is not available. evaluate_marker = _markerlib_evaluate @classmethod def interpret(cls, nodelist): while len(nodelist)==2: nodelist = nodelist[1] try: op = cls.get_op(nodelist[0]) except KeyError: raise SyntaxError("Comparison or logical expression expected") return op(nodelist) @classmethod def evaluate(cls, nodelist): while len(nodelist)==2: nodelist = nodelist[1] kind = nodelist[0] name = nodelist[1] if kind==token.NAME: try: op = cls.values[name] except KeyError: raise SyntaxError("Unknown name %r" % name) return op() if kind==token.STRING: s = nodelist[1] if not cls._safe_string(s): raise SyntaxError( "Only plain strings allowed in environment markers") return s[1:-1] msg = "Language feature not supported in environment markers" raise SyntaxError(msg) @staticmethod def _safe_string(cand): return ( cand[:1] in "'\"" and not cand.startswith('"""') and not cand.startswith("'''") and '\\' not in cand ) invalid_marker = MarkerEvaluation.is_invalid_marker evaluate_marker = MarkerEvaluation.evaluate_marker class NullProvider: """Try to implement resources and metadata for arbitrary PEP 302 loaders""" egg_name = None egg_info = None loader = None def __init__(self, module): self.loader = getattr(module, '__loader__', None) self.module_path = os.path.dirname(getattr(module, '__file__', '')) def get_resource_filename(self, manager, resource_name): return self._fn(self.module_path, resource_name) def get_resource_stream(self, manager, resource_name): return BytesIO(self.get_resource_string(manager, resource_name)) def get_resource_string(self, manager, resource_name): return self._get(self._fn(self.module_path, resource_name)) def has_resource(self, resource_name): return self._has(self._fn(self.module_path, resource_name)) def has_metadata(self, name): return self.egg_info and self._has(self._fn(self.egg_info, name)) if sys.version_info <= (3,): def get_metadata(self, name): if not self.egg_info: return "" return self._get(self._fn(self.egg_info, name)) else: def get_metadata(self, name): if not self.egg_info: return "" return self._get(self._fn(self.egg_info, name)).decode("utf-8") def get_metadata_lines(self, name): return yield_lines(self.get_metadata(name)) def resource_isdir(self, resource_name): return self._isdir(self._fn(self.module_path, resource_name)) def metadata_isdir(self, name): return self.egg_info and self._isdir(self._fn(self.egg_info, name)) def resource_listdir(self, resource_name): return self._listdir(self._fn(self.module_path, resource_name)) def metadata_listdir(self, name): if self.egg_info: return self._listdir(self._fn(self.egg_info, name)) return [] def run_script(self, script_name, namespace): script = 'scripts/'+script_name if not self.has_metadata(script): raise ResolutionError("No script named %r" % script_name) script_text = self.get_metadata(script).replace('\r\n', '\n') script_text = script_text.replace('\r', '\n') script_filename = self._fn(self.egg_info, script) namespace['__file__'] = script_filename if os.path.exists(script_filename): execfile(script_filename, namespace, namespace) else: from linecache import cache cache[script_filename] = ( len(script_text), 0, script_text.split('\n'), script_filename ) script_code = compile(script_text, script_filename,'exec') exec(script_code, namespace, namespace) def _has(self, path): raise NotImplementedError( "Can't perform this operation for unregistered loader type" ) def _isdir(self, path): raise NotImplementedError( "Can't perform this operation for unregistered loader type" ) def _listdir(self, path): raise NotImplementedError( "Can't perform this operation for unregistered loader type" ) def _fn(self, base, resource_name): if resource_name: return os.path.join(base, *resource_name.split('/')) return base def _get(self, path): if hasattr(self.loader, 'get_data'): return self.loader.get_data(path) raise NotImplementedError( "Can't perform this operation for loaders without 'get_data()'" ) register_loader_type(object, NullProvider) class EggProvider(NullProvider): """Provider based on a virtual filesystem""" def __init__(self, module): NullProvider.__init__(self, module) self._setup_prefix() def _setup_prefix(self): # we assume here that our metadata may be nested inside a "basket" # of multiple eggs; that's why we use module_path instead of .archive path = self.module_path old = None while path!=old: if path.lower().endswith('.egg'): self.egg_name = os.path.basename(path) self.egg_info = os.path.join(path, 'EGG-INFO') self.egg_root = path break old = path path, base = os.path.split(path) class DefaultProvider(EggProvider): """Provides access to package resources in the filesystem""" def _has(self, path): return os.path.exists(path) def _isdir(self, path): return os.path.isdir(path) def _listdir(self, path): return os.listdir(path) def get_resource_stream(self, manager, resource_name): return open(self._fn(self.module_path, resource_name), 'rb') def _get(self, path): with open(path, 'rb') as stream: return stream.read() register_loader_type(type(None), DefaultProvider) if importlib_bootstrap is not None: register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider) class EmptyProvider(NullProvider): """Provider that returns nothing for all requests""" _isdir = _has = lambda self, path: False _get = lambda self, path: '' _listdir = lambda self, path: [] module_path = None def __init__(self): pass empty_provider = EmptyProvider() def build_zipmanifest(path): """ This builds a similar dictionary to the zipimport directory caches. However instead of tuples, ZipInfo objects are stored. The translation of the tuple is as follows: * [0] - zipinfo.filename on stock pythons this needs "/" --> os.sep on pypy it is the same (one reason why distribute did work in some cases on pypy and win32). * [1] - zipinfo.compress_type * [2] - zipinfo.compress_size * [3] - zipinfo.file_size * [4] - len(utf-8 encoding of filename) if zipinfo & 0x800 len(ascii encoding of filename) otherwise * [5] - (zipinfo.date_time[0] - 1980) << 9 | zipinfo.date_time[1] << 5 | zipinfo.date_time[2] * [6] - (zipinfo.date_time[3] - 1980) << 11 | zipinfo.date_time[4] << 5 | (zipinfo.date_time[5] // 2) * [7] - zipinfo.CRC """ zipinfo = dict() with ContextualZipFile(path) as zfile: for zitem in zfile.namelist(): zpath = zitem.replace('/', os.sep) zipinfo[zpath] = zfile.getinfo(zitem) assert zipinfo[zpath] is not None return zipinfo class ContextualZipFile(zipfile.ZipFile): """ Supplement ZipFile class to support context manager for Python 2.6 """ def __enter__(self): return self def __exit__(self, type, value, traceback): self.close() def __new__(cls, *args, **kwargs): """ Construct a ZipFile or ContextualZipFile as appropriate """ if hasattr(zipfile.ZipFile, '__exit__'): return zipfile.ZipFile(*args, **kwargs) return super(ContextualZipFile, cls).__new__(cls) class ZipProvider(EggProvider): """Resource support for zips and eggs""" eagers = None def __init__(self, module): EggProvider.__init__(self, module) self.zipinfo = build_zipmanifest(self.loader.archive) self.zip_pre = self.loader.archive+os.sep def _zipinfo_name(self, fspath): # Convert a virtual filename (full path to file) into a zipfile subpath # usable with the zipimport directory cache for our target archive if fspath.startswith(self.zip_pre): return fspath[len(self.zip_pre):] raise AssertionError( "%s is not a subpath of %s" % (fspath, self.zip_pre) ) def _parts(self, zip_path): # Convert a zipfile subpath into an egg-relative path part list fspath = self.zip_pre+zip_path # pseudo-fs path if fspath.startswith(self.egg_root+os.sep): return fspath[len(self.egg_root)+1:].split(os.sep) raise AssertionError( "%s is not a subpath of %s" % (fspath, self.egg_root) ) def get_resource_filename(self, manager, resource_name): if not self.egg_name: raise NotImplementedError( "resource_filename() only supported for .egg, not .zip" ) # no need to lock for extraction, since we use temp names zip_path = self._resource_to_zip(resource_name) eagers = self._get_eager_resources() if '/'.join(self._parts(zip_path)) in eagers: for name in eagers: self._extract_resource(manager, self._eager_to_zip(name)) return self._extract_resource(manager, zip_path) @staticmethod def _get_date_and_size(zip_stat): size = zip_stat.file_size # ymdhms+wday, yday, dst date_time = zip_stat.date_time + (0, 0, -1) # 1980 offset already done timestamp = time.mktime(date_time) return timestamp, size def _extract_resource(self, manager, zip_path): if zip_path in self._index(): for name in self._index()[zip_path]: last = self._extract_resource( manager, os.path.join(zip_path, name) ) # return the extracted directory name return os.path.dirname(last) timestamp, size = self._get_date_and_size(self.zipinfo[zip_path]) if not WRITE_SUPPORT: raise IOError('"os.rename" and "os.unlink" are not supported ' 'on this platform') try: real_path = manager.get_cache_path( self.egg_name, self._parts(zip_path) ) if self._is_current(real_path, zip_path): return real_path outf, tmpnam = _mkstemp(".$extract", dir=os.path.dirname(real_path)) os.write(outf, self.loader.get_data(zip_path)) os.close(outf) utime(tmpnam, (timestamp, timestamp)) manager.postprocess(tmpnam, real_path) try: rename(tmpnam, real_path) except os.error: if os.path.isfile(real_path): if self._is_current(real_path, zip_path): # the file became current since it was checked above, # so proceed. return real_path # Windows, del old file and retry elif os.name=='nt': unlink(real_path) rename(tmpnam, real_path) return real_path raise except os.error: # report a user-friendly error manager.extraction_error() return real_path def _is_current(self, file_path, zip_path): """ Return True if the file_path is current for this zip_path """ timestamp, size = self._get_date_and_size(self.zipinfo[zip_path]) if not os.path.isfile(file_path): return False stat = os.stat(file_path) if stat.st_size!=size or stat.st_mtime!=timestamp: return False # check that the contents match zip_contents = self.loader.get_data(zip_path) with open(file_path, 'rb') as f: file_contents = f.read() return zip_contents == file_contents def _get_eager_resources(self): if self.eagers is None: eagers = [] for name in ('native_libs.txt', 'eager_resources.txt'): if self.has_metadata(name): eagers.extend(self.get_metadata_lines(name)) self.eagers = eagers return self.eagers def _index(self): try: return self._dirindex except AttributeError: ind = {} for path in self.zipinfo: parts = path.split(os.sep) while parts: parent = os.sep.join(parts[:-1]) if parent in ind: ind[parent].append(parts[-1]) break else: ind[parent] = [parts.pop()] self._dirindex = ind return ind def _has(self, fspath): zip_path = self._zipinfo_name(fspath) return zip_path in self.zipinfo or zip_path in self._index() def _isdir(self, fspath): return self._zipinfo_name(fspath) in self._index() def _listdir(self, fspath): return list(self._index().get(self._zipinfo_name(fspath), ())) def _eager_to_zip(self, resource_name): return self._zipinfo_name(self._fn(self.egg_root, resource_name)) def _resource_to_zip(self, resource_name): return self._zipinfo_name(self._fn(self.module_path, resource_name)) register_loader_type(zipimport.zipimporter, ZipProvider) class FileMetadata(EmptyProvider): """Metadata handler for standalone PKG-INFO files Usage:: metadata = FileMetadata("/path/to/PKG-INFO") This provider rejects all data and metadata requests except for PKG-INFO, which is treated as existing, and will be the contents of the file at the provided location. """ def __init__(self, path): self.path = path def has_metadata(self, name): return name=='PKG-INFO' def get_metadata(self, name): if name=='PKG-INFO': with open(self.path,'rU') as f: metadata = f.read() return metadata raise KeyError("No metadata except PKG-INFO is available") def get_metadata_lines(self, name): return yield_lines(self.get_metadata(name)) class PathMetadata(DefaultProvider): """Metadata provider for egg directories Usage:: # Development eggs: egg_info = "/path/to/PackageName.egg-info" base_dir = os.path.dirname(egg_info) metadata = PathMetadata(base_dir, egg_info) dist_name = os.path.splitext(os.path.basename(egg_info))[0] dist = Distribution(basedir, project_name=dist_name, metadata=metadata) # Unpacked egg directories: egg_path = "/path/to/PackageName-ver-pyver-etc.egg" metadata = PathMetadata(egg_path, os.path.join(egg_path,'EGG-INFO')) dist = Distribution.from_filename(egg_path, metadata=metadata) """ def __init__(self, path, egg_info): self.module_path = path self.egg_info = egg_info class EggMetadata(ZipProvider): """Metadata provider for .egg files""" def __init__(self, importer): """Create a metadata provider from a zipimporter""" self.zipinfo = build_zipmanifest(importer.archive) self.zip_pre = importer.archive+os.sep self.loader = importer if importer.prefix: self.module_path = os.path.join(importer.archive, importer.prefix) else: self.module_path = importer.archive self._setup_prefix() _declare_state('dict', _distribution_finders = {}) def register_finder(importer_type, distribution_finder): """Register `distribution_finder` to find distributions in sys.path items `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item handler), and `distribution_finder` is a callable that, passed a path item and the importer instance, yields ``Distribution`` instances found on that path item. See ``pkg_resources.find_on_path`` for an example.""" _distribution_finders[importer_type] = distribution_finder def find_distributions(path_item, only=False): """Yield distributions accessible via `path_item`""" importer = get_importer(path_item) finder = _find_adapter(_distribution_finders, importer) return finder(importer, path_item, only) def find_eggs_in_zip(importer, path_item, only=False): """ Find eggs in zip files; possibly multiple nested eggs. """ if importer.archive.endswith('.whl'): # wheels are not supported with this finder # they don't have PKG-INFO metadata, and won't ever contain eggs return metadata = EggMetadata(importer) if metadata.has_metadata('PKG-INFO'): yield Distribution.from_filename(path_item, metadata=metadata) if only: # don't yield nested distros return for subitem in metadata.resource_listdir('/'): if subitem.endswith('.egg'): subpath = os.path.join(path_item, subitem) for dist in find_eggs_in_zip(zipimport.zipimporter(subpath), subpath): yield dist register_finder(zipimport.zipimporter, find_eggs_in_zip) def find_nothing(importer, path_item, only=False): return () register_finder(object, find_nothing) def find_on_path(importer, path_item, only=False): """Yield distributions accessible on a sys.path directory""" path_item = _normalize_cached(path_item) if os.path.isdir(path_item) and os.access(path_item, os.R_OK): if path_item.lower().endswith('.egg'): # unpacked egg yield Distribution.from_filename( path_item, metadata=PathMetadata( path_item, os.path.join(path_item,'EGG-INFO') ) ) else: # scan for .egg and .egg-info in directory for entry in os.listdir(path_item): lower = entry.lower() if lower.endswith('.egg-info') or lower.endswith('.dist-info'): fullpath = os.path.join(path_item, entry) if os.path.isdir(fullpath): # egg-info directory, allow getting metadata metadata = PathMetadata(path_item, fullpath) else: metadata = FileMetadata(fullpath) yield Distribution.from_location( path_item, entry, metadata, precedence=DEVELOP_DIST ) elif not only and lower.endswith('.egg'): dists = find_distributions(os.path.join(path_item, entry)) for dist in dists: yield dist elif not only and lower.endswith('.egg-link'): with open(os.path.join(path_item, entry)) as entry_file: entry_lines = entry_file.readlines() for line in entry_lines: if not line.strip(): continue path = os.path.join(path_item, line.rstrip()) dists = find_distributions(path) for item in dists: yield item break register_finder(pkgutil.ImpImporter, find_on_path) if importlib_bootstrap is not None: register_finder(importlib_bootstrap.FileFinder, find_on_path) _declare_state('dict', _namespace_handlers={}) _declare_state('dict', _namespace_packages={}) def register_namespace_handler(importer_type, namespace_handler): """Register `namespace_handler` to declare namespace packages `importer_type` is the type or class of a PEP 302 "Importer" (sys.path item handler), and `namespace_handler` is a callable like this:: def namespace_handler(importer, path_entry, moduleName, module): # return a path_entry to use for child packages Namespace handlers are only called if the importer object has already agreed that it can handle the relevant path item, and they should only return a subpath if the module __path__ does not already contain an equivalent subpath. For an example namespace handler, see ``pkg_resources.file_ns_handler``. """ _namespace_handlers[importer_type] = namespace_handler def _handle_ns(packageName, path_item): """Ensure that named package includes a subpath of path_item (if needed)""" importer = get_importer(path_item) if importer is None: return None loader = importer.find_module(packageName) if loader is None: return None module = sys.modules.get(packageName) if module is None: module = sys.modules[packageName] = imp.new_module(packageName) module.__path__ = [] _set_parent_ns(packageName) elif not hasattr(module,'__path__'): raise TypeError("Not a package:", packageName) handler = _find_adapter(_namespace_handlers, importer) subpath = handler(importer, path_item, packageName, module) if subpath is not None: path = module.__path__ path.append(subpath) loader.load_module(packageName) for path_item in path: if path_item not in module.__path__: module.__path__.append(path_item) return subpath def declare_namespace(packageName): """Declare that package 'packageName' is a namespace package""" imp.acquire_lock() try: if packageName in _namespace_packages: return path, parent = sys.path, None if '.' in packageName: parent = '.'.join(packageName.split('.')[:-1]) declare_namespace(parent) if parent not in _namespace_packages: __import__(parent) try: path = sys.modules[parent].__path__ except AttributeError: raise TypeError("Not a package:", parent) # Track what packages are namespaces, so when new path items are added, # they can be updated _namespace_packages.setdefault(parent,[]).append(packageName) _namespace_packages.setdefault(packageName,[]) for path_item in path: # Ensure all the parent's path items are reflected in the child, # if they apply _handle_ns(packageName, path_item) finally: imp.release_lock() def fixup_namespace_packages(path_item, parent=None): """Ensure that previously-declared namespace packages include path_item""" imp.acquire_lock() try: for package in _namespace_packages.get(parent,()): subpath = _handle_ns(package, path_item) if subpath: fixup_namespace_packages(subpath, package) finally: imp.release_lock() def file_ns_handler(importer, path_item, packageName, module): """Compute an ns-package subpath for a filesystem or zipfile importer""" subpath = os.path.join(path_item, packageName.split('.')[-1]) normalized = _normalize_cached(subpath) for item in module.__path__: if _normalize_cached(item)==normalized: break else: # Only return the path if it's not already there return subpath register_namespace_handler(pkgutil.ImpImporter, file_ns_handler) register_namespace_handler(zipimport.zipimporter, file_ns_handler) if importlib_bootstrap is not None: register_namespace_handler(importlib_bootstrap.FileFinder, file_ns_handler) def null_ns_handler(importer, path_item, packageName, module): return None register_namespace_handler(object, null_ns_handler) def normalize_path(filename): """Normalize a file/dir name for comparison purposes""" return os.path.normcase(os.path.realpath(filename)) def _normalize_cached(filename, _cache={}): try: return _cache[filename] except KeyError: _cache[filename] = result = normalize_path(filename) return result def _set_parent_ns(packageName): parts = packageName.split('.') name = parts.pop() if parts: parent = '.'.join(parts) setattr(sys.modules[parent], name, sys.modules[packageName]) def yield_lines(strs): """Yield non-empty/non-comment lines of a ``basestring`` or sequence""" if isinstance(strs, basestring): for s in strs.splitlines(): s = s.strip() # skip blank lines/comments if s and not s.startswith('#'): yield s else: for ss in strs: for s in yield_lines(ss): yield s # whitespace and comment LINE_END = re.compile(r"\s*(#.*)?$").match # line continuation CONTINUE = re.compile(r"\s*\\\s*(#.*)?$").match # Distribution or extra DISTRO = re.compile(r"\s*((\w|[-.])+)").match # ver. info VERSION = re.compile(r"\s*(<=?|>=?|==|!=)\s*((\w|[-.])+)").match # comma between items COMMA = re.compile(r"\s*,").match OBRACKET = re.compile(r"\s*\[").match CBRACKET = re.compile(r"\s*\]").match MODULE = re.compile(r"\w+(\.\w+)*$").match EGG_NAME = re.compile( r"(?P<name>[^-]+)" r"( -(?P<ver>[^-]+) (-py(?P<pyver>[^-]+) (-(?P<plat>.+))? )? )?", re.VERBOSE | re.IGNORECASE ).match component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE) replace = {'pre':'c', 'preview':'c','-':'final-','rc':'c','dev':'@'}.get def _parse_version_parts(s): for part in component_re.split(s): part = replace(part, part) if not part or part=='.': continue if part[:1] in '0123456789': # pad for numeric comparison yield part.zfill(8) else: yield '*'+part # ensure that alpha/beta/candidate are before final yield '*final' def parse_version(s): """Convert a version string to a chronologically-sortable key This is a rough cross between distutils' StrictVersion and LooseVersion; if you give it versions that would work with StrictVersion, then it behaves the same; otherwise it acts like a slightly-smarter LooseVersion. It is *possible* to create pathological version coding schemes that will fool this parser, but they should be very rare in practice. The returned value will be a tuple of strings. Numeric portions of the version are padded to 8 digits so they will compare numerically, but without relying on how numbers compare relative to strings. Dots are dropped, but dashes are retained. Trailing zeros between alpha segments or dashes are suppressed, so that e.g. "2.4.0" is considered the same as "2.4". Alphanumeric parts are lower-cased. The algorithm assumes that strings like "-" and any alpha string that alphabetically follows "final" represents a "patch level". So, "2.4-1" is assumed to be a branch or patch of "2.4", and therefore "2.4.1" is considered newer than "2.4-1", which in turn is newer than "2.4". Strings like "a", "b", "c", "alpha", "beta", "candidate" and so on (that come before "final" alphabetically) are assumed to be pre-release versions, so that the version "2.4" is considered newer than "2.4a1". Finally, to handle miscellaneous cases, the strings "pre", "preview", and "rc" are treated as if they were "c", i.e. as though they were release candidates, and therefore are not as new as a version string that does not contain them, and "dev" is replaced with an '@' so that it sorts lower than than any other pre-release tag. """ parts = [] for part in _parse_version_parts(s.lower()): if part.startswith('*'): # remove '-' before a prerelease tag if part<'*final': while parts and parts[-1]=='*final-': parts.pop() # remove trailing zeros from each series of numeric parts while parts and parts[-1]=='00000000': parts.pop() parts.append(part) return tuple(parts) class EntryPoint(object): """Object representing an advertised importable object""" def __init__(self, name, module_name, attrs=(), extras=(), dist=None): if not MODULE(module_name): raise ValueError("Invalid module name", module_name) self.name = name self.module_name = module_name self.attrs = tuple(attrs) self.extras = Requirement.parse(("x[%s]" % ','.join(extras))).extras self.dist = dist def __str__(self): s = "%s = %s" % (self.name, self.module_name) if self.attrs: s += ':' + '.'.join(self.attrs) if self.extras: s += ' [%s]' % ','.join(self.extras) return s def __repr__(self): return "EntryPoint.parse(%r)" % str(self) def load(self, require=True, env=None, installer=None): if require: self.require(env, installer) entry = __import__(self.module_name, globals(), globals(), ['__name__']) for attr in self.attrs: try: entry = getattr(entry, attr) except AttributeError: raise ImportError("%r has no %r attribute" % (entry, attr)) return entry def require(self, env=None, installer=None): if self.extras and not self.dist: raise UnknownExtra("Can't require() without a distribution", self) reqs = self.dist.requires(self.extras) items = working_set.resolve(reqs, env, installer) list(map(working_set.add, items)) @classmethod def parse(cls, src, dist=None): """Parse a single entry point from string `src` Entry point syntax follows the form:: name = some.module:some.attr [extra1, extra2] The entry name and module name are required, but the ``:attrs`` and ``[extras]`` parts are optional """ try: attrs = extras = () name, value = src.split('=',1) if '[' in value: value, extras = value.split('[',1) req = Requirement.parse("x["+extras) if req.specs: raise ValueError extras = req.extras if ':' in value: value, attrs = value.split(':',1) if not MODULE(attrs.rstrip()): raise ValueError attrs = attrs.rstrip().split('.') except ValueError: raise ValueError( "EntryPoint must be in 'name=module:attrs [extras]' format", src ) else: return cls(name.strip(), value.strip(), attrs, extras, dist) @classmethod def parse_group(cls, group, lines, dist=None): """Parse an entry point group""" if not MODULE(group): raise ValueError("Invalid group name", group) this = {} for line in yield_lines(lines): ep = cls.parse(line, dist) if ep.name in this: raise ValueError("Duplicate entry point", group, ep.name) this[ep.name]=ep return this @classmethod def parse_map(cls, data, dist=None): """Parse a map of entry point groups""" if isinstance(data, dict): data = data.items() else: data = split_sections(data) maps = {} for group, lines in data: if group is None: if not lines: continue raise ValueError("Entry points must be listed in groups") group = group.strip() if group in maps: raise ValueError("Duplicate group name", group) maps[group] = cls.parse_group(group, lines, dist) return maps def _remove_md5_fragment(location): if not location: return '' parsed = urlparse(location) if parsed[-1].startswith('md5='): return urlunparse(parsed[:-1] + ('',)) return location class Distribution(object): """Wrap an actual or potential sys.path entry w/metadata""" PKG_INFO = 'PKG-INFO' def __init__(self, location=None, metadata=None, project_name=None, version=None, py_version=PY_MAJOR, platform=None, precedence=EGG_DIST): self.project_name = safe_name(project_name or 'Unknown') if version is not None: self._version = safe_version(version) self.py_version = py_version self.platform = platform self.location = location self.precedence = precedence self._provider = metadata or empty_provider @classmethod def from_location(cls, location, basename, metadata=None,**kw): project_name, version, py_version, platform = [None]*4 basename, ext = os.path.splitext(basename) if ext.lower() in _distributionImpl: # .dist-info gets much metadata differently match = EGG_NAME(basename) if match: project_name, version, py_version, platform = match.group( 'name','ver','pyver','plat' ) cls = _distributionImpl[ext.lower()] return cls( location, metadata, project_name=project_name, version=version, py_version=py_version, platform=platform, **kw ) @property def hashcmp(self): return ( getattr(self, 'parsed_version', ()), self.precedence, self.key, _remove_md5_fragment(self.location), self.py_version, self.platform, ) def __hash__(self): return hash(self.hashcmp) def __lt__(self, other): return self.hashcmp < other.hashcmp def __le__(self, other): return self.hashcmp <= other.hashcmp def __gt__(self, other): return self.hashcmp > other.hashcmp def __ge__(self, other): return self.hashcmp >= other.hashcmp def __eq__(self, other): if not isinstance(other, self.__class__): # It's not a Distribution, so they are not equal return False return self.hashcmp == other.hashcmp def __ne__(self, other): return not self == other # These properties have to be lazy so that we don't have to load any # metadata until/unless it's actually needed. (i.e., some distributions # may not know their name or version without loading PKG-INFO) @property def key(self): try: return self._key except AttributeError: self._key = key = self.project_name.lower() return key @property def parsed_version(self): try: return self._parsed_version except AttributeError: self._parsed_version = pv = parse_version(self.version) return pv @property def version(self): try: return self._version except AttributeError: for line in self._get_metadata(self.PKG_INFO): if line.lower().startswith('version:'): self._version = safe_version(line.split(':',1)[1].strip()) return self._version else: tmpl = "Missing 'Version:' header and/or %s file" raise ValueError(tmpl % self.PKG_INFO, self) @property def _dep_map(self): try: return self.__dep_map except AttributeError: dm = self.__dep_map = {None: []} for name in 'requires.txt', 'depends.txt': for extra, reqs in split_sections(self._get_metadata(name)): if extra: if ':' in extra: extra, marker = extra.split(':',1) if invalid_marker(marker): # XXX warn reqs=[] elif not evaluate_marker(marker): reqs=[] extra = safe_extra(extra) or None dm.setdefault(extra,[]).extend(parse_requirements(reqs)) return dm def requires(self, extras=()): """List of Requirements needed for this distro if `extras` are used""" dm = self._dep_map deps = [] deps.extend(dm.get(None,())) for ext in extras: try: deps.extend(dm[safe_extra(ext)]) except KeyError: raise UnknownExtra( "%s has no such extra feature %r" % (self, ext) ) return deps def _get_metadata(self, name): if self.has_metadata(name): for line in self.get_metadata_lines(name): yield line def activate(self, path=None): """Ensure distribution is importable on `path` (default=sys.path)""" if path is None: path = sys.path self.insert_on(path) if path is sys.path: fixup_namespace_packages(self.location) for pkg in self._get_metadata('namespace_packages.txt'): if pkg in sys.modules: declare_namespace(pkg) def egg_name(self): """Return what this distribution's standard .egg filename should be""" filename = "%s-%s-py%s" % ( to_filename(self.project_name), to_filename(self.version), self.py_version or PY_MAJOR ) if self.platform: filename += '-'+self.platform return filename def __repr__(self): if self.location: return "%s (%s)" % (self, self.location) else: return str(self) def __str__(self): try: version = getattr(self,'version',None) except ValueError: version = None version = version or "[unknown version]" return "%s %s" % (self.project_name, version) def __getattr__(self, attr): """Delegate all unrecognized public attributes to .metadata provider""" if attr.startswith('_'): raise AttributeError(attr) return getattr(self._provider, attr) @classmethod def from_filename(cls, filename, metadata=None, **kw): return cls.from_location( _normalize_cached(filename), os.path.basename(filename), metadata, **kw ) def as_requirement(self): """Return a ``Requirement`` that matches this distribution exactly""" return Requirement.parse('%s==%s' % (self.project_name, self.version)) def load_entry_point(self, group, name): """Return the `name` entry point of `group` or raise ImportError""" ep = self.get_entry_info(group, name) if ep is None: raise ImportError("Entry point %r not found" % ((group, name),)) return ep.load() def get_entry_map(self, group=None): """Return the entry point map for `group`, or the full entry map""" try: ep_map = self._ep_map except AttributeError: ep_map = self._ep_map = EntryPoint.parse_map( self._get_metadata('entry_points.txt'), self ) if group is not None: return ep_map.get(group,{}) return ep_map def get_entry_info(self, group, name): """Return the EntryPoint object for `group`+`name`, or ``None``""" return self.get_entry_map(group).get(name) def insert_on(self, path, loc = None): """Insert self.location in path before its nearest parent directory""" loc = loc or self.location if not loc: return nloc = _normalize_cached(loc) bdir = os.path.dirname(nloc) npath= [(p and _normalize_cached(p) or p) for p in path] for p, item in enumerate(npath): if item==nloc: break elif item==bdir and self.precedence==EGG_DIST: # if it's an .egg, give it precedence over its directory if path is sys.path: self.check_version_conflict() path.insert(p, loc) npath.insert(p, nloc) break else: if path is sys.path: self.check_version_conflict() path.append(loc) return # p is the spot where we found or inserted loc; now remove duplicates while 1: try: np = npath.index(nloc, p+1) except ValueError: break else: del npath[np], path[np] # ha! p = np return def check_version_conflict(self): if self.key=='setuptools': # ignore the inevitable setuptools self-conflicts :( return nsp = dict.fromkeys(self._get_metadata('namespace_packages.txt')) loc = normalize_path(self.location) for modname in self._get_metadata('top_level.txt'): if (modname not in sys.modules or modname in nsp or modname in _namespace_packages): continue if modname in ('pkg_resources', 'setuptools', 'site'): continue fn = getattr(sys.modules[modname], '__file__', None) if fn and (normalize_path(fn).startswith(loc) or fn.startswith(self.location)): continue issue_warning( "Module %s was already imported from %s, but %s is being added" " to sys.path" % (modname, fn, self.location), ) def has_version(self): try: self.version except ValueError: issue_warning("Unbuilt egg for "+repr(self)) return False return True def clone(self,**kw): """Copy this distribution, substituting in any changed keyword args""" for attr in ( 'project_name', 'version', 'py_version', 'platform', 'location', 'precedence' ): kw.setdefault(attr, getattr(self, attr, None)) kw.setdefault('metadata', self._provider) return self.__class__(**kw) @property def extras(self): return [dep for dep in self._dep_map if dep] class DistInfoDistribution(Distribution): """Wrap an actual or potential sys.path entry w/metadata, .dist-info style""" PKG_INFO = 'METADATA' EQEQ = re.compile(r"([\(,])\s*(\d.*?)\s*([,\)])") @property def _parsed_pkg_info(self): """Parse and cache metadata""" try: return self._pkg_info except AttributeError: from email.parser import Parser metadata = self.get_metadata(self.PKG_INFO) self._pkg_info = Parser().parsestr(metadata) return self._pkg_info @property def _dep_map(self): try: return self.__dep_map except AttributeError: self.__dep_map = self._compute_dependencies() return self.__dep_map def _preparse_requirement(self, requires_dist): """Convert 'Foobar (1); baz' to ('Foobar ==1', 'baz') Split environment marker, add == prefix to version specifiers as necessary, and remove parenthesis. """ parts = requires_dist.split(';', 1) + [''] distvers = parts[0].strip() mark = parts[1].strip() distvers = re.sub(self.EQEQ, r"\1==\2\3", distvers) distvers = distvers.replace('(', '').replace(')', '') return (distvers, mark) def _compute_dependencies(self): """Recompute this distribution's dependencies.""" from _markerlib import compile as compile_marker dm = self.__dep_map = {None: []} reqs = [] # Including any condition expressions for req in self._parsed_pkg_info.get_all('Requires-Dist') or []: distvers, mark = self._preparse_requirement(req) parsed = next(parse_requirements(distvers)) parsed.marker_fn = compile_marker(mark) reqs.append(parsed) def reqs_for_extra(extra): for req in reqs: if req.marker_fn(override={'extra':extra}): yield req common = frozenset(reqs_for_extra(None)) dm[None].extend(common) for extra in self._parsed_pkg_info.get_all('Provides-Extra') or []: extra = safe_extra(extra.strip()) dm[extra] = list(frozenset(reqs_for_extra(extra)) - common) return dm _distributionImpl = { '.egg': Distribution, '.egg-info': Distribution, '.dist-info': DistInfoDistribution, } def issue_warning(*args,**kw): level = 1 g = globals() try: # find the first stack frame that is *not* code in # the pkg_resources module, to use for the warning while sys._getframe(level).f_globals is g: level += 1 except ValueError: pass from warnings import warn warn(stacklevel = level+1, *args, **kw) def parse_requirements(strs): """Yield ``Requirement`` objects for each specification in `strs` `strs` must be an instance of ``basestring``, or a (possibly-nested) iterable thereof. """ # create a steppable iterator, so we can handle \-continuations lines = iter(yield_lines(strs)) def scan_list(ITEM, TERMINATOR, line, p, groups, item_name): items = [] while not TERMINATOR(line, p): if CONTINUE(line, p): try: line = next(lines) p = 0 except StopIteration: raise ValueError( "\\ must not appear on the last nonblank line" ) match = ITEM(line, p) if not match: msg = "Expected " + item_name + " in" raise ValueError(msg, line, "at", line[p:]) items.append(match.group(*groups)) p = match.end() match = COMMA(line, p) if match: # skip the comma p = match.end() elif not TERMINATOR(line, p): msg = "Expected ',' or end-of-list in" raise ValueError(msg, line, "at", line[p:]) match = TERMINATOR(line, p) if match: p = match.end() # skip the terminator, if any return line, p, items for line in lines: match = DISTRO(line) if not match: raise ValueError("Missing distribution spec", line) project_name = match.group(1) p = match.end() extras = [] match = OBRACKET(line, p) if match: p = match.end() line, p, extras = scan_list( DISTRO, CBRACKET, line, p, (1,), "'extra' name" ) line, p, specs = scan_list(VERSION, LINE_END, line, p, (1, 2), "version spec") specs = [(op, safe_version(val)) for op, val in specs] yield Requirement(project_name, specs, extras) class Requirement: def __init__(self, project_name, specs, extras): """DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!""" self.unsafe_name, project_name = project_name, safe_name(project_name) self.project_name, self.key = project_name, project_name.lower() index = [ (parse_version(v), state_machine[op], op, v) for op, v in specs ] index.sort() self.specs = [(op, ver) for parsed, trans, op, ver in index] self.index, self.extras = index, tuple(map(safe_extra, extras)) self.hashCmp = ( self.key, tuple((op, parsed) for parsed, trans, op, ver in index), frozenset(self.extras), ) self.__hash = hash(self.hashCmp) def __str__(self): specs = ','.join([''.join(s) for s in self.specs]) extras = ','.join(self.extras) if extras: extras = '[%s]' % extras return '%s%s%s' % (self.project_name, extras, specs) def __eq__(self, other): return isinstance(other, Requirement) and self.hashCmp==other.hashCmp def __contains__(self, item): if isinstance(item, Distribution): if item.key != self.key: return False # only get if we need it if self.index: item = item.parsed_version elif isinstance(item, basestring): item = parse_version(item) last = None # -1, 0, 1 compare = lambda a, b: (a > b) - (a < b) for parsed, trans, op, ver in self.index: # Indexing: 0, 1, -1 action = trans[compare(item, parsed)] if action=='F': return False elif action=='T': return True elif action=='+': last = True elif action=='-' or last is None: last = False # no rules encountered if last is None: last = True return last def __hash__(self): return self.__hash def __repr__(self): return "Requirement.parse(%r)" % str(self) @staticmethod def parse(s): reqs = list(parse_requirements(s)) if reqs: if len(reqs)==1: return reqs[0] raise ValueError("Expected only one requirement", s) raise ValueError("No requirements found", s) state_machine = { # =>< '<': '--T', '<=': 'T-T', '>': 'F+F', '>=': 'T+F', '==': 'T..', '!=': 'F++', } def _get_mro(cls): """Get an mro for a type or classic class""" if not isinstance(cls, type): class cls(cls, object): pass return cls.__mro__[1:] return cls.__mro__ def _find_adapter(registry, ob): """Return an adapter factory for `ob` from `registry`""" for t in _get_mro(getattr(ob, '__class__', type(ob))): if t in registry: return registry[t] def ensure_directory(path): """Ensure that the parent directory of `path` exists""" dirname = os.path.dirname(path) if not os.path.isdir(dirname): os.makedirs(dirname) def split_sections(s): """Split a string or iterable thereof into (section, content) pairs Each ``section`` is a stripped version of the section header ("[section]") and each ``content`` is a list of stripped lines excluding blank lines and comment-only lines. If there are any such lines before the first section header, they're returned in a first ``section`` of ``None``. """ section = None content = [] for line in yield_lines(s): if line.startswith("["): if line.endswith("]"): if section or content: yield section, content section = line[1:-1].strip() content = [] else: raise ValueError("Invalid section heading", line) else: content.append(line) # wrap up last segment yield section, content def _mkstemp(*args,**kw): from tempfile import mkstemp old_open = os.open try: # temporarily bypass sandboxing os.open = os_open return mkstemp(*args,**kw) finally: # and then put it back os.open = old_open # Set up global resource manager (deliberately not state-saved) _manager = ResourceManager() def _initialize(g): for name in dir(_manager): if not name.startswith('_'): g[name] = getattr(_manager, name) _initialize(globals()) # Prepare the master working set and make the ``require()`` API available working_set = WorkingSet._build_master() _declare_state('object', working_set=working_set) require = working_set.require iter_entry_points = working_set.iter_entry_points add_activation_listener = working_set.subscribe run_script = working_set.run_script # backward compatibility run_main = run_script # Activate all distributions already on sys.path, and ensure that # all distributions added to the working set in the future (e.g. by # calling ``require()``) will get activated as well. add_activation_listener(lambda dist: dist.activate()) working_set.entries=[] list(map(working_set.add_entry, sys.path)) # match order
apache-2.0
[ 624, 199, 8599, 2073, 3261, 199, 777, 375, 199, 199, 33, 2073, 365, 282, 11461, 570, 10470, 4453, 282, 2559, 12, 503, 282, 11461, 199, 954, 3619, 2337, 1618, 14, 221, 710, 2559, 2073, 3261, 14292, 2073, 1561, 199, 475, 1172, 3932, 931, 4184, 11673, 543, 1124, 15, 4542, 627, 1397, 10, 15685, 314, 2257, 199, 515, 9432, 365, 14, 221, 4226, 440, 675, 747, 14, 515, 5331, 370, 27232, 2073, 199, 1247, 3769, 3032, 1901, 314, 3261, 14, 199, 199, 1918, 2559, 2073, 3261, 365, 19829, 370, 1736, 543, 3293, 10036, 6117, 12, 199, 14, 5799, 1584, 12, 436, 23389, 1275, 5799, 1584, 14, 221, 2779, 883, 2597, 1736, 315, 282, 13988, 4340, 543, 199, 14, 3065, 1584, 436, 543, 3537, 13663, 11485, 25520, 626, 2291, 314, 1124, 362, 63, 576, 8497, 199, 765, 14, 199, 624, 199, 199, 646, 984, 199, 646, 747, 199, 646, 900, 199, 646, 295, 199, 646, 1742, 199, 646, 10392, 199, 646, 3482, 646, 199, 646, 3598, 199, 646, 5672, 199, 646, 9143, 199, 646, 28728, 199, 646, 1526, 199, 646, 5272, 199, 646, 4182, 199, 646, 4298, 199, 504, 28728, 492, 664, 63, 12138, 199, 199, 893, 26, 272, 687, 7097, 492, 7097, 12, 30111, 199, 2590, 3545, 26, 272, 687, 4011, 14, 1122, 492, 7097, 12, 30111, 199, 199, 893, 26, 272, 9522, 199, 2590, 12746, 26, 272, 687, 5951, 492, 25609, 1084, 465, 9522, 199, 893, 26, 272, 7116, 272, 2163, 275, 2400, 312, 26, 312, 14, 2184, 342, 272, 687, 15073, 492, 5228, 465, 11808, 199, 2590, 12746, 26, 272, 7116, 275, 620, 272, 687, 5890, 492, 11808, 272, 347, 22711, 8, 2324, 12, 13977, 29, 403, 12, 29502, 29, 403, 304, 267, 340, 13977, 365, 488, 26, 288, 13977, 275, 7992, 342, 267, 340, 29502, 365, 488, 26, 288, 29502, 275, 13977, 267, 2146, 8, 2014, 8, 1490, 8, 2324, 680, 739, 1062, 4325, 12, 283, 1628, 659, 13977, 12, 29502, 9, 199, 199, 3, 12296, 3520, 370, 21115, 19699, 316, 199, 504, 747, 492, 399, 521, 199, 893, 26, 272, 687, 747, 492, 20366, 12, 11441, 12, 17002, 272, 32280, 63, 10640, 275, 715, 199, 2590, 3545, 26, 272, 327, 949, 2218, 2291, 12, 8646, 1334, 598, 12500, 272, 32280, 63, 10640, 275, 756, 199, 199, 504, 747, 492, 1551, 465, 747, 63, 1490, 199, 504, 747, 14, 515, 492, 26004, 12, 3715, 199, 199, 3, 19503, 862, 15, 2590, 7037, 370, 12330, 8826, 543, 24725, 492, 562, 10832, 706, 14, 199, 692, 984, 14, 1023, 63, 815, 2356, 334, 19, 12, 650, 9, 436, 984, 14, 12236, 14, 354, 508, 298, 67, 1548, 582, 272, 492, 14802, 423, 11146, 465, 14802, 63, 11146, 199, 2836, 26, 272, 14802, 63, 11146, 275, 488, 199, 199, 893, 26, 272, 492, 1798, 199, 2590, 3545, 26, 272, 986, 199, 199, 318, 485, 20605, 63, 7505, 63, 3619, 8, 354, 12, 818, 29, 16, 79, 11956, 304, 272, 327, 428, 10075, 13, 20605, 316, 1015, 402, 4868, 63, 3619, 342, 272, 340, 440, 32280, 63, 10640, 26, 267, 746, 5925, 14088, 736, 14, 8215, 2, 440, 3748, 641, 642, 4298, 2659, 272, 9017, 12, 1788, 275, 3715, 8, 354, 9, 272, 340, 9017, 436, 1788, 436, 440, 26004, 8, 3475, 304, 267, 485, 20605, 63, 7505, 63, 3619, 8, 3475, 9, 267, 20366, 8, 3475, 12, 818, 9, 421, 199, 63, 929, 63, 2936, 275, 1052, 199, 199, 318, 485, 16536, 63, 929, 8, 19729, 12, 1011, 829, 304, 272, 7992, 1252, 873, 8, 829, 9, 272, 485, 929, 63, 2936, 14, 873, 8, 807, 14, 19164, 8, 829, 12, 2729, 466, 430, 199, 199, 318, 636, 16011, 721, 304, 272, 1174, 275, 1052, 272, 486, 275, 7992, 342, 272, 367, 1022, 12, 373, 315, 485, 929, 63, 2936, 14, 1744, 837, 267, 1174, 59, 75, 61, 275, 486, 8680, 83, 362, 20013, 86, 8738, 71, 59, 75, 566, 272, 372, 1174, 199, 199, 318, 636, 17212, 721, 929, 304, 272, 486, 275, 7992, 342, 272, 367, 1022, 12, 373, 315, 1174, 14, 1744, 837, 267, 486, 8680, 83, 409, 8650, 6416, 929, 63, 2936, 59, 75, 2677, 8, 75, 12, 486, 59, 75, 467, 373, 9, 272, 372, 1174, 199, 199, 318, 485, 83, 362, 63, 807, 8, 637, 304, 272, 372, 1139, 14, 1574, 342, 199, 199, 318, 485, 83, 409, 63, 807, 8, 498, 12, 2607, 12, 1174, 304, 272, 2607, 14, 3584, 342, 272, 2607, 14, 873, 8, 929, 9, 199, 199, 318, 485, 83, 362, 63, 785, 8, 637, 304, 272, 372, 1139, 855, 16011, 4533, 199, 199, 318, 485, 83, 409, 63, 785, 8, 498, 12, 2607, 12, 1174, 304, 272, 2607, 855, 17212, 721, 929, 9, 199, 199, 63, 83, 362, 63, 3592, 275, 485, 83, 409, 63, 3592, 275, 2400, 627, 589, 26, 488, 421, 199, 318, 664, 63, 4946, 63, 3246, 837, 272, 408, 1767, 642, 4298, 1159, 5696, 9025, 1015, 14, 339, 7065, 14, 1974, 14, 362, 63, 3246, 342, 12252, 13924, 314, 7481, 1015, 272, 402, 10444, 4403, 1323, 626, 3955, 506, 1415, 370, 627, 1180, 10, 5478, 13584, 701, 272, 7065, 14, 221, 11017, 4052, 781, 2934, 1380, 7907, 7163, 365, 370, 5715, 314, 272, 1015, 402, 10444, 4403, 1323, 626, 781, 787, 627, 5720, 4856, 221, 4005, 2040, 4503, 402, 6117, 626, 272, 7662, 4409, 282, 15666, 1015, 402, 10444, 4403, 1323, 12, 781, 1471, 2597, 5715, 314, 272, 1453, 1015, 402, 314, 4403, 14, 339, 982, 642, 5558, 11058, 367, 1263, 1163, 4298, 543, 282, 1015, 315, 2399, 272, 4298, 3326, 12, 642, 805, 1077, 506, 9243, 24137, 14, 272, 408, 272, 20819, 275, 664, 63, 1506, 63, 3246, 342, 272, 333, 275, 610, 5197, 3353, 1558, 14, 1431, 8, 14156, 9, 272, 340, 333, 365, 440, 488, 436, 984, 14, 3246, 508, 298, 13245, 582, 267, 862, 26, 288, 20819, 275, 283, 28546, 3295, 83, 3295, 83, 7, 450, 661, 17374, 904, 1547, 28546, 63, 14895, 20523, 18, 2522, 333, 14, 923, 8, 19, 430, 267, 871, 1722, 26, 288, 327, 440, 10444, 4403, 1323, 288, 986, 272, 372, 20819, 199, 199, 363, 452, 363, 275, 359, 272, 327 ]
[ 199, 8599, 2073, 3261, 199, 777, 375, 199, 199, 33, 2073, 365, 282, 11461, 570, 10470, 4453, 282, 2559, 12, 503, 282, 11461, 199, 954, 3619, 2337, 1618, 14, 221, 710, 2559, 2073, 3261, 14292, 2073, 1561, 199, 475, 1172, 3932, 931, 4184, 11673, 543, 1124, 15, 4542, 627, 1397, 10, 15685, 314, 2257, 199, 515, 9432, 365, 14, 221, 4226, 440, 675, 747, 14, 515, 5331, 370, 27232, 2073, 199, 1247, 3769, 3032, 1901, 314, 3261, 14, 199, 199, 1918, 2559, 2073, 3261, 365, 19829, 370, 1736, 543, 3293, 10036, 6117, 12, 199, 14, 5799, 1584, 12, 436, 23389, 1275, 5799, 1584, 14, 221, 2779, 883, 2597, 1736, 315, 282, 13988, 4340, 543, 199, 14, 3065, 1584, 436, 543, 3537, 13663, 11485, 25520, 626, 2291, 314, 1124, 362, 63, 576, 8497, 199, 765, 14, 199, 624, 199, 199, 646, 984, 199, 646, 747, 199, 646, 900, 199, 646, 295, 199, 646, 1742, 199, 646, 10392, 199, 646, 3482, 646, 199, 646, 3598, 199, 646, 5672, 199, 646, 9143, 199, 646, 28728, 199, 646, 1526, 199, 646, 5272, 199, 646, 4182, 199, 646, 4298, 199, 504, 28728, 492, 664, 63, 12138, 199, 199, 893, 26, 272, 687, 7097, 492, 7097, 12, 30111, 199, 2590, 3545, 26, 272, 687, 4011, 14, 1122, 492, 7097, 12, 30111, 199, 199, 893, 26, 272, 9522, 199, 2590, 12746, 26, 272, 687, 5951, 492, 25609, 1084, 465, 9522, 199, 893, 26, 272, 7116, 272, 2163, 275, 2400, 312, 26, 312, 14, 2184, 342, 272, 687, 15073, 492, 5228, 465, 11808, 199, 2590, 12746, 26, 272, 7116, 275, 620, 272, 687, 5890, 492, 11808, 272, 347, 22711, 8, 2324, 12, 13977, 29, 403, 12, 29502, 29, 403, 304, 267, 340, 13977, 365, 488, 26, 288, 13977, 275, 7992, 342, 267, 340, 29502, 365, 488, 26, 288, 29502, 275, 13977, 267, 2146, 8, 2014, 8, 1490, 8, 2324, 680, 739, 1062, 4325, 12, 283, 1628, 659, 13977, 12, 29502, 9, 199, 199, 3, 12296, 3520, 370, 21115, 19699, 316, 199, 504, 747, 492, 399, 521, 199, 893, 26, 272, 687, 747, 492, 20366, 12, 11441, 12, 17002, 272, 32280, 63, 10640, 275, 715, 199, 2590, 3545, 26, 272, 327, 949, 2218, 2291, 12, 8646, 1334, 598, 12500, 272, 32280, 63, 10640, 275, 756, 199, 199, 504, 747, 492, 1551, 465, 747, 63, 1490, 199, 504, 747, 14, 515, 492, 26004, 12, 3715, 199, 199, 3, 19503, 862, 15, 2590, 7037, 370, 12330, 8826, 543, 24725, 492, 562, 10832, 706, 14, 199, 692, 984, 14, 1023, 63, 815, 2356, 334, 19, 12, 650, 9, 436, 984, 14, 12236, 14, 354, 508, 298, 67, 1548, 582, 272, 492, 14802, 423, 11146, 465, 14802, 63, 11146, 199, 2836, 26, 272, 14802, 63, 11146, 275, 488, 199, 199, 893, 26, 272, 492, 1798, 199, 2590, 3545, 26, 272, 986, 199, 199, 318, 485, 20605, 63, 7505, 63, 3619, 8, 354, 12, 818, 29, 16, 79, 11956, 304, 272, 327, 428, 10075, 13, 20605, 316, 1015, 402, 4868, 63, 3619, 342, 272, 340, 440, 32280, 63, 10640, 26, 267, 746, 5925, 14088, 736, 14, 8215, 2, 440, 3748, 641, 642, 4298, 2659, 272, 9017, 12, 1788, 275, 3715, 8, 354, 9, 272, 340, 9017, 436, 1788, 436, 440, 26004, 8, 3475, 304, 267, 485, 20605, 63, 7505, 63, 3619, 8, 3475, 9, 267, 20366, 8, 3475, 12, 818, 9, 421, 199, 63, 929, 63, 2936, 275, 1052, 199, 199, 318, 485, 16536, 63, 929, 8, 19729, 12, 1011, 829, 304, 272, 7992, 1252, 873, 8, 829, 9, 272, 485, 929, 63, 2936, 14, 873, 8, 807, 14, 19164, 8, 829, 12, 2729, 466, 430, 199, 199, 318, 636, 16011, 721, 304, 272, 1174, 275, 1052, 272, 486, 275, 7992, 342, 272, 367, 1022, 12, 373, 315, 485, 929, 63, 2936, 14, 1744, 837, 267, 1174, 59, 75, 61, 275, 486, 8680, 83, 362, 20013, 86, 8738, 71, 59, 75, 566, 272, 372, 1174, 199, 199, 318, 636, 17212, 721, 929, 304, 272, 486, 275, 7992, 342, 272, 367, 1022, 12, 373, 315, 1174, 14, 1744, 837, 267, 486, 8680, 83, 409, 8650, 6416, 929, 63, 2936, 59, 75, 2677, 8, 75, 12, 486, 59, 75, 467, 373, 9, 272, 372, 1174, 199, 199, 318, 485, 83, 362, 63, 807, 8, 637, 304, 272, 372, 1139, 14, 1574, 342, 199, 199, 318, 485, 83, 409, 63, 807, 8, 498, 12, 2607, 12, 1174, 304, 272, 2607, 14, 3584, 342, 272, 2607, 14, 873, 8, 929, 9, 199, 199, 318, 485, 83, 362, 63, 785, 8, 637, 304, 272, 372, 1139, 855, 16011, 4533, 199, 199, 318, 485, 83, 409, 63, 785, 8, 498, 12, 2607, 12, 1174, 304, 272, 2607, 855, 17212, 721, 929, 9, 199, 199, 63, 83, 362, 63, 3592, 275, 485, 83, 409, 63, 3592, 275, 2400, 627, 589, 26, 488, 421, 199, 318, 664, 63, 4946, 63, 3246, 837, 272, 408, 1767, 642, 4298, 1159, 5696, 9025, 1015, 14, 339, 7065, 14, 1974, 14, 362, 63, 3246, 342, 12252, 13924, 314, 7481, 1015, 272, 402, 10444, 4403, 1323, 626, 3955, 506, 1415, 370, 627, 1180, 10, 5478, 13584, 701, 272, 7065, 14, 221, 11017, 4052, 781, 2934, 1380, 7907, 7163, 365, 370, 5715, 314, 272, 1015, 402, 10444, 4403, 1323, 626, 781, 787, 627, 5720, 4856, 221, 4005, 2040, 4503, 402, 6117, 626, 272, 7662, 4409, 282, 15666, 1015, 402, 10444, 4403, 1323, 12, 781, 1471, 2597, 5715, 314, 272, 1453, 1015, 402, 314, 4403, 14, 339, 982, 642, 5558, 11058, 367, 1263, 1163, 4298, 543, 282, 1015, 315, 2399, 272, 4298, 3326, 12, 642, 805, 1077, 506, 9243, 24137, 14, 272, 408, 272, 20819, 275, 664, 63, 1506, 63, 3246, 342, 272, 333, 275, 610, 5197, 3353, 1558, 14, 1431, 8, 14156, 9, 272, 340, 333, 365, 440, 488, 436, 984, 14, 3246, 508, 298, 13245, 582, 267, 862, 26, 288, 20819, 275, 283, 28546, 3295, 83, 3295, 83, 7, 450,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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 ]
shsingh/ansible
lib/ansible/module_utils/common/removed.py
38
2146
# Copyright (c) 2018, Ansible Project # Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause) # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type import json import sys from ansible.module_utils._text import to_native def removed_module(removed_in, msg='This module has been removed. The module documentation for' ' Ansible-%(version)s may contain hints for porting'): """ This function is deprecated and should not be used. Instead the module should just be actually removed. This function is scheduled for removal for the 2.12 release. Returns module failure along with a message about the module being removed :arg removed_in: The version that the module was removed in :kwarg msg: Message to use in the module's failure message. The default says that the module has been removed and what version of the Ansible documentation to search for porting help. Remove the actual code and instead have boilerplate like this:: from ansible.module_utils.common.removed import removed_module if __name__ == '__main__': removed_module("2.4") """ results = { 'failed': True, 'deprecations': [ { 'msg': 'The removed_module function is deprecated', 'version': '2.12', }, ] } # Convert numbers into strings removed_in = to_native(removed_in) version = removed_in.split('.') try: numeric_minor = int(version[-1]) except Exception: last_version = None else: version = version[:-1] version.append(to_native(numeric_minor - 1)) last_version = '.'.join(version) if last_version is None: results['warnings'] = ['removed modules should specify the version they were removed in'] results['msg'] = 'This module has been removed' else: results['msg'] = msg % {'version': last_version} print('\n{0}\n'.format(json.dumps(results))) sys.exit(1)
gpl-3.0
[ 3, 1898, 334, 67, 9, 14894, 12, 2622, 7290, 199, 3, 29094, 30200, 6289, 844, 334, 3239, 12378, 15, 11184, 30200, 63, 15746, 14, 2424, 503, 4178, 921, 16374, 14, 1308, 15, 2383, 15, 15400, 13, 18, 13, 16009, 9, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 2022, 199, 646, 984, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 421, 199, 318, 4829, 63, 578, 8, 10649, 63, 262, 12, 1499, 534, 2765, 859, 965, 2757, 4829, 14, 710, 859, 3794, 367, 7, 3521, 283, 2622, 13, 2840, 1023, 9, 83, 1443, 1395, 18069, 367, 1844, 316, 735, 272, 408, 272, 961, 805, 365, 5906, 436, 1077, 440, 506, 1202, 14, 15345, 314, 859, 1077, 2951, 506, 272, 5965, 4829, 14, 961, 805, 365, 18416, 367, 20055, 367, 314, 499, 14, 713, 4683, 14, 339, 1803, 859, 5988, 3180, 543, 282, 1245, 3595, 314, 859, 3769, 4829, 339, 520, 1273, 4829, 63, 262, 26, 710, 1015, 626, 314, 859, 1990, 4829, 315, 272, 520, 12745, 1499, 26, 6430, 370, 675, 315, 314, 859, 1159, 5988, 1245, 14, 710, 849, 20065, 626, 314, 859, 267, 965, 2757, 4829, 436, 4052, 1015, 402, 314, 2622, 3794, 370, 2754, 367, 1844, 316, 1720, 14, 339, 5852, 314, 3503, 1233, 436, 3140, 1172, 1234, 27025, 2839, 642, 447, 398, 687, 3242, 14, 578, 63, 1208, 14, 2330, 14, 10649, 492, 4829, 63, 578, 398, 340, 636, 354, 363, 508, 2560, 973, 3706, 288, 4829, 63, 578, 480, 18, 14, 20, 531, 272, 408, 272, 2058, 275, 469, 267, 283, 4892, 356, 715, 12, 267, 283, 15383, 83, 356, 359, 288, 469, 355, 283, 1328, 356, 283, 1918, 4829, 63, 578, 805, 365, 5906, 297, 355, 283, 1023, 356, 283, 18, 14, 713, 297, 288, 1660, 267, 1622, 272, 789, 339, 327, 7905, 5579, 1901, 3326, 272, 4829, 63, 262, 275, 370, 63, 6106, 8, 10649, 63, 262, 9, 339, 1015, 275, 4829, 63, 262, 14, 1294, 7563, 272, 862, 26, 267, 8950, 63, 11067, 275, 1109, 8, 1023, 1988, 17, 566, 272, 871, 2186, 26, 267, 2061, 63, 1023, 275, 488, 272, 587, 26, 267, 1015, 275, 1015, 4439, 17, 61, 267, 1015, 14, 740, 8, 475, 63, 6106, 8, 6677, 63, 11067, 446, 413, 430, 267, 2061, 63, 1023, 275, 15671, 904, 8, 1023, 9, 339, 340, 2061, 63, 1023, 365, 488, 26, 267, 2058, 459, 5451, 418, 275, 788, 10649, 4621, 1077, 4165, 314, 1015, 2985, 4898, 4829, 315, 418, 267, 2058, 459, 1328, 418, 275, 283, 2765, 859, 965, 2757, 4829, 7, 272, 587, 26, 267, 2058, 459, 1328, 418, 275, 1499, 450, 791, 1023, 356, 2061, 63, 1023, 93, 339, 870, 2258, 78, 91, 16, 4988, 78, 1370, 908, 8, 1001, 14, 4180, 8, 2604, 1724, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 14894, 12, 2622, 7290, 199, 3, 29094, 30200, 6289, 844, 334, 3239, 12378, 15, 11184, 30200, 63, 15746, 14, 2424, 503, 4178, 921, 16374, 14, 1308, 15, 2383, 15, 15400, 13, 18, 13, 16009, 9, 199, 199, 3, 4155, 2803, 1655, 2366, 19, 13, 2453, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 870, 63, 1593, 9, 199, 363, 6577, 363, 275, 730, 199, 199, 646, 2022, 199, 646, 984, 199, 199, 504, 3242, 14, 578, 63, 1208, 423, 505, 492, 370, 63, 6106, 421, 199, 318, 4829, 63, 578, 8, 10649, 63, 262, 12, 1499, 534, 2765, 859, 965, 2757, 4829, 14, 710, 859, 3794, 367, 7, 3521, 283, 2622, 13, 2840, 1023, 9, 83, 1443, 1395, 18069, 367, 1844, 316, 735, 272, 408, 272, 961, 805, 365, 5906, 436, 1077, 440, 506, 1202, 14, 15345, 314, 859, 1077, 2951, 506, 272, 5965, 4829, 14, 961, 805, 365, 18416, 367, 20055, 367, 314, 499, 14, 713, 4683, 14, 339, 1803, 859, 5988, 3180, 543, 282, 1245, 3595, 314, 859, 3769, 4829, 339, 520, 1273, 4829, 63, 262, 26, 710, 1015, 626, 314, 859, 1990, 4829, 315, 272, 520, 12745, 1499, 26, 6430, 370, 675, 315, 314, 859, 1159, 5988, 1245, 14, 710, 849, 20065, 626, 314, 859, 267, 965, 2757, 4829, 436, 4052, 1015, 402, 314, 2622, 3794, 370, 2754, 367, 1844, 316, 1720, 14, 339, 5852, 314, 3503, 1233, 436, 3140, 1172, 1234, 27025, 2839, 642, 447, 398, 687, 3242, 14, 578, 63, 1208, 14, 2330, 14, 10649, 492, 4829, 63, 578, 398, 340, 636, 354, 363, 508, 2560, 973, 3706, 288, 4829, 63, 578, 480, 18, 14, 20, 531, 272, 408, 272, 2058, 275, 469, 267, 283, 4892, 356, 715, 12, 267, 283, 15383, 83, 356, 359, 288, 469, 355, 283, 1328, 356, 283, 1918, 4829, 63, 578, 805, 365, 5906, 297, 355, 283, 1023, 356, 283, 18, 14, 713, 297, 288, 1660, 267, 1622, 272, 789, 339, 327, 7905, 5579, 1901, 3326, 272, 4829, 63, 262, 275, 370, 63, 6106, 8, 10649, 63, 262, 9, 339, 1015, 275, 4829, 63, 262, 14, 1294, 7563, 272, 862, 26, 267, 8950, 63, 11067, 275, 1109, 8, 1023, 1988, 17, 566, 272, 871, 2186, 26, 267, 2061, 63, 1023, 275, 488, 272, 587, 26, 267, 1015, 275, 1015, 4439, 17, 61, 267, 1015, 14, 740, 8, 475, 63, 6106, 8, 6677, 63, 11067, 446, 413, 430, 267, 2061, 63, 1023, 275, 15671, 904, 8, 1023, 9, 339, 340, 2061, 63, 1023, 365, 488, 26, 267, 2058, 459, 5451, 418, 275, 788, 10649, 4621, 1077, 4165, 314, 1015, 2985, 4898, 4829, 315, 418, 267, 2058, 459, 1328, 418, 275, 283, 2765, 859, 965, 2757, 4829, 7, 272, 587, 26, 267, 2058, 459, 1328, 418, 275, 1499, 450, 791, 1023, 356, 2061, 63, 1023, 93, 339, 870, 2258, 78, 91, 16, 4988, 78, 1370, 908, 8, 1001, 14, 4180, 8, 2604, 1724, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Awesomeomics/webserver
env/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.py
2360
3778
"""The match_hostname() function from Python 3.3.3, essential when using SSL.""" # Note: This file is under the PSF license as the code comes from the python # stdlib. http://docs.python.org/3/license.html import re __version__ = '3.4.0.2' class CertificateError(ValueError): pass def _dnsname_match(dn, hostname, max_wildcards=1): """Matching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3 """ pats = [] if not dn: return False # Ported from python3-syntax: # leftmost, *remainder = dn.split(r'.') parts = dn.split(r'.') leftmost = parts[0] remainder = parts[1:] wildcards = leftmost.count('*') if wildcards > max_wildcards: # Issue #17980: avoid denials of service by refusing more # than one wildcard per fragment. A survey of established # policy among SSL implementations showed it to be a # reasonable choice. raise CertificateError( "too many wildcards in certificate DNS name: " + repr(dn)) # speed up common case w/o wildcards if not wildcards: return dn.lower() == hostname.lower() # RFC 6125, section 6.4.3, subitem 1. # The client SHOULD NOT attempt to match a presented identifier in which # the wildcard character comprises a label other than the left-most label. if leftmost == '*': # When '*' is a fragment by itself, it matches a non-empty dotless # fragment. pats.append('[^.]+') elif leftmost.startswith('xn--') or hostname.startswith('xn--'): # RFC 6125, section 6.4.3, subitem 3. # The client SHOULD NOT attempt to match a presented identifier # where the wildcard character is embedded within an A-label or # U-label of an internationalized domain name. pats.append(re.escape(leftmost)) else: # Otherwise, '*' matches any dotless string, e.g. www* pats.append(re.escape(leftmost).replace(r'\*', '[^.]*')) # add the remaining fragments, ignore any wildcards for frag in remainder: pats.append(re.escape(frag)) pat = re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE) return pat.match(hostname) def match_hostname(cert, hostname): """Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*. CertificateError is raised on failure. On success, the function returns nothing. """ if not cert: raise ValueError("empty or no certificate") dnsnames = [] san = cert.get('subjectAltName', ()) for key, value in san: if key == 'DNS': if _dnsname_match(value, hostname): return dnsnames.append(value) if not dnsnames: # The subject is only checked when there is no dNSName entry # in subjectAltName for sub in cert.get('subject', ()): for key, value in sub: # XXX according to RFC 2818, the most specific Common Name # must be used. if key == 'commonName': if _dnsname_match(value, hostname): return dnsnames.append(value) if len(dnsnames) > 1: raise CertificateError("hostname %r " "doesn't match either of %s" % (hostname, ', '.join(map(repr, dnsnames)))) elif len(dnsnames) == 1: raise CertificateError("hostname %r " "doesn't match %r" % (hostname, dnsnames[0])) else: raise CertificateError("no appropriate commonName or " "subjectAltName fields were found")
mit
[ 624, 1918, 1336, 63, 4269, 342, 805, 687, 2018, 650, 14, 19, 14, 19, 12, 22829, 1009, 1380, 1808, 7799, 1041, 199, 199, 3, 3390, 26, 961, 570, 365, 1334, 314, 29770, 4190, 465, 314, 1233, 12477, 687, 314, 2366, 199, 3, 26678, 14, 257, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 19, 15, 1682, 14, 1360, 199, 199, 646, 295, 199, 199, 363, 1023, 363, 275, 283, 19, 14, 20, 14, 16, 14, 18, 7, 199, 199, 533, 31953, 8, 3393, 304, 272, 986, 421, 199, 318, 485, 5797, 354, 63, 1431, 8, 4272, 12, 6246, 12, 1390, 63, 29500, 29, 17, 304, 272, 408, 14215, 7182, 370, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 339, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 22, 6889, 3, 2792, 13, 22, 14, 20, 14, 19, 272, 408, 272, 30818, 275, 942, 272, 340, 440, 14052, 26, 267, 372, 756, 339, 327, 510, 1376, 687, 2366, 19, 13, 7093, 26, 272, 327, 29971, 12, 627, 23850, 275, 14052, 14, 1294, 8, 82, 1370, 358, 272, 4184, 275, 14052, 14, 1294, 8, 82, 1370, 358, 272, 29971, 275, 4184, 59, 16, 61, 272, 15748, 275, 4184, 59, 17, 2938, 339, 24952, 275, 29971, 14, 835, 360, 13418, 272, 340, 24952, 690, 1390, 63, 29500, 26, 267, 327, 13383, 327, 10699, 1257, 26, 5126, 5376, 2380, 83, 402, 2435, 701, 2984, 4941, 1655, 267, 327, 2419, 1373, 16792, 1126, 7956, 14, 221, 437, 16576, 402, 23594, 267, 327, 4592, 16885, 7799, 12591, 2498, 379, 652, 370, 506, 282, 267, 327, 23255, 7141, 14, 267, 746, 31953, 8, 288, 298, 7354, 5002, 24952, 315, 5897, 10237, 536, 26, 298, 435, 4700, 8, 4272, 430, 339, 327, 8112, 1536, 2863, 1930, 336, 15, 79, 24952, 272, 340, 440, 24952, 26, 267, 372, 14052, 14, 2325, 342, 508, 6246, 14, 2325, 342, 339, 327, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 12, 1007, 1053, 413, 14, 272, 327, 710, 1890, 428, 31909, 2845, 7427, 370, 1336, 282, 26568, 5148, 315, 1314, 272, 327, 314, 16792, 4528, 1013, 322, 874, 282, 1768, 1163, 2419, 314, 3602, 13, 2786, 1768, 14, 272, 340, 29971, 508, 22969, 267, 327, 3979, 13626, 365, 282, 7956, 701, 6337, 12, 652, 4450, 282, 2222, 13, 1667, 6308, 2003, 267, 327, 7956, 14, 267, 30818, 14, 740, 360, 4735, 32455, 358, 272, 916, 29971, 14, 2460, 360, 5032, 306, 358, 503, 6246, 14, 2460, 360, 5032, 306, 735, 267, 327, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 12, 1007, 1053, 650, 14, 267, 327, 710, 1890, 428, 31909, 2845, 7427, 370, 1336, 282, 26568, 5148, 267, 327, 2382, 314, 16792, 4528, 365, 12169, 4453, 376, 437, 13, 1302, 503, 267, 327, 738, 13, 1302, 402, 376, 10757, 6279, 1759, 2881, 536, 14, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 3039, 2786, 430, 272, 587, 26, 267, 327, 6630, 12, 13626, 4450, 1263, 6308, 2003, 1059, 12, 325, 14, 71, 14, 20732, 10, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 3039, 2786, 680, 1814, 8, 82, 1154, 7693, 283, 4735, 14, 3672, 1333, 339, 327, 1050, 314, 7971, 21495, 12, 3686, 1263, 24952, 272, 367, 11101, 315, 15748, 26, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 11255, 430, 339, 12713, 275, 295, 14, 2014, 8, 82, 1154, 33, 7, 435, 519, 1154, 17374, 904, 8, 30756, 9, 435, 519, 1154, 58, 297, 295, 14, 15434, 9, 272, 372, 12713, 14, 1431, 8, 4269, 9, 421, 199, 318, 1336, 63, 4269, 8, 4736, 12, 6246, 304, 272, 408, 7496, 626, 627, 4736, 10, 334, 262, 11203, 1475, 465, 2138, 701, 272, 7799, 3869, 14, 362, 7866, 4736, 1012, 4450, 314, 627, 4269, 4856, 221, 7329, 7294, 1085, 436, 7329, 1227, 6889, 272, 4713, 787, 9437, 12, 1325, 3531, 7149, 787, 440, 10226, 367, 627, 4269, 4856, 339, 31953, 365, 4915, 641, 5988, 14, 4068, 3182, 12, 314, 805, 272, 2529, 6548, 14, 272, 408, 272, 340, 440, 6250, 26, 267, 746, 1722, 480, 1667, 503, 949, 5897, 531, 272, 6715, 1247, 275, 942, 272, 28698, 275, 6250, 14, 362, 360, 5875, 29171, 297, 14515, 272, 367, 790, 12, 574, 315, 28698, 26, 267, 340, 790, 508, 283, 12323, 356, 288, 340, 485, 5797, 354, 63, 1431, 8, 585, 12, 6246, 304, 355, 372, 288, 6715, 1247, 14, 740, 8, 585, 9, 272, 340, 440, 6715, 1247, 26, 267, 327, 710, 5420, 365, 1454, 7923, 1380, 2337, 365, 949, 366, 2709, 985, 2397, 267, 327, 315, 5420, 29171, 267, 367, 1007, 315, 6250, 14, 362, 360, 5875, 297, 334, 2298, 288, 367, 790, 12, 574, 315, 1007, 26, 355, 327, 5787, 7182, 370, 7329, 7294, 1085, 12, 314, 4750, 2488, 13964, 2812, 355, 327, 1471, 506, 1202, 14, 355, 340, 790, 508, 283, 2330, 985, 356, 490, 340, 485, 5797, 354, 63, 1431, 8, 585, 12, 6246, 304, 717, 372, 490, 6715, 1247, 14, 740, 8, 585, 9, 272, 340, 822, 8, 5797, 1247, 9, 690, 413, 26, 267, 746, 31953, 480, 4269, 450, 82, 298, 288, 298, 30977, 1133, 1336, 1902, 402, 450, 83, 2, 288, 450, 334, 4269, 12, 1656, 1987, 904, 8, 1130, 8, 2722, 12, 6715, 1247, 7845, 272, 916, 822, 8, 5797, 1247, 9, 508, 413, 26, 267, 746, 31953, 480, 4269, 450, 82, 298, 288, 298, 30977, 1133, 1336, 450, 82, 2, 288, 450, 334, 4269, 12, 6715, 1247, 59, 16, 2459, 272, 587, 26, 267, 746, 31953, 480, 889, 5827, 2863, 985, 503, 298, 288, 298, 5875, 29171, 1504, 4898, 1911, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1918, 1336, 63, 4269, 342, 805, 687, 2018, 650, 14, 19, 14, 19, 12, 22829, 1009, 1380, 1808, 7799, 1041, 199, 199, 3, 3390, 26, 961, 570, 365, 1334, 314, 29770, 4190, 465, 314, 1233, 12477, 687, 314, 2366, 199, 3, 26678, 14, 257, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 19, 15, 1682, 14, 1360, 199, 199, 646, 295, 199, 199, 363, 1023, 363, 275, 283, 19, 14, 20, 14, 16, 14, 18, 7, 199, 199, 533, 31953, 8, 3393, 304, 272, 986, 421, 199, 318, 485, 5797, 354, 63, 1431, 8, 4272, 12, 6246, 12, 1390, 63, 29500, 29, 17, 304, 272, 408, 14215, 7182, 370, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 339, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 22, 6889, 3, 2792, 13, 22, 14, 20, 14, 19, 272, 408, 272, 30818, 275, 942, 272, 340, 440, 14052, 26, 267, 372, 756, 339, 327, 510, 1376, 687, 2366, 19, 13, 7093, 26, 272, 327, 29971, 12, 627, 23850, 275, 14052, 14, 1294, 8, 82, 1370, 358, 272, 4184, 275, 14052, 14, 1294, 8, 82, 1370, 358, 272, 29971, 275, 4184, 59, 16, 61, 272, 15748, 275, 4184, 59, 17, 2938, 339, 24952, 275, 29971, 14, 835, 360, 13418, 272, 340, 24952, 690, 1390, 63, 29500, 26, 267, 327, 13383, 327, 10699, 1257, 26, 5126, 5376, 2380, 83, 402, 2435, 701, 2984, 4941, 1655, 267, 327, 2419, 1373, 16792, 1126, 7956, 14, 221, 437, 16576, 402, 23594, 267, 327, 4592, 16885, 7799, 12591, 2498, 379, 652, 370, 506, 282, 267, 327, 23255, 7141, 14, 267, 746, 31953, 8, 288, 298, 7354, 5002, 24952, 315, 5897, 10237, 536, 26, 298, 435, 4700, 8, 4272, 430, 339, 327, 8112, 1536, 2863, 1930, 336, 15, 79, 24952, 272, 340, 440, 24952, 26, 267, 372, 14052, 14, 2325, 342, 508, 6246, 14, 2325, 342, 339, 327, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 12, 1007, 1053, 413, 14, 272, 327, 710, 1890, 428, 31909, 2845, 7427, 370, 1336, 282, 26568, 5148, 315, 1314, 272, 327, 314, 16792, 4528, 1013, 322, 874, 282, 1768, 1163, 2419, 314, 3602, 13, 2786, 1768, 14, 272, 340, 29971, 508, 22969, 267, 327, 3979, 13626, 365, 282, 7956, 701, 6337, 12, 652, 4450, 282, 2222, 13, 1667, 6308, 2003, 267, 327, 7956, 14, 267, 30818, 14, 740, 360, 4735, 32455, 358, 272, 916, 29971, 14, 2460, 360, 5032, 306, 358, 503, 6246, 14, 2460, 360, 5032, 306, 735, 267, 327, 7329, 1227, 6889, 12, 3420, 1227, 14, 20, 14, 19, 12, 1007, 1053, 650, 14, 267, 327, 710, 1890, 428, 31909, 2845, 7427, 370, 1336, 282, 26568, 5148, 267, 327, 2382, 314, 16792, 4528, 365, 12169, 4453, 376, 437, 13, 1302, 503, 267, 327, 738, 13, 1302, 402, 376, 10757, 6279, 1759, 2881, 536, 14, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 3039, 2786, 430, 272, 587, 26, 267, 327, 6630, 12, 13626, 4450, 1263, 6308, 2003, 1059, 12, 325, 14, 71, 14, 20732, 10, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 3039, 2786, 680, 1814, 8, 82, 1154, 7693, 283, 4735, 14, 3672, 1333, 339, 327, 1050, 314, 7971, 21495, 12, 3686, 1263, 24952, 272, 367, 11101, 315, 15748, 26, 267, 30818, 14, 740, 8, 264, 14, 3765, 8, 11255, 430, 339, 12713, 275, 295, 14, 2014, 8, 82, 1154, 33, 7, 435, 519, 1154, 17374, 904, 8, 30756, 9, 435, 519, 1154, 58, 297, 295, 14, 15434, 9, 272, 372, 12713, 14, 1431, 8, 4269, 9, 421, 199, 318, 1336, 63, 4269, 8, 4736, 12, 6246, 304, 272, 408, 7496, 626, 627, 4736, 10, 334, 262, 11203, 1475, 465, 2138, 701, 272, 7799, 3869, 14, 362, 7866, 4736, 1012, 4450, 314, 627, 4269, 4856, 221, 7329, 7294, 1085, 436, 7329, 1227, 6889, 272, 4713, 787, 9437, 12, 1325, 3531, 7149, 787, 440, 10226, 367, 627, 4269, 4856, 339, 31953, 365, 4915, 641, 5988, 14, 4068, 3182, 12, 314, 805, 272, 2529, 6548, 14, 272, 408, 272, 340, 440, 6250, 26, 267, 746, 1722, 480, 1667, 503, 949, 5897, 531, 272, 6715, 1247, 275, 942, 272, 28698, 275, 6250, 14, 362, 360, 5875, 29171, 297, 14515, 272, 367, 790, 12, 574, 315, 28698, 26, 267, 340, 790, 508, 283, 12323, 356, 288, 340, 485, 5797, 354, 63, 1431, 8, 585, 12, 6246, 304, 355, 372, 288, 6715, 1247, 14, 740, 8, 585, 9, 272, 340, 440, 6715, 1247, 26, 267, 327, 710, 5420, 365, 1454, 7923, 1380, 2337, 365, 949, 366, 2709, 985, 2397, 267, 327, 315, 5420, 29171, 267, 367, 1007, 315, 6250, 14, 362, 360, 5875, 297, 334, 2298, 288, 367, 790, 12, 574, 315, 1007, 26, 355, 327, 5787, 7182, 370, 7329, 7294, 1085, 12, 314, 4750, 2488, 13964, 2812, 355, 327, 1471, 506, 1202, 14, 355, 340, 790, 508, 283, 2330, 985, 356, 490, 340, 485, 5797, 354, 63, 1431, 8, 585, 12, 6246, 304, 717, 372, 490, 6715, 1247, 14, 740, 8, 585, 9, 272, 340, 822, 8, 5797, 1247, 9, 690, 413, 26, 267, 746, 31953, 480, 4269, 450, 82, 298, 288, 298, 30977, 1133, 1336, 1902, 402, 450, 83, 2, 288, 450, 334, 4269, 12, 1656, 1987, 904, 8, 1130, 8, 2722, 12, 6715, 1247, 7845, 272, 916, 822, 8, 5797, 1247, 9, 508, 413, 26, 267, 746, 31953, 480, 4269, 450, 82, 298, 288, 298, 30977, 1133, 1336, 450, 82, 2, 288, 450, 334, 4269, 12, 6715, 1247, 59, 16, 2459, 272, 587, 26, 267, 746, 31953, 480, 889, 5827, 2863, 985, 503, 298, 288, 298, 5875, 29171, 1504, 4898, 1911, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
garg10may/youtube-dl
youtube_dl/extractor/vbox7.py
92
2298
# encoding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import ( compat_urllib_parse, compat_urllib_request, compat_urlparse, ) from ..utils import ( ExtractorError, ) class Vbox7IE(InfoExtractor): _VALID_URL = r'http://(?:www\.)?vbox7\.com/play:(?P<id>[^/]+)' _TEST = { 'url': 'http://vbox7.com/play:249bb972c2', 'md5': '99f65c0c9ef9b682b97313e052734c3f', 'info_dict': { 'id': '249bb972c2', 'ext': 'mp4', 'title': 'Смях! Чудо - чист за секунди - Скрита камера', }, } def _real_extract(self, url): video_id = self._match_id(url) # need to get the page 3 times for the correct jsSecretToken cookie # which is necessary for the correct title def get_session_id(): redirect_page = self._download_webpage(url, video_id) session_id_url = self._search_regex( r'var\s*url\s*=\s*\'([^\']+)\';', redirect_page, 'session id url') self._download_webpage( compat_urlparse.urljoin(url, session_id_url), video_id, 'Getting session id') get_session_id() get_session_id() webpage = self._download_webpage(url, video_id, 'Downloading redirect page') title = self._html_search_regex(r'<title>(.*)</title>', webpage, 'title').split('/')[0].strip() info_url = "http://vbox7.com/play/magare.do" data = compat_urllib_parse.urlencode({'as3': '1', 'vid': video_id}) info_request = compat_urllib_request.Request(info_url, data) info_request.add_header('Content-Type', 'application/x-www-form-urlencoded') info_response = self._download_webpage(info_request, video_id, 'Downloading info webpage') if info_response is None: raise ExtractorError('Unable to extract the media url') (final_url, thumbnail_url) = map(lambda x: x.split('=')[1], info_response.split('&')) return { 'id': video_id, 'url': final_url, 'title': title, 'thumbnail': thumbnail_url, }
unlicense
[ 3, 2644, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1122, 12, 272, 8434, 63, 4078, 63, 1069, 12, 272, 8434, 63, 10290, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 199, 9, 421, 199, 533, 812, 1977, 23, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 1014, 921, 5169, 1544, 20316, 19508, 23, 4537, 957, 15, 2802, 26, 2229, 48, 28, 344, 26906, 3171, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 19508, 23, 14, 957, 15, 2802, 26, 11032, 2501, 26433, 67, 18, 297, 267, 283, 1064, 21, 356, 283, 1020, 70, 2182, 67, 16, 67, 25, 2829, 25, 66, 24255, 66, 2576, 19455, 69, 1717, 1465, 1082, 67, 19, 70, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 11032, 2501, 26433, 67, 18, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 141, 95, 23000, 14978, 25969, 1, 7038, 101, 12195, 20497, 5806, 446, 221, 19277, 6500, 18261, 7038, 116, 5657, 24071, 6286, 11487, 12195, 7592, 20497, 6500, 446, 7038, 95, 11487, 7753, 30019, 5657, 31999, 13111, 121, 21273, 5657, 297, 267, 1660, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 327, 1929, 370, 664, 314, 2034, 650, 5431, 367, 314, 3211, 8586, 13790, 3264, 5494, 267, 327, 1314, 365, 5784, 367, 314, 3211, 2538, 267, 347, 664, 63, 1730, 63, 344, 837, 288, 4660, 63, 1606, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 288, 2351, 63, 344, 63, 633, 275, 291, 423, 1733, 63, 3821, 8, 355, 519, 7, 1391, 60, 83, 10, 633, 60, 83, 23440, 83, 10, 3985, 21690, 418, 13439, 7, 10805, 4660, 63, 1606, 12, 355, 283, 1730, 1305, 1166, 358, 288, 291, 423, 4249, 63, 12022, 8, 355, 8434, 63, 10290, 14, 17755, 8, 633, 12, 2351, 63, 344, 63, 633, 395, 3991, 63, 344, 12, 355, 283, 28277, 2351, 1305, 358, 398, 664, 63, 1730, 63, 344, 342, 267, 664, 63, 1730, 63, 344, 342, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 12, 1460, 283, 18085, 4660, 2034, 358, 398, 2538, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 82, 7601, 1213, 13661, 12432, 1108, 1213, 4206, 3147, 9248, 12, 283, 1213, 1959, 1294, 30746, 16, 1055, 1913, 342, 398, 2256, 63, 633, 275, 298, 1014, 921, 19508, 23, 14, 957, 15, 2802, 15, 5615, 1530, 14, 1117, 2, 267, 666, 275, 8434, 63, 4078, 63, 1122, 14, 10738, 3252, 305, 19, 356, 283, 17, 297, 283, 5017, 356, 3991, 63, 344, 1552, 267, 2256, 63, 1069, 275, 8434, 63, 4078, 63, 1069, 14, 2017, 8, 815, 63, 633, 12, 666, 9, 267, 2256, 63, 1069, 14, 525, 63, 1291, 360, 2714, 13, 804, 297, 283, 3578, 15, 88, 13, 1544, 13, 964, 13, 21886, 358, 267, 2256, 63, 1310, 275, 291, 423, 4249, 63, 12022, 8, 815, 63, 1069, 12, 3991, 63, 344, 12, 283, 18085, 2256, 9248, 358, 267, 340, 2256, 63, 1310, 365, 488, 26, 288, 746, 19783, 360, 6005, 370, 5536, 314, 5898, 1166, 358, 267, 334, 5094, 63, 633, 12, 10062, 63, 633, 9, 275, 2341, 8, 2734, 671, 26, 671, 14, 1294, 26800, 5832, 17, 467, 2256, 63, 1310, 14, 1294, 20040, 1333, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 633, 356, 4242, 63, 633, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 8311, 356, 10062, 63, 633, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2644, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1122, 12, 272, 8434, 63, 4078, 63, 1069, 12, 272, 8434, 63, 10290, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 199, 9, 421, 199, 533, 812, 1977, 23, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 1014, 921, 5169, 1544, 20316, 19508, 23, 4537, 957, 15, 2802, 26, 2229, 48, 28, 344, 26906, 3171, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 19508, 23, 14, 957, 15, 2802, 26, 11032, 2501, 26433, 67, 18, 297, 267, 283, 1064, 21, 356, 283, 1020, 70, 2182, 67, 16, 67, 25, 2829, 25, 66, 24255, 66, 2576, 19455, 69, 1717, 1465, 1082, 67, 19, 70, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 11032, 2501, 26433, 67, 18, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 141, 95, 23000, 14978, 25969, 1, 7038, 101, 12195, 20497, 5806, 446, 221, 19277, 6500, 18261, 7038, 116, 5657, 24071, 6286, 11487, 12195, 7592, 20497, 6500, 446, 7038, 95, 11487, 7753, 30019, 5657, 31999, 13111, 121, 21273, 5657, 297, 267, 1660, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 398, 327, 1929, 370, 664, 314, 2034, 650, 5431, 367, 314, 3211, 8586, 13790, 3264, 5494, 267, 327, 1314, 365, 5784, 367, 314, 3211, 2538, 267, 347, 664, 63, 1730, 63, 344, 837, 288, 4660, 63, 1606, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 288, 2351, 63, 344, 63, 633, 275, 291, 423, 1733, 63, 3821, 8, 355, 519, 7, 1391, 60, 83, 10, 633, 60, 83, 23440, 83, 10, 3985, 21690, 418, 13439, 7, 10805, 4660, 63, 1606, 12, 355, 283, 1730, 1305, 1166, 358, 288, 291, 423, 4249, 63, 12022, 8, 355, 8434, 63, 10290, 14, 17755, 8, 633, 12, 2351, 63, 344, 63, 633, 395, 3991, 63, 344, 12, 355, 283, 28277, 2351, 1305, 358, 398, 664, 63, 1730, 63, 344, 342, 267, 664, 63, 1730, 63, 344, 342, 398, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 12, 1460, 283, 18085, 4660, 2034, 358, 398, 2538, 275, 291, 423, 1360, 63, 1733, 63, 3821, 8, 82, 7601, 1213, 13661, 12432, 1108, 1213, 4206, 3147, 9248, 12, 283, 1213, 1959, 1294, 30746, 16, 1055, 1913, 342, 398, 2256, 63, 633, 275, 298, 1014, 921, 19508, 23, 14, 957, 15, 2802, 15, 5615, 1530, 14, 1117, 2, 267, 666, 275, 8434, 63, 4078, 63, 1122, 14, 10738, 3252, 305, 19, 356, 283, 17, 297, 283, 5017, 356, 3991, 63, 344, 1552, 267, 2256, 63, 1069, 275, 8434, 63, 4078, 63, 1069, 14, 2017, 8, 815, 63, 633, 12, 666, 9, 267, 2256, 63, 1069, 14, 525, 63, 1291, 360, 2714, 13, 804, 297, 283, 3578, 15, 88, 13, 1544, 13, 964, 13, 21886, 358, 267, 2256, 63, 1310, 275, 291, 423, 4249, 63, 12022, 8, 815, 63, 1069, 12, 3991, 63, 344, 12, 283, 18085, 2256, 9248, 358, 267, 340, 2256, 63, 1310, 365, 488, 26, 288, 746, 19783, 360, 6005, 370, 5536, 314, 5898, 1166, 358, 267, 334, 5094, 63, 633, 12, 10062, 63, 633, 9, 275, 2341, 8, 2734, 671, 26, 671, 14, 1294, 26800, 5832, 17, 467, 2256, 63, 1310, 14, 1294, 20040, 1333, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 633, 356, 4242, 63, 633, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 8311, 356, 10062, 63, 633, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wbc2010/django1.2.5
django/db/backends/dummy/base.py
64
1511
""" Dummy database backend for Django. Django uses this if the database ENGINE setting is empty (None or empty string). Each of these API functions, except connection.close(), raises ImproperlyConfigured. """ from django.core.exceptions import ImproperlyConfigured from django.db.backends import * from django.db.backends.creation import BaseDatabaseCreation def complain(*args, **kwargs): raise ImproperlyConfigured("You haven't set the database ENGINE setting yet.") def ignore(*args, **kwargs): pass class DatabaseError(Exception): pass class IntegrityError(DatabaseError): pass class DatabaseOperations(BaseDatabaseOperations): quote_name = complain class DatabaseClient(BaseDatabaseClient): runshell = complain class DatabaseIntrospection(BaseDatabaseIntrospection): get_table_list = complain get_table_description = complain get_relations = complain get_indexes = complain class DatabaseWrapper(object): operators = {} cursor = complain _commit = complain _rollback = ignore def __init__(self, settings_dict, alias, *args, **kwargs): self.features = BaseDatabaseFeatures() self.ops = DatabaseOperations() self.client = DatabaseClient(self) self.creation = BaseDatabaseCreation(self) self.introspection = DatabaseIntrospection(self) self.validation = BaseDatabaseValidation(self) self.settings_dict = settings_dict self.alias = alias def close(self): pass
bsd-3-clause
[ 624, 199, 11324, 3050, 4865, 367, 5634, 14, 199, 199, 9323, 4440, 642, 340, 314, 3050, 5070, 14331, 4260, 365, 2701, 334, 403, 503, 2701, 1059, 680, 199, 199, 22321, 402, 3520, 3261, 3423, 12, 871, 1950, 14, 1600, 1062, 6534, 199, 8499, 10951, 14, 199, 624, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 14, 7765, 492, 627, 199, 504, 1639, 14, 697, 14, 7765, 14, 8782, 492, 29103, 13921, 199, 199, 318, 24105, 2031, 589, 12, 1011, 958, 304, 272, 746, 11897, 480, 5556, 19051, 1133, 663, 314, 3050, 5070, 14331, 4260, 5966, 2685, 199, 199, 318, 3686, 2031, 589, 12, 1011, 958, 304, 272, 986, 199, 199, 533, 27728, 8, 1726, 304, 272, 986, 199, 199, 533, 26864, 8, 25198, 304, 272, 986, 199, 199, 533, 8692, 12929, 8, 1563, 7243, 12929, 304, 272, 6313, 63, 354, 275, 24105, 199, 199, 533, 8692, 3041, 8, 1563, 7243, 3041, 304, 272, 1255, 5641, 275, 24105, 199, 199, 533, 8692, 30516, 8, 1563, 7243, 30516, 304, 272, 664, 63, 1224, 63, 513, 275, 24105, 272, 664, 63, 1224, 63, 1802, 275, 24105, 272, 664, 63, 15741, 275, 24105, 272, 664, 63, 10116, 275, 24105, 199, 199, 533, 8692, 4590, 8, 785, 304, 272, 10211, 275, 1052, 272, 3920, 275, 24105, 272, 485, 3543, 275, 24105, 272, 485, 10437, 275, 3686, 339, 347, 636, 826, 721, 277, 12, 2202, 63, 807, 12, 5162, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 3179, 275, 29103, 10807, 342, 267, 291, 14, 1483, 275, 8692, 12929, 342, 267, 291, 14, 1258, 275, 8692, 3041, 8, 277, 9, 267, 291, 14, 8782, 275, 29103, 13921, 8, 277, 9, 267, 291, 14, 21627, 275, 8692, 30516, 8, 277, 9, 267, 291, 14, 6136, 275, 29103, 13816, 8, 277, 9, 398, 291, 14, 1751, 63, 807, 275, 2202, 63, 807, 267, 291, 14, 3620, 275, 5162, 339, 347, 4002, 8, 277, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 11324, 3050, 4865, 367, 5634, 14, 199, 199, 9323, 4440, 642, 340, 314, 3050, 5070, 14331, 4260, 365, 2701, 334, 403, 503, 2701, 1059, 680, 199, 199, 22321, 402, 3520, 3261, 3423, 12, 871, 1950, 14, 1600, 1062, 6534, 199, 8499, 10951, 14, 199, 624, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 14, 7765, 492, 627, 199, 504, 1639, 14, 697, 14, 7765, 14, 8782, 492, 29103, 13921, 199, 199, 318, 24105, 2031, 589, 12, 1011, 958, 304, 272, 746, 11897, 480, 5556, 19051, 1133, 663, 314, 3050, 5070, 14331, 4260, 5966, 2685, 199, 199, 318, 3686, 2031, 589, 12, 1011, 958, 304, 272, 986, 199, 199, 533, 27728, 8, 1726, 304, 272, 986, 199, 199, 533, 26864, 8, 25198, 304, 272, 986, 199, 199, 533, 8692, 12929, 8, 1563, 7243, 12929, 304, 272, 6313, 63, 354, 275, 24105, 199, 199, 533, 8692, 3041, 8, 1563, 7243, 3041, 304, 272, 1255, 5641, 275, 24105, 199, 199, 533, 8692, 30516, 8, 1563, 7243, 30516, 304, 272, 664, 63, 1224, 63, 513, 275, 24105, 272, 664, 63, 1224, 63, 1802, 275, 24105, 272, 664, 63, 15741, 275, 24105, 272, 664, 63, 10116, 275, 24105, 199, 199, 533, 8692, 4590, 8, 785, 304, 272, 10211, 275, 1052, 272, 3920, 275, 24105, 272, 485, 3543, 275, 24105, 272, 485, 10437, 275, 3686, 339, 347, 636, 826, 721, 277, 12, 2202, 63, 807, 12, 5162, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 3179, 275, 29103, 10807, 342, 267, 291, 14, 1483, 275, 8692, 12929, 342, 267, 291, 14, 1258, 275, 8692, 3041, 8, 277, 9, 267, 291, 14, 8782, 275, 29103, 13921, 8, 277, 9, 267, 291, 14, 21627, 275, 8692, 30516, 8, 277, 9, 267, 291, 14, 6136, 275, 29103, 13816, 8, 277, 9, 398, 291, 14, 1751, 63, 807, 275, 2202, 63, 807, 267, 291, 14, 3620, 275, 5162, 339, 347, 4002, 8, 277, 304, 267, 986, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
Ca1ne/Enoch316
tools/perf/scripts/python/check-perf-trace.py
11214
2503
# perf script event handlers, generated by perf script -g python # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # This script tests basic functionality such as flag and symbol # strings, common_xxx() calls back into perf, begin, end, unhandled # events, etc. Basically, if this script runs successfully and # displays expected results, Python scripting support should be ok. import os import sys sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from Core import * from perf_trace_context import * unhandled = autodict() def trace_begin(): print "trace_begin" pass def trace_end(): print_unhandled() def irq__softirq_entry(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, vec): print_header(event_name, common_cpu, common_secs, common_nsecs, common_pid, common_comm) print_uncommon(context) print "vec=%s\n" % \ (symbol_str("irq__softirq_entry", "vec", vec)), def kmem__kmalloc(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, call_site, ptr, bytes_req, bytes_alloc, gfp_flags): print_header(event_name, common_cpu, common_secs, common_nsecs, common_pid, common_comm) print_uncommon(context) print "call_site=%u, ptr=%u, bytes_req=%u, " \ "bytes_alloc=%u, gfp_flags=%s\n" % \ (call_site, ptr, bytes_req, bytes_alloc, flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)), def trace_unhandled(event_name, context, event_fields_dict): try: unhandled[event_name] += 1 except TypeError: unhandled[event_name] = 1 def print_header(event_name, cpu, secs, nsecs, pid, comm): print "%-20s %5u %05u.%09u %8u %-20s " % \ (event_name, cpu, secs, nsecs, pid, comm), # print trace fields not included in handler args def print_uncommon(context): print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \ % (common_pc(context), trace_flag_str(common_flags(context)), \ common_lock_depth(context)) def print_unhandled(): keys = unhandled.keys() if not keys: return print "\nunhandled events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "-----------"), for event_name in keys: print "%-40s %10d\n" % (event_name, unhandled[event_name])
gpl-2.0
[ 3, 8582, 2884, 1566, 8297, 12, 4046, 701, 8582, 2884, 446, 71, 2366, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 961, 2884, 2295, 5678, 9330, 4066, 465, 3305, 436, 5272, 199, 3, 3326, 12, 2863, 63, 10013, 342, 4882, 1771, 1901, 8582, 12, 5386, 12, 1284, 12, 23090, 199, 3, 4474, 12, 5423, 14, 221, 10082, 1183, 12, 340, 642, 2884, 7858, 8792, 436, 199, 3, 17561, 1420, 2058, 12, 2018, 2884, 316, 2291, 1077, 506, 4112, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 11672, 492, 627, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 199, 23648, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 3446, 63, 5037, 2, 199, 198, 1529, 199, 199, 318, 3307, 63, 500, 837, 267, 870, 63, 23648, 342, 199, 199, 318, 10476, 363, 18316, 63, 2373, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 6046, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 6046, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 5155, 63, 495, 480, 7277, 363, 18316, 63, 2373, 401, 298, 6046, 401, 10782, 1826, 199, 199, 318, 1022, 5286, 363, 75, 23981, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 199, 198, 71, 3997, 63, 2469, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 1250, 63, 2124, 2458, 85, 12, 12448, 2458, 85, 12, 2783, 63, 2103, 2458, 85, 12, 298, 971, 507, 198, 2, 2394, 63, 9373, 2458, 85, 12, 486, 3997, 63, 2469, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 2742, 198, 4173, 63, 495, 480, 75, 5286, 363, 75, 23981, 401, 298, 71, 3997, 63, 2469, 401, 486, 3997, 63, 2469, 1826, 199, 199, 318, 3307, 63, 23648, 8, 1430, 63, 354, 12, 1067, 12, 1566, 63, 955, 63, 807, 304, 272, 862, 26, 267, 23090, 59, 1430, 63, 354, 61, 847, 413, 272, 871, 3146, 26, 267, 23090, 59, 1430, 63, 354, 61, 275, 413, 199, 199, 318, 870, 63, 1291, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 304, 199, 198, 1361, 18301, 1165, 83, 450, 21, 85, 450, 1717, 85, 4111, 1643, 85, 450, 24, 85, 19752, 1165, 83, 298, 450, 971, 199, 198, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 395, 199, 199, 3, 870, 3307, 1504, 440, 5120, 315, 3016, 1249, 199, 318, 870, 63, 324, 2330, 8, 1100, 304, 272, 870, 298, 2330, 63, 657, 19046, 63, 835, 2458, 68, 12, 2863, 63, 2469, 2458, 83, 12, 2863, 63, 831, 63, 4631, 2458, 68, 12, 298, 971, 267, 450, 334, 2330, 63, 2352, 8, 1100, 395, 3307, 63, 4173, 63, 495, 8, 2330, 63, 2469, 8, 1100, 1826, 971, 2049, 2863, 63, 831, 63, 4631, 8, 1100, 430, 199, 199, 318, 870, 63, 23648, 837, 272, 2883, 275, 23090, 14, 1612, 342, 272, 340, 440, 2883, 26, 267, 372, 339, 870, 1867, 78, 23648, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1566, 63, 354, 315, 2883, 26, 199, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 1430, 63, 354, 12, 23090, 59, 1430, 63, 354, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8582, 2884, 1566, 8297, 12, 4046, 701, 8582, 2884, 446, 71, 2366, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 961, 2884, 2295, 5678, 9330, 4066, 465, 3305, 436, 5272, 199, 3, 3326, 12, 2863, 63, 10013, 342, 4882, 1771, 1901, 8582, 12, 5386, 12, 1284, 12, 23090, 199, 3, 4474, 12, 5423, 14, 221, 10082, 1183, 12, 340, 642, 2884, 7858, 8792, 436, 199, 3, 17561, 1420, 2058, 12, 2018, 2884, 316, 2291, 1077, 506, 4112, 14, 199, 199, 646, 747, 199, 646, 984, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 11672, 492, 627, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 199, 23648, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 3446, 63, 5037, 2, 199, 198, 1529, 199, 199, 318, 3307, 63, 500, 837, 267, 870, 63, 23648, 342, 199, 199, 318, 10476, 363, 18316, 63, 2373, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 6046, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 6046, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 5155, 63, 495, 480, 7277, 363, 18316, 63, 2373, 401, 298, 6046, 401, 10782, 1826, 199, 199, 318, 1022, 5286, 363, 75, 23981, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 199, 198, 71, 3997, 63, 2469, 304, 507, 198, 1361, 63, 1291, 8, 1430, 63, 354, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 198, 2330, 63, 3150, 12, 2863, 63, 1404, 9, 2234, 870, 63, 324, 2330, 8, 1100, 9, 2742, 198, 1361, 298, 1250, 63, 2124, 2458, 85, 12, 12448, 2458, 85, 12, 2783, 63, 2103, 2458, 85, 12, 298, 971, 507, 198, 2, 2394, 63, 9373, 2458, 85, 12, 486, 3997, 63, 2469, 2458, 83, 60, 78, 2, 450, 971, 507, 198, 8, 1250, 63, 2124, 12, 12448, 12, 2783, 63, 2103, 12, 2783, 63, 9373, 12, 2742, 198, 4173, 63, 495, 480, 75, 5286, 363, 75, 23981, 401, 298, 71, 3997, 63, 2469, 401, 486, 3997, 63, 2469, 1826, 199, 199, 318, 3307, 63, 23648, 8, 1430, 63, 354, 12, 1067, 12, 1566, 63, 955, 63, 807, 304, 272, 862, 26, 267, 23090, 59, 1430, 63, 354, 61, 847, 413, 272, 871, 3146, 26, 267, 23090, 59, 1430, 63, 354, 61, 275, 413, 199, 199, 318, 870, 63, 1291, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 304, 199, 198, 1361, 18301, 1165, 83, 450, 21, 85, 450, 1717, 85, 4111, 1643, 85, 450, 24, 85, 19752, 1165, 83, 298, 450, 971, 199, 198, 8, 1430, 63, 354, 12, 5033, 12, 20091, 12, 13781, 12, 4422, 12, 1923, 395, 199, 199, 3, 870, 3307, 1504, 440, 5120, 315, 3016, 1249, 199, 318, 870, 63, 324, 2330, 8, 1100, 304, 272, 870, 298, 2330, 63, 657, 19046, 63, 835, 2458, 68, 12, 2863, 63, 2469, 2458, 83, 12, 2863, 63, 831, 63, 4631, 2458, 68, 12, 298, 971, 267, 450, 334, 2330, 63, 2352, 8, 1100, 395, 3307, 63, 4173, 63, 495, 8, 2330, 63, 2469, 8, 1100, 1826, 971, 2049, 2863, 63, 831, 63, 4631, 8, 1100, 430, 199, 199, 318, 870, 63, 23648, 837, 272, 2883, 275, 23090, 14, 1612, 342, 272, 340, 440, 2883, 26, 267, 372, 339, 870, 1867, 78, 23648, 4474, 3427, 78, 60, 78, 401, 339, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 272, 870, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 639, 298, 13715, 1288, 339, 367, 1566, 63, 354, 315, 2883, 26, 199, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 1430, 63, 354, 12, 23090, 59, 1430, 63, 354, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Aloomaio/googleads-python-lib
examples/ad_manager/v201805/product_package_item_service/get_product_package_items_for_product_package.py
1
2302
#!/usr/bin/env python # # Copyright 2016 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """This example gets all product package items belonging to a product package. """ # Import appropriate modules from the client library. from googleads import ad_manager PRODUCT_PACKAGE_ID = 'INSERT_PRODUCT_PACKAGE_ID_HERE' def main(client, product_package_id): # Initialize appropriate service. product_package_item_service = client.GetService( 'ProductPackageItemService', version='v201805') # Create a statement to select product package items. statement = (ad_manager.StatementBuilder(version='v201805') .Where('productPackageId = :productPackageId') .WithBindVariable('productPackageId', product_package_id)) # Retrieve a small amount of product package items at a time, paging # through until all product package items have been retrieved. while True: response = product_package_item_service.getProductPackageItemsByStatement( statement.ToStatement()) if 'results' in response and len(response['results']): for product_package_item in response['results']: # Print out some information for each product package item. print('Product package item with ID "%d", product ID "%d", and product ' 'package ID "%d" was found.\n' % (product_package_item['id'], product_package_item['productId'], product_package_item['productPackageId'])) statement.offset += statement.limit else: break print '\nNumber of results found: %s' % response['totalResultSetSize'] if __name__ == '__main__': # Initialize client object. ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage() main(ad_manager_client, PRODUCT_PACKAGE_ID)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 7800, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 2765, 2893, 7545, 1006, 3336, 2559, 2974, 30226, 370, 282, 3336, 2559, 14, 199, 624, 199, 199, 3, 3161, 5827, 4621, 687, 314, 1890, 3555, 14, 199, 504, 6233, 9402, 492, 1503, 63, 2609, 199, 199, 14853, 63, 19265, 63, 998, 275, 283, 10258, 63, 14853, 63, 19265, 63, 998, 63, 5293, 7, 421, 199, 318, 2446, 8, 1258, 12, 3336, 63, 2491, 63, 344, 304, 523, 327, 11578, 5827, 2435, 14, 523, 3336, 63, 2491, 63, 1053, 63, 1364, 275, 1890, 14, 1002, 3167, 8, 489, 283, 5884, 8599, 2081, 3167, 297, 1015, 534, 86, 1797, 13027, 358, 523, 327, 2790, 282, 5164, 370, 3504, 3336, 2559, 2974, 14, 523, 5164, 275, 334, 350, 63, 2609, 14, 15173, 6437, 8, 1023, 534, 86, 1797, 13027, 358, 2049, 1275, 26493, 360, 2558, 8599, 1304, 275, 520, 2558, 8599, 1304, 358, 2049, 1275, 3007, 8198, 2773, 360, 2558, 8599, 1304, 297, 3336, 63, 2491, 63, 344, 430, 819, 327, 13939, 282, 7425, 5982, 402, 3336, 2559, 2974, 737, 282, 900, 12, 299, 7407, 523, 327, 4012, 5133, 1006, 3336, 2559, 2974, 1172, 2757, 12396, 14, 523, 1830, 715, 26, 272, 1177, 275, 3336, 63, 2491, 63, 1053, 63, 1364, 14, 362, 5884, 8599, 7412, 2175, 15173, 8, 267, 5164, 14, 1378, 15173, 1012, 272, 340, 283, 2604, 7, 315, 1177, 436, 822, 8, 1310, 459, 2604, 9090, 489, 367, 3336, 63, 2491, 63, 1053, 315, 1177, 459, 2604, 2565, 267, 327, 9101, 734, 2005, 2556, 367, 1924, 3336, 2559, 1242, 14, 267, 870, 360, 5884, 2559, 1242, 543, 2870, 2071, 68, 401, 3336, 2870, 2071, 68, 401, 436, 3336, 283, 1598, 283, 2491, 2870, 2071, 68, 2, 1990, 1911, 3134, 78, 7, 450, 1598, 334, 2558, 63, 2491, 63, 1053, 459, 344, 995, 3336, 63, 2491, 63, 1053, 459, 2558, 1304, 995, 2049, 3336, 63, 2491, 63, 1053, 459, 2558, 8599, 1304, 5156, 489, 5164, 14, 2743, 847, 5164, 14, 3097, 272, 587, 26, 489, 2059, 819, 870, 1557, 78, 3259, 402, 2058, 1911, 26, 450, 83, 7, 450, 1177, 459, 2923, 21722, 2320, 418, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 327, 11578, 1890, 909, 14, 523, 1503, 63, 2609, 63, 1258, 275, 1503, 63, 2609, 14, 2767, 2988, 3041, 14, 6200, 2532, 6408, 342, 523, 2446, 8, 350, 63, 2609, 63, 1258, 12, 3611, 13461, 63, 19265, 63, 998, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 7800, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 624, 2765, 2893, 7545, 1006, 3336, 2559, 2974, 30226, 370, 282, 3336, 2559, 14, 199, 624, 199, 199, 3, 3161, 5827, 4621, 687, 314, 1890, 3555, 14, 199, 504, 6233, 9402, 492, 1503, 63, 2609, 199, 199, 14853, 63, 19265, 63, 998, 275, 283, 10258, 63, 14853, 63, 19265, 63, 998, 63, 5293, 7, 421, 199, 318, 2446, 8, 1258, 12, 3336, 63, 2491, 63, 344, 304, 523, 327, 11578, 5827, 2435, 14, 523, 3336, 63, 2491, 63, 1053, 63, 1364, 275, 1890, 14, 1002, 3167, 8, 489, 283, 5884, 8599, 2081, 3167, 297, 1015, 534, 86, 1797, 13027, 358, 523, 327, 2790, 282, 5164, 370, 3504, 3336, 2559, 2974, 14, 523, 5164, 275, 334, 350, 63, 2609, 14, 15173, 6437, 8, 1023, 534, 86, 1797, 13027, 358, 2049, 1275, 26493, 360, 2558, 8599, 1304, 275, 520, 2558, 8599, 1304, 358, 2049, 1275, 3007, 8198, 2773, 360, 2558, 8599, 1304, 297, 3336, 63, 2491, 63, 344, 430, 819, 327, 13939, 282, 7425, 5982, 402, 3336, 2559, 2974, 737, 282, 900, 12, 299, 7407, 523, 327, 4012, 5133, 1006, 3336, 2559, 2974, 1172, 2757, 12396, 14, 523, 1830, 715, 26, 272, 1177, 275, 3336, 63, 2491, 63, 1053, 63, 1364, 14, 362, 5884, 8599, 7412, 2175, 15173, 8, 267, 5164, 14, 1378, 15173, 1012, 272, 340, 283, 2604, 7, 315, 1177, 436, 822, 8, 1310, 459, 2604, 9090, 489, 367, 3336, 63, 2491, 63, 1053, 315, 1177, 459, 2604, 2565, 267, 327, 9101, 734, 2005, 2556, 367, 1924, 3336, 2559, 1242, 14, 267, 870, 360, 5884, 2559, 1242, 543, 2870, 2071, 68, 401, 3336, 2870, 2071, 68, 401, 436, 3336, 283, 1598, 283, 2491, 2870, 2071, 68, 2, 1990, 1911, 3134, 78, 7, 450, 1598, 334, 2558, 63, 2491, 63, 1053, 459, 344, 995, 3336, 63, 2491, 63, 1053, 459, 2558, 1304, 995, 2049, 3336, 63, 2491, 63, 1053, 459, 2558, 8599, 1304, 5156, 489, 5164, 14, 2743, 847, 5164, 14, 3097, 272, 587, 26, 489, 2059, 819, 870, 1557, 78, 3259, 402, 2058, 1911, 26, 450, 83, 7, 450, 1177, 459, 2923, 21722, 2320, 418, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 327, 11578, 1890, 909, 14, 523, 1503, 63, 2609, 63, 1258, 275, 1503, 63, 2609, 14, 2767, 2988, 3041, 14, 6200, 2532, 6408, 342, 523, 2446, 8, 350, 63, 2609, 63, 1258, 12, 3611, 13461, 63, 19265, 63, 998, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gmatteo/pymatgen
pymatgen/io/gaussian.py
2
59623
# coding: utf-8 # Copyright (c) Pymatgen Development Team. # Distributed under the terms of the MIT License. """ This module implements input and output processing from Gaussian. """ import re import warnings import numpy as np import scipy.constants as cst from monty.io import zopen from pymatgen.core.composition import Composition from pymatgen.core.periodic_table import Element from pymatgen.core.structure import Molecule from pymatgen.core.operations import SymmOp from pymatgen.core.units import Ha_to_eV from pymatgen.electronic_structure.core import Spin from pymatgen.util.coord import get_angle __author__ = "Shyue Ping Ong, Germain Salvato-Vallverdu, Xin Chen" __copyright__ = "Copyright 2013, The Materials Virtual Lab" __version__ = "0.1" __maintainer__ = "Shyue Ping Ong" __email__ = "ongsp@ucsd.edu" __date__ = "8/1/15" float_patt = re.compile(r"\s*([+-]?\d+\.\d+)") def read_route_line(route): """ read route line in gaussian input/output and return functional basis_set and a dictionary of other route parameters Args: route (str) : the route line return functional (str) : the method (HF, PBE ...) basis_set (str) : the basis set route (dict) : dictionary of parameters """ scrf_patt = re.compile(r"^([sS][cC][rR][fF])\s*=\s*(.+)") multi_params_patt = re.compile(r"^([A-z]+[0-9]*)[\s=]+\((.*)\)$") functional = None basis_set = None route_params = {} dieze_tag = None if route: if "/" in route: tok = route.split("/") functional = tok[0].split()[-1] basis_set = tok[1].split()[0] for tok in [functional, basis_set, "/"]: route = route.replace(tok, "") for tok in route.split(): if scrf_patt.match(tok): m = scrf_patt.match(tok) route_params[m.group(1)] = m.group(2) elif tok.upper() in ["#", "#N", "#P", "#T"]: # does not store # in route to avoid error in input if tok == "#": dieze_tag = "#N" else: dieze_tag = tok continue else: m = re.match(multi_params_patt, tok.strip("#")) if m: pars = {} for par in m.group(2).split(","): p = par.split("=") pars[p[0]] = None if len(p) == 1 else p[1] route_params[m.group(1)] = pars else: d = tok.strip("#").split("=") route_params[d[0]] = None if len(d) == 1 else d[1] return functional, basis_set, route_params, dieze_tag class GaussianInput: """ An object representing a Gaussian input file. """ # Commonly used regex patterns _zmat_patt = re.compile(r"^(\w+)*([\s,]+(\w+)[\s,]+(\w+))*[\-\.\s,\w]*$") _xyz_patt = re.compile(r"^(\w+)[\s,]+([\d\.eE\-]+)[\s,]+([\d\.eE\-]+)[\s,]+" r"([\d\.eE\-]+)[\-\.\s,\w.]*$") def __init__( self, mol, charge=None, spin_multiplicity=None, title=None, functional="HF", basis_set="6-31G(d)", route_parameters=None, input_parameters=None, link0_parameters=None, dieze_tag="#P", gen_basis=None, ): """ Args: mol: Input molecule. It can either be a Molecule object, a string giving the geometry in a format supported by Guassian, or ``None``. If the molecule is ``None``, you will need to use read it in from a checkpoint. Consider adding ``CHK`` to the ``link0_parameters``. charge: Charge of the molecule. If None, charge on molecule is used. Defaults to None. This allows the input file to be set a charge independently from the molecule itself. If ``mol`` is not a Molecule object, then you must specify a charge. spin_multiplicity: Spin multiplicity of molecule. Defaults to None, which means that the spin multiplicity is set to 1 if the molecule has no unpaired electrons and to 2 if there are unpaired electrons. If ``mol`` is not a Molecule object, then you must specify the multiplicity title: Title for run. Defaults to formula of molecule if None. functional: Functional for run. basis_set: Basis set for run. route_parameters: Additional route parameters as a dict. For example, {'SP':"", "SCF":"Tight"} input_parameters: Additional input parameters for run as a dict. Used for example, in PCM calculations. E.g., {"EPS":12} link0_parameters: Link0 parameters as a dict. E.g., {"%mem": "1000MW"} dieze_tag: # preceding the route line. E.g. "#p" gen_basis: allows a user-specified basis set to be used in a Gaussian calculation. If this is not None, the attribute ``basis_set`` will be set to "Gen". """ self._mol = mol # Determine multiplicity and charge settings if isinstance(mol, Molecule): self.charge = charge if charge is not None else mol.charge nelectrons = mol.charge + mol.nelectrons - self.charge if spin_multiplicity is not None: self.spin_multiplicity = spin_multiplicity if (nelectrons + spin_multiplicity) % 2 != 1: raise ValueError( "Charge of {} and spin multiplicity of {} is" " not possible for this molecule".format(self.charge, spin_multiplicity) ) else: self.spin_multiplicity = 1 if nelectrons % 2 == 0 else 2 # Get a title from the molecule name self.title = title if title else self._mol.composition.formula else: self.charge = charge self.spin_multiplicity = spin_multiplicity # Set a title self.title = title if title else "Restart" # Store the remaining settings self.functional = functional self.basis_set = basis_set self.link0_parameters = link0_parameters if link0_parameters else {} self.route_parameters = route_parameters if route_parameters else {} self.input_parameters = input_parameters if input_parameters else {} self.dieze_tag = dieze_tag if dieze_tag[0] == "#" else "#" + dieze_tag self.gen_basis = gen_basis if gen_basis is not None: self.basis_set = "Gen" @property def molecule(self): """ Returns molecule associated with this GaussianInput. """ return self._mol @staticmethod def _parse_coords(coord_lines): """ Helper method to parse coordinates. """ paras = {} var_pattern = re.compile(r"^([A-Za-z]+\S*)[\s=,]+([\d\-\.]+)$") for l in coord_lines: m = var_pattern.match(l.strip()) if m: paras[m.group(1).strip("=")] = float(m.group(2)) species = [] coords = [] # Stores whether a Zmatrix format is detected. Once a zmatrix format # is detected, it is assumed for the remaining of the parsing. zmode = False for l in coord_lines: l = l.strip() if not l: break if (not zmode) and GaussianInput._xyz_patt.match(l): m = GaussianInput._xyz_patt.match(l) species.append(m.group(1)) toks = re.split(r"[,\s]+", l.strip()) if len(toks) > 4: coords.append([float(i) for i in toks[2:5]]) else: coords.append([float(i) for i in toks[1:4]]) elif GaussianInput._zmat_patt.match(l): zmode = True toks = re.split(r"[,\s]+", l.strip()) species.append(toks[0]) toks.pop(0) if len(toks) == 0: coords.append(np.array([0, 0, 0])) else: nn = [] parameters = [] while len(toks) > 1: ind = toks.pop(0) data = toks.pop(0) try: nn.append(int(ind)) except ValueError: nn.append(species.index(ind) + 1) try: val = float(data) parameters.append(val) except ValueError: if data.startswith("-"): parameters.append(-paras[data[1:]]) else: parameters.append(paras[data]) if len(nn) == 1: coords.append(np.array([0, 0, parameters[0]])) elif len(nn) == 2: coords1 = coords[nn[0] - 1] coords2 = coords[nn[1] - 1] bl = parameters[0] angle = parameters[1] axis = [0, 1, 0] op = SymmOp.from_origin_axis_angle(coords1, axis, angle, False) coord = op.operate(coords2) vec = coord - coords1 coord = vec * bl / np.linalg.norm(vec) + coords1 coords.append(coord) elif len(nn) == 3: coords1 = coords[nn[0] - 1] coords2 = coords[nn[1] - 1] coords3 = coords[nn[2] - 1] bl = parameters[0] angle = parameters[1] dih = parameters[2] v1 = coords3 - coords2 v2 = coords1 - coords2 axis = np.cross(v1, v2) op = SymmOp.from_origin_axis_angle(coords1, axis, angle, False) coord = op.operate(coords2) v1 = coord - coords1 v2 = coords1 - coords2 v3 = np.cross(v1, v2) adj = get_angle(v3, axis) axis = coords1 - coords2 op = SymmOp.from_origin_axis_angle(coords1, axis, dih - adj, False) coord = op.operate(coord) vec = coord - coords1 coord = vec * bl / np.linalg.norm(vec) + coords1 coords.append(coord) def _parse_species(sp_str): """ The species specification can take many forms. E.g., simple integers representing atomic numbers ("8"), actual species string ("C") or a labelled species ("C1"). Sometimes, the species string is also not properly capitalized, e.g, ("c1"). This method should take care of these known formats. """ try: return int(sp_str) except ValueError: sp = re.sub(r"\d", "", sp_str) return sp.capitalize() species = [_parse_species(sp) for sp in species] return Molecule(species, coords) @staticmethod def from_string(contents): """ Creates GaussianInput from a string. Args: contents: String representing an Gaussian input file. Returns: GaussianInput object """ lines = [l.strip() for l in contents.split("\n")] link0_patt = re.compile(r"^(%.+)\s*=\s*(.+)") link0_dict = {} for i, l in enumerate(lines): if link0_patt.match(l): m = link0_patt.match(l) link0_dict[m.group(1).strip("=")] = m.group(2) route_patt = re.compile(r"^#[sSpPnN]*.*") route = "" route_index = None for i, l in enumerate(lines): if route_patt.match(l): route += " " + l route_index = i # This condition allows for route cards spanning multiple lines elif (l == "" or l.isspace()) and route_index: break functional, basis_set, route_paras, dieze_tag = read_route_line(route) ind = 2 title = [] while lines[route_index + ind].strip(): title.append(lines[route_index + ind].strip()) ind += 1 title = " ".join(title) ind += 1 toks = re.split(r"[,\s]+", lines[route_index + ind]) charge = int(float(toks[0])) spin_mult = int(toks[1]) coord_lines = [] spaces = 0 input_paras = {} ind += 1 for i in range(route_index + ind, len(lines)): if lines[i].strip() == "": spaces += 1 if spaces >= 2: d = lines[i].split("=") if len(d) == 2: input_paras[d[0]] = d[1] else: coord_lines.append(lines[i].strip()) mol = GaussianInput._parse_coords(coord_lines) mol.set_charge_and_spin(charge, spin_mult) return GaussianInput( mol, charge=charge, spin_multiplicity=spin_mult, title=title, functional=functional, basis_set=basis_set, route_parameters=route_paras, input_parameters=input_paras, link0_parameters=link0_dict, dieze_tag=dieze_tag, ) @staticmethod def from_file(filename): """ Creates GaussianInput from a file. Args: filename: Gaussian input filename Returns: GaussianInput object """ with zopen(filename, "r") as f: return GaussianInput.from_string(f.read()) def _find_nn_pos_before_site(self, siteindex): """ Returns index of nearest neighbor atoms. """ alldist = [(self._mol.get_distance(siteindex, i), i) for i in range(siteindex)] alldist = sorted(alldist, key=lambda x: x[0]) return [d[1] for d in alldist] def get_zmatrix(self): """ Returns a z-matrix representation of the molecule. """ output = [] outputvar = [] for i, site in enumerate(self._mol): if i == 0: output.append("{}".format(site.specie)) elif i == 1: nn = self._find_nn_pos_before_site(i) bondlength = self._mol.get_distance(i, nn[0]) output.append("{} {} B{}".format(self._mol[i].specie, nn[0] + 1, i)) outputvar.append("B{}={:.6f}".format(i, bondlength)) elif i == 2: nn = self._find_nn_pos_before_site(i) bondlength = self._mol.get_distance(i, nn[0]) angle = self._mol.get_angle(i, nn[0], nn[1]) output.append("{} {} B{} {} A{}".format(self._mol[i].specie, nn[0] + 1, i, nn[1] + 1, i)) outputvar.append("B{}={:.6f}".format(i, bondlength)) outputvar.append("A{}={:.6f}".format(i, angle)) else: nn = self._find_nn_pos_before_site(i) bondlength = self._mol.get_distance(i, nn[0]) angle = self._mol.get_angle(i, nn[0], nn[1]) dih = self._mol.get_dihedral(i, nn[0], nn[1], nn[2]) output.append( "{} {} B{} {} A{} {} D{}".format(self._mol[i].specie, nn[0] + 1, i, nn[1] + 1, i, nn[2] + 1, i) ) outputvar.append("B{}={:.6f}".format(i, bondlength)) outputvar.append("A{}={:.6f}".format(i, angle)) outputvar.append("D{}={:.6f}".format(i, dih)) return "\n".join(output) + "\n\n" + "\n".join(outputvar) def get_cart_coords(self): """ Return the cartesian coordinates of the molecule """ def to_s(x): return "%0.6f" % x outs = [] for i, site in enumerate(self._mol): outs.append(" ".join([site.species_string, " ".join([to_s(j) for j in site.coords])])) return "\n".join(outs) def __str__(self): return self.to_string() def to_string(self, cart_coords=False): """ Return GaussianInput string Option: whe cart_coords sets to True return the cartesian coordinates instead of the z-matrix """ def para_dict_to_string(para, joiner=" "): para_str = [] # sorted is only done to make unittests work reliably for par, val in sorted(para.items()): if val is None or val == "": para_str.append(par) elif isinstance(val, dict): val_str = para_dict_to_string(val, joiner=",") para_str.append("{}=({})".format(par, val_str)) else: para_str.append("{}={}".format(par, val)) return joiner.join(para_str) output = [] if self.link0_parameters: output.append(para_dict_to_string(self.link0_parameters, "\n")) # Handle functional or basis set set to None, empty string or whitespace func_str = "" if self.functional is None else self.functional.strip() bset_str = "" if self.basis_set is None else self.basis_set.strip() if func_str != "" and bset_str != "": func_bset_str = " {}/{}".format(func_str, bset_str) else: # don't use the slash if either or both are set as empty func_bset_str = " {}{}".format(func_str, bset_str).rstrip() output.append( "{diez}{func_bset} {route}".format( diez=self.dieze_tag, func_bset=func_bset_str, route=para_dict_to_string(self.route_parameters), ) ) output.append("") output.append(self.title) output.append("") charge_str = "" if self.charge is None else "%d" % self.charge multip_str = "" if self.spin_multiplicity is None else " %d" % self.spin_multiplicity output.append("{}{}".format(charge_str, multip_str)) if isinstance(self._mol, Molecule): if cart_coords is True: output.append(self.get_cart_coords()) else: output.append(self.get_zmatrix()) elif self._mol is not None: output.append(str(self._mol)) output.append("") if self.gen_basis is not None: output.append("{:s}\n".format(self.gen_basis)) output.append(para_dict_to_string(self.input_parameters, "\n")) output.append("\n") return "\n".join(output) def write_file(self, filename, cart_coords=False): """ Write the input string into a file Option: see __str__ method """ with zopen(filename, "w") as f: f.write(self.to_string(cart_coords)) def as_dict(self): """ :return: MSONable dict """ return { "@module": self.__class__.__module__, "@class": self.__class__.__name__, "molecule": self.molecule.as_dict(), "functional": self.functional, "basis_set": self.basis_set, "route_parameters": self.route_parameters, "title": self.title, "charge": self.charge, "spin_multiplicity": self.spin_multiplicity, "input_parameters": self.input_parameters, "link0_parameters": self.link0_parameters, "dieze_tag": self.dieze_tag, } @classmethod def from_dict(cls, d): """ :param d: dict :return: GaussianInput """ return GaussianInput( mol=Molecule.from_dict(d["molecule"]), functional=d["functional"], basis_set=d["basis_set"], route_parameters=d["route_parameters"], title=d["title"], charge=d["charge"], spin_multiplicity=d["spin_multiplicity"], input_parameters=d["input_parameters"], link0_parameters=d["link0_parameters"], ) class GaussianOutput: """ Parser for Gaussian output files. .. note:: Still in early beta. Attributes: .. attribute:: structures All structures from the calculation in the standard orientation. If the symmetry is not considered, the standard orientation is not printed out and the input orientation is used instead. Check the `standard_orientation` attribute. .. attribute:: structures_input_orientation All structures from the calculation in the input orientation or the Z-matrix orientation (if an opt=z-matrix was requested). .. attribute:: opt_structures All optimized structures from the calculation in the standard orientation, if the attribute 'standard_orientation' is True, otherwise in the input or the Z-matrix orientation. .. attribute:: energies All energies from the calculation. .. attribute:: eigenvalues List of eigenvalues for the last geometry .. attribute:: MO_coefficients Matrix of MO coefficients for the last geometry .. attribute:: cart_forces All cartesian forces from the calculation. .. attribute:: frequencies A list for each freq calculation and for each mode of a dict with { "frequency": freq in cm-1, "symmetry": symmetry tag "r_mass": Reduce mass, "f_constant": force constant, "IR_intensity": IR Intensity, "mode": normal mode } The normal mode is a 1D vector of dx, dy dz of each atom. .. attribute:: hessian Matrix of second derivatives of the energy with respect to cartesian coordinates in the **input orientation** frame. Need #P in the route section in order to be in the output. .. attribute:: properly_terminated True if run has properly terminated .. attribute:: is_pcm True if run is a PCM run. .. attribute:: is_spin True if it is an unrestricted run .. attribute:: stationary_type If it is a relaxation run, indicates whether it is a minimum (Minimum) or a saddle point ("Saddle"). .. attribute:: corrections Thermochemical corrections if this run is a Freq run as a dict. Keys are "Zero-point", "Thermal", "Enthalpy" and "Gibbs Free Energy" .. attribute:: functional Functional used in the run. .. attribute:: basis_set Basis set used in the run .. attribute:: route Additional route parameters as a dict. For example, {'SP':"", "SCF":"Tight"} .. attribute:: dieze_tag # preceding the route line, e.g. "#P" .. attribute:: link0 Link0 parameters as a dict. E.g., {"%mem": "1000MW"} .. attribute:: charge Charge for structure .. attribute:: spin_multiplicity Spin multiplicity for structure .. attribute:: num_basis_func Number of basis functions in the run. .. attribute:: electrons number of alpha and beta electrons as (N alpha, N beta) .. attribute:: pcm PCM parameters and output if available. .. attribute:: errors error if not properly terminated (list to be completed in error_defs) .. attribute:: Mulliken_charges Mulliken atomic charges .. attribute:: eigenvectors Matrix of shape (num_basis_func, num_basis_func). Each column is an eigenvectors and contains AO coefficients of an MO. eigenvectors[Spin] = mat(num_basis_func, num_basis_func) .. attribute:: molecular_orbital MO development coefficients on AO in a more convenient array dict for each atom and basis set label. mo[Spin][OM j][atom i] = {AO_k: coeff, AO_k: coeff ... } .. attribute:: atom_basis_labels Labels of AO for each atoms. These labels are those used in the output of molecular orbital coefficients (POP=Full) and in the molecular_orbital array dict. atom_basis_labels[iatom] = [AO_k, AO_k, ...] .. attribute:: resumes List of gaussian data resume given at the end of the output file before the quotation. The resumes are given as string. .. attribute:: title Title of the gaussian run. .. attribute:: standard_orientation If True, the geometries stored in the structures are in the standard orientation. Else, the geometries are in the input orientation. .. attribute:: bond_orders Dict of bond order values read in the output file such as: {(0, 1): 0.8709, (1, 6): 1.234, ...} The keys are the atom indexes and the values are the Wiberg bond indexes that are printed using `pop=NBOREAD` and `$nbo bndidx $end`. Methods: .. method:: to_input() Return a GaussianInput object using the last geometry and the same calculation parameters. .. method:: read_scan() Read a potential energy surface from a gaussian scan calculation. .. method:: get_scan_plot() Get a matplotlib plot of the potential energy surface .. method:: save_scan_plot() Save a matplotlib plot of the potential energy surface to a file """ def __init__(self, filename): """ Args: filename: Filename of Gaussian output file. """ self.filename = filename self._parse(filename) @property def final_energy(self): """ :return: Final energy in Gaussian output. """ return self.energies[-1] @property def final_structure(self): """ :return: Final structure in Gaussian output. """ return self.structures[-1] def _parse(self, filename): start_patt = re.compile(r" \(Enter \S+l101\.exe\)") route_patt = re.compile(r" #[pPnNtT]*.*") link0_patt = re.compile(r"^\s(%.+)\s*=\s*(.+)") charge_mul_patt = re.compile(r"Charge\s+=\s*([-\d]+)\s+" r"Multiplicity\s+=\s*(\d+)") num_basis_func_patt = re.compile(r"([0-9]+)\s+basis functions") num_elec_patt = re.compile(r"(\d+)\s+alpha electrons\s+(\d+)\s+beta electrons") pcm_patt = re.compile(r"Polarizable Continuum Model") stat_type_patt = re.compile(r"imaginary frequencies") scf_patt = re.compile(r"E\(.*\)\s*=\s*([-\.\d]+)\s+") mp2_patt = re.compile(r"EUMP2\s*=\s*(.*)") oniom_patt = re.compile(r"ONIOM:\s+extrapolated energy\s*=\s*(.*)") termination_patt = re.compile(r"(Normal|Error) termination") error_patt = re.compile(r"(! Non-Optimized Parameters !|Convergence failure)") mulliken_patt = re.compile(r"^\s*(Mulliken charges|Mulliken atomic charges)") mulliken_charge_patt = re.compile(r"^\s+(\d+)\s+([A-Z][a-z]?)\s*(\S*)") end_mulliken_patt = re.compile(r"(Sum of Mulliken )(.*)(charges)\s*=\s*(\D)") std_orientation_patt = re.compile(r"Standard orientation") input_orientation_patt = re.compile(r"Input orientation|Z-Matrix orientation") orbital_patt = re.compile(r"(Alpha|Beta)\s*\S+\s*eigenvalues --(.*)") thermo_patt = re.compile(r"(Zero-point|Thermal) correction(.*)=" r"\s+([\d\.-]+)") forces_on_patt = re.compile(r"Center\s+Atomic\s+Forces\s+\(Hartrees/Bohr\)") forces_off_patt = re.compile(r"Cartesian\s+Forces:\s+Max.*RMS.*") forces_patt = re.compile(r"\s+(\d+)\s+(\d+)\s+([0-9\.-]+)\s+([0-9\.-]+)\s+([0-9\.-]+)") freq_on_patt = re.compile(r"Harmonic\sfrequencies\s+\(cm\*\*-1\),\sIR\sintensities.*Raman.*") normal_mode_patt = re.compile(r"\s+(\d+)\s+(\d+)\s+([0-9\.-]{4,5})\s+([0-9\.-]{4,5}).*") mo_coeff_patt = re.compile(r"Molecular Orbital Coefficients:") mo_coeff_name_patt = re.compile(r"\d+\s((\d+|\s+)\s+([a-zA-Z]{1,2}|\s+))\s+(\d+\S+)") hessian_patt = re.compile(r"Force constants in Cartesian coordinates:") resume_patt = re.compile(r"^\s1\\1\\GINC-\S*") resume_end_patt = re.compile(r"^\s.*\\\\@") bond_order_patt = re.compile(r"Wiberg bond index matrix in the NAO basis:") self.properly_terminated = False self.is_pcm = False self.stationary_type = "Minimum" self.corrections = {} self.energies = [] self.pcm = None self.errors = [] self.Mulliken_charges = {} self.link0 = {} self.cart_forces = [] self.frequencies = [] self.eigenvalues = [] self.is_spin = False self.hessian = None self.resumes = [] self.title = None self.bond_orders = {} read_coord = 0 read_mulliken = False read_eigen = False eigen_txt = [] parse_stage = 0 num_basis_found = False terminated = False parse_forces = False forces = [] parse_freq = False frequencies = [] read_mo = False parse_hessian = False routeline = "" standard_orientation = False parse_bond_order = False input_structures = list() std_structures = list() geom_orientation = None opt_structures = list() with zopen(filename) as f: for line in f: if parse_stage == 0: if start_patt.search(line): parse_stage = 1 elif link0_patt.match(line): m = link0_patt.match(line) self.link0[m.group(1)] = m.group(2) elif route_patt.search(line) or routeline != "": if set(line.strip()) == {"-"}: params = read_route_line(routeline) self.functional = params[0] self.basis_set = params[1] self.route_parameters = params[2] route_lower = {k.lower(): v for k, v in self.route_parameters.items()} self.dieze_tag = params[3] parse_stage = 1 else: routeline += line.strip() elif parse_stage == 1: if set(line.strip()) == {"-"} and self.title is None: self.title = "" elif self.title == "": self.title = line.strip() elif charge_mul_patt.search(line): m = charge_mul_patt.search(line) self.charge = int(m.group(1)) self.spin_multiplicity = int(m.group(2)) parse_stage = 2 elif parse_stage == 2: if self.is_pcm: self._check_pcm(line) if "freq" in route_lower and thermo_patt.search(line): m = thermo_patt.search(line) if m.group(1) == "Zero-point": self.corrections["Zero-point"] = float(m.group(3)) else: key = m.group(2).strip(" to ") self.corrections[key] = float(m.group(3)) if read_coord: [f.readline() for i in range(3)] line = f.readline() sp = [] coords = [] while set(line.strip()) != {"-"}: toks = line.split() sp.append(Element.from_Z(int(toks[1]))) coords.append([float(x) for x in toks[3:6]]) line = f.readline() read_coord = False if geom_orientation == "input": input_structures.append(Molecule(sp, coords)) elif geom_orientation == "standard": std_structures.append(Molecule(sp, coords)) if parse_forces: m = forces_patt.search(line) if m: forces.extend([float(_v) for _v in m.groups()[2:5]]) elif forces_off_patt.search(line): self.cart_forces.append(forces) forces = [] parse_forces = False # read molecular orbital eigenvalues if read_eigen: m = orbital_patt.search(line) if m: eigen_txt.append(line) else: read_eigen = False self.eigenvalues = {Spin.up: []} for eigenline in eigen_txt: if "Alpha" in eigenline: self.eigenvalues[Spin.up] += [float(e) for e in float_patt.findall(eigenline)] elif "Beta" in eigenline: if Spin.down not in self.eigenvalues: self.eigenvalues[Spin.down] = [] self.eigenvalues[Spin.down] += [float(e) for e in float_patt.findall(eigenline)] eigen_txt = [] # read molecular orbital coefficients if (not num_basis_found) and num_basis_func_patt.search(line): m = num_basis_func_patt.search(line) self.num_basis_func = int(m.group(1)) num_basis_found = True elif read_mo: # build a matrix with all coefficients all_spin = [Spin.up] if self.is_spin: all_spin.append(Spin.down) mat_mo = {} for spin in all_spin: mat_mo[spin] = np.zeros((self.num_basis_func, self.num_basis_func)) nMO = 0 end_mo = False while nMO < self.num_basis_func and not end_mo: f.readline() f.readline() self.atom_basis_labels = [] for i in range(self.num_basis_func): line = f.readline() # identify atom and OA labels m = mo_coeff_name_patt.search(line) if m.group(1).strip() != "": iat = int(m.group(2)) - 1 # atname = m.group(3) self.atom_basis_labels.append([m.group(4)]) else: self.atom_basis_labels[iat].append(m.group(4)) # MO coefficients coeffs = [float(c) for c in float_patt.findall(line)] for j, c in enumerate(coeffs): mat_mo[spin][i, nMO + j] = c nMO += len(coeffs) line = f.readline() # manage pop=regular case (not all MO) if nMO < self.num_basis_func and ( "Density Matrix:" in line or mo_coeff_patt.search(line) ): end_mo = True warnings.warn("POP=regular case, matrix " "coefficients not complete") f.readline() self.eigenvectors = mat_mo read_mo = False # build a more convenient array dict with MO # coefficient of each atom in each MO. # mo[Spin][OM j][atom i] = # {AO_k: coeff, AO_k: coeff ... } mo = {} for spin in all_spin: mo[spin] = [ [{} for iat in range(len(self.atom_basis_labels))] for j in range(self.num_basis_func) ] for j in range(self.num_basis_func): i = 0 for iat in range(len(self.atom_basis_labels)): for label in self.atom_basis_labels[iat]: mo[spin][j][iat][label] = self.eigenvectors[spin][i, j] i += 1 self.molecular_orbital = mo elif parse_freq: while line.strip() != "": #  blank line ifreqs = [int(val) - 1 for val in line.split()] for ifreq in ifreqs: frequencies.append( { "frequency": None, "r_mass": None, "f_constant": None, "IR_intensity": None, "symmetry": None, "mode": [], } ) # read freq, intensity, masses, symmetry ... while "Atom AN" not in line: if "Frequencies --" in line: freqs = map(float, float_patt.findall(line)) for ifreq, freq in zip(ifreqs, freqs): frequencies[ifreq]["frequency"] = freq elif "Red. masses --" in line: r_masses = map(float, float_patt.findall(line)) for ifreq, r_mass in zip(ifreqs, r_masses): frequencies[ifreq]["r_mass"] = r_mass elif "Frc consts --" in line: f_consts = map(float, float_patt.findall(line)) for ifreq, f_const in zip(ifreqs, f_consts): frequencies[ifreq]["f_constant"] = f_const elif "IR Inten --" in line: IR_intens = map(float, float_patt.findall(line)) for ifreq, intens in zip(ifreqs, IR_intens): frequencies[ifreq]["IR_intensity"] = intens else: syms = line.split()[:3] for ifreq, sym in zip(ifreqs, syms): frequencies[ifreq]["symmetry"] = sym line = f.readline() #  read normal modes line = f.readline() while normal_mode_patt.search(line): values = list(map(float, float_patt.findall(line))) for i, ifreq in zip(range(0, len(values), 3), ifreqs): frequencies[ifreq]["mode"].extend(values[i : i + 3]) line = f.readline() parse_freq = False self.frequencies.append(frequencies) frequencies = [] elif parse_hessian: #  read Hessian matrix under "Force constants in Cartesian coordinates" #  Hessian matrix is in the input orientation framework # WARNING : need #P in the route line parse_hessian = False ndf = 3 * len(input_structures[0]) self.hessian = np.zeros((ndf, ndf)) j_indices = range(5) jndf = 0 while jndf < ndf: for i in range(jndf, ndf): line = f.readline() vals = re.findall(r"\s*([+-]?\d+\.\d+[eEdD]?[+-]\d+)", line) vals = [float(val.replace("D", "E")) for val in vals] for jval, val in enumerate(vals): j = j_indices[jval] self.hessian[i, j] = val self.hessian[j, i] = val jndf += len(vals) line = f.readline() j_indices = [j + 5 for j in j_indices] elif parse_bond_order: # parse Wiberg bond order line = f.readline() line = f.readline() nat = len(input_structures[0]) matrix = list() for iat in range(nat): line = f.readline() matrix.append([float(v) for v in line.split()[2:]]) self.bond_orders = dict() for iat in range(nat): for jat in range(iat + 1, nat): self.bond_orders[(iat, jat)] = matrix[iat][jat] parse_bond_order = False elif termination_patt.search(line): m = termination_patt.search(line) if m.group(1) == "Normal": self.properly_terminated = True terminated = True elif error_patt.search(line): error_defs = { "! Non-Optimized Parameters !": "Optimization " "error", "Convergence failure": "SCF convergence error", } m = error_patt.search(line) self.errors.append(error_defs[m.group(1)]) elif num_elec_patt.search(line): m = num_elec_patt.search(line) self.electrons = (int(m.group(1)), int(m.group(2))) elif (not self.is_pcm) and pcm_patt.search(line): self.is_pcm = True self.pcm = {} elif "freq" in route_lower and "opt" in route_lower and stat_type_patt.search(line): self.stationary_type = "Saddle" elif mp2_patt.search(line): m = mp2_patt.search(line) self.energies.append(float(m.group(1).replace("D", "E"))) elif oniom_patt.search(line): m = oniom_patt.matcher(line) self.energies.append(float(m.group(1))) elif scf_patt.search(line): m = scf_patt.search(line) self.energies.append(float(m.group(1))) elif std_orientation_patt.search(line): standard_orientation = True geom_orientation = "standard" read_coord = True elif input_orientation_patt.search(line): geom_orientation = "input" read_coord = True elif "Optimization completed." in line: line = f.readline() if " -- Stationary point found." not in line: warnings.warn( "\n" + self.filename + ": Optimization complete but this is not a stationary point" ) if standard_orientation: opt_structures.append(std_structures[-1]) else: opt_structures.append(input_structures[-1]) elif not read_eigen and orbital_patt.search(line): eigen_txt.append(line) read_eigen = True elif mulliken_patt.search(line): mulliken_txt = [] read_mulliken = True elif not parse_forces and forces_on_patt.search(line): parse_forces = True elif freq_on_patt.search(line): parse_freq = True [f.readline() for i in range(3)] elif mo_coeff_patt.search(line): if "Alpha" in line: self.is_spin = True read_mo = True elif hessian_patt.search(line): parse_hessian = True elif resume_patt.search(line): resume = [] while not resume_end_patt.search(line): resume.append(line) line = f.readline() #  security if \\@ not in one line ! if line == "\n": break resume.append(line) resume = "".join([r.strip() for r in resume]) self.resumes.append(resume) elif bond_order_patt.search(line): parse_bond_order = True if read_mulliken: if not end_mulliken_patt.search(line): mulliken_txt.append(line) else: m = end_mulliken_patt.search(line) mulliken_charges = {} for line in mulliken_txt: if mulliken_charge_patt.search(line): m = mulliken_charge_patt.search(line) dic = {int(m.group(1)): [m.group(2), float(m.group(3))]} mulliken_charges.update(dic) read_mulliken = False self.Mulliken_charges = mulliken_charges # store the structures. If symmetry is considered, the standard orientation # is used. Else the input orientation is used. if standard_orientation: self.structures = std_structures self.structures_input_orientation = input_structures else: self.structures = input_structures self.structures_input_orientation = input_structures # store optimized structure in input orientation self.opt_structures = opt_structures if not terminated: warnings.warn("\n" + self.filename + ": Termination error or bad Gaussian output file !") def _check_pcm(self, line): energy_patt = re.compile(r"(Dispersion|Cavitation|Repulsion) energy" r"\s+\S+\s+=\s+(\S*)") total_patt = re.compile(r"with all non electrostatic terms\s+\S+\s+" r"=\s+(\S*)") parameter_patt = re.compile(r"(Eps|Numeral density|RSolv|Eps" r"\(inf[inity]*\))\s+=\s*(\S*)") if energy_patt.search(line): m = energy_patt.search(line) self.pcm["{} energy".format(m.group(1))] = float(m.group(2)) elif total_patt.search(line): m = total_patt.search(line) self.pcm["Total energy"] = float(m.group(1)) elif parameter_patt.search(line): m = parameter_patt.search(line) self.pcm[m.group(1)] = float(m.group(2)) def as_dict(self): """ Json-serializable dict representation. """ structure = self.final_structure d = { "has_gaussian_completed": self.properly_terminated, "nsites": len(structure), } comp = structure.composition d["unit_cell_formula"] = comp.as_dict() d["reduced_cell_formula"] = Composition(comp.reduced_formula).as_dict() d["pretty_formula"] = comp.reduced_formula d["is_pcm"] = self.is_pcm d["errors"] = self.errors d["Mulliken_charges"] = self.Mulliken_charges unique_symbols = sorted(list(d["unit_cell_formula"].keys())) d["elements"] = unique_symbols d["nelements"] = len(unique_symbols) d["charge"] = self.charge d["spin_multiplicity"] = self.spin_multiplicity vin = { "route": self.route_parameters, "functional": self.functional, "basis_set": self.basis_set, "nbasisfunctions": self.num_basis_func, "pcm_parameters": self.pcm, } d["input"] = vin nsites = len(self.final_structure) vout = { "energies": self.energies, "final_energy": self.final_energy, "final_energy_per_atom": self.final_energy / nsites, "molecule": structure.as_dict(), "stationary_type": self.stationary_type, "corrections": self.corrections, } d["output"] = vout d["@module"] = self.__class__.__module__ d["@class"] = self.__class__.__name__ return d def read_scan(self): """ Read a potential energy surface from a gaussian scan calculation. Returns: A dict: {"energies": [ values ], "coords": {"d1": [ values ], "A2", [ values ], ... }} "energies" are the energies of all points of the potential energy surface. "coords" are the internal coordinates used to compute the potential energy surface and the internal coordinates optimized, labelled by their name as defined in the calculation. """ def floatList(l): """return a list of float from a list of string""" return [float(v) for v in l] scan_patt = re.compile(r"^\sSummary of the potential surface scan:") optscan_patt = re.compile(r"^\sSummary of Optimized Potential Surface Scan") coord_patt = re.compile(r"^\s*(\w+)((\s*[+-]?\d+\.\d+)+)") # data dict return data = {"energies": list(), "coords": dict()} # read in file with zopen(self.filename, "r") as f: line = f.readline() while line != "": if optscan_patt.match(line): f.readline() line = f.readline() endScan = False while not endScan: data["energies"] += floatList(float_patt.findall(line)) line = f.readline() while coord_patt.match(line): icname = line.split()[0].strip() if icname in data["coords"]: data["coords"][icname] += floatList(float_patt.findall(line)) else: data["coords"][icname] = floatList(float_patt.findall(line)) line = f.readline() if not re.search(r"^\s+((\s*\d+)+)", line): endScan = True else: line = f.readline() elif scan_patt.match(line): line = f.readline() data["coords"] = {icname: list() for icname in line.split()[1:-1]} f.readline() line = f.readline() while not re.search(r"^\s-+", line): values = floatList(line.split()) data["energies"].append(values[-1]) for i, icname in enumerate(data["coords"]): data["coords"][icname].append(values[i + 1]) line = f.readline() else: line = f.readline() return data def get_scan_plot(self, coords=None): """ Get a matplotlib plot of the potential energy surface. Args: coords: internal coordinate name to use as abcissa. """ from pymatgen.util.plotting import pretty_plot plt = pretty_plot(12, 8) d = self.read_scan() if coords and coords in d["coords"]: x = d["coords"][coords] plt.xlabel(coords) else: x = range(len(d["energies"])) plt.xlabel("points") plt.ylabel("Energy (eV)") e_min = min(d["energies"]) y = [(e - e_min) * Ha_to_eV for e in d["energies"]] plt.plot(x, y, "ro--") return plt def save_scan_plot(self, filename="scan.pdf", img_format="pdf", coords=None): """ Save matplotlib plot of the potential energy surface to a file. Args: filename: Filename to write to. img_format: Image format to use. Defaults to EPS. coords: internal coordinate name to use as abcissa. """ plt = self.get_scan_plot(coords) plt.savefig(filename, format=img_format) def read_excitation_energies(self): """ Read a excitation energies after a TD-DFT calculation. Returns: A list: A list of tuple for each transition such as [(energie (eV), lambda (nm), oscillatory strength), ... ] """ transitions = list() # read in file with zopen(self.filename, "r") as f: line = f.readline() td = False while line != "": if re.search(r"^\sExcitation energies and oscillator strengths:", line): td = True if td: if re.search(r"^\sExcited State\s*\d", line): val = [float(v) for v in float_patt.findall(line)] transitions.append(tuple(val[0:3])) line = f.readline() return transitions def get_spectre_plot(self, sigma=0.05, step=0.01): """ Get a matplotlib plot of the UV-visible xas. Transition are plotted as vertical lines and as a sum of normal functions with sigma with. The broadening is applied in energy and the xas is plotted as a function of the wavelength. Args: sigma: Full width at half maximum in eV for normal functions. step: bin interval in eV Returns: A dict: {"energies": values, "lambda": values, "xas": values} where values are lists of abscissa (energies, lamba) and the sum of gaussian functions (xas). A matplotlib plot. """ from scipy.stats import norm from pymatgen.util.plotting import pretty_plot plt = pretty_plot(12, 8) transitions = self.read_excitation_energies() minval = min([val[0] for val in transitions]) - 5.0 * sigma maxval = max([val[0] for val in transitions]) + 5.0 * sigma npts = int((maxval - minval) / step) + 1 eneval = np.linspace(minval, maxval, npts) # in eV lambdaval = [cst.h * cst.c / (val * cst.e) * 1.0e9 for val in eneval] # in nm # sum of gaussian functions spectre = np.zeros(npts) for trans in transitions: spectre += trans[2] * norm(eneval, trans[0], sigma) spectre /= spectre.max() plt.plot(lambdaval, spectre, "r-", label="spectre") data = {"energies": eneval, "lambda": lambdaval, "xas": spectre} # plot transitions as vlines plt.vlines( [val[1] for val in transitions], 0.0, [val[2] for val in transitions], color="blue", label="transitions", linewidth=2, ) plt.xlabel("$\\lambda$ (nm)") plt.ylabel("Arbitrary unit") plt.legend() return data, plt def save_spectre_plot(self, filename="spectre.pdf", img_format="pdf", sigma=0.05, step=0.01): """ Save matplotlib plot of the spectre to a file. Args: filename: Filename to write to. img_format: Image format to use. Defaults to EPS. sigma: Full width at half maximum in eV for normal functions. step: bin interval in eV """ d, plt = self.get_spectre_plot(sigma, step) plt.savefig(filename, format=img_format) def to_input( self, mol=None, charge=None, spin_multiplicity=None, title=None, functional=None, basis_set=None, route_parameters=None, input_parameters=None, link0_parameters=None, dieze_tag=None, cart_coords=False, ): """ Create a new input object using by default the last geometry read in the output file and with the same calculation parameters. Arguments are the same as GaussianInput class. Returns gaunip (GaussianInput) : the gaussian input object """ if not mol: mol = self.final_structure if charge is None: charge = self.charge if spin_multiplicity is None: spin_multiplicity = self.spin_multiplicity if not title: title = self.title if not functional: functional = self.functional if not basis_set: basis_set = self.basis_set if not route_parameters: route_parameters = self.route_parameters if not link0_parameters: link0_parameters = self.link0 if not dieze_tag: dieze_tag = self.dieze_tag return GaussianInput( mol=mol, charge=charge, spin_multiplicity=spin_multiplicity, title=title, functional=functional, basis_set=basis_set, route_parameters=route_parameters, input_parameters=input_parameters, link0_parameters=link0_parameters, dieze_tag=dieze_tag, )
mit
[ 3, 2803, 26, 2774, 13, 24, 199, 3, 1898, 334, 67, 9, 1611, 30649, 15290, 11682, 14, 199, 3, 17484, 1334, 314, 2895, 402, 314, 10697, 844, 14, 199, 199, 624, 199, 2765, 859, 9031, 1324, 436, 1072, 6661, 687, 17131, 14, 199, 624, 199, 199, 646, 295, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 5559, 465, 286, 270, 199, 504, 3485, 369, 14, 2308, 492, 1315, 1490, 199, 199, 504, 1134, 30649, 14, 1018, 14, 13000, 492, 27506, 1588, 199, 504, 1134, 30649, 14, 1018, 14, 20339, 63, 1224, 492, 6566, 199, 504, 1134, 30649, 14, 1018, 14, 6976, 492, 3930, 14413, 199, 504, 1134, 30649, 14, 1018, 14, 8170, 492, 5515, 596, 4619, 199, 504, 1134, 30649, 14, 1018, 14, 5260, 492, 869, 65, 63, 475, 63, 27786, 199, 504, 1134, 30649, 14, 30169, 530, 63, 6976, 14, 1018, 492, 428, 7751, 199, 504, 1134, 30649, 14, 1974, 14, 7988, 492, 664, 63, 4593, 199, 199, 363, 2502, 363, 275, 298, 2662, 89, 310, 510, 316, 593, 2753, 12, 22261, 973, 221, 428, 279, 86, 11318, 13, 54, 452, 422, 2033, 12, 1323, 262, 2799, 287, 2, 199, 363, 7307, 363, 275, 298, 7384, 6171, 12, 710, 26570, 83, 13311, 16871, 2, 199, 363, 1023, 363, 275, 298, 16, 14, 17, 2, 199, 363, 26665, 363, 275, 298, 2662, 89, 310, 510, 316, 593, 2753, 2, 199, 363, 2123, 363, 275, 298, 12358, 80, 32, 947, 3893, 14, 8654, 2, 199, 363, 602, 363, 275, 298, 24, 15, 17, 15, 1046, 2, 421, 199, 1609, 63, 80, 6796, 275, 295, 14, 2014, 8, 82, 3212, 83, 10, 779, 16341, 22426, 68, 23294, 68, 11, 6320, 421, 199, 318, 1586, 63, 4449, 63, 604, 8, 4449, 304, 272, 408, 272, 1586, 7475, 1004, 315, 28912, 1324, 15, 1199, 436, 372, 22380, 5597, 63, 409, 272, 436, 282, 2600, 402, 1163, 7475, 2633, 339, 3033, 26, 267, 7475, 334, 495, 9, 520, 314, 7475, 1004, 339, 372, 267, 22380, 334, 495, 9, 520, 314, 1083, 334, 25500, 12, 510, 6773, 19172, 267, 5597, 63, 409, 334, 495, 9, 520, 314, 5597, 663, 267, 7475, 334, 807, 9, 520, 2600, 402, 2633, 272, 408, 272, 19270, 70, 63, 80, 6796, 275, 295, 14, 2014, 8, 82, 16136, 779, 83, 51, 1527, 67, 35, 1527, 82, 50, 1527, 70, 38, 27147, 83, 23440, 83, 5830, 6977, 6320, 272, 3510, 63, 1162, 63, 80, 6796, 275, 295, 14, 2014, 8, 82, 16136, 779, 33, 13, 90, 2807, 59, 16, 13, 25, 3672, 2788, 60, 83, 29, 24621, 1332, 2795, 2862, 9, 22550, 272, 22380, 275, 488, 272, 5597, 63, 409, 275, 488, 272, 7475, 63, 1162, 275, 1052, 272, 18833, 806, 63, 1450, 275, 488, 272, 340, 7475, 26, 267, 340, 10609, 315, 7475, 26, 288, 8431, 275, 7475, 14, 1294, 19031, 288, 22380, 275, 8431, 59, 16, 1055, 1294, 19105, 17, 61, 288, 5597, 63, 409, 275, 8431, 59, 17, 1055, 1294, 3430, 16, 61, 288, 367, 8431, 315, 359, 15481, 12, 5597, 63, 409, 12, 3286, 6229, 355, 7475, 275, 7475, 14, 1814, 8, 9305, 12, 6899, 398, 367, 8431, 315, 7475, 14, 1294, 837, 288, 340, 19270, 70, 63, 80, 6796, 14, 1431, 8, 9305, 304, 355, 333, 275, 19270, 70, 63, 80, 6796, 14, 1431, 8, 9305, 9, 355, 7475, 63, 1162, 59, 77, 14, 923, 8, 17, 1874, 275, 333, 14, 923, 8, 18, 9, 288, 916, 8431, 14, 4142, 342, 315, 2097, 3, 401, 5426, 46, 401, 5426, 48, 401, 5426, 52, 6229, 355, 327, 1630, 440, 3877, 327, 315, 7475, 370, 5126, 1125, 315, 1324, 355, 340, 8431, 508, 5426, 582, 490, 18833, 806, 63, 1450, 275, 5426, 46, 2, 355, 587, 26, 490, 18833, 806, 63, 1450, 275, 8431, 355, 1980, 288, 587, 26, 355, 333, 275, 295, 14, 1431, 8, 3029, 63, 1162, 63, 80, 6796, 12, 8431, 14, 1913, 10064, 2237, 355, 340, 333, 26, 490, 30903, 275, 1052, 490, 367, 623, 315, 333, 14, 923, 8, 18, 680, 1294, 8, 2266, 304, 717, 299, 275, 623, 14, 1294, 480, 23758, 717, 30903, 59, 80, 59, 16, 2677, 275, 488, 340, 822, 8, 80, 9, 508, 413, 587, 299, 59, 17, 61, 490, 7475, 63, 1162, 59, 77, 14, 923, 8, 17, 1874, 275, 30903, 355, 587, 26, 490, 366, 275, 8431, 14, 1913, 10064, 3471, 1294, 480, 23758, 490, 7475, 63, 1162, 59, 68, 59, 16, 2677, 275, 488, 340, 822, 8, 68, 9, 508, 413, 587, 366, 59, 17, 61, 339, 372, 22380, 12, 5597, 63, 409, 12, 7475, 63, 1162, 12, 18833, 806, 63, 1450, 421, 199, 533, 17131, 3205, 26, 272, 408, 272, 1626, 909, 6144, 282, 17131, 1324, 570, 14, 272, 408, 339, 327, 7046, 2118, 1202, 5163, 7970, 272, 485, 90, 569, 63, 80, 6796, 275, 295, 14, 2014, 8, 82, 16136, 2961, 87, 11, 3342, 16510, 83, 12, 2807, 2961, 87, 11, 2788, 60, 83, 12, 2807, 2961, 87, 11, 19198, 7023, 2696, 3134, 83, 4202, 87, 3672, 22550, 272, 485, 8568, 63, 80, 6796, 275, 295, 14, 2014, 8, 82, 16136, 2961, 87, 11, 2788, 60, 83, 12, 2807, 16510, 68, 4537, 20565, 16185, 2807, 2788, 60, 83, 12, 2807, 16510, 68, 4537, 20565, 16185, 2807, 2788, 60, 83, 12, 2807, 2, 519, 2, 16510, 68, 4537, 20565, 16185, 2807, 2788, 60, 2696, 3134, 83, 4202, 87, 14, 3672, 22550, 339, 347, 636, 826, 721, 267, 291, 12, 267, 22956, 12, 267, 11204, 29, 403, 12, 267, 20749, 63, 8016, 20976, 29, 403, 12, 267, 2538, 29, 403, 12, 267, 22380, 628, 25500, 401, 267, 5597, 63, 409, 628, 22, 13, 2192, 39, 8, 68, 4186, 267, 7475, 63, 3214, 29, 403, 12, 267, 1324, 63, 3214, 29, 403, 12, 267, 2142, 16, 63, 3214, 29, 403, 12, 267, 18833, 806, 63, 1450, 13476, 48, 401, 267, 3805, 63, 19220, 29, 403, 12, 272, 3461, 267, 408, 267, 3033, 26, 288, 22956, 26, 6924, 26350, 14, 2779, 883, 1902, 506, 282, 3930, 14413, 909, 12, 355, 282, 1059, 15131, 314, 3400, 315, 282, 1475, 3748, 701, 12436, 2608, 290, 12, 355, 503, 1124 ]
[ 2803, 26, 2774, 13, 24, 199, 3, 1898, 334, 67, 9, 1611, 30649, 15290, 11682, 14, 199, 3, 17484, 1334, 314, 2895, 402, 314, 10697, 844, 14, 199, 199, 624, 199, 2765, 859, 9031, 1324, 436, 1072, 6661, 687, 17131, 14, 199, 624, 199, 199, 646, 295, 199, 646, 3598, 199, 199, 646, 2680, 465, 980, 199, 646, 7026, 14, 5559, 465, 286, 270, 199, 504, 3485, 369, 14, 2308, 492, 1315, 1490, 199, 199, 504, 1134, 30649, 14, 1018, 14, 13000, 492, 27506, 1588, 199, 504, 1134, 30649, 14, 1018, 14, 20339, 63, 1224, 492, 6566, 199, 504, 1134, 30649, 14, 1018, 14, 6976, 492, 3930, 14413, 199, 504, 1134, 30649, 14, 1018, 14, 8170, 492, 5515, 596, 4619, 199, 504, 1134, 30649, 14, 1018, 14, 5260, 492, 869, 65, 63, 475, 63, 27786, 199, 504, 1134, 30649, 14, 30169, 530, 63, 6976, 14, 1018, 492, 428, 7751, 199, 504, 1134, 30649, 14, 1974, 14, 7988, 492, 664, 63, 4593, 199, 199, 363, 2502, 363, 275, 298, 2662, 89, 310, 510, 316, 593, 2753, 12, 22261, 973, 221, 428, 279, 86, 11318, 13, 54, 452, 422, 2033, 12, 1323, 262, 2799, 287, 2, 199, 363, 7307, 363, 275, 298, 7384, 6171, 12, 710, 26570, 83, 13311, 16871, 2, 199, 363, 1023, 363, 275, 298, 16, 14, 17, 2, 199, 363, 26665, 363, 275, 298, 2662, 89, 310, 510, 316, 593, 2753, 2, 199, 363, 2123, 363, 275, 298, 12358, 80, 32, 947, 3893, 14, 8654, 2, 199, 363, 602, 363, 275, 298, 24, 15, 17, 15, 1046, 2, 421, 199, 1609, 63, 80, 6796, 275, 295, 14, 2014, 8, 82, 3212, 83, 10, 779, 16341, 22426, 68, 23294, 68, 11, 6320, 421, 199, 318, 1586, 63, 4449, 63, 604, 8, 4449, 304, 272, 408, 272, 1586, 7475, 1004, 315, 28912, 1324, 15, 1199, 436, 372, 22380, 5597, 63, 409, 272, 436, 282, 2600, 402, 1163, 7475, 2633, 339, 3033, 26, 267, 7475, 334, 495, 9, 520, 314, 7475, 1004, 339, 372, 267, 22380, 334, 495, 9, 520, 314, 1083, 334, 25500, 12, 510, 6773, 19172, 267, 5597, 63, 409, 334, 495, 9, 520, 314, 5597, 663, 267, 7475, 334, 807, 9, 520, 2600, 402, 2633, 272, 408, 272, 19270, 70, 63, 80, 6796, 275, 295, 14, 2014, 8, 82, 16136, 779, 83, 51, 1527, 67, 35, 1527, 82, 50, 1527, 70, 38, 27147, 83, 23440, 83, 5830, 6977, 6320, 272, 3510, 63, 1162, 63, 80, 6796, 275, 295, 14, 2014, 8, 82, 16136, 779, 33, 13, 90, 2807, 59, 16, 13, 25, 3672, 2788, 60, 83, 29, 24621, 1332, 2795, 2862, 9, 22550, 272, 22380, 275, 488, 272, 5597, 63, 409, 275, 488, 272, 7475, 63, 1162, 275, 1052, 272, 18833, 806, 63, 1450, 275, 488, 272, 340, 7475, 26, 267, 340, 10609, 315, 7475, 26, 288, 8431, 275, 7475, 14, 1294, 19031, 288, 22380, 275, 8431, 59, 16, 1055, 1294, 19105, 17, 61, 288, 5597, 63, 409, 275, 8431, 59, 17, 1055, 1294, 3430, 16, 61, 288, 367, 8431, 315, 359, 15481, 12, 5597, 63, 409, 12, 3286, 6229, 355, 7475, 275, 7475, 14, 1814, 8, 9305, 12, 6899, 398, 367, 8431, 315, 7475, 14, 1294, 837, 288, 340, 19270, 70, 63, 80, 6796, 14, 1431, 8, 9305, 304, 355, 333, 275, 19270, 70, 63, 80, 6796, 14, 1431, 8, 9305, 9, 355, 7475, 63, 1162, 59, 77, 14, 923, 8, 17, 1874, 275, 333, 14, 923, 8, 18, 9, 288, 916, 8431, 14, 4142, 342, 315, 2097, 3, 401, 5426, 46, 401, 5426, 48, 401, 5426, 52, 6229, 355, 327, 1630, 440, 3877, 327, 315, 7475, 370, 5126, 1125, 315, 1324, 355, 340, 8431, 508, 5426, 582, 490, 18833, 806, 63, 1450, 275, 5426, 46, 2, 355, 587, 26, 490, 18833, 806, 63, 1450, 275, 8431, 355, 1980, 288, 587, 26, 355, 333, 275, 295, 14, 1431, 8, 3029, 63, 1162, 63, 80, 6796, 12, 8431, 14, 1913, 10064, 2237, 355, 340, 333, 26, 490, 30903, 275, 1052, 490, 367, 623, 315, 333, 14, 923, 8, 18, 680, 1294, 8, 2266, 304, 717, 299, 275, 623, 14, 1294, 480, 23758, 717, 30903, 59, 80, 59, 16, 2677, 275, 488, 340, 822, 8, 80, 9, 508, 413, 587, 299, 59, 17, 61, 490, 7475, 63, 1162, 59, 77, 14, 923, 8, 17, 1874, 275, 30903, 355, 587, 26, 490, 366, 275, 8431, 14, 1913, 10064, 3471, 1294, 480, 23758, 490, 7475, 63, 1162, 59, 68, 59, 16, 2677, 275, 488, 340, 822, 8, 68, 9, 508, 413, 587, 366, 59, 17, 61, 339, 372, 22380, 12, 5597, 63, 409, 12, 7475, 63, 1162, 12, 18833, 806, 63, 1450, 421, 199, 533, 17131, 3205, 26, 272, 408, 272, 1626, 909, 6144, 282, 17131, 1324, 570, 14, 272, 408, 339, 327, 7046, 2118, 1202, 5163, 7970, 272, 485, 90, 569, 63, 80, 6796, 275, 295, 14, 2014, 8, 82, 16136, 2961, 87, 11, 3342, 16510, 83, 12, 2807, 2961, 87, 11, 2788, 60, 83, 12, 2807, 2961, 87, 11, 19198, 7023, 2696, 3134, 83, 4202, 87, 3672, 22550, 272, 485, 8568, 63, 80, 6796, 275, 295, 14, 2014, 8, 82, 16136, 2961, 87, 11, 2788, 60, 83, 12, 2807, 16510, 68, 4537, 20565, 16185, 2807, 2788, 60, 83, 12, 2807, 16510, 68, 4537, 20565, 16185, 2807, 2788, 60, 83, 12, 2807, 2, 519, 2, 16510, 68, 4537, 20565, 16185, 2807, 2788, 60, 2696, 3134, 83, 4202, 87, 14, 3672, 22550, 339, 347, 636, 826, 721, 267, 291, 12, 267, 22956, 12, 267, 11204, 29, 403, 12, 267, 20749, 63, 8016, 20976, 29, 403, 12, 267, 2538, 29, 403, 12, 267, 22380, 628, 25500, 401, 267, 5597, 63, 409, 628, 22, 13, 2192, 39, 8, 68, 4186, 267, 7475, 63, 3214, 29, 403, 12, 267, 1324, 63, 3214, 29, 403, 12, 267, 2142, 16, 63, 3214, 29, 403, 12, 267, 18833, 806, 63, 1450, 13476, 48, 401, 267, 3805, 63, 19220, 29, 403, 12, 272, 3461, 267, 408, 267, 3033, 26, 288, 22956, 26, 6924, 26350, 14, 2779, 883, 1902, 506, 282, 3930, 14413, 909, 12, 355, 282, 1059, 15131, 314, 3400, 315, 282, 1475, 3748, 701, 12436, 2608, 290, 12, 355, 503, 1124, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
orbitfp7/nova
nova/cmd/conductor.py
2
1558
# 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. """Starter script for Nova Conductor.""" import sys from oslo_concurrency import processutils from oslo_config import cfg from nova import config from nova import objects from nova.openstack.common import log as logging from nova.openstack.common.report import guru_meditation_report as gmr from nova import service from nova import utils from nova import version CONF = cfg.CONF CONF.import_opt('topic', 'nova.conductor.api', group='conductor') def main(): config.parse_args(sys.argv) logging.setup("nova") utils.monkey_patch() objects.register_all() gmr.TextGuruMeditation.setup_autorun(version) server = service.Service.create(binary='nova-conductor', topic=CONF.conductor.topic, manager=CONF.conductor.manager) workers = CONF.conductor.workers or processutils.get_worker_count() service.serve(server, workers=workers) service.wait()
apache-2.0
[ 3, 259, 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, 624, 933, 16972, 2884, 367, 28184, 1448, 19966, 1041, 199, 199, 646, 984, 199, 199, 504, 11258, 63, 27518, 492, 2112, 1208, 199, 504, 11258, 63, 888, 492, 4810, 199, 199, 504, 5913, 492, 1101, 199, 504, 5913, 492, 2251, 199, 504, 5913, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 5913, 14, 8512, 14, 2330, 14, 3070, 492, 486, 300, 85, 63, 278, 1741, 425, 63, 3070, 465, 486, 13118, 199, 504, 5913, 492, 2435, 199, 504, 5913, 492, 3778, 199, 504, 5913, 492, 1015, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 646, 63, 2992, 360, 5746, 297, 283, 6765, 14, 28678, 14, 1246, 297, 1572, 534, 28678, 358, 421, 199, 318, 2446, 837, 272, 1101, 14, 1122, 63, 589, 8, 1274, 14, 3020, 9, 272, 2050, 14, 2758, 480, 6765, 531, 272, 3778, 14, 20372, 63, 2068, 342, 272, 2251, 14, 2683, 63, 452, 342, 339, 486, 13118, 14, 1872, 39, 300, 85, 1352, 1741, 425, 14, 2758, 63, 65, 4139, 324, 8, 1023, 9, 339, 1654, 275, 2435, 14, 3167, 14, 981, 8, 3008, 534, 6765, 13, 28678, 297, 2511, 7482, 29, 3103, 14, 28678, 14, 5746, 12, 2511, 5256, 29, 3103, 14, 28678, 14, 2609, 9, 272, 14123, 275, 6392, 14, 28678, 14, 11009, 503, 2112, 1208, 14, 362, 63, 6599, 63, 835, 342, 272, 2435, 14, 4909, 8, 1000, 12, 14123, 29, 11009, 9, 272, 2435, 14, 2573, 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 ]
[ 259, 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, 624, 933, 16972, 2884, 367, 28184, 1448, 19966, 1041, 199, 199, 646, 984, 199, 199, 504, 11258, 63, 27518, 492, 2112, 1208, 199, 504, 11258, 63, 888, 492, 4810, 199, 199, 504, 5913, 492, 1101, 199, 504, 5913, 492, 2251, 199, 504, 5913, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 5913, 14, 8512, 14, 2330, 14, 3070, 492, 486, 300, 85, 63, 278, 1741, 425, 63, 3070, 465, 486, 13118, 199, 504, 5913, 492, 2435, 199, 504, 5913, 492, 3778, 199, 504, 5913, 492, 1015, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 646, 63, 2992, 360, 5746, 297, 283, 6765, 14, 28678, 14, 1246, 297, 1572, 534, 28678, 358, 421, 199, 318, 2446, 837, 272, 1101, 14, 1122, 63, 589, 8, 1274, 14, 3020, 9, 272, 2050, 14, 2758, 480, 6765, 531, 272, 3778, 14, 20372, 63, 2068, 342, 272, 2251, 14, 2683, 63, 452, 342, 339, 486, 13118, 14, 1872, 39, 300, 85, 1352, 1741, 425, 14, 2758, 63, 65, 4139, 324, 8, 1023, 9, 339, 1654, 275, 2435, 14, 3167, 14, 981, 8, 3008, 534, 6765, 13, 28678, 297, 2511, 7482, 29, 3103, 14, 28678, 14, 5746, 12, 2511, 5256, 29, 3103, 14, 28678, 14, 2609, 9, 272, 14123, 275, 6392, 14, 28678, 14, 11009, 503, 2112, 1208, 14, 362, 63, 6599, 63, 835, 342, 272, 2435, 14, 4909, 8, 1000, 12, 14123, 29, 11009, 9, 272, 2435, 14, 2573, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tripathi62674/flask
docs/conf.py
140
9573
# -*- coding: utf-8 -*- # # Flask documentation build configuration file, created by # sphinx-quickstart on Tue Apr 6 15:24:58 2010. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.append(os.path.abspath('_themes')) sys.path.append(os.path.abspath('.')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'flaskdocext'] # 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'Flask' copyright = u'2015, Armin Ronacher' # 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. import pkg_resources try: release = pkg_resources.get_distribution('Flask').version except pkg_resources.DistributionNotFound: print 'To build the documentation, The distribution information of Flask' print 'Has to be available. Either install the package into your' print 'development environment or run "setup.py develop" to setup the' print 'metadata. A virtualenv is recommended!' sys.exit(1) del pkg_resources if 'dev' in release: release = release.split('dev')[0] + 'dev' version = '.'.join(release.split('.')[:2]) # 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 # 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 = 'flask' # 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 = { 'touch_icon': 'touch-icon.png' } # Add any paths that contain custom themes here, relative to this directory. html_theme_path = ['_themes'] # 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. Do not set, template magic! #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 = "flask-favicon.ico" # 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 = { 'index': ['sidebarintro.html', 'sourcelink.html', 'searchbox.html'], '**': ['sidebarlogo.html', 'localtoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html'] } # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. html_use_modindex = False # 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 = False # 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 = '' # 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 = 'Flaskdoc' # -- Options for LaTeX output -------------------------------------------------- # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('latexindex', 'Flask.tex', u'Flask Documentation', u'Armin Ronacher', 'manual'), ] # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. latex_use_modindex = False latex_elements = { 'fontpkg': r'\usepackage{mathpazo}', 'papersize': 'a4paper', 'pointsize': '12pt', 'preamble': r'\usepackage{flaskstyle}' } latex_use_parts = True latex_additional_files = ['flaskstyle.sty', 'logo.pdf'] # -- Options for Epub output --------------------------------------------------- # Bibliographic Dublin Core info. #epub_title = '' #epub_author = '' #epub_publisher = '' #epub_copyright = '' # The language of the text. It defaults to the language option # or en if the language is not set. #epub_language = '' # The scheme of the identifier. Typical schemes are ISBN or URL. #epub_scheme = '' # The unique identifier of the text. This can be a ISBN number # or the project homepage. #epub_identifier = '' # A unique identification for the text. #epub_uid = '' # HTML files that should be inserted before the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_pre_files = [] # HTML files shat should be inserted after the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_post_files = [] # A list of files that should not be packed into the epub file. #epub_exclude_files = [] # The depth of the table of contents in toc.ncx. #epub_tocdepth = 3 intersphinx_mapping = { 'https://docs.python.org/dev': None, 'http://werkzeug.pocoo.org/docs/': None, 'http://click.pocoo.org/': None, 'http://jinja.pocoo.org/docs/': None, 'http://www.sqlalchemy.org/docs/': None, 'https://wtforms.readthedocs.org/en/latest/': None, 'https://pythonhosted.org/blinker/': None } pygments_style = 'flask_theme_support.FlaskyStyle' # fall back if theme is not there try: __import__('flask_theme_support') except ImportError, e: print '-' * 74 print 'Warning: Flask themes unavailable. Building with default theme' print 'If you want the Flask themes, run this command and build again:' print print ' git submodule update --init' print '-' * 74 pygments_style = 'tango' html_theme = 'default' html_theme_options = {} # unwrap decorators def unwrap_decorators(): import sphinx.util.inspect as inspect import functools old_getargspec = inspect.getargspec def getargspec(x): return old_getargspec(getattr(x, '_original_function', x)) inspect.getargspec = getargspec old_update_wrapper = functools.update_wrapper def update_wrapper(wrapper, wrapped, *a, **kw): rv = old_update_wrapper(wrapper, wrapped, *a, **kw) rv._original_function = wrapped return rv functools.update_wrapper = update_wrapper unwrap_decorators() del unwrap_decorators
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 16704, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 437, 2700, 221, 1227, 4114, 26, 1194, 26, 2010, 7129, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 6412, 23900, 1333, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 1058, 8008, 297, 1598, 283, 15720, 1117, 301, 400, 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, 14182, 7, 199, 7307, 275, 399, 7, 7806, 12, 1952, 827, 32472, 19728, 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, 646, 5496, 63, 4435, 199, 893, 26, 272, 4683, 275, 5496, 63, 4435, 14, 362, 63, 4972, 360, 14182, 1959, 1023, 199, 2590, 5496, 63, 4435, 14, 8580, 4667, 26, 272, 870, 283, 1378, 1900, 314, 3794, 12, 710, 4084, 2556, 402, 16704, 7, 272, 870, 283, 6362, 370, 506, 2808, 14, 221, 13083, 3907, 314, 2559, 1901, 2195, 7, 272, 870, 283, 31688, 3734, 503, 1255, 298, 2758, 14, 647, 477, 7549, 2, 370, 3272, 314, 7, 272, 870, 283, 2343, 14, 221, 437, 19128, 365, 14318, 11213, 272, 984, 14, 2224, 8, 17, 9, 199, 2264, 5496, 63, 4435, 199, 199, 692, 283, 2374, 7, 315, 4683, 26, 272, 4683, 275, 4683, 14, 1294, 360, 2374, 5832, 16, 61, 435, 283, 2374, 7, 199, 1023, 275, 15671, 904, 8, 3221, 14, 1294, 7563, 1491, 18, 566, 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, 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, 1360, 63, 7915, 275, 283, 15720, 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, 1360, 63, 7915, 63, 1419, 275, 469, 272, 283, 12376, 63, 4677, 356, 257, 283, 12376, 13, 4677, 14, 4524, 7, 199, 93, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 1360, 63, 7915, 63, 515, 275, 4044, 23900, 418, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 16704, 3794, 1900, 2897, 570, 12, 2737, 701, 199, 3, 15882, 13, 28957, 641, 377, 310, 437, 2700, 221, 1227, 4114, 26, 1194, 26, 2010, 7129, 14, 199, 3, 199, 3, 961, 570, 365, 22711, 342, 68, 543, 314, 1453, 2082, 663, 370, 2399, 3035, 2935, 14, 199, 3, 199, 3, 3390, 626, 440, 1006, 3962, 2897, 1338, 787, 3451, 315, 642, 199, 3, 18392, 570, 14, 199, 3, 199, 3, 2900, 2897, 1338, 1172, 282, 849, 27, 1338, 626, 787, 21804, 734, 199, 3, 14062, 370, 2498, 314, 849, 14, 199, 199, 646, 984, 12, 747, 199, 199, 3, 982, 5478, 334, 269, 4621, 370, 2213, 543, 29973, 9, 787, 315, 4573, 2082, 12, 199, 3, 1050, 3520, 6602, 370, 984, 14, 515, 2348, 14, 982, 314, 2082, 365, 3847, 370, 314, 199, 3, 3794, 1738, 12, 675, 747, 14, 515, 14, 4832, 370, 1852, 652, 3679, 12, 2839, 9164, 2348, 14, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 6412, 23900, 1333, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 4832, 24535, 199, 199, 3, 1553, 1696, 2897, 9527, 9858, 199, 199, 3, 982, 2195, 3794, 4839, 282, 13460, 10229, 1015, 12, 1174, 652, 2348, 14, 199, 3, 10065, 63, 8008, 275, 283, 17, 14, 16, 7, 199, 199, 3, 2654, 1263, 10229, 3329, 859, 1561, 2348, 12, 465, 3326, 14, 9322, 883, 506, 5478, 199, 3, 17262, 543, 10229, 334, 4579, 283, 8008, 14, 832, 24915, 503, 2195, 3537, 7869, 14, 199, 5359, 275, 788, 8008, 14, 832, 14, 28056, 297, 283, 8008, 14, 832, 14, 1058, 8008, 297, 1598, 283, 15720, 1117, 301, 400, 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, 14182, 7, 199, 7307, 275, 399, 7, 7806, 12, 1952, 827, 32472, 19728, 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, 646, 5496, 63, 4435, 199, 893, 26, 272, 4683, 275, 5496, 63, 4435, 14, 362, 63, 4972, 360, 14182, 1959, 1023, 199, 2590, 5496, 63, 4435, 14, 8580, 4667, 26, 272, 870, 283, 1378, 1900, 314, 3794, 12, 710, 4084, 2556, 402, 16704, 7, 272, 870, 283, 6362, 370, 506, 2808, 14, 221, 13083, 3907, 314, 2559, 1901, 2195, 7, 272, 870, 283, 31688, 3734, 503, 1255, 298, 2758, 14, 647, 477, 7549, 2, 370, 3272, 314, 7, 272, 870, 283, 2343, 14, 221, 437, 19128, 365, 14318, 11213, 272, 984, 14, 2224, 8, 17, 9, 199, 2264, 5496, 63, 4435, 199, 199, 692, 283, 2374, 7, 315, 4683, 26, 272, 4683, 275, 4683, 14, 1294, 360, 2374, 5832, 16, 61, 435, 283, 2374, 7, 199, 1023, 275, 15671, 904, 8, 3221, 14, 1294, 7563, 1491, 18, 566, 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, 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, 1360, 63, 7915, 275, 283, 15720, 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, 1360, 63, 7915, 63, 1419, 275, 469, 272, 283, 12376, 63, 4677, 356, 257, 283, 12376, 13, 4677, 14, 4524, 7, 199, 93, 199, 199, 3, 2654, 1263, 3792, 626, 1395, 3537, 17915, 2348, 12, 3847, 370, 642, 2082, 14, 199, 1360, 63, 7915, 63, 515, 275, 4044, 23900, 418, 199, 199, 3, 710, 536, 367, 642, 663, 402, 10229, 8247, 14, 221, 982, 488, 12, 652, 4243, 370, 199, 3, 3886, 1715, 30, 373, 28, 3221, 30, 3794, 1674, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jobsafran/mediadrop
mediadrop/controllers/media.py
9
15969
# This file is a part of MediaDrop (http://www.mediadrop.net), # Copyright 2009-2015 MediaDrop contributors # For the exact contribution history, see the git revision log. # The source code contained in this file is licensed under the GPLv3 or # (at your option) any later version. # See LICENSE.txt in the main project directory, for more information. """ Publicly Facing Media Controllers """ import logging import os.path from akismet import Akismet from paste.fileapp import FileApp from paste.util import mimeparse from pylons import config, request, response from pylons.controllers.util import abort, forward from sqlalchemy import orm, sql from sqlalchemy.exc import OperationalError from webob.exc import HTTPNotAcceptable, HTTPNotFound from mediadrop import USER_AGENT from mediadrop.forms.comments import PostCommentSchema from mediadrop.lib import helpers from mediadrop.lib.base import BaseController from mediadrop.lib.decorators import expose, expose_xhr, observable, paginate, validate_xhr, autocommit from mediadrop.lib.email import send_comment_notification from mediadrop.lib.helpers import (filter_vulgarity, redirect, url_for, viewable_media) from mediadrop.lib.i18n import _ from mediadrop.lib.services import Facebook from mediadrop.lib.templating import render from mediadrop.model import (DBSession, fetch_row, Media, MediaFile, Comment, Tag, Category, AuthorWithIP, Podcast) from mediadrop.plugin import events log = logging.getLogger(__name__) comment_schema = PostCommentSchema() class MediaController(BaseController): """ Media actions -- for both regular and podcast media """ @expose('media/index.html') @paginate('media', items_per_page=10) @observable(events.MediaController.index) def index(self, page=1, show='latest', q=None, tag=None, **kwargs): """List media with pagination. The media paginator may be accessed in the template with :attr:`c.paginators.media`, see :class:`webhelpers.paginate.Page`. :param page: Page number, defaults to 1. :type page: int :param show: 'latest', 'popular' or 'featured' :type show: unicode or None :param q: A search query to filter by :type q: unicode or None :param tag: A tag slug to filter for :type tag: unicode or None :rtype: dict :returns: media The list of :class:`~mediadrop.model.media.Media` instances for this page. result_count The total number of media items for this query search_query The query the user searched for, if any """ media = Media.query.published() media, show = helpers.filter_library_controls(media, show) if q: media = media.search(q, bool=True) if tag: tag = fetch_row(Tag, slug=tag) media = media.filter(Media.tags.contains(tag)) if (request.settings['rss_display'] == 'True') and (not (q or tag)): if show == 'latest': response.feed_links.extend([ (url_for(controller='/sitemaps', action='latest'), _(u'Latest RSS')), ]) elif show == 'featured': response.feed_links.extend([ (url_for(controller='/sitemaps', action='featured'), _(u'Featured RSS')), ]) media = viewable_media(media) return dict( media = media, result_count = media.count(), search_query = q, show = show, tag = tag, ) @expose('media/tags.html') def tags(self, **kwargs): """Display a listing of all tags.""" tags = Tag.query\ .options(orm.undefer('media_count_published'))\ .filter(Tag.media_count_published > 0) return dict( tags = tags, ) @expose('media/explore.html') @observable(events.MediaController.explore) def explore(self, **kwargs): """Display the most recent 15 media. :rtype: Dict :returns: latest Latest media popular Latest media """ media = Media.query.published() latest = media.order_by(Media.publish_on.desc()) popular = media.order_by(Media.popularity_points.desc()) featured = None featured_cat = helpers.get_featured_category() if featured_cat: featured = viewable_media(latest.in_category(featured_cat)).first() if not featured: featured = viewable_media(popular).first() latest = viewable_media(latest.exclude(featured))[:8] popular = viewable_media(popular.exclude(featured, latest))[:5] if request.settings['sitemaps_display'] == 'True': response.feed_links.extend([ (url_for(controller='/sitemaps', action='google'), _(u'Sitemap XML')), (url_for(controller='/sitemaps', action='mrss'), _(u'Sitemap RSS')), ]) if request.settings['rss_display'] == 'True': response.feed_links.extend([ (url_for(controller='/sitemaps', action='latest'), _(u'Latest RSS')), ]) return dict( featured = featured, latest = latest, popular = popular, categories = Category.query.populated_tree(), ) @expose() def random(self, **kwargs): """Redirect to a randomly selected media item.""" # TODO: Implement something more efficient than ORDER BY RAND(). # This method does a full table scan every time. random_query = Media.query.published().order_by(sql.func.random()) media = viewable_media(random_query).first() if media is None: redirect(action='explore') if media.podcast_id: podcast_slug = DBSession.query(Podcast.slug).get(media.podcast_id) else: podcast_slug = None redirect(action='view', slug=media.slug, podcast_slug=podcast_slug) @expose('media/view.html') @observable(events.MediaController.view) def view(self, slug, podcast_slug=None, **kwargs): """Display the media player, info and comments. :param slug: The :attr:`~mediadrop.models.media.Media.slug` to lookup :param podcast_slug: The :attr:`~mediadrop.models.podcasts.Podcast.slug` for podcast this media belongs to. Although not necessary for looking up the media, it tells us that the podcast slug was specified in the URL and therefore we reached this action by the preferred route. :rtype dict: :returns: media The :class:`~mediadrop.model.media.Media` instance for display. related_media A list of :class:`~mediadrop.model.media.Media` instances that rank as topically related to the given media item. comments A list of :class:`~mediadrop.model.comments.Comment` instances associated with the selected media item. comment_form_action ``str`` comment form action comment_form_values ``dict`` form values next_episode The next episode in the podcast series, if this media belongs to a podcast, another :class:`~mediadrop.model.media.Media` instance. """ media = fetch_row(Media, slug=slug) request.perm.assert_permission(u'view', media.resource) if media.podcast_id is not None: # Always view podcast media from a URL that shows the context of the podcast if url_for() != url_for(podcast_slug=media.podcast.slug): redirect(podcast_slug=media.podcast.slug) try: media.increment_views() DBSession.commit() except OperationalError: DBSession.rollback() if request.settings['comments_engine'] == 'facebook': response.facebook = Facebook(request.settings['facebook_appid']) related_media = viewable_media(Media.query.related(media))[:6] # TODO: finish implementation of different 'likes' buttons # e.g. the default one, plus a setting to use facebook. return dict( media = media, related_media = related_media, comments = media.comments.published().all(), comment_form_action = url_for(action='comment'), comment_form_values = kwargs, ) @expose('players/iframe.html') @observable(events.MediaController.embed_player) def embed_player(self, slug, w=None, h=None, **kwargs): media = fetch_row(Media, slug=slug) request.perm.assert_permission(u'view', media.resource) return dict( media = media, width = w and int(w) or None, height = h and int(h) or None, ) @expose(request_method="POST") @autocommit @observable(events.MediaController.rate) def rate(self, slug, up=None, down=None, **kwargs): """Say 'I like this' for the given media. :param slug: The media :attr:`~mediadrop.model.media.Media.slug` :rtype: unicode :returns: The new number of likes """ media = fetch_row(Media, slug=slug) request.perm.assert_permission(u'view', media.resource) if up: if not request.settings['appearance_show_like']: abort(status_code=403) media.increment_likes() elif down: if not request.settings['appearance_show_dislike']: abort(status_code=403) media.increment_dislikes() if request.is_xhr: return u'' else: redirect(action='view') @expose_xhr(request_method='POST') @validate_xhr(comment_schema, error_handler=view) @autocommit @observable(events.MediaController.comment) def comment(self, slug, name='', email=None, body='', **kwargs): """Post a comment from :class:`~mediadrop.forms.comments.PostCommentForm`. :param slug: The media :attr:`~mediadrop.model.media.Media.slug` :returns: Redirect to :meth:`view` page for media. """ def result(success, message=None, comment=None): if request.is_xhr: result = dict(success=success, message=message) if comment: result['comment'] = render('comments/_list.html', {'comment_to_render': comment}, method='xhtml') return result elif success: return redirect(action='view') else: return self.view(slug, name=name, email=email, body=body, **kwargs) if request.settings['comments_engine'] != 'builtin': abort(404) akismet_key = request.settings['akismet_key'] if akismet_key: akismet = Akismet(agent=USER_AGENT) akismet.key = akismet_key akismet.blog_url = request.settings['akismet_url'] or \ url_for('/', qualified=True) akismet.verify_key() data = {'comment_author': name.encode('utf-8'), 'user_ip': request.environ.get('REMOTE_ADDR'), 'user_agent': request.environ.get('HTTP_USER_AGENT', ''), 'referrer': request.environ.get('HTTP_REFERER', 'unknown'), 'HTTP_ACCEPT': request.environ.get('HTTP_ACCEPT')} if akismet.comment_check(body.encode('utf-8'), data): return result(False, _(u'Your comment has been rejected.')) media = fetch_row(Media, slug=slug) request.perm.assert_permission(u'view', media.resource) c = Comment() name = filter_vulgarity(name) c.author = AuthorWithIP(name, email, request.environ['REMOTE_ADDR']) c.subject = 'Re: %s' % media.title c.body = filter_vulgarity(body) require_review = request.settings['req_comment_approval'] if not require_review: c.reviewed = True c.publishable = True media.comments.append(c) DBSession.flush() send_comment_notification(media, c) if require_review: message = _('Thank you for your comment! We will post it just as ' 'soon as a moderator approves it.') return result(True, message=message) else: return result(True, comment=c) @expose() def serve(self, id, download=False, **kwargs): """Serve a :class:`~mediadrop.model.media.MediaFile` binary. :param id: File ID :type id: ``int`` :param bool download: If true, serve with an Content-Disposition that makes the file download to the users computer instead of playing in the browser. :raises webob.exc.HTTPNotFound: If no file exists with this ID. :raises webob.exc.HTTPNotAcceptable: If an Accept header field is present, and if the mimetype of the requested file doesn't match, then a 406 (not acceptable) response is returned. """ file = fetch_row(MediaFile, id=id) request.perm.assert_permission(u'view', file.media.resource) file_type = file.mimetype.encode('utf-8') file_name = file.display_name.encode('utf-8') file_path = helpers.file_path(file) if file_path is None: log.warn('No path exists for requested media file: %r', file) raise HTTPNotFound() file_path = file_path.encode('utf-8') if not os.path.exists(file_path): log.warn('No such file or directory: %r', file_path) raise HTTPNotFound() # Ensure the request accepts files with this container accept = request.environ.get('HTTP_ACCEPT', '*/*') if not mimeparse.best_match([file_type], accept): raise HTTPNotAcceptable() # 406 method = config.get('file_serve_method', None) headers = [] # Serving files with this header breaks playback on iPhone if download: headers.append(('Content-Disposition', 'attachment; filename="%s"' % file_name)) if method == 'apache_xsendfile': # Requires mod_xsendfile for Apache 2.x # XXX: Don't send Content-Length or Etag headers, # Apache handles them for you. response.headers['X-Sendfile'] = file_path response.body = '' elif method == 'nginx_redirect': # Requires NGINX server configuration: # NGINX must have a location block configured that matches # the /__mediadrop_serve__ path below (the value configured by # setting "nginx_serve_path" option in the configuration). It # should also be configured as an "internal" location to prevent # people from surfing directly to it. # For more information see: http://wiki.nginx.org/XSendfile serve_path = config.get('nginx_serve_path', '__mediadrop_serve__') if not serve_path.startswith('/'): serve_path = '/' + serve_path redirect_filename = '%s/%s' % (serve_path, os.path.basename(file_path)) response.headers['X-Accel-Redirect'] = redirect_filename else: app = FileApp(file_path, headers, content_type=file_type) return forward(app) response.headers['Content-Type'] = file_type for header, value in headers: response.headers[header] = value return None
gpl-3.0
[ 3, 961, 570, 365, 282, 1777, 402, 12300, 11070, 334, 1014, 921, 1544, 14, 3700, 350, 2675, 14, 846, 395, 199, 3, 1898, 8937, 13, 7806, 12300, 11070, 8417, 199, 3, 2104, 314, 5835, 406, 15980, 7994, 12, 1937, 314, 6135, 6974, 943, 14, 199, 3, 710, 1350, 1233, 10470, 315, 642, 570, 365, 18233, 1334, 314, 14629, 86, 19, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 1666, 5113, 14, 2424, 315, 314, 2446, 2199, 2082, 12, 367, 1655, 2556, 14, 199, 199, 624, 199, 18060, 317, 429, 89, 481, 645, 316, 12300, 16282, 83, 199, 624, 199, 646, 2050, 199, 646, 747, 14, 515, 199, 199, 504, 282, 75, 374, 10207, 492, 437, 75, 374, 10207, 199, 504, 20901, 14, 493, 571, 492, 3814, 2640, 199, 504, 20901, 14, 1974, 492, 6660, 1122, 199, 504, 1134, 76, 4654, 492, 1101, 12, 1056, 12, 1177, 199, 504, 1134, 76, 4654, 14, 20531, 14, 1974, 492, 12004, 12, 7568, 199, 504, 8335, 492, 9813, 12, 3875, 199, 504, 8335, 14, 2804, 492, 6654, 6279, 547, 199, 504, 14568, 14, 2804, 492, 3101, 1763, 8422, 461, 12, 3101, 4667, 199, 199, 504, 25796, 350, 2675, 492, 13044, 63, 14565, 199, 504, 25796, 350, 2675, 14, 3351, 14, 6223, 492, 7711, 7488, 6700, 199, 504, 25796, 350, 2675, 14, 773, 492, 10897, 199, 504, 25796, 350, 2675, 14, 773, 14, 1095, 492, 3523, 7506, 199, 504, 25796, 350, 2675, 14, 773, 14, 11582, 492, 23705, 12, 23705, 63, 88, 6271, 12, 2607, 29454, 12, 9881, 23043, 12, 4107, 63, 88, 6271, 12, 24845, 199, 504, 25796, 350, 2675, 14, 773, 14, 2123, 492, 3222, 63, 3349, 63, 6761, 199, 504, 25796, 350, 2675, 14, 773, 14, 7546, 492, 334, 1541, 63, 86, 27092, 7945, 12, 4660, 12, 1166, 63, 509, 12, 5591, 2455, 461, 63, 4603, 9, 199, 504, 25796, 350, 2675, 14, 773, 14, 73, 1085, 78, 492, 485, 199, 504, 25796, 350, 2675, 14, 773, 14, 5950, 492, 27107, 199, 504, 25796, 350, 2675, 14, 773, 14, 808, 24615, 492, 3795, 199, 504, 25796, 350, 2675, 14, 1238, 492, 334, 2846, 4434, 12, 5267, 63, 1143, 12, 12300, 12, 12300, 1173, 12, 6819, 12, 5591, 8053, 12, 13573, 12, 6529, 3007, 1772, 12, 510, 364, 2931, 9, 199, 504, 25796, 350, 2675, 14, 2718, 492, 4474, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3349, 63, 3629, 275, 7711, 7488, 6700, 342, 199, 199, 533, 12300, 7506, 8, 1563, 7506, 304, 272, 408, 272, 12300, 5445, 1553, 367, 3865, 5578, 436, 15329, 2931, 5898, 272, 408, 339, 768, 20586, 360, 4603, 15, 1080, 14, 1360, 358, 272, 768, 30979, 360, 4603, 297, 2974, 63, 529, 63, 1606, 29, 709, 9, 272, 768, 2873, 29454, 8, 4368, 14, 11398, 7506, 14, 1080, 9, 272, 347, 1478, 8, 277, 12, 2034, 29, 17, 12, 2498, 534, 7410, 297, 1894, 29, 403, 12, 1947, 29, 403, 12, 1011, 958, 304, 267, 408, 1296, 5898, 543, 21192, 14, 398, 710, 5898, 21398, 1443, 506, 13810, 315, 314, 1978, 543, 267, 520, 962, 1705, 67, 14, 11069, 2750, 14, 4603, 3559, 1937, 520, 533, 1705, 2520, 7546, 14, 30979, 14, 3276, 2313, 398, 520, 635, 2034, 26, 10331, 1329, 12, 4243, 370, 413, 14, 267, 520, 466, 2034, 26, 1109, 267, 520, 635, 2498, 26, 283, 7410, 297, 283, 1935, 2238, 7, 503, 283, 30779, 7, 267, 520, 466, 2498, 26, 2649, 503, 488, 267, 520, 635, 1894, 26, 437, 2754, 1827, 370, 2457, 701, 267, 520, 466, 1894, 26, 2649, 503, 488, 267, 520, 635, 1947, 26, 437, 1947, 8889, 370, 2457, 367, 267, 520, 466, 1947, 26, 2649, 503, 488, 267, 520, 4500, 26, 1211, 267, 520, 5808, 26, 288, 5898, 355, 710, 769, 402, 520, 533, 6054, 3700, 350, 2675, 14, 1238, 14, 4603, 14, 11398, 64, 4454, 355, 367, 642, 2034, 14, 288, 754, 63, 835, 355, 710, 3141, 1329, 402, 5898, 2974, 367, 642, 1827, 288, 2754, 63, 1131, 355, 710, 1827, 314, 922, 17543, 367, 12, 340, 1263, 398, 408, 267, 5898, 275, 12300, 14, 1131, 14, 8987, 342, 398, 5898, 12, 2498, 275, 10897, 14, 1541, 63, 4342, 63, 13658, 8, 4603, 12, 2498, 9, 398, 340, 1894, 26, 288, 5898, 275, 5898, 14, 1733, 8, 81, 12, 2155, 29, 549, 9, 398, 340, 1947, 26, 288, 1947, 275, 5267, 63, 1143, 8, 1931, 12, 8889, 29, 1450, 9, 288, 5898, 275, 5898, 14, 1541, 8, 11398, 14, 2969, 14, 6134, 8, 1450, 430, 398, 340, 334, 1069, 14, 1751, 459, 13614, 63, 2918, 418, 508, 283, 549, 358, 436, 334, 1397, 334, 81, 503, 1947, 2298, 288, 340, 2498, 508, 283, 7410, 356, 355, 1177, 14, 3871, 63, 4614, 14, 2880, 779, 490, 334, 633, 63, 509, 8, 5538, 8805, 30515, 297, 1595, 534, 7410, 659, 12561, 85, 7, 31438, 30331, 3855, 355, 4794, 288, 916, 2498, 508, 283, 30779, 356, 355, 1177, 14, 3871, 63, 4614, 14, 2880, 779, 490, 334, 633, 63, 509, 8, 5538, 8805, 30515, 297, 1595, 534, 30779, 659, 12561, 85, 7, 24927, 3297, 30331, 3855, 355, 4794, 398, 5898, 275, 2455, 461, 63, 4603, 8, 4603, 9, 267, 372, 1211, 8, 288, 5898, 275, 5898, 12, 288, 754, 63, 835, 275, 5898, 14, 835, 1062, 288, 2754, 63, 1131, 275, 1894, 12, 288, 2498, 275, 2498, 12, 288, 1947, 275, 1947, 12, 267, 776, 339, 768, 20586, 360, 4603, 15, 2969, 14, 1360, 358, 272, 347, 3762, 8, 277, 12, 1011, 958, 304, 267, 408, 7687, 282, 13778, 402, 1006, 3762, 1041, 267, 3762, 275, 8053, 14, 1131, 60, 288, 1275, 1419, 8, 1025, 14, 324, 11610, 360, 4603, 63, 835, 63, 8987, 1333, 60, 288, 1275, 1541, 8, 1931, 14, 4603, 63, 835, 63, 8987, 690, 378, 9, 267, 372, 1211, 8, 288, 3762, 275, 3762, 12, 267, 776, 339, 768, 20586, 360, 4603, 15, 16971, 264, 14, 1360, 358, 272, 768, 2873, 29454, 8, 4368, 14, 11398, 7506, 14, 16971, 264, 9, 272, 347, 15868, 264, 8, 277, 12, 1011, 958, 304, 267, 408, 7687, 314, 4750, 8058, 4114, 5898, 14, 398, 520 ]
[ 961, 570, 365, 282, 1777, 402, 12300, 11070, 334, 1014, 921, 1544, 14, 3700, 350, 2675, 14, 846, 395, 199, 3, 1898, 8937, 13, 7806, 12300, 11070, 8417, 199, 3, 2104, 314, 5835, 406, 15980, 7994, 12, 1937, 314, 6135, 6974, 943, 14, 199, 3, 710, 1350, 1233, 10470, 315, 642, 570, 365, 18233, 1334, 314, 14629, 86, 19, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 1666, 5113, 14, 2424, 315, 314, 2446, 2199, 2082, 12, 367, 1655, 2556, 14, 199, 199, 624, 199, 18060, 317, 429, 89, 481, 645, 316, 12300, 16282, 83, 199, 624, 199, 646, 2050, 199, 646, 747, 14, 515, 199, 199, 504, 282, 75, 374, 10207, 492, 437, 75, 374, 10207, 199, 504, 20901, 14, 493, 571, 492, 3814, 2640, 199, 504, 20901, 14, 1974, 492, 6660, 1122, 199, 504, 1134, 76, 4654, 492, 1101, 12, 1056, 12, 1177, 199, 504, 1134, 76, 4654, 14, 20531, 14, 1974, 492, 12004, 12, 7568, 199, 504, 8335, 492, 9813, 12, 3875, 199, 504, 8335, 14, 2804, 492, 6654, 6279, 547, 199, 504, 14568, 14, 2804, 492, 3101, 1763, 8422, 461, 12, 3101, 4667, 199, 199, 504, 25796, 350, 2675, 492, 13044, 63, 14565, 199, 504, 25796, 350, 2675, 14, 3351, 14, 6223, 492, 7711, 7488, 6700, 199, 504, 25796, 350, 2675, 14, 773, 492, 10897, 199, 504, 25796, 350, 2675, 14, 773, 14, 1095, 492, 3523, 7506, 199, 504, 25796, 350, 2675, 14, 773, 14, 11582, 492, 23705, 12, 23705, 63, 88, 6271, 12, 2607, 29454, 12, 9881, 23043, 12, 4107, 63, 88, 6271, 12, 24845, 199, 504, 25796, 350, 2675, 14, 773, 14, 2123, 492, 3222, 63, 3349, 63, 6761, 199, 504, 25796, 350, 2675, 14, 773, 14, 7546, 492, 334, 1541, 63, 86, 27092, 7945, 12, 4660, 12, 1166, 63, 509, 12, 5591, 2455, 461, 63, 4603, 9, 199, 504, 25796, 350, 2675, 14, 773, 14, 73, 1085, 78, 492, 485, 199, 504, 25796, 350, 2675, 14, 773, 14, 5950, 492, 27107, 199, 504, 25796, 350, 2675, 14, 773, 14, 808, 24615, 492, 3795, 199, 504, 25796, 350, 2675, 14, 1238, 492, 334, 2846, 4434, 12, 5267, 63, 1143, 12, 12300, 12, 12300, 1173, 12, 6819, 12, 5591, 8053, 12, 13573, 12, 6529, 3007, 1772, 12, 510, 364, 2931, 9, 199, 504, 25796, 350, 2675, 14, 2718, 492, 4474, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 3349, 63, 3629, 275, 7711, 7488, 6700, 342, 199, 199, 533, 12300, 7506, 8, 1563, 7506, 304, 272, 408, 272, 12300, 5445, 1553, 367, 3865, 5578, 436, 15329, 2931, 5898, 272, 408, 339, 768, 20586, 360, 4603, 15, 1080, 14, 1360, 358, 272, 768, 30979, 360, 4603, 297, 2974, 63, 529, 63, 1606, 29, 709, 9, 272, 768, 2873, 29454, 8, 4368, 14, 11398, 7506, 14, 1080, 9, 272, 347, 1478, 8, 277, 12, 2034, 29, 17, 12, 2498, 534, 7410, 297, 1894, 29, 403, 12, 1947, 29, 403, 12, 1011, 958, 304, 267, 408, 1296, 5898, 543, 21192, 14, 398, 710, 5898, 21398, 1443, 506, 13810, 315, 314, 1978, 543, 267, 520, 962, 1705, 67, 14, 11069, 2750, 14, 4603, 3559, 1937, 520, 533, 1705, 2520, 7546, 14, 30979, 14, 3276, 2313, 398, 520, 635, 2034, 26, 10331, 1329, 12, 4243, 370, 413, 14, 267, 520, 466, 2034, 26, 1109, 267, 520, 635, 2498, 26, 283, 7410, 297, 283, 1935, 2238, 7, 503, 283, 30779, 7, 267, 520, 466, 2498, 26, 2649, 503, 488, 267, 520, 635, 1894, 26, 437, 2754, 1827, 370, 2457, 701, 267, 520, 466, 1894, 26, 2649, 503, 488, 267, 520, 635, 1947, 26, 437, 1947, 8889, 370, 2457, 367, 267, 520, 466, 1947, 26, 2649, 503, 488, 267, 520, 4500, 26, 1211, 267, 520, 5808, 26, 288, 5898, 355, 710, 769, 402, 520, 533, 6054, 3700, 350, 2675, 14, 1238, 14, 4603, 14, 11398, 64, 4454, 355, 367, 642, 2034, 14, 288, 754, 63, 835, 355, 710, 3141, 1329, 402, 5898, 2974, 367, 642, 1827, 288, 2754, 63, 1131, 355, 710, 1827, 314, 922, 17543, 367, 12, 340, 1263, 398, 408, 267, 5898, 275, 12300, 14, 1131, 14, 8987, 342, 398, 5898, 12, 2498, 275, 10897, 14, 1541, 63, 4342, 63, 13658, 8, 4603, 12, 2498, 9, 398, 340, 1894, 26, 288, 5898, 275, 5898, 14, 1733, 8, 81, 12, 2155, 29, 549, 9, 398, 340, 1947, 26, 288, 1947, 275, 5267, 63, 1143, 8, 1931, 12, 8889, 29, 1450, 9, 288, 5898, 275, 5898, 14, 1541, 8, 11398, 14, 2969, 14, 6134, 8, 1450, 430, 398, 340, 334, 1069, 14, 1751, 459, 13614, 63, 2918, 418, 508, 283, 549, 358, 436, 334, 1397, 334, 81, 503, 1947, 2298, 288, 340, 2498, 508, 283, 7410, 356, 355, 1177, 14, 3871, 63, 4614, 14, 2880, 779, 490, 334, 633, 63, 509, 8, 5538, 8805, 30515, 297, 1595, 534, 7410, 659, 12561, 85, 7, 31438, 30331, 3855, 355, 4794, 288, 916, 2498, 508, 283, 30779, 356, 355, 1177, 14, 3871, 63, 4614, 14, 2880, 779, 490, 334, 633, 63, 509, 8, 5538, 8805, 30515, 297, 1595, 534, 30779, 659, 12561, 85, 7, 24927, 3297, 30331, 3855, 355, 4794, 398, 5898, 275, 2455, 461, 63, 4603, 8, 4603, 9, 267, 372, 1211, 8, 288, 5898, 275, 5898, 12, 288, 754, 63, 835, 275, 5898, 14, 835, 1062, 288, 2754, 63, 1131, 275, 1894, 12, 288, 2498, 275, 2498, 12, 288, 1947, 275, 1947, 12, 267, 776, 339, 768, 20586, 360, 4603, 15, 2969, 14, 1360, 358, 272, 347, 3762, 8, 277, 12, 1011, 958, 304, 267, 408, 7687, 282, 13778, 402, 1006, 3762, 1041, 267, 3762, 275, 8053, 14, 1131, 60, 288, 1275, 1419, 8, 1025, 14, 324, 11610, 360, 4603, 63, 835, 63, 8987, 1333, 60, 288, 1275, 1541, 8, 1931, 14, 4603, 63, 835, 63, 8987, 690, 378, 9, 267, 372, 1211, 8, 288, 3762, 275, 3762, 12, 267, 776, 339, 768, 20586, 360, 4603, 15, 16971, 264, 14, 1360, 358, 272, 768, 2873, 29454, 8, 4368, 14, 11398, 7506, 14, 16971, 264, 9, 272, 347, 15868, 264, 8, 277, 12, 1011, 958, 304, 267, 408, 7687, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
janocat/odoo
addons/base_report_designer/plugin/openerp_report_designer/bin/script/NewReport.py
384
3903
######################################################################### # # Copyright (c) 2003-2004 Danny Brewer d29583@groovegarden.com # Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>). # # 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 Street, Fifth Floor, Boston, MA 02110-1301 USA # # See: http://www.gnu.org/licenses/lgpl.html # ############################################################################# import uno import string import unohelper import xmlrpclib from com.sun.star.task import XJobExecutor if __name__<>"package": from lib.gui import * from lib.error import ErrorDialog from lib.functions import * from lib.logreport import * from LoginTest import * from lib.rpc import * database="test" uid = 3 # # # # Start OpenOffice.org, listen for connections and open testing document # # class NewReport(unohelper.Base, XJobExecutor): def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" self.version = "0.1" LoginTest() self.logobj=Logger() if not loginstatus and __name__=="package": exit(1) self.win=DBModalDialog(60, 50, 180, 115, "Open New Report") self.win.addFixedText("lblModuleSelection", 2, 2, 60, 15, "Module Selection") self.win.addComboListBox("lstModule", -2,13,176,80 , False) self.lstModule = self.win.getControl( "lstModule" ) self.aModuleName=[] desktop=getDesktop() doc = desktop.getCurrentComponent() docinfo=doc.getDocumentInfo() global passwd self.password = passwd global url self.sock=RPCSession(url) ids = self.sock.execute(database, uid, self.password, 'ir.model' , 'search',[]) fields = [ 'model','name'] res = self.sock.execute(database, uid, self.password, 'ir.model' , 'read', ids, fields) res.sort(lambda x, y: cmp(x['name'],y['name'])) for i in range(len(res)): self.lstModule.addItem(res[i]['name'],self.lstModule.getItemCount()) self.aModuleName.append(res[i]['model']) self.win.addButton('btnOK',-2 ,-5, 70,15,'Use Module in Report' ,actionListenerProc = self.btnOk_clicked ) self.win.addButton('btnCancel',-2 - 70 - 5 ,-5, 35,15,'Cancel' ,actionListenerProc = self.btnCancel_clicked ) self.win.doModalDialog("",None) def btnOk_clicked(self, oActionEvent): desktop=getDesktop() doc = desktop.getCurrentComponent() docinfo=doc.getDocumentInfo() docinfo.setUserFieldValue(3,self.aModuleName[self.lstModule.getSelectedItemPos()]) self.logobj.log_write('Module Name',LOG_INFO, ':Module use in creating a report %s using database %s' % (self.aModuleName[self.lstModule.getSelectedItemPos()], database)) self.win.endExecute() def btnCancel_clicked(self, oActionEvent): self.win.endExecute() if __name__<>"package" and __name__=="__main__": NewReport(None) elif __name__=="package": g_ImplementationHelper.addImplementation( \ NewReport, "org.openoffice.openerp.report.opennewreport", ("com.sun.star.task.Job",),) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3949, 3, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 13004, 13, 15431, 577, 1189, 89, 699, 264, 2135, 366, 1398, 16793, 32, 23260, 79, 432, 23909, 848, 14, 957, 199, 3, 221, 1898, 334, 35, 9, 8353, 13, 6542, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 199, 3, 199, 3, 221, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 221, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 221, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 221, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 221, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 199, 3, 221, 1666, 26, 221, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 199, 3, 199, 31635, 199, 199, 646, 625, 79, 199, 646, 1059, 199, 646, 625, 79, 3676, 199, 646, 19122, 199, 199, 504, 2414, 14, 11846, 14, 7848, 14, 1765, 492, 1323, 6694, 16752, 199, 692, 636, 354, 363, 28, 4335, 2491, 582, 272, 687, 1973, 14, 5885, 492, 627, 272, 687, 1973, 14, 705, 492, 4520, 5619, 272, 687, 1973, 14, 5777, 492, 627, 272, 687, 1973, 14, 793, 3070, 492, 627, 272, 687, 16430, 774, 492, 627, 272, 687, 1973, 14, 4354, 492, 627, 272, 3050, 628, 396, 2, 272, 1747, 275, 650, 199, 3, 199, 3, 199, 3, 199, 3, 7707, 3232, 31166, 14, 1308, 12, 6938, 367, 6947, 436, 1551, 5343, 2213, 199, 3, 199, 3, 199, 533, 7053, 7457, 8, 324, 79, 3676, 14, 1563, 12, 1323, 6694, 16752, 304, 272, 347, 636, 826, 721, 277, 12, 4027, 304, 267, 291, 14, 3799, 258, 275, 4027, 267, 291, 14, 578, 221, 275, 298, 11267, 63, 3070, 2, 267, 291, 14, 1023, 275, 298, 16, 14, 17, 2, 267, 16430, 774, 342, 267, 291, 14, 793, 1113, 29, 4455, 342, 267, 340, 440, 4676, 1205, 436, 636, 354, 363, 11800, 2491, 582, 288, 4458, 8, 17, 9, 267, 291, 14, 2676, 29, 2846, 23689, 5619, 8, 2259, 12, 5238, 12, 13576, 12, 22560, 12, 298, 4299, 7053, 11774, 531, 267, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 2377, 7713, 401, 499, 12, 499, 12, 5212, 12, 4114, 12, 298, 2377, 3240, 1486, 531, 267, 291, 14, 2676, 14, 525, 12413, 26764, 480, 6916, 2377, 401, 446, 18, 12, 969, 12, 10216, 12, 1257, 2360, 756, 9, 267, 291, 14, 6916, 2377, 275, 291, 14, 2676, 14, 25117, 8, 298, 6916, 2377, 2, 776, 267, 291, 14, 65, 2377, 985, 9811, 267, 19763, 29, 362, 20436, 342, 267, 1382, 275, 19763, 14, 16662, 7004, 342, 267, 1382, 815, 29, 1301, 14, 362, 5564, 2354, 342, 398, 2288, 15081, 267, 291, 14, 2060, 275, 15081, 267, 2288, 1166, 267, 291, 14, 5096, 29, 18612, 3298, 3552, 8, 633, 9, 267, 2762, 275, 291, 14, 5096, 14, 2526, 8, 4659, 12, 1747, 12, 291, 14, 2060, 12, 283, 723, 14, 1238, 7, 2360, 283, 1733, 23993, 566, 267, 1504, 275, 359, 283, 1238, 1673, 354, 418, 267, 522, 275, 291, 14, 5096, 14, 2526, 8, 4659, 12, 1747, 12, 291, 14, 2060, 12, 283, 723, 14, 1238, 7, 2360, 283, 739, 297, 2762, 12, 1504, 9, 267, 522, 14, 3191, 8, 2734, 671, 12, 612, 26, 10467, 8, 88, 459, 354, 995, 89, 459, 354, 5156, 398, 367, 284, 315, 1425, 8, 552, 8, 470, 2298, 288, 291, 14, 6916, 2377, 14, 19798, 8, 470, 59, 73, 2733, 354, 995, 277, 14, 6916, 2377, 14, 362, 2081, 2353, 1012, 288, 291, 14, 65, 2377, 985, 14, 740, 8, 470, 59, 73, 2733, 1238, 1105, 267, 291, 14, 2676, 14, 525, 4259, 360, 9633, 3593, 297, 13, 18, 2360, 13, 21, 12, 10045, 12, 1046, 2584, 6119, 5673, 315, 11774, 7, 2360, 1287, 10464, 15019, 275, 291, 14, 9633, 11622, 63, 11276, 776, 267, 291, 14, 2676, 14, 525, 4259, 360, 9633, 9083, 297, 13, 18, 446, 10045, 446, 959, 2360, 13, 21, 12, 8685, 12, 1046, 2584, 9083, 7, 2360, 1287, 10464, 15019, 275, 291, 14, 9633, 9083, 63, 11276, 776, 267, 291, 14, 2676, 14, 1117, 23689, 5619, 12398, 403, 9, 339, 347, 19368, 11622, 63, 11276, 8, 277, 12, 312, 3310, 2390, 304, 267, 19763, 29, 362, 20436, 342, 267, 1382, 275, 19763, 14, 16662, 7004, 342, 267, 1382, 815, 29, 1301, 14, 362, 5564, 2354, 342, 267, 1382, 815, 14, 409, 1899, 792, 1110, 8, 19, 12, 277, 14, 65, 2377, 985, 59, 277, 14, 6916, 2377, 14, 362, 12461, 2081, 6981, 9383, 267, 291, 14, 793, 1113, 14, 793, 63, 952, 360, 2377, 2812, 297, 4947, 63, 4531, 12, 7596, 2377, 675, 315, 6425, 282, 3622, 450, 83, 221, 1808, 3050, 450, 83, 7, 450, 334, 277, 14, 65, 2377, 985, 59, 277, 14, 6916, 2377, 14, 362, 12461, 2081, 6981, 15618, 3050, 430, 267, 291, 14, 2676, 14, 500, 12049, 342, 339, 347, 19368, 9083, 63, 11276, 8, 277, 12, 312, 3310, 2390, 304, 267, 291, 14, 2676, 14, 500, 12049, 342, 199, 199, 692, 636, 354, 363, 28, 4335, 2491, 2, 436, 636, 354, 363, 11800, 363, 973, 5727, 272, 7053, 7457, 8, 403, 9, 199, 4164, 636, 354, 363, 11800, 2491, 582, 272, 486, 63, 7921, 4433, 14, 525, 7921, 8, 971, 288, 7053, 7457, 12, 288, 298, 1308, 14, 1490, 18812, 14, 11267, 14, 3070, 14, 1490, 1222, 3070, 401 ]
[ 3, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 13004, 13, 15431, 577, 1189, 89, 699, 264, 2135, 366, 1398, 16793, 32, 23260, 79, 432, 23909, 848, 14, 957, 199, 3, 221, 1898, 334, 35, 9, 8353, 13, 6542, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 199, 3, 199, 3, 221, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 221, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 221, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 221, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 221, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 199, 3, 221, 1666, 26, 221, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 199, 3, 199, 31635, 199, 199, 646, 625, 79, 199, 646, 1059, 199, 646, 625, 79, 3676, 199, 646, 19122, 199, 199, 504, 2414, 14, 11846, 14, 7848, 14, 1765, 492, 1323, 6694, 16752, 199, 692, 636, 354, 363, 28, 4335, 2491, 582, 272, 687, 1973, 14, 5885, 492, 627, 272, 687, 1973, 14, 705, 492, 4520, 5619, 272, 687, 1973, 14, 5777, 492, 627, 272, 687, 1973, 14, 793, 3070, 492, 627, 272, 687, 16430, 774, 492, 627, 272, 687, 1973, 14, 4354, 492, 627, 272, 3050, 628, 396, 2, 272, 1747, 275, 650, 199, 3, 199, 3, 199, 3, 199, 3, 7707, 3232, 31166, 14, 1308, 12, 6938, 367, 6947, 436, 1551, 5343, 2213, 199, 3, 199, 3, 199, 533, 7053, 7457, 8, 324, 79, 3676, 14, 1563, 12, 1323, 6694, 16752, 304, 272, 347, 636, 826, 721, 277, 12, 4027, 304, 267, 291, 14, 3799, 258, 275, 4027, 267, 291, 14, 578, 221, 275, 298, 11267, 63, 3070, 2, 267, 291, 14, 1023, 275, 298, 16, 14, 17, 2, 267, 16430, 774, 342, 267, 291, 14, 793, 1113, 29, 4455, 342, 267, 340, 440, 4676, 1205, 436, 636, 354, 363, 11800, 2491, 582, 288, 4458, 8, 17, 9, 267, 291, 14, 2676, 29, 2846, 23689, 5619, 8, 2259, 12, 5238, 12, 13576, 12, 22560, 12, 298, 4299, 7053, 11774, 531, 267, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 2377, 7713, 401, 499, 12, 499, 12, 5212, 12, 4114, 12, 298, 2377, 3240, 1486, 531, 267, 291, 14, 2676, 14, 525, 12413, 26764, 480, 6916, 2377, 401, 446, 18, 12, 969, 12, 10216, 12, 1257, 2360, 756, 9, 267, 291, 14, 6916, 2377, 275, 291, 14, 2676, 14, 25117, 8, 298, 6916, 2377, 2, 776, 267, 291, 14, 65, 2377, 985, 9811, 267, 19763, 29, 362, 20436, 342, 267, 1382, 275, 19763, 14, 16662, 7004, 342, 267, 1382, 815, 29, 1301, 14, 362, 5564, 2354, 342, 398, 2288, 15081, 267, 291, 14, 2060, 275, 15081, 267, 2288, 1166, 267, 291, 14, 5096, 29, 18612, 3298, 3552, 8, 633, 9, 267, 2762, 275, 291, 14, 5096, 14, 2526, 8, 4659, 12, 1747, 12, 291, 14, 2060, 12, 283, 723, 14, 1238, 7, 2360, 283, 1733, 23993, 566, 267, 1504, 275, 359, 283, 1238, 1673, 354, 418, 267, 522, 275, 291, 14, 5096, 14, 2526, 8, 4659, 12, 1747, 12, 291, 14, 2060, 12, 283, 723, 14, 1238, 7, 2360, 283, 739, 297, 2762, 12, 1504, 9, 267, 522, 14, 3191, 8, 2734, 671, 12, 612, 26, 10467, 8, 88, 459, 354, 995, 89, 459, 354, 5156, 398, 367, 284, 315, 1425, 8, 552, 8, 470, 2298, 288, 291, 14, 6916, 2377, 14, 19798, 8, 470, 59, 73, 2733, 354, 995, 277, 14, 6916, 2377, 14, 362, 2081, 2353, 1012, 288, 291, 14, 65, 2377, 985, 14, 740, 8, 470, 59, 73, 2733, 1238, 1105, 267, 291, 14, 2676, 14, 525, 4259, 360, 9633, 3593, 297, 13, 18, 2360, 13, 21, 12, 10045, 12, 1046, 2584, 6119, 5673, 315, 11774, 7, 2360, 1287, 10464, 15019, 275, 291, 14, 9633, 11622, 63, 11276, 776, 267, 291, 14, 2676, 14, 525, 4259, 360, 9633, 9083, 297, 13, 18, 446, 10045, 446, 959, 2360, 13, 21, 12, 8685, 12, 1046, 2584, 9083, 7, 2360, 1287, 10464, 15019, 275, 291, 14, 9633, 9083, 63, 11276, 776, 267, 291, 14, 2676, 14, 1117, 23689, 5619, 12398, 403, 9, 339, 347, 19368, 11622, 63, 11276, 8, 277, 12, 312, 3310, 2390, 304, 267, 19763, 29, 362, 20436, 342, 267, 1382, 275, 19763, 14, 16662, 7004, 342, 267, 1382, 815, 29, 1301, 14, 362, 5564, 2354, 342, 267, 1382, 815, 14, 409, 1899, 792, 1110, 8, 19, 12, 277, 14, 65, 2377, 985, 59, 277, 14, 6916, 2377, 14, 362, 12461, 2081, 6981, 9383, 267, 291, 14, 793, 1113, 14, 793, 63, 952, 360, 2377, 2812, 297, 4947, 63, 4531, 12, 7596, 2377, 675, 315, 6425, 282, 3622, 450, 83, 221, 1808, 3050, 450, 83, 7, 450, 334, 277, 14, 65, 2377, 985, 59, 277, 14, 6916, 2377, 14, 362, 12461, 2081, 6981, 15618, 3050, 430, 267, 291, 14, 2676, 14, 500, 12049, 342, 339, 347, 19368, 9083, 63, 11276, 8, 277, 12, 312, 3310, 2390, 304, 267, 291, 14, 2676, 14, 500, 12049, 342, 199, 199, 692, 636, 354, 363, 28, 4335, 2491, 2, 436, 636, 354, 363, 11800, 363, 973, 5727, 272, 7053, 7457, 8, 403, 9, 199, 4164, 636, 354, 363, 11800, 2491, 582, 272, 486, 63, 7921, 4433, 14, 525, 7921, 8, 971, 288, 7053, 7457, 12, 288, 298, 1308, 14, 1490, 18812, 14, 11267, 14, 3070, 14, 1490, 1222, 3070, 401, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sgraham/nope
third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/coverage/html.py
64
10721
"""HTML reporting for Coverage.""" import os, re, shutil import coverage from coverage.backward import pickle, write_encoded from coverage.misc import CoverageException, Hasher from coverage.phystokens import source_token_lines from coverage.report import Reporter from coverage.templite import Templite # Disable pylint msg W0612, because a bunch of variables look unused, but # they're accessed in a Templite context via locals(). # pylint: disable=W0612 def data_filename(fname): """Return the path to a data file of ours.""" return os.path.join(os.path.split(__file__)[0], fname) def data(fname): """Return the contents of a data file of ours.""" data_file = open(data_filename(fname)) try: return data_file.read() finally: data_file.close() class HtmlReporter(Reporter): """HTML reporting.""" # These files will be copied from the htmlfiles dir to the output dir. STATIC_FILES = [ "style.css", "jquery-1.4.3.min.js", "jquery.hotkeys.js", "jquery.isonscreen.js", "jquery.tablesorter.min.js", "coverage_html.js", "keybd_closed.png", "keybd_open.png", ] def __init__(self, cov, ignore_errors=False): super(HtmlReporter, self).__init__(cov, ignore_errors) self.directory = None self.template_globals = { 'escape': escape, '__url__': coverage.__url__, '__version__': coverage.__version__, } self.source_tmpl = Templite( data("htmlfiles/pyfile.html"), self.template_globals ) self.coverage = cov self.files = [] self.arcs = self.coverage.data.has_arcs() self.status = HtmlStatus() def report(self, morfs, config=None): """Generate an HTML report for `morfs`. `morfs` is a list of modules or filenames. `config` is a CoverageConfig instance. """ assert config.html_dir, "must provide a directory for html reporting" # Read the status data. self.status.read(config.html_dir) # Check that this run used the same settings as the last run. m = Hasher() m.update(config) these_settings = m.digest() if self.status.settings_hash() != these_settings: self.status.reset() self.status.set_settings_hash(these_settings) # Process all the files. self.report_files(self.html_file, morfs, config, config.html_dir) if not self.files: raise CoverageException("No data to report.") # Write the index file. self.index_file() self.make_local_static_report_files() def make_local_static_report_files(self): """Make local instances of static files for HTML report.""" for static in self.STATIC_FILES: shutil.copyfile( data_filename("htmlfiles/" + static), os.path.join(self.directory, static) ) def write_html(self, fname, html): """Write `html` to `fname`, properly encoded.""" write_encoded(fname, html, 'ascii', 'xmlcharrefreplace') def file_hash(self, source, cu): """Compute a hash that changes if the file needs to be re-reported.""" m = Hasher() m.update(source) self.coverage.data.add_to_hash(cu.filename, m) return m.digest() def html_file(self, cu, analysis): """Generate an HTML file for one source file.""" source_file = cu.source_file() try: source = source_file.read() finally: source_file.close() # Find out if the file on disk is already correct. flat_rootname = cu.flat_rootname() this_hash = self.file_hash(source, cu) that_hash = self.status.file_hash(flat_rootname) if this_hash == that_hash: # Nothing has changed to require the file to be reported again. self.files.append(self.status.index_info(flat_rootname)) return self.status.set_file_hash(flat_rootname, this_hash) nums = analysis.numbers missing_branch_arcs = analysis.missing_branch_arcs() n_par = 0 # accumulated below. arcs = self.arcs # These classes determine which lines are highlighted by default. c_run = "run hide_run" c_exc = "exc" c_mis = "mis" c_par = "par " + c_run lines = [] for lineno, line in enumerate(source_token_lines(source)): lineno += 1 # 1-based line numbers. # Figure out how to mark this line. line_class = [] annotate_html = "" annotate_title = "" if lineno in analysis.statements: line_class.append("stm") if lineno in analysis.excluded: line_class.append(c_exc) elif lineno in analysis.missing: line_class.append(c_mis) elif self.arcs and lineno in missing_branch_arcs: line_class.append(c_par) n_par += 1 annlines = [] for b in missing_branch_arcs[lineno]: if b < 0: annlines.append("exit") else: annlines.append(str(b)) annotate_html = "&nbsp;&nbsp; ".join(annlines) if len(annlines) > 1: annotate_title = "no jumps to these line numbers" elif len(annlines) == 1: annotate_title = "no jump to this line number" elif lineno in analysis.statements: line_class.append(c_run) # Build the HTML for the line html = [] for tok_type, tok_text in line: if tok_type == "ws": html.append(escape(tok_text)) else: tok_html = escape(tok_text) or '&nbsp;' html.append( "<span class='%s'>%s</span>" % (tok_type, tok_html) ) lines.append({ 'html': ''.join(html), 'number': lineno, 'class': ' '.join(line_class) or "pln", 'annotate': annotate_html, 'annotate_title': annotate_title, }) # Write the HTML page for this file. html_filename = flat_rootname + ".html" html_path = os.path.join(self.directory, html_filename) html = spaceless(self.source_tmpl.render(locals())) self.write_html(html_path, html) # Save this file's information for the index file. index_info = { 'nums': nums, 'par': n_par, 'html_filename': html_filename, 'name': cu.name, } self.files.append(index_info) self.status.set_index_info(flat_rootname, index_info) def index_file(self): """Write the index.html file for this report.""" index_tmpl = Templite( data("htmlfiles/index.html"), self.template_globals ) files = self.files arcs = self.arcs totals = sum([f['nums'] for f in files]) self.write_html( os.path.join(self.directory, "index.html"), index_tmpl.render(locals()) ) # Write the latest hashes for next time. self.status.write(self.directory) class HtmlStatus(object): """The status information we keep to support incremental reporting.""" STATUS_FILE = "status.dat" STATUS_FORMAT = 1 def __init__(self): self.reset() def reset(self): """Initialize to empty.""" self.settings = '' self.files = {} def read(self, directory): """Read the last status in `directory`.""" usable = False try: status_file = os.path.join(directory, self.STATUS_FILE) status = pickle.load(open(status_file, "rb")) except IOError: usable = False else: usable = True if status['format'] != self.STATUS_FORMAT: usable = False elif status['version'] != coverage.__version__: usable = False if usable: self.files = status['files'] self.settings = status['settings'] else: self.reset() def write(self, directory): """Write the current status to `directory`.""" status_file = os.path.join(directory, self.STATUS_FILE) status = { 'format': self.STATUS_FORMAT, 'version': coverage.__version__, 'settings': self.settings, 'files': self.files, } fout = open(status_file, "wb") try: pickle.dump(status, fout) finally: fout.close() def settings_hash(self): """Get the hash of the coverage.py settings.""" return self.settings def set_settings_hash(self, settings): """Set the hash of the coverage.py settings.""" self.settings = settings def file_hash(self, fname): """Get the hash of `fname`'s contents.""" return self.files.get(fname, {}).get('hash', '') def set_file_hash(self, fname, val): """Set the hash of `fname`'s contents.""" self.files.setdefault(fname, {})['hash'] = val def index_info(self, fname): """Get the information for index.html for `fname`.""" return self.files.get(fname, {}).get('index', {}) def set_index_info(self, fname, info): """Set the information for index.html for `fname`.""" self.files.setdefault(fname, {})['index'] = info # Helpers for templates and generating HTML def escape(t): """HTML-escape the text in `t`.""" return (t # Convert HTML special chars into HTML entities. .replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;") .replace("'", "&#39;").replace('"', "&quot;") # Convert runs of spaces: "......" -> "&nbsp;.&nbsp;.&nbsp;." .replace(" ", "&nbsp; ") # To deal with odd-length runs, convert the final pair of spaces # so that "....." -> "&nbsp;.&nbsp;&nbsp;." .replace(" ", "&nbsp; ") ) def spaceless(html): """Squeeze out some annoying extra space from an HTML string. Nicely-formatted templates mean lots of extra space in the result. Get rid of some. """ html = re.sub(">\s+<p ", ">\n<p ", html) return html
bsd-3-clause
[ 624, 4943, 17290, 367, 1849, 3652, 1041, 199, 199, 646, 747, 12, 295, 12, 5145, 199, 199, 646, 11745, 199, 504, 11745, 14, 15457, 492, 5927, 12, 2218, 63, 8167, 199, 504, 11745, 14, 9923, 492, 1849, 3652, 1726, 12, 16101, 281, 199, 504, 11745, 14, 6581, 270, 2858, 83, 492, 1350, 63, 1418, 63, 1278, 199, 504, 11745, 14, 3070, 492, 23786, 199, 504, 11745, 14, 808, 5333, 492, 12540, 5333, 199, 199, 3, 17534, 4287, 1499, 644, 1690, 713, 12, 2952, 282, 22219, 402, 2860, 3648, 9563, 12, 1325, 199, 3, 2985, 3984, 13810, 315, 282, 12540, 5333, 1067, 4799, 9480, 1252, 199, 3, 4287, 26, 3507, 29, 55, 1690, 713, 199, 199, 318, 666, 63, 1501, 8, 5252, 304, 272, 408, 1767, 314, 931, 370, 282, 666, 570, 402, 4154, 83, 1041, 272, 372, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 1294, 3460, 493, 363, 2788, 16, 467, 6748, 9, 199, 199, 318, 666, 8, 5252, 304, 272, 408, 1767, 314, 4072, 402, 282, 666, 570, 402, 4154, 83, 1041, 272, 666, 63, 493, 275, 1551, 8, 576, 63, 1501, 8, 5252, 430, 272, 862, 26, 267, 372, 666, 63, 493, 14, 739, 342, 272, 3753, 26, 267, 666, 63, 493, 14, 1600, 342, 421, 199, 533, 20880, 15891, 8, 15891, 304, 272, 408, 4943, 17290, 1041, 339, 327, 5723, 1584, 911, 506, 8876, 687, 314, 30010, 12059, 83, 2935, 370, 314, 1072, 2935, 14, 272, 27815, 63, 9472, 275, 359, 288, 298, 2487, 14, 3919, 401, 288, 298, 22324, 13, 17, 14, 20, 14, 19, 14, 827, 14, 3596, 401, 288, 298, 22324, 14, 8885, 1612, 14, 3596, 401, 288, 298, 22324, 14, 28287, 5410, 14, 3596, 401, 288, 298, 22324, 14, 1224, 1509, 351, 14, 827, 14, 3596, 401, 288, 298, 10828, 63, 1360, 14, 3596, 401, 288, 298, 498, 3691, 63, 5938, 14, 4524, 401, 288, 298, 498, 3691, 63, 1490, 14, 4524, 401, 288, 1622, 339, 347, 636, 826, 721, 277, 12, 13786, 12, 3686, 63, 2550, 29, 797, 304, 267, 1613, 8, 12957, 15891, 12, 291, 2843, 826, 721, 8695, 12, 3686, 63, 2550, 9, 267, 291, 14, 3619, 275, 488, 267, 291, 14, 1160, 63, 8473, 275, 469, 288, 283, 3765, 356, 4772, 12, 288, 2560, 633, 3706, 11745, 855, 633, 3108, 288, 2560, 1023, 3706, 11745, 855, 1023, 3108, 288, 789, 267, 291, 14, 1365, 63, 11510, 275, 12540, 5333, 8, 288, 666, 480, 15575, 12059, 83, 15, 14792, 14, 1360, 1288, 291, 14, 1160, 63, 8473, 288, 776, 398, 291, 14, 10828, 275, 13786, 398, 291, 14, 1725, 275, 942, 267, 291, 14, 20672, 275, 291, 14, 10828, 14, 576, 14, 1989, 63, 20672, 342, 267, 291, 14, 1205, 275, 20880, 3694, 342, 339, 347, 3622, 8, 277, 12, 21333, 2319, 12, 1101, 29, 403, 304, 267, 408, 6864, 376, 4163, 3622, 367, 658, 12416, 2319, 2313, 398, 658, 12416, 2319, 64, 365, 282, 769, 402, 4621, 503, 6203, 14, 221, 658, 888, 64, 365, 282, 267, 1849, 3652, 2028, 1256, 14, 398, 408, 267, 702, 1101, 14, 1360, 63, 694, 12, 298, 7790, 5647, 282, 2082, 367, 3517, 17290, 2, 398, 327, 5574, 314, 2004, 666, 14, 267, 291, 14, 1205, 14, 739, 8, 888, 14, 1360, 63, 694, 9, 398, 327, 2670, 626, 642, 1255, 1202, 314, 2011, 2202, 465, 314, 2061, 1255, 14, 267, 333, 275, 16101, 281, 342, 267, 333, 14, 873, 8, 888, 9, 267, 3520, 63, 1751, 275, 333, 14, 5671, 342, 267, 340, 291, 14, 1205, 14, 1751, 63, 2227, 342, 1137, 3520, 63, 1751, 26, 288, 291, 14, 1205, 14, 3958, 342, 288, 291, 14, 1205, 14, 409, 63, 1751, 63, 2227, 8, 29032, 63, 1751, 9, 398, 327, 7132, 1006, 314, 1584, 14, 267, 291, 14, 3070, 63, 1725, 8, 277, 14, 1360, 63, 493, 12, 21333, 2319, 12, 1101, 12, 1101, 14, 1360, 63, 694, 9, 398, 340, 440, 291, 14, 1725, 26, 288, 746, 1849, 3652, 1726, 480, 1944, 666, 370, 3622, 2685, 398, 327, 6990, 314, 1478, 570, 14, 267, 291, 14, 1080, 63, 493, 342, 398, 291, 14, 1875, 63, 1832, 63, 1986, 63, 3070, 63, 1725, 342, 339, 347, 1852, 63, 1832, 63, 1986, 63, 3070, 63, 1725, 8, 277, 304, 267, 408, 5483, 2257, 4454, 402, 2955, 1584, 367, 4163, 3622, 1041, 267, 367, 2955, 315, 291, 14, 10449, 63, 9472, 26, 288, 5145, 14, 21997, 8, 355, 666, 63, 1501, 480, 15575, 12059, 83, 6687, 435, 2955, 395, 355, 747, 14, 515, 14, 904, 8, 277, 14, 3619, 12, 2955, 9, 355, 776, 339, 347, 2218, 63, 1360, 8, 277, 12, 6748, 12, 3517, 304, 267, 408, 3534, 658, 1360, 64, 370, 658, 5252, 3559, 7684, 5737, 1041, 267, 2218, 63, 8167, 8, 5252, 12, 3517, 12, 283, 4371, 297, 283, 1652, 24253, 1814, 358, 339, 347, 570, 63, 2227, 8, 277, 12, 1350, 12, 30353, 304, 267, 408, 8564, 282, 2631, 626, 4493, 340, 314, 570, 4839, 370, 506, 295, 13, 1155, 1376, 1041, 267, 333, 275, 16101, 281, 342, 267, 333, 14, 873, 8, 1365, 9, 267, 291, 14, 10828, 14, 576, 14, 525, 63, 475, 63, 2227, 8, 15140, 14, 1501, 12, 333, 9, 267, 372, 333, 14, 5671, 342, 339, 347, 3517, 63, 493, 8, 277, 12, 30353, 12, 11284, 304, 267, 408, 6864, 376, 4163, 570, 367, 1373, 1350, 570, 1041, 267, 1350, 63, 493, 275, 30353, 14, 1365, 63, 493, 342, 267, 862, 26, 288, 1350, 275, 1350, 63, 493, 14, 739, 342, 267, 3753, 26, 288, 1350, 63, 493, 14, 1600, 342, 398, 327, 6668, 734, 340, 314, 570, 641, 4543, 365, 2575, 3211, 14, 267, 6829, 63, 1231, 354, 275, 30353, 14, 7088, 63, 1231, 354, 342, 267, 642, 63, 2227, 275, 291, 14, 493, 63, 2227, 8, 1365, 12, 30353, 9, 267, 626, 63, 2227, 275, 291, 14, 1205, 14, 493, 63, 2227, 8, 7088, 63, 1231, 354, 9, 267, 340, 642, 63, 2227, 508, 626, 63, 2227, 26, 288, 327, 20550, 965, 2896, 370, 4409, 314, 570, 370, 506, 14581, 4020, 14, 288, 291, 14, 1725, 14, 740, 8, 277, 14, 1205, 14, 1080 ]
[ 4943, 17290, 367, 1849, 3652, 1041, 199, 199, 646, 747, 12, 295, 12, 5145, 199, 199, 646, 11745, 199, 504, 11745, 14, 15457, 492, 5927, 12, 2218, 63, 8167, 199, 504, 11745, 14, 9923, 492, 1849, 3652, 1726, 12, 16101, 281, 199, 504, 11745, 14, 6581, 270, 2858, 83, 492, 1350, 63, 1418, 63, 1278, 199, 504, 11745, 14, 3070, 492, 23786, 199, 504, 11745, 14, 808, 5333, 492, 12540, 5333, 199, 199, 3, 17534, 4287, 1499, 644, 1690, 713, 12, 2952, 282, 22219, 402, 2860, 3648, 9563, 12, 1325, 199, 3, 2985, 3984, 13810, 315, 282, 12540, 5333, 1067, 4799, 9480, 1252, 199, 3, 4287, 26, 3507, 29, 55, 1690, 713, 199, 199, 318, 666, 63, 1501, 8, 5252, 304, 272, 408, 1767, 314, 931, 370, 282, 666, 570, 402, 4154, 83, 1041, 272, 372, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 1294, 3460, 493, 363, 2788, 16, 467, 6748, 9, 199, 199, 318, 666, 8, 5252, 304, 272, 408, 1767, 314, 4072, 402, 282, 666, 570, 402, 4154, 83, 1041, 272, 666, 63, 493, 275, 1551, 8, 576, 63, 1501, 8, 5252, 430, 272, 862, 26, 267, 372, 666, 63, 493, 14, 739, 342, 272, 3753, 26, 267, 666, 63, 493, 14, 1600, 342, 421, 199, 533, 20880, 15891, 8, 15891, 304, 272, 408, 4943, 17290, 1041, 339, 327, 5723, 1584, 911, 506, 8876, 687, 314, 30010, 12059, 83, 2935, 370, 314, 1072, 2935, 14, 272, 27815, 63, 9472, 275, 359, 288, 298, 2487, 14, 3919, 401, 288, 298, 22324, 13, 17, 14, 20, 14, 19, 14, 827, 14, 3596, 401, 288, 298, 22324, 14, 8885, 1612, 14, 3596, 401, 288, 298, 22324, 14, 28287, 5410, 14, 3596, 401, 288, 298, 22324, 14, 1224, 1509, 351, 14, 827, 14, 3596, 401, 288, 298, 10828, 63, 1360, 14, 3596, 401, 288, 298, 498, 3691, 63, 5938, 14, 4524, 401, 288, 298, 498, 3691, 63, 1490, 14, 4524, 401, 288, 1622, 339, 347, 636, 826, 721, 277, 12, 13786, 12, 3686, 63, 2550, 29, 797, 304, 267, 1613, 8, 12957, 15891, 12, 291, 2843, 826, 721, 8695, 12, 3686, 63, 2550, 9, 267, 291, 14, 3619, 275, 488, 267, 291, 14, 1160, 63, 8473, 275, 469, 288, 283, 3765, 356, 4772, 12, 288, 2560, 633, 3706, 11745, 855, 633, 3108, 288, 2560, 1023, 3706, 11745, 855, 1023, 3108, 288, 789, 267, 291, 14, 1365, 63, 11510, 275, 12540, 5333, 8, 288, 666, 480, 15575, 12059, 83, 15, 14792, 14, 1360, 1288, 291, 14, 1160, 63, 8473, 288, 776, 398, 291, 14, 10828, 275, 13786, 398, 291, 14, 1725, 275, 942, 267, 291, 14, 20672, 275, 291, 14, 10828, 14, 576, 14, 1989, 63, 20672, 342, 267, 291, 14, 1205, 275, 20880, 3694, 342, 339, 347, 3622, 8, 277, 12, 21333, 2319, 12, 1101, 29, 403, 304, 267, 408, 6864, 376, 4163, 3622, 367, 658, 12416, 2319, 2313, 398, 658, 12416, 2319, 64, 365, 282, 769, 402, 4621, 503, 6203, 14, 221, 658, 888, 64, 365, 282, 267, 1849, 3652, 2028, 1256, 14, 398, 408, 267, 702, 1101, 14, 1360, 63, 694, 12, 298, 7790, 5647, 282, 2082, 367, 3517, 17290, 2, 398, 327, 5574, 314, 2004, 666, 14, 267, 291, 14, 1205, 14, 739, 8, 888, 14, 1360, 63, 694, 9, 398, 327, 2670, 626, 642, 1255, 1202, 314, 2011, 2202, 465, 314, 2061, 1255, 14, 267, 333, 275, 16101, 281, 342, 267, 333, 14, 873, 8, 888, 9, 267, 3520, 63, 1751, 275, 333, 14, 5671, 342, 267, 340, 291, 14, 1205, 14, 1751, 63, 2227, 342, 1137, 3520, 63, 1751, 26, 288, 291, 14, 1205, 14, 3958, 342, 288, 291, 14, 1205, 14, 409, 63, 1751, 63, 2227, 8, 29032, 63, 1751, 9, 398, 327, 7132, 1006, 314, 1584, 14, 267, 291, 14, 3070, 63, 1725, 8, 277, 14, 1360, 63, 493, 12, 21333, 2319, 12, 1101, 12, 1101, 14, 1360, 63, 694, 9, 398, 340, 440, 291, 14, 1725, 26, 288, 746, 1849, 3652, 1726, 480, 1944, 666, 370, 3622, 2685, 398, 327, 6990, 314, 1478, 570, 14, 267, 291, 14, 1080, 63, 493, 342, 398, 291, 14, 1875, 63, 1832, 63, 1986, 63, 3070, 63, 1725, 342, 339, 347, 1852, 63, 1832, 63, 1986, 63, 3070, 63, 1725, 8, 277, 304, 267, 408, 5483, 2257, 4454, 402, 2955, 1584, 367, 4163, 3622, 1041, 267, 367, 2955, 315, 291, 14, 10449, 63, 9472, 26, 288, 5145, 14, 21997, 8, 355, 666, 63, 1501, 480, 15575, 12059, 83, 6687, 435, 2955, 395, 355, 747, 14, 515, 14, 904, 8, 277, 14, 3619, 12, 2955, 9, 355, 776, 339, 347, 2218, 63, 1360, 8, 277, 12, 6748, 12, 3517, 304, 267, 408, 3534, 658, 1360, 64, 370, 658, 5252, 3559, 7684, 5737, 1041, 267, 2218, 63, 8167, 8, 5252, 12, 3517, 12, 283, 4371, 297, 283, 1652, 24253, 1814, 358, 339, 347, 570, 63, 2227, 8, 277, 12, 1350, 12, 30353, 304, 267, 408, 8564, 282, 2631, 626, 4493, 340, 314, 570, 4839, 370, 506, 295, 13, 1155, 1376, 1041, 267, 333, 275, 16101, 281, 342, 267, 333, 14, 873, 8, 1365, 9, 267, 291, 14, 10828, 14, 576, 14, 525, 63, 475, 63, 2227, 8, 15140, 14, 1501, 12, 333, 9, 267, 372, 333, 14, 5671, 342, 339, 347, 3517, 63, 493, 8, 277, 12, 30353, 12, 11284, 304, 267, 408, 6864, 376, 4163, 570, 367, 1373, 1350, 570, 1041, 267, 1350, 63, 493, 275, 30353, 14, 1365, 63, 493, 342, 267, 862, 26, 288, 1350, 275, 1350, 63, 493, 14, 739, 342, 267, 3753, 26, 288, 1350, 63, 493, 14, 1600, 342, 398, 327, 6668, 734, 340, 314, 570, 641, 4543, 365, 2575, 3211, 14, 267, 6829, 63, 1231, 354, 275, 30353, 14, 7088, 63, 1231, 354, 342, 267, 642, 63, 2227, 275, 291, 14, 493, 63, 2227, 8, 1365, 12, 30353, 9, 267, 626, 63, 2227, 275, 291, 14, 1205, 14, 493, 63, 2227, 8, 7088, 63, 1231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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 ]
baidu/palo
build-support/run_clang_format.py
2
5703
#!/usr/bin/env python # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # # Modified from Apache Arrow project. from __future__ import print_function import lintutils from subprocess import PIPE import argparse import difflib import multiprocessing as mp import sys from functools import partial # examine the output of clang-format and if changes are # present assemble a (unified)patch of the difference def _check_one_file(filename, formatted): with open(filename, "rb") as reader: original = reader.read() if formatted != original: # Run the equivalent of diff -u diff = list(difflib.unified_diff( original.decode('utf8').splitlines(True), formatted.decode('utf8').splitlines(True), fromfile=filename, tofile="{} (after clang format)".format( filename))) else: diff = None return filename, diff def _check_dir(arguments, source_dir, exclude_globs): formatted_filenames = [] for path in lintutils.get_sources(source_dir, exclude_globs): formatted_filenames.append(str(path)) if arguments.fix: if not arguments.quiet: print("\n".join(map(lambda x: "Formatting {}".format(x), formatted_filenames))) # Break clang-format invocations into chunks: each invocation formats # 16 files. Wait for all processes to complete results = lintutils.run_parallel([ [arguments.clang_format_binary, "-style=file", "-i"] + some for some in lintutils.chunk(formatted_filenames, 16) ]) for returncode, stdout, stderr in results: # if any clang-format reported a parse error, bubble it if returncode != 0: sys.exit(returncode) else: # run an instance of clang-format for each source file in parallel, # then wait for all processes to complete results = lintutils.run_parallel([ [arguments.clang_format_binary, "-style=file", filename] for filename in formatted_filenames ], stdout=PIPE, stderr=PIPE) checker_args = [] for filename, res in zip(formatted_filenames, results): # if any clang-format reported a parse error, bubble it returncode, stdout, stderr = res if returncode != 0: print(stderr) sys.exit(returncode) checker_args.append((filename, stdout)) error = False pool = mp.Pool() try: # check the output from each invocation of clang-format in parallel for filename, diff in pool.starmap(_check_one_file, checker_args): if not arguments.quiet: print("Checking {}".format(filename)) if diff: print("{} had clang-format style issues".format(filename)) # Print out the diff to stderr error = True # pad with a newline print(file=sys.stderr) sys.stderr.writelines(diff) except Exception: error = True raise finally: pool.terminate() pool.join() sys.exit(1 if error else 0) if __name__ == "__main__": parser = argparse.ArgumentParser( description="Runs clang-format on all of the source " "files. If --fix is specified enforce format by " "modifying in place, otherwise compare the output " "with the existing file and output any necessary " "changes as a patch in unified diff format") parser.add_argument("--clang_format_binary", required=True, help="Path to the clang-format binary") parser.add_argument("--exclude_globs", help="Filename containing globs for files " "that should be excluded from the checks") parser.add_argument("--source_dirs", required=True, help="Comma-separated root directories of the source code") parser.add_argument("--fix", default=False, action="store_true", help="If specified, will re-format the source " "code instead of comparing the re-formatted " "output, defaults to %(default)s") parser.add_argument("--quiet", default=False, action="store_true", help="If specified, only print errors") arguments = parser.parse_args() exclude_globs = [] if arguments.exclude_globs: with open(arguments.exclude_globs) as f: exclude_globs.extend(line.strip() for line in f) for source_dir in arguments.source_dirs.split(','): if len(source_dir) > 0: _check_dir(arguments, source_dir, exclude_globs)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 3, 22016, 687, 3668, 1952, 1143, 2199, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 24620, 1208, 199, 504, 3873, 492, 22773, 199, 646, 7534, 199, 646, 27070, 199, 646, 12866, 465, 6118, 199, 646, 984, 199, 504, 9143, 492, 7417, 421, 199, 3, 31758, 314, 1072, 402, 25444, 13, 908, 436, 340, 4493, 787, 199, 3, 3451, 22931, 282, 334, 32180, 9, 2068, 402, 314, 8865, 199, 318, 485, 1074, 63, 368, 63, 493, 8, 1501, 12, 7871, 304, 272, 543, 1551, 8, 1501, 12, 298, 4848, 531, 465, 7002, 26, 267, 3379, 275, 7002, 14, 739, 342, 339, 340, 7871, 1137, 3379, 26, 267, 327, 3378, 314, 7353, 402, 3915, 446, 85, 267, 3915, 275, 769, 8, 3028, 773, 14, 32180, 63, 3028, 8, 288, 3379, 14, 2708, 360, 1624, 24, 1959, 7644, 8, 549, 395, 288, 7871, 14, 2708, 360, 1624, 24, 1959, 7644, 8, 549, 395, 288, 687, 493, 29, 1501, 12, 288, 370, 493, 32053, 334, 4399, 25444, 1475, 30351, 908, 8, 355, 1788, 1724, 272, 587, 26, 267, 3915, 275, 488, 339, 372, 1788, 12, 3915, 199, 199, 318, 485, 1074, 63, 694, 8, 4958, 12, 1350, 63, 694, 12, 5760, 63, 15581, 304, 272, 7871, 63, 10309, 275, 942, 272, 367, 931, 315, 24620, 1208, 14, 362, 63, 4553, 8, 1365, 63, 694, 12, 5760, 63, 15581, 304, 288, 7871, 63, 10309, 14, 740, 8, 495, 8, 515, 430, 339, 340, 2368, 14, 970, 26, 267, 340, 440, 2368, 14, 10243, 26, 288, 870, 4582, 78, 1674, 904, 8, 1130, 8, 2734, 671, 26, 298, 20552, 8352, 908, 8, 88, 395, 1816, 7871, 63, 10309, 1724, 398, 327, 22535, 25444, 13, 908, 28202, 1901, 8291, 26, 1924, 19569, 6752, 267, 327, 3193, 1584, 14, 13144, 367, 1006, 10358, 370, 4890, 267, 2058, 275, 24620, 1208, 14, 1065, 63, 11887, 779, 288, 359, 4958, 14, 16066, 63, 908, 63, 3008, 12, 3905, 2487, 29, 493, 401, 3905, 73, 937, 435, 2005, 288, 367, 2005, 315, 24620, 1208, 14, 4604, 8, 15317, 63, 10309, 12, 3193, 9, 267, 4794, 267, 367, 17630, 12, 3839, 12, 4635, 315, 2058, 26, 288, 327, 340, 1263, 25444, 13, 908, 14581, 282, 2198, 1125, 12, 330, 21749, 652, 288, 340, 17630, 1137, 378, 26, 355, 984, 14, 2224, 8, 9913, 9, 339, 587, 26, 267, 327, 1255, 376, 1256, 402, 25444, 13, 908, 367, 1924, 1350, 570, 315, 9861, 12, 267, 327, 2066, 3618, 367, 1006, 10358, 370, 4890, 267, 2058, 275, 24620, 1208, 14, 1065, 63, 11887, 779, 288, 359, 4958, 14, 16066, 63, 908, 63, 3008, 12, 3905, 2487, 29, 493, 401, 1788, 61, 288, 367, 1788, 315, 7871, 63, 10309, 267, 2156, 3839, 29, 6089, 12, 4635, 29, 6089, 9, 398, 7739, 63, 589, 275, 942, 267, 367, 1788, 12, 522, 315, 3482, 8, 15317, 63, 10309, 12, 2058, 304, 288, 327, 340, 1263, 25444, 13, 908, 14581, 282, 2198, 1125, 12, 330, 21749, 652, 288, 17630, 12, 3839, 12, 4635, 275, 522, 288, 340, 17630, 1137, 378, 26, 355, 870, 8, 3083, 9, 355, 984, 14, 2224, 8, 9913, 9, 288, 7739, 63, 589, 14, 740, 1332, 1501, 12, 3839, 430, 398, 1125, 275, 756, 267, 4203, 275, 6118, 14, 5453, 342, 267, 862, 26, 288, 327, 1104, 314, 1072, 687, 1924, 19569, 402, 25444, 13, 908, 315, 9861, 288, 367, 1788, 12, 3915, 315, 4203, 14, 7848, 1130, 1547, 1074, 63, 368, 63, 493, 12, 7739, 63, 589, 304, 355, 340, 440, 2368, 14, 10243, 26, 490, 870, 480, 14740, 8352, 908, 8, 1501, 430, 355, 340, 3915, 26, 490, 870, 20794, 10530, 25444, 13, 908, 3449, 10876, 1674, 908, 8, 1501, 430, 490, 327, 9101, 734, 314, 3915, 370, 4635, 490, 1125, 275, 715, 490, 327, 6567, 543, 282, 8057, 490, 870, 8, 493, 29, 1274, 14, 3083, 9, 490, 984, 14, 3083, 14, 23277, 8, 3028, 9, 267, 871, 2186, 26, 288, 1125, 275, 715, 288, 746, 267, 3753, 26, 288, 4203, 14, 14478, 342, 288, 4203, 14, 904, 342, 267, 984, 14, 2224, 8, 17, 340, 1125, 587, 378, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 628, 16291, 25444, 13, 908, 641, 1006, 402, 314, 1350, 298, 267, 298, 1725, 14, 982, 1553, 970, 365, 2013, 15814, 1475, 701, 298, 267, 298, 8951, 316, 315, 4192, 12, 4257, 6540, 314, 1072, 298, 267, 298, 1045, 314, 3411, 570, 436, 1072, 1263, 5784, 298, 267, 298, 6627, 465, 282, 3371, 315, 25344, 3915, 1475, 531, 272, 1798, 14, 525, 63, 2094, 6739, 16066, 63, 908, 63, 3008, 401, 717, 1415, 29, 549, 12, 717, 1720, 628, 2042, 370, 314, 25444, 13, 908, 3366, 531, 272, 1798, 14, 525, 63, 2094, 6739, 5473, 63, 15581, 401, 717, 1720, 628, 8117, 3035, 13977, 367, 1584, 298, 717, 298, 9099, 1077, 506, 8789, 687, 314, 5920, 531, 272, 1798, 14, 525, 63, 2094, 6739, 1365, 63, 3220, 401, 717, 1415 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 3, 22016, 687, 3668, 1952, 1143, 2199, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 24620, 1208, 199, 504, 3873, 492, 22773, 199, 646, 7534, 199, 646, 27070, 199, 646, 12866, 465, 6118, 199, 646, 984, 199, 504, 9143, 492, 7417, 421, 199, 3, 31758, 314, 1072, 402, 25444, 13, 908, 436, 340, 4493, 787, 199, 3, 3451, 22931, 282, 334, 32180, 9, 2068, 402, 314, 8865, 199, 318, 485, 1074, 63, 368, 63, 493, 8, 1501, 12, 7871, 304, 272, 543, 1551, 8, 1501, 12, 298, 4848, 531, 465, 7002, 26, 267, 3379, 275, 7002, 14, 739, 342, 339, 340, 7871, 1137, 3379, 26, 267, 327, 3378, 314, 7353, 402, 3915, 446, 85, 267, 3915, 275, 769, 8, 3028, 773, 14, 32180, 63, 3028, 8, 288, 3379, 14, 2708, 360, 1624, 24, 1959, 7644, 8, 549, 395, 288, 7871, 14, 2708, 360, 1624, 24, 1959, 7644, 8, 549, 395, 288, 687, 493, 29, 1501, 12, 288, 370, 493, 32053, 334, 4399, 25444, 1475, 30351, 908, 8, 355, 1788, 1724, 272, 587, 26, 267, 3915, 275, 488, 339, 372, 1788, 12, 3915, 199, 199, 318, 485, 1074, 63, 694, 8, 4958, 12, 1350, 63, 694, 12, 5760, 63, 15581, 304, 272, 7871, 63, 10309, 275, 942, 272, 367, 931, 315, 24620, 1208, 14, 362, 63, 4553, 8, 1365, 63, 694, 12, 5760, 63, 15581, 304, 288, 7871, 63, 10309, 14, 740, 8, 495, 8, 515, 430, 339, 340, 2368, 14, 970, 26, 267, 340, 440, 2368, 14, 10243, 26, 288, 870, 4582, 78, 1674, 904, 8, 1130, 8, 2734, 671, 26, 298, 20552, 8352, 908, 8, 88, 395, 1816, 7871, 63, 10309, 1724, 398, 327, 22535, 25444, 13, 908, 28202, 1901, 8291, 26, 1924, 19569, 6752, 267, 327, 3193, 1584, 14, 13144, 367, 1006, 10358, 370, 4890, 267, 2058, 275, 24620, 1208, 14, 1065, 63, 11887, 779, 288, 359, 4958, 14, 16066, 63, 908, 63, 3008, 12, 3905, 2487, 29, 493, 401, 3905, 73, 937, 435, 2005, 288, 367, 2005, 315, 24620, 1208, 14, 4604, 8, 15317, 63, 10309, 12, 3193, 9, 267, 4794, 267, 367, 17630, 12, 3839, 12, 4635, 315, 2058, 26, 288, 327, 340, 1263, 25444, 13, 908, 14581, 282, 2198, 1125, 12, 330, 21749, 652, 288, 340, 17630, 1137, 378, 26, 355, 984, 14, 2224, 8, 9913, 9, 339, 587, 26, 267, 327, 1255, 376, 1256, 402, 25444, 13, 908, 367, 1924, 1350, 570, 315, 9861, 12, 267, 327, 2066, 3618, 367, 1006, 10358, 370, 4890, 267, 2058, 275, 24620, 1208, 14, 1065, 63, 11887, 779, 288, 359, 4958, 14, 16066, 63, 908, 63, 3008, 12, 3905, 2487, 29, 493, 401, 1788, 61, 288, 367, 1788, 315, 7871, 63, 10309, 267, 2156, 3839, 29, 6089, 12, 4635, 29, 6089, 9, 398, 7739, 63, 589, 275, 942, 267, 367, 1788, 12, 522, 315, 3482, 8, 15317, 63, 10309, 12, 2058, 304, 288, 327, 340, 1263, 25444, 13, 908, 14581, 282, 2198, 1125, 12, 330, 21749, 652, 288, 17630, 12, 3839, 12, 4635, 275, 522, 288, 340, 17630, 1137, 378, 26, 355, 870, 8, 3083, 9, 355, 984, 14, 2224, 8, 9913, 9, 288, 7739, 63, 589, 14, 740, 1332, 1501, 12, 3839, 430, 398, 1125, 275, 756, 267, 4203, 275, 6118, 14, 5453, 342, 267, 862, 26, 288, 327, 1104, 314, 1072, 687, 1924, 19569, 402, 25444, 13, 908, 315, 9861, 288, 367, 1788, 12, 3915, 315, 4203, 14, 7848, 1130, 1547, 1074, 63, 368, 63, 493, 12, 7739, 63, 589, 304, 355, 340, 440, 2368, 14, 10243, 26, 490, 870, 480, 14740, 8352, 908, 8, 1501, 430, 355, 340, 3915, 26, 490, 870, 20794, 10530, 25444, 13, 908, 3449, 10876, 1674, 908, 8, 1501, 430, 490, 327, 9101, 734, 314, 3915, 370, 4635, 490, 1125, 275, 715, 490, 327, 6567, 543, 282, 8057, 490, 870, 8, 493, 29, 1274, 14, 3083, 9, 490, 984, 14, 3083, 14, 23277, 8, 3028, 9, 267, 871, 2186, 26, 288, 1125, 275, 715, 288, 746, 267, 3753, 26, 288, 4203, 14, 14478, 342, 288, 4203, 14, 904, 342, 267, 984, 14, 2224, 8, 17, 340, 1125, 587, 378, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 628, 16291, 25444, 13, 908, 641, 1006, 402, 314, 1350, 298, 267, 298, 1725, 14, 982, 1553, 970, 365, 2013, 15814, 1475, 701, 298, 267, 298, 8951, 316, 315, 4192, 12, 4257, 6540, 314, 1072, 298, 267, 298, 1045, 314, 3411, 570, 436, 1072, 1263, 5784, 298, 267, 298, 6627, 465, 282, 3371, 315, 25344, 3915, 1475, 531, 272, 1798, 14, 525, 63, 2094, 6739, 16066, 63, 908, 63, 3008, 401, 717, 1415, 29, 549, 12, 717, 1720, 628, 2042, 370, 314, 25444, 13, 908, 3366, 531, 272, 1798, 14, 525, 63, 2094, 6739, 5473, 63, 15581, 401, 717, 1720, 628, 8117, 3035, 13977, 367, 1584, 298, 717, 298, 9099, 1077, 506, 8789, 687, 314, 5920, 531, 272, 1798, 14, 525, 63, 2094, 6739, 1365, 63, 3220, 401, 717, 1415, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dhenrygithub/QGIS
python/plugins/processing/gui/ContextAction.py
6
1440
# -*- coding: utf-8 -*- """ *************************************************************************** ContextAction.py --------------------- Date : August 2012 Copyright : (C) 2012 by Victor Olaya Email : volayaf at gmail dot com *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** """ __author__ = 'Victor Olaya' __date__ = 'August 2012' __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' from qgis.PyQt.QtCore import QCoreApplication class ContextAction: def setData(self, itemData, toolbox): self.itemData = itemData self.toolbox = toolbox def tr(self, string, context=''): if context == '': context = 'ContextAction' return QCoreApplication.translate(context, string)
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 9470, 3310, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 25298, 833, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 6561, 630, 593, 817, 65, 272, 11426, 4483, 520, 5236, 1187, 2756, 737, 29712, 6308, 2414, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 2201, 630, 593, 817, 65, 7, 199, 363, 602, 363, 275, 283, 21640, 833, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 6561, 630, 593, 817, 65, 7, 199, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 421, 199, 504, 15640, 14, 24107, 14, 10901, 492, 1413, 29263, 421, 199, 533, 9470, 3310, 26, 339, 347, 663, 1451, 8, 277, 12, 1242, 1451, 12, 4744, 1977, 304, 267, 291, 14, 1053, 1451, 275, 1242, 1451, 267, 291, 14, 3557, 1977, 275, 4744, 1977, 339, 347, 5651, 8, 277, 12, 1059, 12, 1067, 9280, 267, 340, 1067, 508, 8061, 288, 1067, 275, 283, 2998, 3310, 7, 267, 372, 1413, 29263, 14, 5275, 8, 1100, 12, 1059, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 9470, 3310, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 25298, 833, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 6561, 630, 593, 817, 65, 272, 11426, 4483, 520, 5236, 1187, 2756, 737, 29712, 6308, 2414, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 2201, 630, 593, 817, 65, 7, 199, 363, 602, 363, 275, 283, 21640, 833, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 6561, 630, 593, 817, 65, 7, 199, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 421, 199, 504, 15640, 14, 24107, 14, 10901, 492, 1413, 29263, 421, 199, 533, 9470, 3310, 26, 339, 347, 663, 1451, 8, 277, 12, 1242, 1451, 12, 4744, 1977, 304, 267, 291, 14, 1053, 1451, 275, 1242, 1451, 267, 291, 14, 3557, 1977, 275, 4744, 1977, 339, 347, 5651, 8, 277, 12, 1059, 12, 1067, 9280, 267, 340, 1067, 508, 8061, 288, 1067, 275, 283, 2998, 3310, 7, 267, 372, 1413, 29263, 14, 5275, 8, 1100, 12, 1059, 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, 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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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 ]
AladdinSonni/youtube-dl
youtube_dl/extractor/veoh.py
128
4851
from __future__ import unicode_literals import re import json from .common import InfoExtractor from ..compat import ( compat_urllib_request, ) from ..utils import ( int_or_none, ExtractorError, ) class VeohIE(InfoExtractor): _VALID_URL = r'http://(?:www\.)?veoh\.com/(?:watch|iphone/#_Watch)/(?P<id>(?:v|yapi-)[\da-zA-Z]+)' _TESTS = [ { 'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3', 'md5': '620e68e6a3cff80086df3348426c9ca3', 'info_dict': { 'id': '56314296', 'ext': 'mp4', 'title': 'Straight Backs Are Stronger', 'uploader': 'LUMOback', 'description': 'At LUMOback, we believe straight backs are stronger. The LUMOback Posture & Movement Sensor: It gently vibrates when you slouch, inspiring improved posture and mobility. Use the app to track your data and improve your posture over time. ', }, }, { 'url': 'http://www.veoh.com/watch/v27701988pbTc4wzN?h1=Chile+workers+cover+up+to+avoid+skin+damage', 'md5': '4a6ff84b87d536a6a71e6aa6c0ad07fa', 'info_dict': { 'id': '27701988', 'ext': 'mp4', 'title': 'Chile workers cover up to avoid skin damage', 'description': 'md5:2bd151625a60a32822873efc246ba20d', 'uploader': 'afp-news', 'duration': 123, }, }, { 'url': 'http://www.veoh.com/watch/v69525809F6Nc4frX', 'md5': '4fde7b9e33577bab2f2f8f260e30e979', 'note': 'Embedded ooyala video', 'info_dict': { 'id': '69525809', 'ext': 'mp4', 'title': 'Doctors Alter Plan For Preteen\'s Weight Loss Surgery', 'description': 'md5:f5a11c51f8fb51d2315bca0937526891', 'uploader': 'newsy-videos', }, 'skip': 'This video has been deleted.', }, ] def _extract_formats(self, source): formats = [] link = source.get('aowPermalink') if link: formats.append({ 'url': link, 'ext': 'mp4', 'format_id': 'aow', }) link = source.get('fullPreviewHashLowPath') if link: formats.append({ 'url': link, 'format_id': 'low', }) link = source.get('fullPreviewHashHighPath') if link: formats.append({ 'url': link, 'format_id': 'high', }) return formats def _extract_video(self, source): return { 'id': source.get('videoId'), 'title': source.get('title'), 'description': source.get('description'), 'thumbnail': source.get('highResImage') or source.get('medResImage'), 'uploader': source.get('username'), 'duration': int_or_none(source.get('length')), 'view_count': int_or_none(source.get('views')), 'age_limit': 18 if source.get('isMature') == 'true' or source.get('isSexy') == 'true' else 0, 'formats': self._extract_formats(source), } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group('id') if video_id.startswith('v'): rsp = self._download_xml( r'http://www.veoh.com/api/findByPermalink?permalink=%s' % video_id, video_id, 'Downloading video XML') stat = rsp.get('stat') if stat == 'ok': return self._extract_video(rsp.find('./videoList/video')) elif stat == 'fail': raise ExtractorError( '%s said: %s' % (self.IE_NAME, rsp.find('./errorList/error').get('errorMessage')), expected=True) webpage = self._download_webpage(url, video_id) age_limit = 0 if 'class="adultwarning-container"' in webpage: self.report_age_confirmation() age_limit = 18 request = compat_urllib_request.Request(url) request.add_header('Cookie', 'confirmedAdult=true') webpage = self._download_webpage(request, video_id) m_youtube = re.search(r'http://www\.youtube\.com/v/(.*?)(\&|"|\?)', webpage) if m_youtube is not None: youtube_id = m_youtube.group(1) self.to_screen('%s: detected Youtube video.' % video_id) return self.url_result(youtube_id, 'Youtube') info = json.loads( self._search_regex(r'videoDetailsJSON = \'({.*?})\';', webpage, 'info').replace('\\\'', '\'')) video = self._extract_video(info) video['age_limit'] = age_limit return video
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 646, 2022, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1069, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 1109, 63, 269, 63, 3592, 12, 272, 19783, 12, 199, 9, 421, 199, 533, 25777, 19194, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 1014, 921, 5169, 1544, 20316, 432, 19194, 4537, 957, 32576, 6821, 92, 28303, 12645, 63, 13978, 2447, 2229, 48, 28, 344, 30, 5169, 86, 92, 89, 1246, 13, 2788, 60, 983, 13, 6353, 13, 58, 29716, 339, 485, 7569, 275, 359, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 432, 19194, 14, 957, 15, 6821, 15, 86, 1367, 8988, 11700, 23175, 23, 58, 6428, 90, 19, 297, 288, 283, 1064, 21, 356, 283, 22085, 69, 2333, 69, 22, 65, 19, 28667, 6718, 1184, 1587, 8425, 1349, 1479, 67, 25, 696, 19, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 1367, 8988, 11700, 297, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 1213, 356, 283, 933, 345, 1070, 10257, 83, 23889, 8303, 265, 836, 297, 355, 283, 13671, 356, 283, 44, 2639, 47, 894, 297, 355, 283, 1802, 356, 283, 1271, 491, 2639, 47, 894, 12, 781, 506, 317, 4754, 23669, 1771, 83, 787, 620, 265, 836, 14, 221, 710, 491, 2639, 47, 894, 7711, 608, 1253, 14171, 434, 18474, 26, 221, 2779, 486, 484, 590, 1321, 66, 17153, 1380, 1265, 308, 320, 2133, 12, 315, 681, 16648, 1742, 26429, 2963, 608, 436, 1303, 3195, 14, 221, 3645, 314, 1145, 370, 4426, 2195, 666, 436, 19053, 2195, 2963, 608, 1806, 900, 14, 1656, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 432, 19194, 14, 957, 15, 6821, 15, 86, 18, 4801, 31024, 3317, 52, 67, 20, 87, 90, 46, 31, 72, 17, 29, 1049, 441, 11, 11009, 11, 5899, 11, 384, 11, 475, 11, 27403, 11, 16409, 11, 26551, 297, 288, 283, 1064, 21, 356, 283, 20, 65, 22, 556, 1349, 66, 1555, 68, 25839, 65, 22, 65, 3172, 69, 22, 2158, 22, 67, 16, 350, 1780, 667, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 18, 4801, 31024, 297, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 1213, 356, 283, 1049, 441, 14123, 8486, 1536, 370, 5126, 28337, 12927, 960, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 18, 3691, 1046, 975, 821, 65, 2259, 65, 708, 10228, 17430, 2829, 67, 11440, 2470, 1165, 68, 297, 355, 283, 13671, 356, 283, 2756, 80, 13, 13224, 297, 355, 283, 5553, 356, 11869, 12, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 432, 19194, 14, 957, 15, 6821, 15, 86, 20017, 821, 11782, 38, 22, 46, 67, 20, 4391, 56, 297, 288, 283, 1064, 21, 356, 283, 20, 70, 271, 23, 66, 25, 69, 1153, 13539, 26118, 18, 70, 18, 70, 24, 70, 13085, 69, 1216, 69, 31955, 297, 288, 283, 4610, 356, 283, 27395, 16390, 89, 14774, 3991, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 20017, 821, 11782, 297, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 1213, 356, 283, 2585, 13451, 4580, 351, 32427, 2104, 5543, 25076, 3985, 83, 2136, 1070, 3835, 385, 17079, 836, 89, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 70, 21, 65, 845, 67, 2869, 70, 24, 4675, 2869, 68, 1789, 1046, 66, 696, 1643, 9946, 1479, 15601, 297, 355, 283, 13671, 356, 283, 1222, 1786, 13, 11418, 297, 288, 1660, 288, 283, 2759, 356, 283, 2765, 3991, 965, 2757, 5463, 3130, 267, 1660, 272, 1622, 339, 347, 485, 5005, 63, 6321, 8, 277, 12, 1350, 304, 267, 6752, 275, 942, 267, 2142, 275, 1350, 14, 362, 360, 65, 583, 2623, 2174, 2292, 358, 267, 340, 2142, 26, 288, 6752, 14, 740, 2561, 355, 283, 633, 356, 2142, 12, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 908, 63, 344, 356, 283, 65, 583, 297, 288, 3828, 267, 2142, 275, 1350, 14, 362, 360, 2861, 27116, 3476, 10281, 2042, 358, 267, 340, 2142, 26, 288, 6752, 14, 740, 2561, 355, 283, 633, 356, 2142, 12, 355, 283, 908, 63, 344, 356, 283, 674, 297, 288, 3828, 267, 2142, 275, 1350, 14, 362, 360, 2861, 27116, 3476, 11688, 2042, 358, 267, 340, 2142, 26, 288, 6752, 14, 740, 2561, 355, 283, 633, 356, 2142, 12, 355, 283, 908, 63, 344, 356, 283, 6260, 297, 288, 3828, 267, 372, 6752, 339, 347, 485, 5005, 63, 3722, 8, 277, 12, 1350, 304, 267, 372, 469, 288, 283, 344, 356, 1350, 14, 362, 360, 3722, 1304, 659, 288, 283, 1213, 356, 1350, 14, 362, 360, 1213, 659, 288, 283, 1802, 356, 1350, 14, 362, 360, 1802, 659, 288, 283, 8311, 356, 1350, 14, 362, 360, 6260, 1322, 3491, 358, 503, 1350, 14, 362, 360, 3594, 1322, 3491, 659, 288, 283, 13671, 356, 1350, 14, 362, 360, 2473, 659, 288, 283, 5553, 356, 1109, 63, 269, 63, 3592, 8, 1365, 14, 362, 360, 1267, 3855, 288, 283, 1345, 63, 835, 356, 1109, 63, 269, 63, 3592, 8, 1365, 14, 362, 360, 4196, 3855, 288, 283, 474, 63, 3097, 356, 6155, 340, 1350, 14, 362, 360, 374, 45, 1463, 358, 508, 283, 2052, 7, 503, 1350, 14, 362, 360, 374, 51, 476, 89, 358, 508, 283, 2052, 7, 587, 378, 12, 288, 283, 6321, 356, 291, 423, 5005, 63, 6321, 8, 1365, 395, 267, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 398, 340, 3991, 63, 344, 14, 2460, 360, 86, 735, 288, 13684, 275, 291, 423, 4249, 63, 1652, 8, 355, 519, 7, 1014, 921, 1544, 14, 432, 19194, 14, 957, 15, 1246, 15, 1623, 2175, 2623, 2174, 2292, 31, 529, 2174, 2292, 2458, 83, 7, 450, 3991, 63 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 646, 2022, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 4078, 63, 1069, 12, 199, 9, 199, 504, 2508, 1208, 492, 334, 272, 1109, 63, 269, 63, 3592, 12, 272, 19783, 12, 199, 9, 421, 199, 533, 25777, 19194, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 1014, 921, 5169, 1544, 20316, 432, 19194, 4537, 957, 32576, 6821, 92, 28303, 12645, 63, 13978, 2447, 2229, 48, 28, 344, 30, 5169, 86, 92, 89, 1246, 13, 2788, 60, 983, 13, 6353, 13, 58, 29716, 339, 485, 7569, 275, 359, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 432, 19194, 14, 957, 15, 6821, 15, 86, 1367, 8988, 11700, 23175, 23, 58, 6428, 90, 19, 297, 288, 283, 1064, 21, 356, 283, 22085, 69, 2333, 69, 22, 65, 19, 28667, 6718, 1184, 1587, 8425, 1349, 1479, 67, 25, 696, 19, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 1367, 8988, 11700, 297, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 1213, 356, 283, 933, 345, 1070, 10257, 83, 23889, 8303, 265, 836, 297, 355, 283, 13671, 356, 283, 44, 2639, 47, 894, 297, 355, 283, 1802, 356, 283, 1271, 491, 2639, 47, 894, 12, 781, 506, 317, 4754, 23669, 1771, 83, 787, 620, 265, 836, 14, 221, 710, 491, 2639, 47, 894, 7711, 608, 1253, 14171, 434, 18474, 26, 221, 2779, 486, 484, 590, 1321, 66, 17153, 1380, 1265, 308, 320, 2133, 12, 315, 681, 16648, 1742, 26429, 2963, 608, 436, 1303, 3195, 14, 221, 3645, 314, 1145, 370, 4426, 2195, 666, 436, 19053, 2195, 2963, 608, 1806, 900, 14, 1656, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 432, 19194, 14, 957, 15, 6821, 15, 86, 18, 4801, 31024, 3317, 52, 67, 20, 87, 90, 46, 31, 72, 17, 29, 1049, 441, 11, 11009, 11, 5899, 11, 384, 11, 475, 11, 27403, 11, 16409, 11, 26551, 297, 288, 283, 1064, 21, 356, 283, 20, 65, 22, 556, 1349, 66, 1555, 68, 25839, 65, 22, 65, 3172, 69, 22, 2158, 22, 67, 16, 350, 1780, 667, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 18, 4801, 31024, 297, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 1213, 356, 283, 1049, 441, 14123, 8486, 1536, 370, 5126, 28337, 12927, 960, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 18, 3691, 1046, 975, 821, 65, 2259, 65, 708, 10228, 17430, 2829, 67, 11440, 2470, 1165, 68, 297, 355, 283, 13671, 356, 283, 2756, 80, 13, 13224, 297, 355, 283, 5553, 356, 11869, 12, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 432, 19194, 14, 957, 15, 6821, 15, 86, 20017, 821, 11782, 38, 22, 46, 67, 20, 4391, 56, 297, 288, 283, 1064, 21, 356, 283, 20, 70, 271, 23, 66, 25, 69, 1153, 13539, 26118, 18, 70, 18, 70, 24, 70, 13085, 69, 1216, 69, 31955, 297, 288, 283, 4610, 356, 283, 27395, 16390, 89, 14774, 3991, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 20017, 821, 11782, 297, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 1213, 356, 283, 2585, 13451, 4580, 351, 32427, 2104, 5543, 25076, 3985, 83, 2136, 1070, 3835, 385, 17079, 836, 89, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 70, 21, 65, 845, 67, 2869, 70, 24, 4675, 2869, 68, 1789, 1046, 66, 696, 1643, 9946, 1479, 15601, 297, 355, 283, 13671, 356, 283, 1222, 1786, 13, 11418, 297, 288, 1660, 288, 283, 2759, 356, 283, 2765, 3991, 965, 2757, 5463, 3130, 267, 1660, 272, 1622, 339, 347, 485, 5005, 63, 6321, 8, 277, 12, 1350, 304, 267, 6752, 275, 942, 267, 2142, 275, 1350, 14, 362, 360, 65, 583, 2623, 2174, 2292, 358, 267, 340, 2142, 26, 288, 6752, 14, 740, 2561, 355, 283, 633, 356, 2142, 12, 355, 283, 832, 356, 283, 311, 20, 297, 355, 283, 908, 63, 344, 356, 283, 65, 583, 297, 288, 3828, 267, 2142, 275, 1350, 14, 362, 360, 2861, 27116, 3476, 10281, 2042, 358, 267, 340, 2142, 26, 288, 6752, 14, 740, 2561, 355, 283, 633, 356, 2142, 12, 355, 283, 908, 63, 344, 356, 283, 674, 297, 288, 3828, 267, 2142, 275, 1350, 14, 362, 360, 2861, 27116, 3476, 11688, 2042, 358, 267, 340, 2142, 26, 288, 6752, 14, 740, 2561, 355, 283, 633, 356, 2142, 12, 355, 283, 908, 63, 344, 356, 283, 6260, 297, 288, 3828, 267, 372, 6752, 339, 347, 485, 5005, 63, 3722, 8, 277, 12, 1350, 304, 267, 372, 469, 288, 283, 344, 356, 1350, 14, 362, 360, 3722, 1304, 659, 288, 283, 1213, 356, 1350, 14, 362, 360, 1213, 659, 288, 283, 1802, 356, 1350, 14, 362, 360, 1802, 659, 288, 283, 8311, 356, 1350, 14, 362, 360, 6260, 1322, 3491, 358, 503, 1350, 14, 362, 360, 3594, 1322, 3491, 659, 288, 283, 13671, 356, 1350, 14, 362, 360, 2473, 659, 288, 283, 5553, 356, 1109, 63, 269, 63, 3592, 8, 1365, 14, 362, 360, 1267, 3855, 288, 283, 1345, 63, 835, 356, 1109, 63, 269, 63, 3592, 8, 1365, 14, 362, 360, 4196, 3855, 288, 283, 474, 63, 3097, 356, 6155, 340, 1350, 14, 362, 360, 374, 45, 1463, 358, 508, 283, 2052, 7, 503, 1350, 14, 362, 360, 374, 51, 476, 89, 358, 508, 283, 2052, 7, 587, 378, 12, 288, 283, 6321, 356, 291, 423, 5005, 63, 6321, 8, 1365, 395, 267, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 360, 344, 358, 398, 340, 3991, 63, 344, 14, 2460, 360, 86, 735, 288, 13684, 275, 291, 423, 4249, 63, 1652, 8, 355, 519, 7, 1014, 921, 1544, 14, 432, 19194, 14, 957, 15, 1246, 15, 1623, 2175, 2623, 2174, 2292, 31, 529, 2174, 2292, 2458, 83, 7, 450, 3991, 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, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
etzhou/edx-platform
lms/djangoapps/branding/migrations/0002_auto__add_brandingapiconfig.py
84
5295
# -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding model 'BrandingApiConfig' db.create_table('branding_brandingapiconfig', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('change_date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), ('changed_by', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, on_delete=models.PROTECT)), ('enabled', self.gf('django.db.models.fields.BooleanField')(default=False)), )) db.send_create_signal('branding', ['BrandingApiConfig']) def backwards(self, orm): # Deleting model 'BrandingApiConfig' db.delete_table('branding_brandingapiconfig') 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'}) }, 'branding.brandingapiconfig': { 'Meta': {'object_name': 'BrandingApiConfig'}, 'change_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'changed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'on_delete': 'models.PROTECT'}), 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, 'branding.brandinginfoconfig': { 'Meta': {'object_name': 'BrandingInfoConfig'}, 'change_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'changed_by': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'on_delete': 'models.PROTECT'}), 'configuration': ('django.db.models.fields.TextField', [], {}), 'enabled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) } } complete_apps = ['branding']
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 1402, 283, 34, 3759, 316, 7394, 2028, 7, 267, 1592, 14, 981, 63, 1224, 360, 19026, 316, 63, 19026, 316, 1246, 888, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 1461, 63, 602, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 2489, 63, 991, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 995, 2973, 29, 549, 12, 641, 63, 1807, 29, 992, 14, 29148, 1826, 288, 661, 3827, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 797, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 19026, 316, 297, 788, 34, 3759, 316, 7394, 2028, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 34, 3759, 316, 7394, 2028, 7, 267, 1592, 14, 1807, 63, 1224, 360, 19026, 316, 63, 19026, 316, 1246, 888, 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, 19026, 316, 14, 19026, 316, 1246, 888, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 34, 3759, 316, 7394, 2028, 2267, 288, 283, 1461, 63, 602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 2495, 63, 2131, 63, 525, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2489, 63, 991, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 12919, 14, 1208, 492, 2197, 63, 1208, 465, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 12090, 8, 24822, 304, 339, 347, 17465, 8, 277, 12, 9813, 304, 267, 327, 12934, 1402, 283, 34, 3759, 316, 7394, 2028, 7, 267, 1592, 14, 981, 63, 1224, 360, 19026, 316, 63, 19026, 316, 1246, 888, 297, 334, 288, 661, 344, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 7533, 3327, 63, 498, 29, 549, 1826, 288, 661, 1461, 63, 602, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 2495, 63, 2131, 63, 525, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 2489, 63, 991, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 1178, 14, 1899, 995, 2973, 29, 549, 12, 641, 63, 1807, 29, 992, 14, 29148, 1826, 288, 661, 3827, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 797, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 19026, 316, 297, 788, 34, 3759, 316, 7394, 2028, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 34, 3759, 316, 7394, 2028, 7, 267, 1592, 14, 1807, 63, 1224, 360, 19026, 316, 63, 19026, 316, 1246, 888, 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, 19026, 316, 14, 19026, 316, 1246, 888, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 34, 3759, 316, 7394, 2028, 2267, 288, 283, 1461, 63, 602, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 2495, 63, 2131, 63, 525, 356, 283, 549, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2489, 63, 991, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
smithfarm/s3-tests
s3tests/functional/test_s3.py
1
203153
from cStringIO import StringIO import boto.exception import boto.s3.connection import boto.s3.acl import bunch import datetime import time import email.utils import isodate import nose import operator import socket import ssl import os import requests import base64 import hmac import sha import pytz import json import httplib2 import threading import itertools import string import random import xml.etree.ElementTree as ET from httplib import HTTPConnection, HTTPSConnection from urlparse import urlparse from nose.tools import eq_ as eq from nose.plugins.attrib import attr from nose.plugins.skip import SkipTest from .utils import assert_raises from .utils import generate_random from .utils import region_sync_meta import AnonymousAuth from email.header import decode_header from ordereddict import OrderedDict from boto.s3.cors import CORSConfiguration from . import ( nuke_prefixed_buckets, get_new_bucket, get_new_bucket_name, s3, targets, config, get_prefix, is_slow_backend, ) NONEXISTENT_EMAIL = 'doesnotexist@dreamhost.com.invalid' def not_eq(a, b): assert a != b, "%r == %r" % (a, b) def check_access_denied(fn, *args, **kwargs): e = assert_raises(boto.exception.S3ResponseError, fn, *args, **kwargs) eq(e.status, 403) eq(e.reason, 'Forbidden') eq(e.error_code, 'AccessDenied') def check_grants(got, want): """ Check that grants list in got matches the dictionaries in want, in any order. """ eq(len(got), len(want)) got = sorted(got, key=operator.attrgetter('id')) want = sorted(want, key=operator.itemgetter('id')) for g, w in zip(got, want): w = dict(w) eq(g.permission, w.pop('permission')) eq(g.id, w.pop('id')) eq(g.display_name, w.pop('display_name')) eq(g.uri, w.pop('uri')) eq(g.email_address, w.pop('email_address')) eq(g.type, w.pop('type')) eq(w, {}) @attr(resource='bucket') @attr(method='get') @attr(operation='list') @attr(assertion='empty buckets return no contents') def test_bucket_list_empty(): bucket = get_new_bucket() l = bucket.list() l = list(l) eq(l, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list') @attr(assertion='distinct buckets have different contents') def test_bucket_list_distinct(): bucket1 = get_new_bucket() bucket2 = get_new_bucket() key = bucket1.new_key('asdf') key.set_contents_from_string('asdf') l = bucket2.list() l = list(l) eq(l, []) def _create_keys(bucket=None, keys=[]): """ Populate a (specified or new) bucket with objects with specified names (and contents identical to their names). """ if bucket is None: bucket = get_new_bucket() for s in keys: key = bucket.new_key(s) key.set_contents_from_string(s) return bucket def _get_keys_prefixes(li): """ figure out which of the strings in a list are actually keys return lists of strings that are (keys) and are not (prefixes) """ keys = [x for x in li if isinstance(x, boto.s3.key.Key)] prefixes = [x for x in li if not isinstance(x, boto.s3.key.Key)] return (keys, prefixes) @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='pagination w/max_keys=2, no marker') def test_bucket_list_many(): bucket = _create_keys(keys=['foo', 'bar', 'baz']) # bucket.list() is high-level and will not let us set max-keys, # using it would require using >1000 keys to test, and that would # be too slow; use the lower-level call bucket.get_all_keys() # instead l = bucket.get_all_keys(max_keys=2) eq(len(l), 2) eq(l.is_truncated, True) names = [e.name for e in l] eq(names, ['bar', 'baz']) l = bucket.get_all_keys(max_keys=2, marker=names[-1]) eq(len(l), 1) eq(l.is_truncated, False) names = [e.name for e in l] eq(names, ['foo']) @attr(resource='bucket') @attr(method='get') @attr(operation='list') @attr(assertion='prefixes in multi-component object names') def test_bucket_list_delimiter_basic(): bucket = _create_keys(keys=['foo/bar', 'foo/baz/xyzzy', 'quux/thud', 'asdf']) # listings should treat / delimiter in a directory-like fashion li = bucket.list(delimiter='/') eq(li.delimiter, '/') # asdf is the only terminal object that should appear in the listing (keys,prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, ['asdf']) # In Amazon, you will have two CommonPrefixes elements, each with a single # prefix. According to Amazon documentation # (http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketGET.html), # the response's CommonPrefixes should contain all the prefixes, which DHO # does. # # Unfortunately, boto considers a CommonPrefixes element as a prefix, and # will store the last Prefix element within a CommonPrefixes element, # effectively overwriting any other prefixes. # the other returned values should be the pure prefixes foo/ and quux/ prefix_names = [e.name for e in prefixes] eq(len(prefixes), 2) eq(prefix_names, ['foo/', 'quux/']) def validate_bucket_list(bucket, prefix, delimiter, marker, max_keys, is_truncated, check_objs, check_prefixes, next_marker): # li = bucket.get_all_keys(delimiter=delimiter, prefix=prefix, max_keys=max_keys, marker=marker) eq(li.is_truncated, is_truncated) eq(li.next_marker, next_marker) (keys, prefixes) = _get_keys_prefixes(li) eq(len(keys), len(check_objs)) eq(len(prefixes), len(check_prefixes)) objs = [e.name for e in keys] eq(objs, check_objs) prefix_names = [e.name for e in prefixes] eq(prefix_names, check_prefixes) return li.next_marker @attr(resource='bucket') @attr(method='get') @attr(operation='list') @attr(assertion='prefixes in multi-component object names') def test_bucket_list_delimiter_prefix(): bucket = _create_keys(keys=['asdf', 'boo/bar', 'boo/baz/xyzzy', 'cquux/thud', 'cquux/bla']) delim = '/' marker = '' prefix = '' marker = validate_bucket_list(bucket, prefix, delim, '', 1, True, ['asdf'], [], 'asdf') marker = validate_bucket_list(bucket, prefix, delim, marker, 1, True, [], ['boo/'], 'boo/') marker = validate_bucket_list(bucket, prefix, delim, marker, 1, False, [], ['cquux/'], None) marker = validate_bucket_list(bucket, prefix, delim, '', 2, True, ['asdf'], ['boo/'], 'boo/') marker = validate_bucket_list(bucket, prefix, delim, marker, 2, False, [], ['cquux/'], None) prefix = 'boo/' marker = validate_bucket_list(bucket, prefix, delim, '', 1, True, ['boo/bar'], [], 'boo/bar') marker = validate_bucket_list(bucket, prefix, delim, marker, 1, False, [], ['boo/baz/'], None) marker = validate_bucket_list(bucket, prefix, delim, '', 2, False, ['boo/bar'], ['boo/baz/'], None) @attr(resource='bucket') @attr(method='get') @attr(operation='list') @attr(assertion='non-slash delimiter characters') def test_bucket_list_delimiter_alt(): bucket = _create_keys(keys=['bar', 'baz', 'cab', 'foo']) li = bucket.list(delimiter='a') eq(li.delimiter, 'a') # foo contains no 'a' and so is a complete key (keys,prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, ['foo']) # bar, baz, and cab should be broken up by the 'a' delimiters prefix_names = [e.name for e in prefixes] eq(len(prefixes), 2) eq(prefix_names, ['ba', 'ca']) @attr(resource='bucket') @attr(method='get') @attr(operation='list') @attr(assertion='non-printable delimiter can be specified') def test_bucket_list_delimiter_unreadable(): key_names = ['bar', 'baz', 'cab', 'foo'] bucket = _create_keys(keys=key_names) li = bucket.list(delimiter='\x0a') eq(li.delimiter, '\x0a') (keys, prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, key_names) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list') @attr(assertion='empty delimiter can be specified') def test_bucket_list_delimiter_empty(): key_names = ['bar', 'baz', 'cab', 'foo'] bucket = _create_keys(keys=key_names) li = bucket.list(delimiter='') eq(li.delimiter, '') (keys, prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, key_names) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list') @attr(assertion='unspecified delimiter defaults to none') def test_bucket_list_delimiter_none(): key_names = ['bar', 'baz', 'cab', 'foo'] bucket = _create_keys(keys=key_names) li = bucket.list() eq(li.delimiter, '') (keys, prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, key_names) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list') @attr(assertion='unused delimiter is not found') def test_bucket_list_delimiter_not_exist(): key_names = ['bar', 'baz', 'cab', 'foo'] bucket = _create_keys(keys=key_names) li = bucket.list(delimiter='/') eq(li.delimiter, '/') (keys, prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, key_names) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list under prefix') @attr(assertion='returns only objects under prefix') def test_bucket_list_prefix_basic(): bucket = _create_keys(keys=['foo/bar', 'foo/baz', 'quux']) li = bucket.list(prefix='foo/') eq(li.prefix, 'foo/') (keys, prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, ['foo/bar', 'foo/baz']) eq(prefixes, []) # just testing that we can do the delimeter and prefix logic on non-slashes @attr(resource='bucket') @attr(method='get') @attr(operation='list under prefix') @attr(assertion='prefixes w/o delimiters') def test_bucket_list_prefix_alt(): bucket = _create_keys(keys=['bar', 'baz', 'foo']) li = bucket.list(prefix='ba') eq(li.prefix, 'ba') (keys, prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, ['bar', 'baz']) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list under prefix') @attr(assertion='empty prefix returns everything') def test_bucket_list_prefix_empty(): key_names = ['foo/bar', 'foo/baz', 'quux'] bucket = _create_keys(keys=key_names) li = bucket.list(prefix='') eq(li.prefix, '') (keys, prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, key_names) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list under prefix') @attr(assertion='unspecified prefix returns everything') def test_bucket_list_prefix_none(): key_names = ['foo/bar', 'foo/baz', 'quux'] bucket = _create_keys(keys=key_names) li = bucket.list() eq(li.prefix, '') (keys, prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, key_names) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list under prefix') @attr(assertion='nonexistent prefix returns nothing') def test_bucket_list_prefix_not_exist(): bucket = _create_keys(keys=['foo/bar', 'foo/baz', 'quux']) li = bucket.list(prefix='d') eq(li.prefix, 'd') (keys, prefixes) = _get_keys_prefixes(li) eq(keys, []) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list under prefix') @attr(assertion='non-printable prefix can be specified') def test_bucket_list_prefix_unreadable(): # FIX: shouldn't this test include strings that start with the tested prefix bucket = _create_keys(keys=['foo/bar', 'foo/baz', 'quux']) li = bucket.list(prefix='\x0a') eq(li.prefix, '\x0a') (keys, prefixes) = _get_keys_prefixes(li) eq(keys, []) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list under prefix w/delimiter') @attr(assertion='returns only objects directly under prefix') def test_bucket_list_prefix_delimiter_basic(): bucket = _create_keys(keys=['foo/bar', 'foo/baz/xyzzy', 'quux/thud', 'asdf']) li = bucket.list(prefix='foo/', delimiter='/') eq(li.prefix, 'foo/') eq(li.delimiter, '/') (keys, prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, ['foo/bar']) prefix_names = [e.name for e in prefixes] eq(prefix_names, ['foo/baz/']) @attr(resource='bucket') @attr(method='get') @attr(operation='list under prefix w/delimiter') @attr(assertion='non-slash delimiters') def test_bucket_list_prefix_delimiter_alt(): bucket = _create_keys(keys=['bar', 'bazar', 'cab', 'foo']) li = bucket.list(prefix='ba', delimiter='a') eq(li.prefix, 'ba') eq(li.delimiter, 'a') (keys, prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, ['bar']) prefix_names = [e.name for e in prefixes] eq(prefix_names, ['baza']) @attr(resource='bucket') @attr(method='get') @attr(operation='list under prefix w/delimiter') @attr(assertion='finds nothing w/unmatched prefix') def test_bucket_list_prefix_delimiter_prefix_not_exist(): bucket = _create_keys(keys=['b/a/r', 'b/a/c', 'b/a/g', 'g']) li = bucket.list(prefix='d', delimiter='/') (keys, prefixes) = _get_keys_prefixes(li) eq(keys, []) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list under prefix w/delimiter') @attr(assertion='over-ridden slash ceases to be a delimiter') def test_bucket_list_prefix_delimiter_delimiter_not_exist(): bucket = _create_keys(keys=['b/a/c', 'b/a/g', 'b/a/r', 'g']) li = bucket.list(prefix='b', delimiter='z') (keys, prefixes) = _get_keys_prefixes(li) names = [e.name for e in keys] eq(names, ['b/a/c', 'b/a/g', 'b/a/r']) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list under prefix w/delimiter') @attr(assertion='finds nothing w/unmatched prefix and delimiter') def test_bucket_list_prefix_delimiter_prefix_delimiter_not_exist(): bucket = _create_keys(keys=['b/a/c', 'b/a/g', 'b/a/r', 'g']) li = bucket.list(prefix='y', delimiter='z') (keys, prefixes) = _get_keys_prefixes(li) eq(keys, []) eq(prefixes, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='pagination w/max_keys=1, marker') def test_bucket_list_maxkeys_one(): key_names = ['bar', 'baz', 'foo', 'quxx'] bucket = _create_keys(keys=key_names) li = bucket.get_all_keys(max_keys=1) eq(len(li), 1) eq(li.is_truncated, True) names = [e.name for e in li] eq(names, key_names[0:1]) li = bucket.get_all_keys(marker=key_names[0]) eq(li.is_truncated, False) names = [e.name for e in li] eq(names, key_names[1:]) @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='pagination w/max_keys=0') def test_bucket_list_maxkeys_zero(): bucket = _create_keys(keys=['bar', 'baz', 'foo', 'quxx']) li = bucket.get_all_keys(max_keys=0) eq(li.is_truncated, False) eq(li, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='pagination w/o max_keys') def test_bucket_list_maxkeys_none(): key_names = ['bar', 'baz', 'foo', 'quxx'] bucket = _create_keys(keys=key_names) li = bucket.get_all_keys() eq(li.is_truncated, False) names = [e.name for e in li] eq(names, key_names) eq(li.MaxKeys, '1000') @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='invalid max_keys') def test_bucket_list_maxkeys_invalid(): bucket = _create_keys(keys=['bar', 'baz', 'foo', 'quxx']) e = assert_raises(boto.exception.S3ResponseError, bucket.get_all_keys, max_keys='blah') eq(e.status, 400) eq(e.reason, 'Bad Request') eq(e.error_code, 'InvalidArgument') @attr('fails_on_rgw') @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='non-printing max_keys') def test_bucket_list_maxkeys_unreadable(): bucket = _create_keys(keys=['bar', 'baz', 'foo', 'quxx']) e = assert_raises(boto.exception.S3ResponseError, bucket.get_all_keys, max_keys='\x0a') eq(e.status, 400) eq(e.reason, 'Bad Request') # Weird because you can clearly see an InvalidArgument error code. What's # also funny is the Amazon tells us that it's not an interger or within an # integer range. Is 'blah' in the integer range? eq(e.error_code, 'InvalidArgument') @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='no pagination, no marker') def test_bucket_list_marker_none(): key_names = ['bar', 'baz', 'foo', 'quxx'] bucket = _create_keys(keys=key_names) li = bucket.get_all_keys() eq(li.marker, '') @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='no pagination, empty marker') def test_bucket_list_marker_empty(): key_names = ['bar', 'baz', 'foo', 'quxx'] bucket = _create_keys(keys=key_names) li = bucket.get_all_keys(marker='') eq(li.marker, '') eq(li.is_truncated, False) names = [e.name for e in li] eq(names, key_names) @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='non-printing marker') def test_bucket_list_marker_unreadable(): key_names = ['bar', 'baz', 'foo', 'quxx'] bucket = _create_keys(keys=key_names) li = bucket.get_all_keys(marker='\x0a') eq(li.marker, '\x0a') eq(li.is_truncated, False) names = [e.name for e in li] eq(names, key_names) @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='marker not-in-list') def test_bucket_list_marker_not_in_list(): bucket = _create_keys(keys=['bar', 'baz', 'foo', 'quxx']) li = bucket.get_all_keys(marker='blah') eq(li.marker, 'blah') names = [e.name for e in li] eq(names, ['foo', 'quxx']) @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='marker after list') def test_bucket_list_marker_after_list(): bucket = _create_keys(keys=['bar', 'baz', 'foo', 'quxx']) li = bucket.get_all_keys(marker='zzz') eq(li.marker, 'zzz') eq(li.is_truncated, False) eq(li, []) @attr(resource='bucket') @attr(method='get') @attr(operation='list all keys') @attr(assertion='marker before list') def test_bucket_list_marker_before_list(): key_names = ['bar', 'baz', 'foo', 'quxx'] bucket = _create_keys(keys=key_names) li = bucket.get_all_keys(marker='aaa') eq(li.marker, 'aaa') eq(li.is_truncated, False) names = [e.name for e in li] eq(names, key_names) def _compare_dates(iso_datetime, http_datetime): """ compare an iso date and an http date, within an epsiolon """ date = isodate.parse_datetime(iso_datetime) pd = email.utils.parsedate_tz(http_datetime) tz = isodate.tzinfo.FixedOffset(0, pd[-1]/60, 'who cares') date2 = datetime.datetime(*pd[:6], tzinfo=tz) # our tolerance minutes = 5 acceptable_delta = datetime.timedelta(minutes=minutes) assert abs(date - date2) < acceptable_delta, \ ("Times are not within {minutes} minutes of each other: " + "{date1!r}, {date2!r}" ).format( minutes=minutes, date1=iso_datetime, date2=http_datetime, ) @attr(resource='object') @attr(method='head') @attr(operation='compare w/bucket list') @attr(assertion='return same metadata') def test_bucket_list_return_data(): key_names = ['bar', 'baz', 'foo'] bucket = _create_keys(keys=key_names) # grab the data from each key individually data = {} for key_name in key_names: key = bucket.get_key(key_name) acl = key.get_acl() data.update({ key_name: { 'user_id': acl.owner.id, 'display_name': acl.owner.display_name, 'etag': key.etag, 'last_modified': key.last_modified, 'size': key.size, 'md5': key.md5, 'content_encoding': key.content_encoding, } }) # now grab the data from each key through list li = bucket.list() for key in li: key_data = data[key.name] eq(key.content_encoding, key_data['content_encoding']) eq(key.owner.display_name, key_data['display_name']) eq(key.etag, key_data['etag']) eq(key.md5, key_data['md5']) eq(key.size, key_data['size']) eq(key.owner.id, key_data['user_id']) _compare_dates(key.last_modified, key_data['last_modified']) @attr(resource='object.metadata') @attr(method='head') @attr(operation='modification-times') @attr(assertion='http and ISO-6801 times agree') def test_bucket_list_object_time(): bucket = _create_keys(keys=['foo']) # Wed, 10 Aug 2011 21:58:25 GMT' key = bucket.get_key('foo') http_datetime = key.last_modified # ISO-6801 formatted datetime # there should be only one element, but list doesn't have a __getitem__ # only an __iter__ for key in bucket.list(): iso_datetime = key.last_modified _compare_dates(iso_datetime, http_datetime) @attr(resource='bucket') @attr(method='get') @attr(operation='non-existant bucket') @attr(assertion='fails 404') def test_bucket_notexist(): # generate a (hopefully) unique, not-yet existent bucket name name = '{prefix}foo'.format(prefix=get_prefix()) print 'Trying bucket {name!r}'.format(name=name) e = assert_raises(boto.exception.S3ResponseError, s3.main.get_bucket, name) eq(e.status, 404) eq(e.reason, 'Not Found') eq(e.error_code, 'NoSuchBucket') @attr(resource='bucket') @attr(method='delete') @attr(operation='non-existant bucket') @attr(assertion='fails 404') def test_bucket_delete_notexist(): name = '{prefix}foo'.format(prefix=get_prefix()) print 'Trying bucket {name!r}'.format(name=name) e = assert_raises(boto.exception.S3ResponseError, s3.main.delete_bucket, name) eq(e.status, 404) eq(e.reason, 'Not Found') eq(e.error_code, 'NoSuchBucket') @attr(resource='bucket') @attr(method='delete') @attr(operation='non-empty bucket') @attr(assertion='fails 409') def test_bucket_delete_nonempty(): bucket = get_new_bucket() # fill up bucket key = bucket.new_key('foo') key.set_contents_from_string('foocontent') # try to delete e = assert_raises(boto.exception.S3ResponseError, bucket.delete) eq(e.status, 409) eq(e.reason, 'Conflict') eq(e.error_code, 'BucketNotEmpty') @attr(resource='object') @attr(method='put') @attr(operation='non-existant bucket') @attr(assertion='fails 404') def test_object_write_to_nonexist_bucket(): name = '{prefix}foo'.format(prefix=get_prefix()) print 'Trying bucket {name!r}'.format(name=name) bucket = s3.main.get_bucket(name, validate=False) key = bucket.new_key('foo123bar') e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'foo') eq(e.status, 404) eq(e.reason, 'Not Found') eq(e.error_code, 'NoSuchBucket') @attr(resource='bucket') @attr(method='del') @attr(operation='deleted bucket') @attr(assertion='fails 404') def test_bucket_create_delete(): name = '{prefix}foo'.format(prefix=get_prefix()) print 'Trying bucket {name!r}'.format(name=name) bucket = get_new_bucket(targets.main.default, name) # make sure it's actually there s3.main.get_bucket(bucket.name) bucket.delete() # make sure it's gone e = assert_raises(boto.exception.S3ResponseError, bucket.delete) eq(e.status, 404) eq(e.reason, 'Not Found') eq(e.error_code, 'NoSuchBucket') @attr(resource='object') @attr(method='get') @attr(operation='read contents that were never written') @attr(assertion='fails 404') def test_object_read_notexist(): bucket = get_new_bucket() key = bucket.new_key('foobar') e = assert_raises(boto.exception.S3ResponseError, key.get_contents_as_string) eq(e.status, 404) eq(e.reason, 'Not Found') eq(e.error_code, 'NoSuchKey') @attr(resource='object') @attr(method='put') @attr(operation='write to special characters key') @attr(assertion='fails 404') def test_object_create_special_characters(): bucket = get_new_bucket() # sourced from: http://xml.silmaril.ie/specials.html key = bucket.new_key('<&>"\'') key.set_contents_from_string('bar') got = key.get_contents_as_string() eq(got, 'bar') bucket.get_all_keys() # While the test itself passes, there's a SAX parser error during teardown. It # seems to be a boto bug. It happens with both amazon and dho. # http://code.google.com/p/boto/issues/detail?id=501 @attr(resource='object') @attr(method='put') @attr(operation='write to non-printing key') @attr(assertion='fails 404') def test_object_create_unreadable(): bucket = get_new_bucket() key = bucket.new_key('\x0a') key.set_contents_from_string('bar') @attr(resource='object') @attr(method='post') @attr(operation='delete multiple objects') @attr(assertion='deletes multiple objects with a single call') def test_multi_object_delete(): bucket = get_new_bucket() key0 = bucket.new_key('key0') key0.set_contents_from_string('foo') key1 = bucket.new_key('key1') key1.set_contents_from_string('bar') stored_keys = bucket.get_all_keys() eq(len(stored_keys), 2) result = bucket.delete_keys(stored_keys) eq(len(result.deleted), 2) eq(len(result.errors), 0) eq(len(bucket.get_all_keys()), 0) # now remove again, should all succeed due to idempotency result = bucket.delete_keys(stored_keys) eq(len(result.deleted), 2) eq(len(result.errors), 0) eq(len(bucket.get_all_keys()), 0) @attr(resource='object') @attr(method='put') @attr(operation='write key') @attr(assertion='correct etag') def test_object_write_check_etag(): bucket = get_new_bucket() key = bucket.new_key('foo') res = _make_request('PUT', bucket, key, body='bar', authenticated=True) eq(res.status, 200) eq(res.reason, 'OK') eq(res.getheader("ETag"), '"37b51d194a7513e45b56f6524f2d51f2"') @attr(resource='object') @attr(method='put') @attr(operation='write key') @attr(assertion='correct cache control header') def test_object_write_cache_control(): bucket = get_new_bucket() key = bucket.new_key('foo') cache_control = 'public, max-age=14400' key.set_contents_from_string('bar', headers = {'Cache-Control': cache_control}) key2 = bucket.get_key('foo') eq(key2.cache_control, cache_control) @attr(resource='object') @attr(method='put') @attr(operation='write key') @attr(assertion='correct expires header') def test_object_write_expires(): bucket = get_new_bucket() key = bucket.new_key('foo') utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) expires = expires.strftime("%a, %d %b %Y %H:%M:%S GMT") key.set_contents_from_string('bar', headers = {'Expires': expires}) key2 = bucket.get_key('foo') eq(key2.expires, expires) @attr(resource='object') @attr(method='all') @attr(operation='complete object life cycle') @attr(assertion='read back what we wrote and rewrote') def test_object_write_read_update_read_delete(): bucket = get_new_bucket() # Write key = bucket.new_key('foo') key.set_contents_from_string('bar') # Read got = key.get_contents_as_string() eq(got, 'bar') # Update key.set_contents_from_string('soup') # Read got = key.get_contents_as_string() eq(got, 'soup') # Delete key.delete() def _set_get_metadata(metadata, bucket=None): """ create a new key in a (new or specified) bucket, set the meta1 property to a specified, value, and then re-read and return that property """ if bucket is None: bucket = get_new_bucket() key = boto.s3.key.Key(bucket) key.key = ('foo') key.set_metadata('meta1', metadata) key.set_contents_from_string('bar') key2 = bucket.get_key('foo') return key2.get_metadata('meta1') @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata write/re-read') @attr(assertion='reread what we wrote') def test_object_set_get_metadata_none_to_good(): got = _set_get_metadata('mymeta') eq(got, 'mymeta') @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata write/re-read') @attr(assertion='write empty value, returns empty value') def test_object_set_get_metadata_none_to_empty(): got = _set_get_metadata('') eq(got, '') @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata write/re-write') @attr(assertion='new value replaces old') def test_object_set_get_metadata_overwrite_to_good(): bucket = get_new_bucket() got = _set_get_metadata('oldmeta', bucket) eq(got, 'oldmeta') got = _set_get_metadata('newmeta', bucket) eq(got, 'newmeta') @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata write/re-write') @attr(assertion='empty value replaces old') def test_object_set_get_metadata_overwrite_to_empty(): bucket = get_new_bucket() got = _set_get_metadata('oldmeta', bucket) eq(got, 'oldmeta') got = _set_get_metadata('', bucket) eq(got, '') @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata write/re-write') @attr(assertion='UTF-8 values passed through') def test_object_set_get_unicode_metadata(): bucket = get_new_bucket() key = boto.s3.key.Key(bucket) key.key = (u'foo') key.set_metadata('meta1', u"Hello World\xe9") key.set_contents_from_string('bar') key2 = bucket.get_key('foo') got = key2.get_metadata('meta1') eq(got, u"Hello World\xe9") @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata write/re-write') @attr(assertion='non-UTF-8 values detected, but preserved') @attr('fails_strict_rfc2616') def test_object_set_get_non_utf8_metadata(): bucket = get_new_bucket() key = boto.s3.key.Key(bucket) key.key = ('foo') key.set_metadata('meta1', '\x04mymeta') key.set_contents_from_string('bar') key2 = bucket.get_key('foo') got = key2.get_metadata('meta1') eq(got, '=?UTF-8?Q?=04mymeta?=') def _set_get_metadata_unreadable(metadata, bucket=None): """ set and then read back a meta-data value (which presumably includes some interesting characters), and return a list containing the stored value AND the encoding with which it was returned. """ got = _set_get_metadata(metadata, bucket) got = decode_header(got) return got @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata write') @attr(assertion='non-priting prefixes noted and preserved') @attr('fails_strict_rfc2616') def test_object_set_get_metadata_empty_to_unreadable_prefix(): metadata = '\x04w' got = _set_get_metadata_unreadable(metadata) eq(got, [(metadata, 'utf-8')]) @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata write') @attr(assertion='non-priting suffixes noted and preserved') @attr('fails_strict_rfc2616') def test_object_set_get_metadata_empty_to_unreadable_suffix(): metadata = 'h\x04' got = _set_get_metadata_unreadable(metadata) eq(got, [(metadata, 'utf-8')]) @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata write') @attr(assertion='non-priting in-fixes noted and preserved') def test_object_set_get_metadata_empty_to_unreadable_infix(): metadata = 'h\x04w' got = _set_get_metadata_unreadable(metadata) eq(got, [(metadata, 'utf-8')]) @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata re-write') @attr(assertion='non-priting prefixes noted and preserved') @attr('fails_strict_rfc2616') def test_object_set_get_metadata_overwrite_to_unreadable_prefix(): metadata = '\x04w' got = _set_get_metadata_unreadable(metadata) eq(got, [(metadata, 'utf-8')]) metadata2 = '\x05w' got2 = _set_get_metadata_unreadable(metadata2) eq(got2, [(metadata2, 'utf-8')]) @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata re-write') @attr(assertion='non-priting suffixes noted and preserved') @attr('fails_strict_rfc2616') def test_object_set_get_metadata_overwrite_to_unreadable_suffix(): metadata = 'h\x04' got = _set_get_metadata_unreadable(metadata) eq(got, [(metadata, 'utf-8')]) metadata2 = 'h\x05' got2 = _set_get_metadata_unreadable(metadata2) eq(got2, [(metadata2, 'utf-8')]) @attr(resource='object.metadata') @attr(method='put') @attr(operation='metadata re-write') @attr(assertion='non-priting in-fixes noted and preserved') def test_object_set_get_metadata_overwrite_to_unreadable_infix(): metadata = 'h\x04w' got = _set_get_metadata_unreadable(metadata) eq(got, [(metadata, 'utf-8')]) metadata2 = 'h\x05w' got2 = _set_get_metadata_unreadable(metadata2) eq(got2, [(metadata2, 'utf-8')]) @attr(resource='object') @attr(method='put') @attr(operation='data re-write') @attr(assertion='replaces previous metadata') def test_object_metadata_replaced_on_put(): bucket = get_new_bucket() # create object with metadata key = bucket.new_key('foo') key.set_metadata('meta1', 'bar') key.set_contents_from_string('bar') # overwrite previous object, no metadata key2 = bucket.new_key('foo') key2.set_contents_from_string('bar') # should see no metadata, as per 2nd write key3 = bucket.get_key('foo') got = key3.get_metadata('meta1') assert got is None, "did not expect to see metadata: %r" % got @attr(resource='object') @attr(method='put') @attr(operation='data write from file (w/100-Continue)') @attr(assertion='succeeds and returns written data') def test_object_write_file(): # boto Key.set_contents_from_file / .send_file uses Expect: # 100-Continue, so this test exercises that (though a bit too # subtly) bucket = get_new_bucket() key = bucket.new_key('foo') data = StringIO('bar') key.set_contents_from_file(fp=data) got = key.get_contents_as_string() eq(got, 'bar') def _get_post_url(conn, bucket): url = '{protocol}://{host}:{port}/{bucket}'.format(protocol= 'https' if conn.is_secure else 'http',\ host=conn.host, port=conn.port, bucket=bucket.name) return url @attr(resource='object') @attr(method='post') @attr(operation='anonymous browser based upload via POST request') @attr(assertion='succeeds and returns written data') def test_post_object_anonymous_request(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) bucket.set_acl('public-read-write') payload = OrderedDict([("key" , "foo.txt"),("acl" , "public-read"),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 204) key = bucket.get_key("foo.txt") got = key.get_contents_as_string() eq(got, 'bar') @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='succeeds and returns written data') def test_post_object_authenticated_request(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 204) key = bucket.get_key("foo.txt") got = key.get_contents_as_string() eq(got, 'bar') @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request, bad access key') @attr(assertion='fails') def test_post_object_authenticated_request_bad_access_key(): bucket = get_new_bucket() bucket.set_acl('public-read-write') url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , 'foo'),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 403) @attr(resource='object') @attr(method='post') @attr(operation='anonymous browser based upload via POST request') @attr(assertion='succeeds with status 201') def test_post_object_set_success_code(): bucket = get_new_bucket() bucket.set_acl('public-read-write') url = _get_post_url(s3.main, bucket) payload = OrderedDict([("key" , "foo.txt"),("acl" , "public-read"),\ ("success_action_status" , "201"),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 201) message = ET.fromstring(r.content).find('Key') eq(message.text,'foo.txt') @attr(resource='object') @attr(method='post') @attr(operation='anonymous browser based upload via POST request') @attr(assertion='succeeds with status 204') def test_post_object_set_invalid_success_code(): bucket = get_new_bucket() bucket.set_acl('public-read-write') url = _get_post_url(s3.main, bucket) payload = OrderedDict([("key" , "foo.txt"),("acl" , "public-read"),\ ("success_action_status" , "404"),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 204) eq(r.content,'') @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='succeeds and returns written data') def test_post_object_upload_larger_than_chunk(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 5*1024*1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) foo_string = 'foo' * 1024*1024 payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', foo_string)]) r = requests.post(url, files = payload) eq(r.status_code, 204) key = bucket.get_key("foo.txt") got = key.get_contents_as_string() eq(got, foo_string) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='succeeds and returns written data') def test_post_object_set_key_from_filename(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 5*1024*1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "${filename}"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('foo.txt', 'bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 204) key = bucket.get_key("foo.txt") got = key.get_contents_as_string() eq(got, 'bar') @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='succeeds with status 204') def test_post_object_ignored_header(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),("x-ignore-foo" , "bar"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 204) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='succeeds with status 204') def test_post_object_case_insensitive_condition_fields(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bUcKeT": bucket.name},\ ["StArTs-WiTh", "$KeY", "foo"],\ {"AcL": "private"},\ ["StArTs-WiTh", "$CoNtEnT-TyPe", "text/plain"],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("kEy" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("aCl" , "private"),("signature" , signature),("pOLICy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 204) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='succeeds with escaped leading $ and returns written data') def test_post_object_escaped_field_values(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "\$foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "\$foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 204) key = bucket.get_key("\$foo.txt") got = key.get_contents_as_string() eq(got, 'bar') @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='succeeds and returns redirect url') def test_post_object_success_redirect_action(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) redirect_url = _get_post_url(s3.main, bucket) bucket.set_acl('public-read') utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["eq", "$success_action_redirect", redirect_url],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),("success_action_redirect" , redirect_url),\ ('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 200) url = r.url key = bucket.get_key("foo.txt") eq(url, '{rurl}?bucket={bucket}&key={key}&etag=%22{etag}%22'.format(rurl = redirect_url, bucket = bucket.name, key = key.name, etag = key.etag.strip('"'))) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with invalid signature error') def test_post_object_invalid_signature(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "\$foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest())[::-1] payload = OrderedDict([ ("key" , "\$foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 403) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with access key does not exist error') def test_post_object_invalid_access_key(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "\$foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "\$foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id[::-1]),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 403) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with invalid expiration error') def test_post_object_invalid_date_format(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": str(expires),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "\$foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "\$foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 400) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with missing key error') def test_post_object_no_key_specified(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 400) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with missing signature error') def test_post_object_missing_signature(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "\$foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 400) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with extra input fields policy error') def test_post_object_missing_policy_condition(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 403) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='succeeds using starts-with restriction on metadata header') def test_post_object_user_specified_header(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024],\ ["starts-with", "$x-amz-meta-foo", "bar"] ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('x-amz-meta-foo' , 'barclamp'),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 204) key = bucket.get_key("foo.txt") eq(key.get_metadata('foo'), 'barclamp') @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with policy condition failed error due to missing field in POST request') def test_post_object_request_missing_policy_specified_field(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024],\ ["starts-with", "$x-amz-meta-foo", "bar"] ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 403) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with conditions must be list error') def test_post_object_condition_is_case_sensitive(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "CONDITIONS": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024],\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 400) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with expiration must be string error') def test_post_object_expires_is_case_sensitive(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"EXPIRATION": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024],\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 400) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with policy expired error') def test_post_object_expired_policy(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=-6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024],\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 403) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails using equality restriction on metadata header') def test_post_object_invalid_request_field_value(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024],\ ["eq", "$x-amz-meta-foo", ""] ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('x-amz-meta-foo' , 'barclamp'),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 403) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with policy missing expiration error') def test_post_object_missing_expires_condition(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 1024],\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 400) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with policy missing conditions error') def test_post_object_missing_conditions_list(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 400) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with allowable upload size exceeded error') def test_post_object_upload_size_limit_exceeded(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0, 0]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 400) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with invalid content length error') def test_post_object_missing_content_length_argument(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 0]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 400) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with invalid JSON error') def test_post_object_invalid_content_length_argument(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", -1, 0]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 400) @attr(resource='object') @attr(method='post') @attr(operation='authenticated browser based upload via POST request') @attr(assertion='fails with upload size less than minimum allowable error') def test_post_object_upload_size_below_minimum(): bucket = get_new_bucket() url = _get_post_url(s3.main, bucket) utc = pytz.utc expires = datetime.datetime.now(utc) + datetime.timedelta(seconds=+6000) policy_document = {"expiration": expires.strftime("%Y-%m-%dT%H:%M:%SZ"),\ "conditions": [\ {"bucket": bucket.name},\ ["starts-with", "$key", "foo"],\ {"acl": "private"},\ ["starts-with", "$Content-Type", "text/plain"],\ ["content-length-range", 512, 1000]\ ]\ } json_policy_document = json.JSONEncoder().encode(policy_document) policy = base64.b64encode(json_policy_document) conn = s3.main signature = base64.b64encode(hmac.new(conn.aws_secret_access_key, policy, sha).digest()) payload = OrderedDict([ ("key" , "foo.txt"),("AWSAccessKeyId" , conn.aws_access_key_id),\ ("acl" , "private"),("signature" , signature),("policy" , policy),\ ("Content-Type" , "text/plain"),('file', ('bar'))]) r = requests.post(url, files = payload) eq(r.status_code, 400) @attr(resource='object') @attr(method='put') @attr(operation='data re-write w/ If-Match: the latest ETag') @attr(assertion='replaces previous data and metadata') @attr('fails_on_aws') def test_put_object_ifmatch_good(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') got_data = key.get_contents_as_string() eq(got_data, 'bar') key.set_contents_from_string('zar', headers={'If-Match': key.etag.replace('"', '').strip()}) got_new_data = key.get_contents_as_string() eq(got_new_data, 'zar') @attr(resource='object') @attr(method='put') @attr(operation='data re-write w/ If-Match: outdated ETag') @attr(assertion='fails 412') @attr('fails_on_aws') def test_put_object_ifmatch_failed(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') got_data = key.get_contents_as_string() eq(got_data, 'bar') e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'zar', headers={'If-Match': 'ABCORZ'}) eq(e.status, 412) eq(e.reason, 'Precondition Failed') eq(e.error_code, 'PreconditionFailed') got_old_data = key.get_contents_as_string() eq(got_old_data, 'bar') @attr(resource='object') @attr(method='put') @attr(operation='overwrite existing object w/ If-Match: *') @attr(assertion='replaces previous data and metadata') @attr('fails_on_aws') def test_put_object_ifmatch_overwrite_existed_good(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') got_data = key.get_contents_as_string() eq(got_data, 'bar') key.set_contents_from_string('zar', headers={'If-Match': '*'}) got_new_data = key.get_contents_as_string() eq(got_new_data, 'zar') @attr(resource='object') @attr(method='put') @attr(operation='overwrite non-existing object w/ If-Match: *') @attr(assertion='fails 412') @attr('fails_on_aws') def test_put_object_ifmatch_nonexisted_failed(): bucket = get_new_bucket() key = bucket.new_key('foo') e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'bar', headers={'If-Match': '*'}) eq(e.status, 412) eq(e.reason, 'Precondition Failed') eq(e.error_code, 'PreconditionFailed') e = assert_raises(boto.exception.S3ResponseError, key.get_contents_as_string) eq(e.status, 404) eq(e.reason, 'Not Found') eq(e.error_code, 'NoSuchKey') @attr(resource='object') @attr(method='put') @attr(operation='overwrite existing object w/ If-None-Match: outdated ETag') @attr(assertion='replaces previous data and metadata') @attr('fails_on_aws') def test_put_object_ifnonmatch_good(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') got_data = key.get_contents_as_string() eq(got_data, 'bar') key.set_contents_from_string('zar', headers={'If-None-Match': 'ABCORZ'}) got_new_data = key.get_contents_as_string() eq(got_new_data, 'zar') @attr(resource='object') @attr(method='put') @attr(operation='overwrite existing object w/ If-None-Match: the latest ETag') @attr(assertion='fails 412') @attr('fails_on_aws') def test_put_object_ifnonmatch_failed(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') got_data = key.get_contents_as_string() eq(got_data, 'bar') e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'zar', headers={'If-None-Match': key.etag.replace('"', '').strip()}) eq(e.status, 412) eq(e.reason, 'Precondition Failed') eq(e.error_code, 'PreconditionFailed') got_old_data = key.get_contents_as_string() eq(got_old_data, 'bar') @attr(resource='object') @attr(method='put') @attr(operation='overwrite non-existing object w/ If-None-Match: *') @attr(assertion='succeeds') @attr('fails_on_aws') def test_put_object_ifnonmatch_nonexisted_good(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar', headers={'If-None-Match': '*'}) got_data = key.get_contents_as_string() eq(got_data, 'bar') @attr(resource='object') @attr(method='put') @attr(operation='overwrite existing object w/ If-None-Match: *') @attr(assertion='fails 412') @attr('fails_on_aws') def test_put_object_ifnonmatch_overwrite_existed_failed(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') got_data = key.get_contents_as_string() eq(got_data, 'bar') e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_string, 'zar', headers={'If-None-Match': '*'}) eq(e.status, 412) eq(e.reason, 'Precondition Failed') eq(e.error_code, 'PreconditionFailed') got_old_data = key.get_contents_as_string() eq(got_old_data, 'bar') def _setup_request(bucket_acl=None, object_acl=None): """ add a foo key, and specified key and bucket acls to a (new or existing) bucket. """ bucket = _create_keys(keys=['foo']) key = bucket.get_key('foo') if bucket_acl is not None: bucket.set_acl(bucket_acl) if object_acl is not None: key.set_acl(object_acl) return (bucket, key) def _setup_bucket_request(bucket_acl=None): """ set up a (new or existing) bucket with specified acl """ bucket = get_new_bucket() if bucket_acl is not None: bucket.set_acl(bucket_acl) return bucket def _make_request(method, bucket, key, body=None, authenticated=False, response_headers=None, expires_in=100000): """ issue a request for a specified method, on a specified <bucket,key>, with a specified (optional) body (encrypted per the connection), and return the response (status, reason) """ if authenticated: url = key.generate_url(expires_in, method=method, response_headers=response_headers) o = urlparse(url) path = o.path + '?' + o.query else: path = '/{bucket}/{obj}'.format(bucket=key.bucket.name, obj=key.name) if s3.main.is_secure: class_ = HTTPSConnection else: class_ = HTTPConnection c = class_(s3.main.host, s3.main.port, strict=True) c.request(method, path, body=body) res = c.getresponse() print res.status, res.reason return res def _make_bucket_request(method, bucket, body=None, authenticated=False, expires_in=100000): """ issue a request for a specified method, on a specified <bucket,key>, with a specified (optional) body (encrypted per the connection), and return the response (status, reason) """ if authenticated: url = bucket.generate_url(expires_in, method=method) o = urlparse(url) path = o.path + '?' + o.query else: path = '/{bucket}'.format(bucket=bucket.name) if s3.main.is_secure: class_ = HTTPSConnection else: class_ = HTTPConnection c = class_(s3.main.host, s3.main.port, strict=True) c.request(method, path, body=body) res = c.getresponse() print res.status, res.reason return res @attr(resource='object') @attr(method='get') @attr(operation='publically readable bucket') @attr(assertion='bucket is readable') def test_object_raw_get(): (bucket, key) = _setup_request('public-read', 'public-read') res = _make_request('GET', bucket, key) eq(res.status, 200) eq(res.reason, 'OK') @attr(resource='object') @attr(method='get') @attr(operation='deleted object and bucket') @attr(assertion='fails 404') def test_object_raw_get_bucket_gone(): (bucket, key) = _setup_request('public-read', 'public-read') key.delete() bucket.delete() res = _make_request('GET', bucket, key) eq(res.status, 404) eq(res.reason, 'Not Found') @attr(resource='object') @attr(method='delete') @attr(operation='deleted object and bucket') @attr(assertion='fails 404') def test_object_delete_key_bucket_gone(): (bucket, key) = _setup_request() key.delete() bucket.delete() e = assert_raises(boto.exception.S3ResponseError, key.delete) eq(e.status, 404) eq(e.reason, 'Not Found') eq(e.error_code, 'NoSuchBucket') @attr(resource='object') @attr(method='get') @attr(operation='deleted object') @attr(assertion='fails 404') def test_object_raw_get_object_gone(): (bucket, key) = _setup_request('public-read', 'public-read') key.delete() res = _make_request('GET', bucket, key) eq(res.status, 404) eq(res.reason, 'Not Found') def _head_bucket(bucket, authenticated=True): res = _make_bucket_request('HEAD', bucket, authenticated=authenticated) eq(res.status, 200) eq(res.reason, 'OK') result = {} obj_count = res.getheader('x-rgw-object-count') if obj_count != None: result['x-rgw-object-count'] = int(obj_count) bytes_used = res.getheader('x-rgw-bytes-used') if bytes_used is not None: result['x-rgw-bytes-used'] = int(bytes_used) return result @attr(resource='bucket') @attr(method='head') @attr(operation='head bucket') @attr(assertion='succeeds') def test_bucket_head(): bucket = get_new_bucket() _head_bucket(bucket) # This test relies on Ceph extensions. # http://tracker.ceph.com/issues/2313 @attr('fails_on_aws') @attr(resource='bucket') @attr(method='head') @attr(operation='read bucket extended information') @attr(assertion='extended information is getting updated') def test_bucket_head_extended(): bucket = get_new_bucket() result = _head_bucket(bucket) eq(result.get('x-rgw-object-count', 0), 0) eq(result.get('x-rgw-bytes-used', 0), 0) _create_keys(bucket, keys=['foo', 'bar', 'baz']) result = _head_bucket(bucket) eq(result.get('x-rgw-object-count', 3), 3) assert result.get('x-rgw-bytes-used', 9) > 0 @attr(resource='bucket.acl') @attr(method='get') @attr(operation='unauthenticated on private bucket') @attr(assertion='succeeds') def test_object_raw_get_bucket_acl(): (bucket, key) = _setup_request('private', 'public-read') res = _make_request('GET', bucket, key) eq(res.status, 200) eq(res.reason, 'OK') @attr(resource='object.acl') @attr(method='get') @attr(operation='unauthenticated on private object') @attr(assertion='fails 403') def test_object_raw_get_object_acl(): (bucket, key) = _setup_request('public-read', 'private') res = _make_request('GET', bucket, key) eq(res.status, 403) eq(res.reason, 'Forbidden') @attr(resource='object') @attr(method='ACLs') @attr(operation='authenticated on public bucket/object') @attr(assertion='succeeds') def test_object_raw_authenticated(): (bucket, key) = _setup_request('public-read', 'public-read') res = _make_request('GET', bucket, key, authenticated=True) eq(res.status, 200) eq(res.reason, 'OK') @attr(resource='object') @attr(method='get') @attr(operation='authenticated on private bucket/private object with modified response headers') @attr(assertion='succeeds') @attr('fails_on_rgw') def test_object_raw_response_headers(): (bucket, key) = _setup_request('private', 'private') response_headers = { 'response-content-type': 'foo/bar', 'response-content-disposition': 'bla', 'response-content-language': 'esperanto', 'response-content-encoding': 'aaa', 'response-expires': '123', 'response-cache-control': 'no-cache', } res = _make_request('GET', bucket, key, authenticated=True, response_headers=response_headers) eq(res.status, 200) eq(res.reason, 'OK') eq(res.getheader('content-type'), 'foo/bar') eq(res.getheader('content-disposition'), 'bla') eq(res.getheader('content-language'), 'esperanto') eq(res.getheader('content-encoding'), 'aaa') eq(res.getheader('expires'), '123') eq(res.getheader('cache-control'), 'no-cache') @attr(resource='object') @attr(method='ACLs') @attr(operation='authenticated on private bucket/public object') @attr(assertion='succeeds') def test_object_raw_authenticated_bucket_acl(): (bucket, key) = _setup_request('private', 'public-read') res = _make_request('GET', bucket, key, authenticated=True) eq(res.status, 200) eq(res.reason, 'OK') @attr(resource='object') @attr(method='ACLs') @attr(operation='authenticated on public bucket/private object') @attr(assertion='succeeds') def test_object_raw_authenticated_object_acl(): (bucket, key) = _setup_request('public-read', 'private') res = _make_request('GET', bucket, key, authenticated=True) eq(res.status, 200) eq(res.reason, 'OK') @attr(resource='object') @attr(method='get') @attr(operation='authenticated on deleted object and bucket') @attr(assertion='fails 404') def test_object_raw_authenticated_bucket_gone(): (bucket, key) = _setup_request('public-read', 'public-read') key.delete() bucket.delete() res = _make_request('GET', bucket, key, authenticated=True) eq(res.status, 404) eq(res.reason, 'Not Found') @attr(resource='object') @attr(method='get') @attr(operation='authenticated on deleted object') @attr(assertion='fails 404') def test_object_raw_authenticated_object_gone(): (bucket, key) = _setup_request('public-read', 'public-read') key.delete() res = _make_request('GET', bucket, key, authenticated=True) eq(res.status, 404) eq(res.reason, 'Not Found') @attr(resource='object') @attr(method='put') @attr(operation='unauthenticated, no object acls') @attr(assertion='fails 403') def test_object_raw_put(): bucket = get_new_bucket() key = bucket.new_key('foo') res = _make_request('PUT', bucket, key, body='foo') eq(res.status, 403) eq(res.reason, 'Forbidden') @attr(resource='object') @attr(method='put') @attr(operation='unauthenticated, publically writable object') @attr(assertion='succeeds') def test_object_raw_put_write_access(): bucket = get_new_bucket() bucket.set_acl('public-read-write') key = bucket.new_key('foo') res = _make_request('PUT', bucket, key, body='foo') eq(res.status, 200) eq(res.reason, 'OK') @attr(resource='object') @attr(method='put') @attr(operation='authenticated, no object acls') @attr(assertion='succeeds') def test_object_raw_put_authenticated(): bucket = get_new_bucket() key = bucket.new_key('foo') res = _make_request('PUT', bucket, key, body='foo', authenticated=True) eq(res.status, 200) eq(res.reason, 'OK') @attr(resource='object') @attr(method='put') @attr(operation='authenticated, no object acls') @attr(assertion='succeeds') def test_object_raw_put_authenticated_expired(): bucket = get_new_bucket() key = bucket.new_key('foo') res = _make_request('PUT', bucket, key, body='foo', authenticated=True, expires_in=-1000) eq(res.status, 403) eq(res.reason, 'Forbidden') def check_bad_bucket_name(name): """ Attempt to create a bucket with a specified name, and confirm that the request fails because of an invalid bucket name. """ e = assert_raises(boto.exception.S3ResponseError, get_new_bucket, targets.main.default, name) eq(e.status, 400) eq(e.reason, 'Bad Request') eq(e.error_code, 'InvalidBucketName') # AWS does not enforce all documented bucket restrictions. # http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?BucketRestrictions.html @attr('fails_on_aws') # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='name begins with underscore') @attr(assertion='fails with subdomain: 400') def test_bucket_create_naming_bad_starts_nonalpha(): bucket_name = get_new_bucket_name() check_bad_bucket_name('_' + bucket_name) @attr(resource='bucket') @attr(method='put') @attr(operation='empty name') @attr(assertion='fails 405') def test_bucket_create_naming_bad_short_empty(): # bucket creates where name is empty look like PUTs to the parent # resource (with slash), hence their error response is different e = assert_raises(boto.exception.S3ResponseError, get_new_bucket, targets.main.default, '') eq(e.status, 405) eq(e.reason, 'Method Not Allowed') eq(e.error_code, 'MethodNotAllowed') @attr(resource='bucket') @attr(method='put') @attr(operation='short (one character) name') @attr(assertion='fails 400') def test_bucket_create_naming_bad_short_one(): check_bad_bucket_name('a') @attr(resource='bucket') @attr(method='put') @attr(operation='short (two character) name') @attr(assertion='fails 400') def test_bucket_create_naming_bad_short_two(): check_bad_bucket_name('aa') # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='excessively long names') @attr(assertion='fails with subdomain: 400') def test_bucket_create_naming_bad_long(): check_bad_bucket_name(256*'a') check_bad_bucket_name(280*'a') check_bad_bucket_name(3000*'a') def check_good_bucket_name(name, _prefix=None): """ Attempt to create a bucket with a specified name and (specified or default) prefix, returning the results of that effort. """ # tests using this with the default prefix must *not* rely on # being able to set the initial character, or exceed the max len # tests using this with a custom prefix are responsible for doing # their own setup/teardown nukes, with their custom prefix; this # should be very rare if _prefix is None: _prefix = get_prefix() get_new_bucket(targets.main.default, '{prefix}{name}'.format( prefix=_prefix, name=name, )) def _test_bucket_create_naming_good_long(length): """ Attempt to create a bucket whose name (including the prefix) is of a specified length. """ prefix = get_new_bucket_name() assert len(prefix) < 255 num = length - len(prefix) get_new_bucket(targets.main.default, '{prefix}{name}'.format( prefix=prefix, name=num*'a', )) # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/250 byte name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_good_long_250(): _test_bucket_create_naming_good_long(250) # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/251 byte name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_good_long_251(): _test_bucket_create_naming_good_long(251) # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/252 byte name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_good_long_252(): _test_bucket_create_naming_good_long(252) # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/253 byte name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_good_long_253(): _test_bucket_create_naming_good_long(253) # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/254 byte name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_good_long_254(): _test_bucket_create_naming_good_long(254) # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/255 byte name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_good_long_255(): _test_bucket_create_naming_good_long(255) # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='get') @attr(operation='list w/251 byte name') @attr(assertion='fails with subdomain') def test_bucket_list_long_name(): prefix = get_new_bucket_name() length = 251 num = length - len(prefix) bucket = get_new_bucket(targets.main.default, '{prefix}{name}'.format( prefix=prefix, name=num*'a', )) got = bucket.list() got = list(got) eq(got, []) # AWS does not enforce all documented bucket restrictions. # http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?BucketRestrictions.html @attr('fails_on_aws') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/ip address for name') @attr(assertion='fails on aws') def test_bucket_create_naming_bad_ip(): check_bad_bucket_name('192.168.5.123') # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/! in name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_bad_punctuation(): # characters other than [a-zA-Z0-9._-] check_bad_bucket_name('alpha!soup') # test_bucket_create_naming_dns_* are valid but not recommended @attr(resource='bucket') @attr(method='put') @attr(operation='create w/underscore in name') @attr(assertion='succeeds') def test_bucket_create_naming_dns_underscore(): check_good_bucket_name('foo_bar') # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/100 byte name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_dns_long(): prefix = get_prefix() assert len(prefix) < 50 num = 100 - len(prefix) check_good_bucket_name(num * 'a') # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/dash at end of name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_dns_dash_at_end(): check_good_bucket_name('foo-') # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/.. in name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_dns_dot_dot(): check_good_bucket_name('foo..bar') # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/.- in name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_dns_dot_dash(): check_good_bucket_name('foo.-bar') # Breaks DNS with SubdomainCallingFormat @attr('fails_with_subdomain') @attr(resource='bucket') @attr(method='put') @attr(operation='create w/-. in name') @attr(assertion='fails with subdomain') def test_bucket_create_naming_dns_dash_dot(): check_good_bucket_name('foo-.bar') @attr(resource='bucket') @attr(method='put') @attr(operation='re-create') @attr(assertion='idempotent success') def test_bucket_create_exists(): bucket = get_new_bucket(targets.main.default) # REST idempotency means this should be a nop get_new_bucket(targets.main.default, bucket.name) @attr(resource='bucket') @attr(method='get') @attr(operation='get location') def test_bucket_get_location(): bucket = get_new_bucket(targets.main.default) actual_location = bucket.get_location() expected_location = targets.main.default.conf.api_name eq(actual_location, expected_location) @attr(resource='bucket') @attr(method='put') @attr(operation='re-create by non-owner') @attr(assertion='fails 409') def test_bucket_create_exists_nonowner(): # Names are shared across a global namespace. As such, no two # users can create a bucket with that same name. bucket = get_new_bucket() e = assert_raises(boto.exception.S3CreateError, get_new_bucket, targets.alt.default, bucket.name) eq(e.status, 409) eq(e.reason, 'Conflict') eq(e.error_code, 'BucketAlreadyExists') @attr(resource='bucket') @attr(method='del') @attr(operation='delete by non-owner') @attr(assertion='fails') def test_bucket_delete_nonowner(): bucket = get_new_bucket() check_access_denied(s3.alt.delete_bucket, bucket.name) @attr(resource='bucket') @attr(method='get') @attr(operation='default acl') @attr(assertion='read back expected defaults') def test_bucket_acl_default(): bucket = get_new_bucket() policy = bucket.get_acl() print repr(policy) eq(policy.owner.type, None) eq(policy.owner.id, config.main.user_id) eq(policy.owner.display_name, config.main.display_name) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), ], ) @attr(resource='bucket') @attr(method='get') @attr(operation='public-read acl') @attr(assertion='read back expected defaults') def test_bucket_acl_canned_during_create(): name = get_new_bucket_name() bucket = targets.main.default.connection.create_bucket(name, policy = 'public-read') policy = bucket.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ', id=None, display_name=None, uri='http://acs.amazonaws.com/groups/global/AllUsers', email_address=None, type='Group', ), ], ) @attr(resource='bucket') @attr(method='put') @attr(operation='acl: public-read,private') @attr(assertion='read back expected values') def test_bucket_acl_canned(): bucket = get_new_bucket() # Since it defaults to private, set it public-read first bucket.set_acl('public-read') policy = bucket.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ', id=None, display_name=None, uri='http://acs.amazonaws.com/groups/global/AllUsers', email_address=None, type='Group', ), ], ) # Then back to private. bucket.set_acl('private') policy = bucket.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), ], ) @attr(resource='bucket.acls') @attr(method='put') @attr(operation='acl: public-read-write') @attr(assertion='read back expected values') def test_bucket_acl_canned_publicreadwrite(): bucket = get_new_bucket() bucket.set_acl('public-read-write') policy = bucket.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ', id=None, display_name=None, uri='http://acs.amazonaws.com/groups/global/AllUsers', email_address=None, type='Group', ), dict( permission='WRITE', id=None, display_name=None, uri='http://acs.amazonaws.com/groups/global/AllUsers', email_address=None, type='Group', ), ], ) @attr(resource='bucket') @attr(method='put') @attr(operation='acl: authenticated-read') @attr(assertion='read back expected values') def test_bucket_acl_canned_authenticatedread(): bucket = get_new_bucket() bucket.set_acl('authenticated-read') policy = bucket.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ', id=None, display_name=None, uri='http://acs.amazonaws.com/groups/global/AuthenticatedUsers', email_address=None, type='Group', ), ], ) @attr(resource='object.acls') @attr(method='get') @attr(operation='default acl') @attr(assertion='read back expected defaults') def test_object_acl_default(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') policy = key.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), ], ) @attr(resource='object.acls') @attr(method='put') @attr(operation='acl public-read') @attr(assertion='read back expected values') def test_object_acl_canned_during_create(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar', policy='public-read') policy = key.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ', id=None, display_name=None, uri='http://acs.amazonaws.com/groups/global/AllUsers', email_address=None, type='Group', ), ], ) @attr(resource='object.acls') @attr(method='put') @attr(operation='acl public-read,private') @attr(assertion='read back expected values') def test_object_acl_canned(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') # Since it defaults to private, set it public-read first key.set_acl('public-read') policy = key.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ', id=None, display_name=None, uri='http://acs.amazonaws.com/groups/global/AllUsers', email_address=None, type='Group', ), ], ) # Then back to private. key.set_acl('private') policy = key.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), ], ) @attr(resource='object') @attr(method='put') @attr(operation='acl public-read-write') @attr(assertion='read back expected values') def test_object_acl_canned_publicreadwrite(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') key.set_acl('public-read-write') policy = key.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ', id=None, display_name=None, uri='http://acs.amazonaws.com/groups/global/AllUsers', email_address=None, type='Group', ), dict( permission='WRITE', id=None, display_name=None, uri='http://acs.amazonaws.com/groups/global/AllUsers', email_address=None, type='Group', ), ], ) @attr(resource='object.acls') @attr(method='put') @attr(operation='acl authenticated-read') @attr(assertion='read back expected values') def test_object_acl_canned_authenticatedread(): bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') key.set_acl('authenticated-read') policy = key.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ', id=None, display_name=None, uri='http://acs.amazonaws.com/groups/global/AuthenticatedUsers', email_address=None, type='Group', ), ], ) @attr(resource='object.acls') @attr(method='put') @attr(operation='acl bucket-owner-read') @attr(assertion='read back expected values') def test_object_acl_canned_bucketownerread(): bucket = get_new_bucket(targets.main.default) bucket.set_acl('public-read-write') key = s3.alt.get_bucket(bucket.name).new_key('foo') key.set_contents_from_string('bar') bucket_policy = bucket.get_acl() bucket_owner_id = bucket_policy.owner.id bucket_owner_display = bucket_policy.owner.display_name key.set_acl('bucket-owner-read') policy = key.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ', id=bucket_owner_id, display_name=bucket_owner_display, uri=None, email_address=None, type='CanonicalUser', ), ], ) key.delete() bucket.delete() @attr(resource='object.acls') @attr(method='put') @attr(operation='acl bucket-owner-read') @attr(assertion='read back expected values') def test_object_acl_canned_bucketownerfullcontrol(): bucket = get_new_bucket(targets.main.default) bucket.set_acl('public-read-write') key = s3.alt.get_bucket(bucket.name).new_key('foo') key.set_contents_from_string('bar') bucket_policy = bucket.get_acl() bucket_owner_id = bucket_policy.owner.id bucket_owner_display = bucket_policy.owner.display_name key.set_acl('bucket-owner-full-control') policy = key.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='FULL_CONTROL', id=bucket_owner_id, display_name=bucket_owner_display, uri=None, email_address=None, type='CanonicalUser', ), ], ) key.delete() bucket.delete() @attr(resource='object.acls') @attr(method='put') @attr(operation='set write-acp') @attr(assertion='does not modify owner') def test_object_acl_full_control_verify_owner(): bucket = get_new_bucket(targets.main.default) bucket.set_acl('public-read-write') key = bucket.new_key('foo') key.set_contents_from_string('bar') key.add_user_grant(permission='FULL_CONTROL', user_id=config.alt.user_id) k2 = s3.alt.get_bucket(bucket.name).get_key('foo') k2.add_user_grant(permission='READ_ACP', user_id=config.alt.user_id) policy = k2.get_acl() eq(policy.owner.id, config.main.user_id) @attr(resource='bucket') @attr(method='ACLs') @attr(operation='set acl private') @attr(assertion='a private object can be set to private') def test_bucket_acl_canned_private_to_private(): bucket = get_new_bucket() bucket.set_acl('private') def _make_acl_xml(acl): """ Return the xml form of an ACL entry """ return '<?xml version="1.0" encoding="UTF-8"?><AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>' + config.main.user_id + '</ID></Owner>' + acl.to_xml() + '</AccessControlPolicy>' def _build_bucket_acl_xml(permission, bucket=None): """ add the specified permission for the current user to a (new or specified) bucket, in XML form, set it, and then read it back to confirm it was correctly set """ acl = boto.s3.acl.ACL() acl.add_user_grant(permission=permission, user_id=config.main.user_id) XML = _make_acl_xml(acl) if bucket is None: bucket = get_new_bucket() bucket.set_xml_acl(XML) policy = bucket.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission=permission, id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), ], ) @attr(resource='bucket.acls') @attr(method='ACLs') @attr(operation='set acl FULL_CONTROL (xml)') @attr(assertion='reads back correctly') def test_bucket_acl_xml_fullcontrol(): _build_bucket_acl_xml('FULL_CONTROL') @attr(resource='bucket.acls') @attr(method='ACLs') @attr(operation='set acl WRITE (xml)') @attr(assertion='reads back correctly') def test_bucket_acl_xml_write(): _build_bucket_acl_xml('WRITE') @attr(resource='bucket.acls') @attr(method='ACLs') @attr(operation='set acl WRITE_ACP (xml)') @attr(assertion='reads back correctly') def test_bucket_acl_xml_writeacp(): _build_bucket_acl_xml('WRITE_ACP') @attr(resource='bucket.acls') @attr(method='ACLs') @attr(operation='set acl READ (xml)') @attr(assertion='reads back correctly') def test_bucket_acl_xml_read(): _build_bucket_acl_xml('READ') @attr(resource='bucket.acls') @attr(method='ACLs') @attr(operation='set acl READ_ACP (xml)') @attr(assertion='reads back correctly') def test_bucket_acl_xml_readacp(): _build_bucket_acl_xml('READ_ACP') def _build_object_acl_xml(permission): """ add the specified permission for the current user to a new object in a new bucket, in XML form, set it, and then read it back to confirm it was correctly set """ acl = boto.s3.acl.ACL() acl.add_user_grant(permission=permission, user_id=config.main.user_id) XML = _make_acl_xml(acl) bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') key.set_xml_acl(XML) policy = key.get_acl() print repr(policy) check_grants( policy.acl.grants, [ dict( permission=permission, id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), ], ) @attr(resource='object') @attr(method='ACLs') @attr(operation='set acl FULL_CONTROL (xml)') @attr(assertion='reads back correctly') def test_object_acl_xml(): _build_object_acl_xml('FULL_CONTROL') @attr(resource='object') @attr(method='ACLs') @attr(operation='set acl WRITE (xml)') @attr(assertion='reads back correctly') def test_object_acl_xml_write(): _build_object_acl_xml('WRITE') @attr(resource='object') @attr(method='ACLs') @attr(operation='set acl WRITE_ACP (xml)') @attr(assertion='reads back correctly') def test_object_acl_xml_writeacp(): _build_object_acl_xml('WRITE_ACP') @attr(resource='object') @attr(method='ACLs') @attr(operation='set acl READ (xml)') @attr(assertion='reads back correctly') def test_object_acl_xml_read(): _build_object_acl_xml('READ') @attr(resource='object') @attr(method='ACLs') @attr(operation='set acl READ_ACP (xml)') @attr(assertion='reads back correctly') def test_object_acl_xml_readacp(): _build_object_acl_xml('READ_ACP') def _bucket_acl_grant_userid(permission): """ create a new bucket, grant a specific user the specified permission, read back the acl and verify correct setting """ bucket = get_new_bucket() # add alt user policy = bucket.get_acl() policy.acl.add_user_grant(permission, config.alt.user_id) bucket.set_acl(policy) policy = bucket.get_acl() check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission=permission, id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), ], ) return bucket def _check_bucket_acl_grant_can_read(bucket): """ verify ability to read the specified bucket """ bucket2 = s3.alt.get_bucket(bucket.name) def _check_bucket_acl_grant_cant_read(bucket): """ verify inability to read the specified bucket """ check_access_denied(s3.alt.get_bucket, bucket.name) def _check_bucket_acl_grant_can_readacp(bucket): """ verify ability to read acls on specified bucket """ bucket2 = s3.alt.get_bucket(bucket.name, validate=False) bucket2.get_acl() def _check_bucket_acl_grant_cant_readacp(bucket): """ verify inability to read acls on specified bucket """ bucket2 = s3.alt.get_bucket(bucket.name, validate=False) check_access_denied(bucket2.get_acl) def _check_bucket_acl_grant_can_write(bucket): """ verify ability to write the specified bucket """ bucket2 = s3.alt.get_bucket(bucket.name, validate=False) key = bucket2.new_key('foo-write') key.set_contents_from_string('bar') def _check_bucket_acl_grant_cant_write(bucket): """ verify inability to write the specified bucket """ bucket2 = s3.alt.get_bucket(bucket.name, validate=False) key = bucket2.new_key('foo-write') check_access_denied(key.set_contents_from_string, 'bar') def _check_bucket_acl_grant_can_writeacp(bucket): """ verify ability to set acls on the specified bucket """ bucket2 = s3.alt.get_bucket(bucket.name, validate=False) bucket2.set_acl('public-read') def _check_bucket_acl_grant_cant_writeacp(bucket): """ verify inability to set acls on the specified bucket """ bucket2 = s3.alt.get_bucket(bucket.name, validate=False) check_access_denied(bucket2.set_acl, 'public-read') @attr(resource='bucket') @attr(method='ACLs') @attr(operation='set acl w/userid FULL_CONTROL') @attr(assertion='can read/write data/acls') def test_bucket_acl_grant_userid_fullcontrol(): bucket = _bucket_acl_grant_userid('FULL_CONTROL') # alt user can read _check_bucket_acl_grant_can_read(bucket) # can read acl _check_bucket_acl_grant_can_readacp(bucket) # can write _check_bucket_acl_grant_can_write(bucket) # can write acl _check_bucket_acl_grant_can_writeacp(bucket) # verify owner did not change bucket2 = s3.main.get_bucket(bucket.name) policy = bucket2.get_acl() eq(policy.owner.id, config.main.user_id) eq(policy.owner.display_name, config.main.display_name) @attr(resource='bucket') @attr(method='ACLs') @attr(operation='set acl w/userid READ') @attr(assertion='can read data, no other r/w') def test_bucket_acl_grant_userid_read(): bucket = _bucket_acl_grant_userid('READ') # alt user can read _check_bucket_acl_grant_can_read(bucket) # can't read acl _check_bucket_acl_grant_cant_readacp(bucket) # can't write _check_bucket_acl_grant_cant_write(bucket) # can't write acl _check_bucket_acl_grant_cant_writeacp(bucket) @attr(resource='bucket') @attr(method='ACLs') @attr(operation='set acl w/userid READ_ACP') @attr(assertion='can read acl, no other r/w') def test_bucket_acl_grant_userid_readacp(): bucket = _bucket_acl_grant_userid('READ_ACP') # alt user can't read _check_bucket_acl_grant_cant_read(bucket) # can read acl _check_bucket_acl_grant_can_readacp(bucket) # can't write _check_bucket_acl_grant_cant_write(bucket) # can't write acp #_check_bucket_acl_grant_cant_writeacp_can_readacp(bucket) _check_bucket_acl_grant_cant_writeacp(bucket) @attr(resource='bucket') @attr(method='ACLs') @attr(operation='set acl w/userid WRITE') @attr(assertion='can write data, no other r/w') def test_bucket_acl_grant_userid_write(): bucket = _bucket_acl_grant_userid('WRITE') # alt user can't read _check_bucket_acl_grant_cant_read(bucket) # can't read acl _check_bucket_acl_grant_cant_readacp(bucket) # can write _check_bucket_acl_grant_can_write(bucket) # can't write acl _check_bucket_acl_grant_cant_writeacp(bucket) @attr(resource='bucket') @attr(method='ACLs') @attr(operation='set acl w/userid WRITE_ACP') @attr(assertion='can write acls, no other r/w') def test_bucket_acl_grant_userid_writeacp(): bucket = _bucket_acl_grant_userid('WRITE_ACP') # alt user can't read _check_bucket_acl_grant_cant_read(bucket) # can't read acl _check_bucket_acl_grant_cant_readacp(bucket) # can't write _check_bucket_acl_grant_cant_write(bucket) # can write acl _check_bucket_acl_grant_can_writeacp(bucket) @attr(resource='bucket') @attr(method='ACLs') @attr(operation='set acl w/invalid userid') @attr(assertion='fails 400') def test_bucket_acl_grant_nonexist_user(): bucket = get_new_bucket() # add alt user bad_user_id = '_foo' policy = bucket.get_acl() policy.acl.add_user_grant('FULL_CONTROL', bad_user_id) print policy.to_xml() e = assert_raises(boto.exception.S3ResponseError, bucket.set_acl, policy) eq(e.status, 400) eq(e.reason, 'Bad Request') eq(e.error_code, 'InvalidArgument') @attr(resource='bucket') @attr(method='ACLs') @attr(operation='revoke all ACLs') @attr(assertion='can: read obj, get/set bucket acl, cannot write objs') def test_bucket_acl_no_grants(): bucket = get_new_bucket() # write content to the bucket key = bucket.new_key('foo') key.set_contents_from_string('bar') # clear grants policy = bucket.get_acl() policy.acl.grants = [] # remove read/write permission bucket.set_acl(policy) # can read bucket.get_key('foo') # can't write key = bucket.new_key('baz') check_access_denied(key.set_contents_from_string, 'bar') # can read acl bucket.get_acl() # can write acl bucket.set_acl('private') def _get_acl_header(user=None, perms=None): all_headers = ["read", "write", "read-acp", "write-acp", "full-control"] headers = {} if user == None: user = config.alt.user_id if perms != None: for perm in perms: headers["x-amz-grant-{perm}".format(perm=perm)] = "id={uid}".format(uid=user) else: for perm in all_headers: headers["x-amz-grant-{perm}".format(perm=perm)] = "id={uid}".format(uid=user) return headers @attr(resource='object') @attr(method='PUT') @attr(operation='add all grants to user through headers') @attr(assertion='adds all grants individually to second user') @attr('fails_on_dho') def test_object_header_acl_grants(): bucket = get_new_bucket() headers = _get_acl_header() k = bucket.new_key("foo_key") k.set_contents_from_string("bar", headers=headers) policy = k.get_acl() check_grants( policy.acl.grants, [ dict( permission='READ', id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='WRITE', id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ_ACP', id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='WRITE_ACP', id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='FULL_CONTROL', id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), ], ) @attr(resource='bucket') @attr(method='PUT') @attr(operation='add all grants to user through headers') @attr(assertion='adds all grants individually to second user') @attr('fails_on_dho') def test_bucket_header_acl_grants(): headers = _get_acl_header() bucket = get_new_bucket(targets.main.default, get_prefix(), headers) policy = bucket.get_acl() check_grants( policy.acl.grants, [ dict( permission='READ', id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='WRITE', id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ_ACP', id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='WRITE_ACP', id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='FULL_CONTROL', id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), ], ) # alt user can write bucket2 = s3.alt.get_bucket(bucket.name) key = bucket2.new_key('foo') key.set_contents_from_string('bar') # This test will fail on DH Objects. DHO allows multiple users with one account, which # would violate the uniqueness requirement of a user's email. As such, DHO users are # created without an email. @attr(resource='bucket') @attr(method='ACLs') @attr(operation='add second FULL_CONTROL user') @attr(assertion='works for S3, fails for DHO') def test_bucket_acl_grant_email(): bucket = get_new_bucket() # add alt user policy = bucket.get_acl() policy.acl.add_email_grant('FULL_CONTROL', config.alt.email) bucket.set_acl(policy) policy = bucket.get_acl() check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='FULL_CONTROL', id=config.alt.user_id, display_name=config.alt.display_name, uri=None, email_address=None, type='CanonicalUser', ), ], ) # alt user can write bucket2 = s3.alt.get_bucket(bucket.name) key = bucket2.new_key('foo') key.set_contents_from_string('bar') @attr(resource='bucket') @attr(method='ACLs') @attr(operation='add acl for nonexistent user') @attr(assertion='fail 400') def test_bucket_acl_grant_email_notexist(): # behavior not documented by amazon bucket = get_new_bucket() policy = bucket.get_acl() policy.acl.add_email_grant('FULL_CONTROL', NONEXISTENT_EMAIL) e = assert_raises(boto.exception.S3ResponseError, bucket.set_acl, policy) eq(e.status, 400) eq(e.reason, 'Bad Request') eq(e.error_code, 'UnresolvableGrantByEmailAddress') @attr(resource='bucket') @attr(method='ACLs') @attr(operation='revoke all ACLs') @attr(assertion='acls read back as empty') def test_bucket_acl_revoke_all(): # revoke all access, including the owner's access bucket = get_new_bucket() policy = bucket.get_acl() policy.acl.grants = [] bucket.set_acl(policy) policy = bucket.get_acl() eq(len(policy.acl.grants), 0) # TODO rgw log_bucket.set_as_logging_target() gives 403 Forbidden # http://tracker.newdream.net/issues/984 @attr(resource='bucket.log') @attr(method='put') @attr(operation='set/enable/disable logging target') @attr(assertion='operations succeed') @attr('fails_on_rgw') def test_logging_toggle(): bucket = get_new_bucket() log_bucket = get_new_bucket(targets.main.default, bucket.name + '-log') log_bucket.set_as_logging_target() bucket.enable_logging(target_bucket=log_bucket, target_prefix=bucket.name) bucket.disable_logging() # NOTE: this does not actually test whether or not logging works def _setup_access(bucket_acl, object_acl): """ Simple test fixture: create a bucket with given ACL, with objects: - a: owning user, given ACL - a2: same object accessed by some other user - b: owning user, default ACL in bucket w/given ACL - b2: same object accessed by a some other user """ obj = bunch.Bunch() bucket = get_new_bucket() bucket.set_acl(bucket_acl) obj.a = bucket.new_key('foo') obj.a.set_contents_from_string('foocontent') obj.a.set_acl(object_acl) obj.b = bucket.new_key('bar') obj.b.set_contents_from_string('barcontent') # bucket2 is being accessed by a different user obj.bucket2 = s3.alt.get_bucket(bucket.name, validate=False) obj.a2 = obj.bucket2.new_key(obj.a.name) obj.b2 = obj.bucket2.new_key(obj.b.name) obj.new = obj.bucket2.new_key('new') return obj def get_bucket_key_names(bucket): return frozenset(k.name for k in bucket.list()) @attr(resource='object') @attr(method='ACLs') @attr(operation='set bucket/object acls: private/private') @attr(assertion='public has no access to bucket or objects') def test_access_bucket_private_object_private(): # all the test_access_* tests follow this template obj = _setup_access(bucket_acl='private', object_acl='private') # a should be public-read, b gets default (private) # acled object read fail check_access_denied(obj.a2.get_contents_as_string) # acled object write fail check_access_denied(obj.a2.set_contents_from_string, 'barcontent') # default object read fail check_access_denied(obj.b2.get_contents_as_string) # default object write fail check_access_denied(obj.b2.set_contents_from_string, 'baroverwrite') # bucket read fail check_access_denied(get_bucket_key_names, obj.bucket2) # bucket write fail check_access_denied(obj.new.set_contents_from_string, 'newcontent') @attr(resource='object') @attr(method='ACLs') @attr(operation='set bucket/object acls: private/public-read') @attr(assertion='public can only read readable object') def test_access_bucket_private_object_publicread(): obj = _setup_access(bucket_acl='private', object_acl='public-read') # a should be public-read, b gets default (private) eq(obj.a2.get_contents_as_string(), 'foocontent') check_access_denied(obj.a2.set_contents_from_string, 'foooverwrite') check_access_denied(obj.b2.get_contents_as_string) check_access_denied(obj.b2.set_contents_from_string, 'baroverwrite') check_access_denied(get_bucket_key_names, obj.bucket2) check_access_denied(obj.new.set_contents_from_string, 'newcontent') @attr(resource='object') @attr(method='ACLs') @attr(operation='set bucket/object acls: private/public-read/write') @attr(assertion='public can only read the readable object') def test_access_bucket_private_object_publicreadwrite(): obj = _setup_access(bucket_acl='private', object_acl='public-read-write') # a should be public-read-only ... because it is in a private bucket # b gets default (private) eq(obj.a2.get_contents_as_string(), 'foocontent') check_access_denied(obj.a2.set_contents_from_string, 'foooverwrite') check_access_denied(obj.b2.get_contents_as_string) check_access_denied(obj.b2.set_contents_from_string, 'baroverwrite') check_access_denied(get_bucket_key_names, obj.bucket2) check_access_denied(obj.new.set_contents_from_string, 'newcontent') @attr(resource='object') @attr(method='ACLs') @attr(operation='set bucket/object acls: public-read/private') @attr(assertion='public can only list the bucket') def test_access_bucket_publicread_object_private(): obj = _setup_access(bucket_acl='public-read', object_acl='private') # a should be private, b gets default (private) check_access_denied(obj.a2.get_contents_as_string) check_access_denied(obj.a2.set_contents_from_string, 'barcontent') check_access_denied(obj.b2.get_contents_as_string) check_access_denied(obj.b2.set_contents_from_string, 'baroverwrite') eq(get_bucket_key_names(obj.bucket2), frozenset(['foo', 'bar'])) check_access_denied(obj.new.set_contents_from_string, 'newcontent') @attr(resource='object') @attr(method='ACLs') @attr(operation='set bucket/object acls: public-read/public-read') @attr(assertion='public can read readable objects and list bucket') def test_access_bucket_publicread_object_publicread(): obj = _setup_access(bucket_acl='public-read', object_acl='public-read') # a should be public-read, b gets default (private) eq(obj.a2.get_contents_as_string(), 'foocontent') check_access_denied(obj.a2.set_contents_from_string, 'foooverwrite') check_access_denied(obj.b2.get_contents_as_string) check_access_denied(obj.b2.set_contents_from_string, 'baroverwrite') eq(get_bucket_key_names(obj.bucket2), frozenset(['foo', 'bar'])) check_access_denied(obj.new.set_contents_from_string, 'newcontent') @attr(resource='object') @attr(method='ACLs') @attr(operation='set bucket/object acls: public-read/public-read-write') @attr(assertion='public can read readable objects and list bucket') def test_access_bucket_publicread_object_publicreadwrite(): obj = _setup_access(bucket_acl='public-read', object_acl='public-read-write') # a should be public-read-only ... because it is in a r/o bucket # b gets default (private) eq(obj.a2.get_contents_as_string(), 'foocontent') check_access_denied(obj.a2.set_contents_from_string, 'foooverwrite') check_access_denied(obj.b2.get_contents_as_string) check_access_denied(obj.b2.set_contents_from_string, 'baroverwrite') eq(get_bucket_key_names(obj.bucket2), frozenset(['foo', 'bar'])) check_access_denied(obj.new.set_contents_from_string, 'newcontent') @attr(resource='object') @attr(method='ACLs') @attr(operation='set bucket/object acls: public-read-write/private') @attr(assertion='private objects cannot be read, but can be overwritten') def test_access_bucket_publicreadwrite_object_private(): obj = _setup_access(bucket_acl='public-read-write', object_acl='private') # a should be private, b gets default (private) check_access_denied(obj.a2.get_contents_as_string) obj.a2.set_contents_from_string('barcontent') check_access_denied(obj.b2.get_contents_as_string) obj.b2.set_contents_from_string('baroverwrite') eq(get_bucket_key_names(obj.bucket2), frozenset(['foo', 'bar'])) obj.new.set_contents_from_string('newcontent') @attr(resource='object') @attr(method='ACLs') @attr(operation='set bucket/object acls: public-read-write/public-read') @attr(assertion='private objects cannot be read, but can be overwritten') def test_access_bucket_publicreadwrite_object_publicread(): obj = _setup_access(bucket_acl='public-read-write', object_acl='public-read') # a should be public-read, b gets default (private) eq(obj.a2.get_contents_as_string(), 'foocontent') obj.a2.set_contents_from_string('barcontent') check_access_denied(obj.b2.get_contents_as_string) obj.b2.set_contents_from_string('baroverwrite') eq(get_bucket_key_names(obj.bucket2), frozenset(['foo', 'bar'])) obj.new.set_contents_from_string('newcontent') @attr(resource='object') @attr(method='ACLs') @attr(operation='set bucket/object acls: public-read-write/public-read-write') @attr(assertion='private objects cannot be read, but can be overwritten') def test_access_bucket_publicreadwrite_object_publicreadwrite(): obj = _setup_access(bucket_acl='public-read-write', object_acl='public-read-write') # a should be public-read-write, b gets default (private) eq(obj.a2.get_contents_as_string(), 'foocontent') obj.a2.set_contents_from_string('foooverwrite') check_access_denied(obj.b2.get_contents_as_string) obj.b2.set_contents_from_string('baroverwrite') eq(get_bucket_key_names(obj.bucket2), frozenset(['foo', 'bar'])) obj.new.set_contents_from_string('newcontent') @attr(resource='object') @attr(method='put') @attr(operation='set object acls') @attr(assertion='valid XML ACL sets properly') def test_object_set_valid_acl(): XML_1 = '<?xml version="1.0" encoding="UTF-8"?><AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>' + config.main.user_id + '</ID></Owner><AccessControlList><Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>' + config.main.user_id + '</ID></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>' bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') key.set_xml_acl(XML_1) @attr(resource='object') @attr(method='put') @attr(operation='set object acls') @attr(assertion='invalid XML ACL fails 403') def test_object_giveaway(): CORRECT_ACL = '<?xml version="1.0" encoding="UTF-8"?><AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>' + config.main.user_id + '</ID></Owner><AccessControlList><Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>' + config.main.user_id + '</ID></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>' WRONG_ACL = '<?xml version="1.0" encoding="UTF-8"?><AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>' + config.alt.user_id + '</ID></Owner><AccessControlList><Grant><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"><ID>' + config.alt.user_id + '</ID></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>' bucket = get_new_bucket() key = bucket.new_key('foo') key.set_contents_from_string('bar') key.set_xml_acl(CORRECT_ACL) e = assert_raises(boto.exception.S3ResponseError, key.set_xml_acl, WRONG_ACL) eq(e.status, 403) eq(e.reason, 'Forbidden') eq(e.error_code, 'AccessDenied') @attr(resource='bucket') @attr(method='get') @attr(operation='list all buckets') @attr(assertion='returns all expected buckets') def test_buckets_create_then_list(): create_buckets = [get_new_bucket() for i in xrange(5)] list_buckets = s3.main.get_all_buckets() names = frozenset(bucket.name for bucket in list_buckets) for bucket in create_buckets: if bucket.name not in names: raise RuntimeError("S3 implementation's GET on Service did not return bucket we created: %r", bucket.name) # Common code to create a connection object, which'll use bad authorization information def _create_connection_bad_auth(aws_access_key_id='badauth'): # We're going to need to manually build a connection using bad authorization info. # But to save the day, lets just hijack the settings from s3.main. :) main = s3.main conn = boto.s3.connection.S3Connection( aws_access_key_id=aws_access_key_id, aws_secret_access_key='roflmao', is_secure=main.is_secure, port=main.port, host=main.host, calling_format=main.calling_format, ) return conn @attr(resource='bucket') @attr(method='get') @attr(operation='list all buckets (anonymous)') @attr(assertion='succeeds') @attr('fails_on_aws') def test_list_buckets_anonymous(): # Get a connection with bad authorization, then change it to be our new Anonymous auth mechanism, # emulating standard HTTP access. # # While it may have been possible to use httplib directly, doing it this way takes care of also # allowing us to vary the calling format in testing. conn = _create_connection_bad_auth() conn._auth_handler = AnonymousAuth.AnonymousAuthHandler(None, None, None) # Doesn't need this buckets = conn.get_all_buckets() eq(len(buckets), 0) @attr(resource='bucket') @attr(method='get') @attr(operation='list all buckets (bad auth)') @attr(assertion='fails 403') def test_list_buckets_invalid_auth(): conn = _create_connection_bad_auth() e = assert_raises(boto.exception.S3ResponseError, conn.get_all_buckets) eq(e.status, 403) eq(e.reason, 'Forbidden') eq(e.error_code, 'InvalidAccessKeyId') @attr(resource='bucket') @attr(method='get') @attr(operation='list all buckets (bad auth)') @attr(assertion='fails 403') def test_list_buckets_bad_auth(): conn = _create_connection_bad_auth(aws_access_key_id=s3.main.aws_access_key_id) e = assert_raises(boto.exception.S3ResponseError, conn.get_all_buckets) eq(e.status, 403) eq(e.reason, 'Forbidden') eq(e.error_code, 'SignatureDoesNotMatch') @attr(resource='bucket') @attr(method='put') @attr(operation='create bucket') @attr(assertion='name starts with alphabetic works') # this test goes outside the user-configure prefix because it needs to # control the initial character of the bucket name @nose.with_setup( setup=lambda: nuke_prefixed_buckets(prefix='a'+get_prefix()), teardown=lambda: nuke_prefixed_buckets(prefix='a'+get_prefix()), ) def test_bucket_create_naming_good_starts_alpha(): check_good_bucket_name('foo', _prefix='a'+get_prefix()) @attr(resource='bucket') @attr(method='put') @attr(operation='create bucket') @attr(assertion='name starts with numeric works') # this test goes outside the user-configure prefix because it needs to # control the initial character of the bucket name @nose.with_setup( setup=lambda: nuke_prefixed_buckets(prefix='0'+get_prefix()), teardown=lambda: nuke_prefixed_buckets(prefix='0'+get_prefix()), ) def test_bucket_create_naming_good_starts_digit(): check_good_bucket_name('foo', _prefix='0'+get_prefix()) @attr(resource='bucket') @attr(method='put') @attr(operation='create bucket') @attr(assertion='name containing dot works') def test_bucket_create_naming_good_contains_period(): check_good_bucket_name('aaa.111') @attr(resource='bucket') @attr(method='put') @attr(operation='create bucket') @attr(assertion='name containing hyphen works') def test_bucket_create_naming_good_contains_hyphen(): check_good_bucket_name('aaa-111') @attr(resource='bucket') @attr(method='put') @attr(operation='create bucket with objects and recreate it') @attr(assertion='bucket recreation not overriding index') def test_bucket_recreate_not_overriding(): key_names = ['mykey1', 'mykey2'] bucket = _create_keys(keys=key_names) li = bucket.list() names = [e.name for e in list(li)] eq(names, key_names) bucket2 = get_new_bucket(targets.main.default, bucket.name) li = bucket.list() names = [e.name for e in list(li)] eq(names, key_names) @attr(resource='object') @attr(method='put') @attr(operation='create and list objects with special names') @attr(assertion='special names work') def test_bucket_create_special_key_names(): key_names = [' ', '%', '_', '_ ', '_ _', '__'] bucket = _create_keys(keys=key_names) li = bucket.list() names = [e.name for e in list(li)] eq(names, key_names) @attr(resource='bucket') @attr(method='get') @attr(operation='create and list objects with underscore as prefix, list using prefix') @attr(assertion='listing works correctly') def test_bucket_list_special_prefix(): key_names = ['_bla/1', '_bla/2', '_bla/3', '_bla/4', 'abcd'] bucket = _create_keys(keys=key_names) li = bucket.get_all_keys() eq(len(li), 5) li2 = bucket.get_all_keys(prefix='_bla/') eq(len(li2), 4) @attr(resource='object') @attr(method='put') @attr(operation='copy zero sized object in same bucket') @attr(assertion='works') def test_object_copy_zero_size(): bucket = get_new_bucket() key = bucket.new_key('foo123bar') fp_a = FakeWriteFile(0, '') key.set_contents_from_file(fp_a) key.copy(bucket, 'bar321foo') key2 = bucket.get_key('bar321foo') eq(key2.size, 0) @attr(resource='object') @attr(method='put') @attr(operation='copy object in same bucket') @attr(assertion='works') def test_object_copy_same_bucket(): bucket = get_new_bucket() key = bucket.new_key('foo123bar') key.set_contents_from_string('foo') key.copy(bucket, 'bar321foo') key2 = bucket.get_key('bar321foo') eq(key2.get_contents_as_string(), 'foo') @attr(resource='object') @attr(method='put') @attr(operation='copy object to itself') @attr(assertion='fails') def test_object_copy_to_itself(): bucket = get_new_bucket() key = bucket.new_key('foo123bar') key.set_contents_from_string('foo') e = assert_raises(boto.exception.S3ResponseError, key.copy, bucket, 'foo123bar') eq(e.status, 400) eq(e.reason, 'Bad Request') eq(e.error_code, 'InvalidRequest') @attr(resource='object') @attr(method='put') @attr(operation='modify object metadata by copying') @attr(assertion='fails') def test_object_copy_to_itself_with_metadata(): bucket = get_new_bucket() key = bucket.new_key('foo123bar') key.set_contents_from_string('foo') key.copy(bucket, 'foo123bar', {'foo': 'bar'}) key.close() bucket2 = s3.main.get_bucket(bucket.name) key2 = bucket2.get_key('foo123bar') md = key2.get_metadata('foo') eq(md, 'bar') @attr(resource='object') @attr(method='put') @attr(operation='copy object from different bucket') @attr(assertion='works') def test_object_copy_diff_bucket(): buckets = [get_new_bucket(), get_new_bucket()] key = buckets[0].new_key('foo123bar') key.set_contents_from_string('foo') key.copy(buckets[1], 'bar321foo') key2 = buckets[1].get_key('bar321foo') eq(key2.get_contents_as_string(), 'foo') # is this a necessary check? a NoneType object is being touched here # it doesn't get to the S3 level @attr(resource='object') @attr(method='put') @attr(operation='copy from an inaccessible bucket') @attr(assertion='fails w/AttributeError') def test_object_copy_not_owned_bucket(): buckets = [get_new_bucket(), get_new_bucket(targets.alt.default)] print repr(buckets[1]) key = buckets[0].new_key('foo123bar') key.set_contents_from_string('foo') try: key.copy(buckets[1], 'bar321foo') except AttributeError: pass @attr(resource='object') @attr(method='put') @attr(operation='copy a non-owned object in a non-owned bucket, but with perms') @attr(assertion='works') def test_object_copy_not_owned_object_bucket(): bucket = get_new_bucket(targets.main.default) key = bucket.new_key('foo123bar') key.set_contents_from_string('foo') bucket.add_user_grant(permission='FULL_CONTROL', user_id=config.alt.user_id, recursive=True) k2 = s3.alt.get_bucket(bucket.name).get_key('foo123bar') k2.copy(bucket.name, 'bar321foo') @attr(resource='object') @attr(method='put') @attr(operation='copy object and change acl') @attr(assertion='works') def test_object_copy_canned_acl(): bucket = get_new_bucket() key = bucket.new_key('foo123bar') key.set_contents_from_string('foo') # use COPY directive key2 = bucket.copy_key('bar321foo', bucket.name, 'foo123bar', headers={'x-amz-acl': 'public-read'}) res = _make_request('GET', bucket, key2) eq(res.status, 200) eq(res.reason, 'OK') # use REPLACE directive key3 = bucket.copy_key('bar321foo2', bucket.name, 'foo123bar', headers={'x-amz-acl': 'public-read'}, metadata={'abc': 'def'}) res = _make_request('GET', bucket, key3) eq(res.status, 200) eq(res.reason, 'OK') @attr(resource='object') @attr(method='put') @attr(operation='copy object and retain metadata') def test_object_copy_retaining_metadata(): for size in [3, 1024 * 1024]: bucket = get_new_bucket() key = bucket.new_key('foo123bar') metadata = {'key1': 'value1', 'key2': 'value2'} key.set_metadata('key1', 'value1') key.set_metadata('key2', 'value2') content_type = 'audio/ogg' key.content_type = content_type key.set_contents_from_string(str(bytearray(size))) bucket.copy_key('bar321foo', bucket.name, 'foo123bar') key2 = bucket.get_key('bar321foo') eq(key2.size, size) eq(key2.metadata, metadata) eq(key2.content_type, content_type) @attr(resource='object') @attr(method='put') @attr(operation='copy object and replace metadata') def test_object_copy_replacing_metadata(): for size in [3, 1024 * 1024]: bucket = get_new_bucket() key = bucket.new_key('foo123bar') key.set_metadata('key1', 'value1') key.set_metadata('key2', 'value2') key.content_type = 'audio/ogg' key.set_contents_from_string(str(bytearray(size))) metadata = {'key3': 'value3', 'key1': 'value4'} content_type = 'audio/mpeg' bucket.copy_key('bar321foo', bucket.name, 'foo123bar', metadata=metadata, headers={'Content-Type': content_type}) key2 = bucket.get_key('bar321foo') eq(key2.size, size) eq(key2.metadata, metadata) eq(key2.content_type, content_type) def transfer_part(bucket, mp_id, mp_keyname, i, part): """Transfer a part of a multipart upload. Designed to be run in parallel. """ mp = boto.s3.multipart.MultiPartUpload(bucket) mp.key_name = mp_keyname mp.id = mp_id part_out = StringIO(part) mp.upload_part_from_file(part_out, i+1) def generate_random(size, part_size=5*1024*1024): """ Generate the specified number random data. (actually each MB is a repetition of the first KB) """ chunk = 1024 allowed = string.ascii_letters for x in range(0, size, part_size): strpart = ''.join([allowed[random.randint(0, len(allowed) - 1)] for _ in xrange(chunk)]) s = '' left = size - x this_part_size = min(left, part_size) for y in range(this_part_size / chunk): s = s + strpart if this_part_size > len(s): s = s + strpart[0:this_part_size - len(s)] yield s if (x == size): return def _multipart_upload(bucket, s3_key_name, size, part_size=5*1024*1024, do_list=None, headers=None, metadata=None, resend_parts=[]): """ generate a multi-part upload for a random file of specifed size, if requested, generate a list of the parts return the upload descriptor """ upload = bucket.initiate_multipart_upload(s3_key_name, headers=headers, metadata=metadata) s = '' for i, part in enumerate(generate_random(size, part_size)): s += part transfer_part(bucket, upload.id, upload.key_name, i, part) if i in resend_parts: transfer_part(bucket, upload.id, upload.key_name, i, part) if do_list is not None: l = bucket.list_multipart_uploads() l = list(l) return (upload, s) @attr(resource='object') @attr(method='put') @attr(operation='check multipart upload without parts') def test_multipart_upload_empty(): bucket = get_new_bucket() key = "mymultipart" (upload, data) = _multipart_upload(bucket, key, 0) e = assert_raises(boto.exception.S3ResponseError, upload.complete_upload) eq(e.status, 400) eq(e.error_code, u'MalformedXML') @attr(resource='object') @attr(method='put') @attr(operation='check multipart uploads with single small part') def test_multipart_upload_small(): bucket = get_new_bucket() key = "mymultipart" size = 1 (upload, data) = _multipart_upload(bucket, key, size) upload.complete_upload() key2 = bucket.get_key(key) eq(key2.size, size) def _check_content_using_range(k, data, step): objlen = k.size for ofs in xrange(0, k.size, step): toread = k.size - ofs if toread > step: toread = step end = ofs + toread - 1 read_range = k.get_contents_as_string(headers={'Range': 'bytes={s}-{e}'.format(s=ofs, e=end)}) eq(len(read_range), toread) eq(read_range, data[ofs:end+1]) @attr(resource='object') @attr(method='put') @attr(operation='complete multi-part upload') @attr(assertion='successful') def test_multipart_upload(): bucket = get_new_bucket() key="mymultipart" content_type='text/bla' objlen = 30 * 1024 * 1024 (upload, data) = _multipart_upload(bucket, key, objlen, headers={'Content-Type': content_type}, metadata={'foo': 'bar'}) upload.complete_upload() result = _head_bucket(bucket) eq(result.get('x-rgw-object-count', 1), 1) eq(result.get('x-rgw-bytes-used', 30 * 1024 * 1024), 30 * 1024 * 1024) k=bucket.get_key(key) eq(k.metadata['foo'], 'bar') eq(k.content_type, content_type) test_string=k.get_contents_as_string() eq(len(test_string), k.size) eq(test_string, data) _check_content_using_range(k, data, 1000000) _check_content_using_range(k, data, 10000000) def _check_upload_multipart_resend(bucket, key, objlen, resend_parts): content_type='text/bla' (upload, data) = _multipart_upload(bucket, key, objlen, headers={'Content-Type': content_type}, metadata={'foo': 'bar'}, resend_parts=resend_parts) upload.complete_upload() k=bucket.get_key(key) eq(k.metadata['foo'], 'bar') eq(k.content_type, content_type) test_string=k.get_contents_as_string() eq(k.size, len(test_string)) eq(k.size, objlen) eq(test_string, data) _check_content_using_range(k, data, 1000000) _check_content_using_range(k, data, 10000000) @attr(resource='object') @attr(method='put') @attr(operation='complete multiple multi-part upload with different sizes') @attr(resource='object') @attr(method='put') @attr(operation='complete multi-part upload') @attr(assertion='successful') def test_multipart_upload_resend_part(): bucket = get_new_bucket() key="mymultipart" objlen = 30 * 1024 * 1024 _check_upload_multipart_resend(bucket, key, objlen, [0]) _check_upload_multipart_resend(bucket, key, objlen, [1]) _check_upload_multipart_resend(bucket, key, objlen, [2]) _check_upload_multipart_resend(bucket, key, objlen, [1,2]) _check_upload_multipart_resend(bucket, key, objlen, [0,1,2,3,4,5]) @attr(assertion='successful') def test_multipart_upload_multiple_sizes(): bucket = get_new_bucket() key="mymultipart" (upload, data) = _multipart_upload(bucket, key, 5 * 1024 * 1024) upload.complete_upload() (upload, data) = _multipart_upload(bucket, key, 5 * 1024 * 1024 + 100 * 1024) upload.complete_upload() (upload, data) = _multipart_upload(bucket, key, 5 * 1024 * 1024 + 600 * 1024) upload.complete_upload() (upload, data) = _multipart_upload(bucket, key, 10 * 1024 * 1024 + 100 * 1024) upload.complete_upload() (upload, data) = _multipart_upload(bucket, key, 10 * 1024 * 1024 + 600 * 1024) upload.complete_upload() (upload, data) = _multipart_upload(bucket, key, 10 * 1024 * 1024) upload.complete_upload() @attr(resource='object') @attr(method='put') @attr(operation='check failure on multiple multi-part upload with size too small') @attr(assertion='fails 400') def test_multipart_upload_size_too_small(): bucket = get_new_bucket() key="mymultipart" (upload, data) = _multipart_upload(bucket, key, 100 * 1024, part_size=10*1024) e = assert_raises(boto.exception.S3ResponseError, upload.complete_upload) eq(e.status, 400) eq(e.error_code, u'EntityTooSmall') def gen_rand_string(size, chars=string.ascii_uppercase + string.digits): return ''.join(random.choice(chars) for _ in range(size)) def _do_test_multipart_upload_contents(bucket, key_name, num_parts): payload=gen_rand_string(5)*1024*1024 mp=bucket.initiate_multipart_upload(key_name) for i in range(0, num_parts): mp.upload_part_from_file(StringIO(payload), i+1) last_payload='123'*1024*1024 mp.upload_part_from_file(StringIO(last_payload), num_parts + 1) mp.complete_upload() key=bucket.get_key(key_name) test_string=key.get_contents_as_string() all_payload = payload*num_parts + last_payload print 'JJJ', key_name, len(all_payload), len(test_string) assert test_string == all_payload return all_payload @attr(resource='object') @attr(method='put') @attr(operation='check contents of multi-part upload') @attr(assertion='successful') def test_multipart_upload_contents(): _do_test_multipart_upload_contents(get_new_bucket(), 'mymultipart', 3) @attr(resource='object') @attr(method='put') @attr(operation=' multi-part upload overwrites existing key') @attr(assertion='successful') def test_multipart_upload_overwrite_existing_object(): bucket = get_new_bucket() key_name="mymultipart" payload='12345'*1024*1024 num_parts=2 key=bucket.new_key(key_name) key.set_contents_from_string(payload) mp=bucket.initiate_multipart_upload(key_name) for i in range(0, num_parts): mp.upload_part_from_file(StringIO(payload), i+1) mp.complete_upload() key=bucket.get_key(key_name) test_string=key.get_contents_as_string() assert test_string == payload*num_parts @attr(resource='object') @attr(method='put') @attr(operation='abort multi-part upload') @attr(assertion='successful') def test_abort_multipart_upload(): bucket = get_new_bucket() key="mymultipart" (upload, data) = _multipart_upload(bucket, key, 10 * 1024 * 1024) upload.cancel_upload() result = _head_bucket(bucket) eq(result.get('x-rgw-object-count', 0), 0) eq(result.get('x-rgw-bytes-used', 0), 0) def test_abort_multipart_upload_not_found(): bucket = get_new_bucket() key="mymultipart" e = assert_raises(boto.exception.S3ResponseError, bucket.cancel_multipart_upload, key, '1') eq(e.status, 404) eq(e.reason, 'Not Found') eq(e.error_code, 'NoSuchUpload') @attr(resource='object') @attr(method='put') @attr(operation='concurrent multi-part uploads') @attr(assertion='successful') def test_list_multipart_upload(): bucket = get_new_bucket() key="mymultipart" mb = 1024 * 1024 (upload1, data) = _multipart_upload(bucket, key, 5 * mb, do_list = True) (upload2, data) = _multipart_upload(bucket, key, 6 * mb, do_list = True) key2="mymultipart2" (upload3, data) = _multipart_upload(bucket, key2, 5 * mb, do_list = True) l = bucket.list_multipart_uploads() l = list(l) index = dict([(key, 2), (key2, 1)]) for upload in l: index[upload.key_name] -= 1; for k, c in index.items(): eq(c, 0) upload1.cancel_upload() upload2.cancel_upload() upload3.cancel_upload() @attr(resource='object') @attr(method='put') @attr(operation='multi-part upload with missing part') def test_multipart_upload_missing_part(): bucket = get_new_bucket() key_name = "mymultipart" mp = bucket.initiate_multipart_upload(key_name) mp.upload_part_from_file(StringIO('\x00'), 1) xml = mp.to_xml() xml = xml.replace('<PartNumber>1</PartNumber>', '<PartNumber>9999</PartNumber>') e = assert_raises(boto.exception.S3ResponseError, bucket.complete_multipart_upload, key_name, mp.id, xml) eq(e.status, 400) eq(e.reason, 'Bad Request') eq(e.error_code, 'InvalidPart') @attr(resource='object') @attr(method='put') @attr(operation='multi-part upload with incorrect ETag') def test_multipart_upload_incorrect_etag(): bucket = get_new_bucket() key_name = "mymultipart" mp = bucket.initiate_multipart_upload(key_name) mp.upload_part_from_file(StringIO('\x00'), 1) xml = mp.to_xml() xml = xml.replace('<ETag>"93b885adfe0da089cdf634904fd59f71"</ETag>', '<ETag>"ffffffffffffffffffffffffffffffff"</ETag>') e = assert_raises(boto.exception.S3ResponseError, bucket.complete_multipart_upload, key_name, mp.id, xml) eq(e.status, 400) eq(e.reason, 'Bad Request') eq(e.error_code, 'InvalidPart') def _simple_http_req_100_cont(host, port, is_secure, method, resource): """ Send the specified request w/expect 100-continue and await confirmation. """ req = '{method} {resource} HTTP/1.1\r\nHost: {host}\r\nAccept-Encoding: identity\r\nContent-Length: 123\r\nExpect: 100-continue\r\n\r\n'.format( method=method, resource=resource, host=host, ) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if is_secure: s = ssl.wrap_socket(s); s.settimeout(5) s.connect((host, port)) s.send(req) try: data = s.recv(1024) except socket.error, msg: print 'got response: ', msg print 'most likely server doesn\'t support 100-continue' s.close() l = data.split(' ') assert l[0].startswith('HTTP') return l[1] @attr(resource='object') @attr(method='put') @attr(operation='w/expect continue') @attr(assertion='succeeds if object is public-read-write') @attr('100_continue') @attr('fails_on_mod_proxy_fcgi') def test_100_continue(): bucket = get_new_bucket() objname = 'testobj' resource = '/{bucket}/{obj}'.format(bucket=bucket.name, obj=objname) status = _simple_http_req_100_cont(s3.main.host, s3.main.port, s3.main.is_secure, 'PUT', resource) eq(status, '403') bucket.set_acl('public-read-write') status = _simple_http_req_100_cont(s3.main.host, s3.main.port, s3.main.is_secure, 'PUT', resource) eq(status, '100') def _test_bucket_acls_changes_persistent(bucket): """ set and verify readback of each possible permission """ perms = ('FULL_CONTROL', 'WRITE', 'WRITE_ACP', 'READ', 'READ_ACP') for p in perms: _build_bucket_acl_xml(p, bucket) @attr(resource='bucket') @attr(method='put') @attr(operation='acl set') @attr(assertion='all permissions are persistent') def test_bucket_acls_changes_persistent(): bucket = get_new_bucket() _test_bucket_acls_changes_persistent(bucket); @attr(resource='bucket') @attr(method='put') @attr(operation='repeated acl set') @attr(assertion='all permissions are persistent') def test_stress_bucket_acls_changes(): bucket = get_new_bucket() for i in xrange(10): _test_bucket_acls_changes_persistent(bucket); @attr(resource='bucket') @attr(method='put') @attr(operation='set cors') @attr(assertion='succeeds') def test_set_cors(): bucket = get_new_bucket() cfg = CORSConfiguration() cfg.add_rule('GET', '*.get') cfg.add_rule('PUT', '*.put') e = assert_raises(boto.exception.S3ResponseError, bucket.get_cors) eq(e.status, 404) bucket.set_cors(cfg) new_cfg = bucket.get_cors() eq(len(new_cfg), 2) result = bunch.Bunch() for c in new_cfg: eq(len(c.allowed_method), 1) eq(len(c.allowed_origin), 1) result[c.allowed_method[0]] = c.allowed_origin[0] eq(result['GET'], '*.get') eq(result['PUT'], '*.put') bucket.delete_cors() e = assert_raises(boto.exception.S3ResponseError, bucket.get_cors) eq(e.status, 404) def _cors_request_and_check(func, url, headers, expect_status, expect_allow_origin, expect_allow_methods): r = func(url, headers=headers) eq(r.status_code, expect_status) assert r.headers['access-control-allow-origin'] == expect_allow_origin assert r.headers['access-control-allow-methods'] == expect_allow_methods @attr(resource='bucket') @attr(method='get') @attr(operation='check cors response when origin header set') @attr(assertion='returning cors header') def test_cors_origin_response(): cfg = CORSConfiguration() bucket = get_new_bucket() bucket.set_acl('public-read') cfg.add_rule('GET', '*suffix') cfg.add_rule('GET', 'start*end') cfg.add_rule('GET', 'prefix*') cfg.add_rule('PUT', '*.put') e = assert_raises(boto.exception.S3ResponseError, bucket.get_cors) eq(e.status, 404) bucket.set_cors(cfg) time.sleep(3) # waiting, since if running against amazon data consistency model is not strict read-after-write url = _get_post_url(s3.main, bucket) _cors_request_and_check(requests.get, url, None, 200, None, None) _cors_request_and_check(requests.get, url, {'Origin': 'foo.suffix'}, 200, 'foo.suffix', 'GET') _cors_request_and_check(requests.get, url, {'Origin': 'foo.bar'}, 200, None, None) _cors_request_and_check(requests.get, url, {'Origin': 'foo.suffix.get'}, 200, None, None) _cors_request_and_check(requests.get, url, {'Origin': 'startend'}, 200, 'startend', 'GET') _cors_request_and_check(requests.get, url, {'Origin': 'start1end'}, 200, 'start1end', 'GET') _cors_request_and_check(requests.get, url, {'Origin': 'start12end'}, 200, 'start12end', 'GET') _cors_request_and_check(requests.get, url, {'Origin': '0start12end'}, 200, None, None) _cors_request_and_check(requests.get, url, {'Origin': 'prefix'}, 200, 'prefix', 'GET') _cors_request_and_check(requests.get, url, {'Origin': 'prefix.suffix'}, 200, 'prefix.suffix', 'GET') _cors_request_and_check(requests.get, url, {'Origin': 'bla.prefix'}, 200, None, None) obj_url = '{u}/{o}'.format(u=url, o='bar') _cors_request_and_check(requests.get, obj_url, {'Origin': 'foo.suffix'}, 404, 'foo.suffix', 'GET') _cors_request_and_check(requests.put, obj_url, {'Origin': 'foo.suffix', 'Access-Control-Request-Method': 'GET', 'content-length': '0'}, 403, 'foo.suffix', 'GET') _cors_request_and_check(requests.put, obj_url, {'Origin': 'foo.suffix', 'Access-Control-Request-Method': 'PUT', 'content-length': '0'}, 403, None, None) _cors_request_and_check(requests.put, obj_url, {'Origin': 'foo.suffix', 'Access-Control-Request-Method': 'DELETE', 'content-length': '0'}, 403, None, None) _cors_request_and_check(requests.put, obj_url, {'Origin': 'foo.suffix', 'content-length': '0'}, 403, None, None) _cors_request_and_check(requests.put, obj_url, {'Origin': 'foo.put', 'content-length': '0'}, 403, 'foo.put', 'PUT') _cors_request_and_check(requests.get, obj_url, {'Origin': 'foo.suffix'}, 404, 'foo.suffix', 'GET') _cors_request_and_check(requests.options, url, None, 400, None, None) _cors_request_and_check(requests.options, url, {'Origin': 'foo.suffix'}, 400, None, None) _cors_request_and_check(requests.options, url, {'Origin': 'bla'}, 400, None, None) _cors_request_and_check(requests.options, obj_url, {'Origin': 'foo.suffix', 'Access-Control-Request-Method': 'GET', 'content-length': '0'}, 200, 'foo.suffix', 'GET') _cors_request_and_check(requests.options, url, {'Origin': 'foo.bar', 'Access-Control-Request-Method': 'GET'}, 403, None, None) _cors_request_and_check(requests.options, url, {'Origin': 'foo.suffix.get', 'Access-Control-Request-Method': 'GET'}, 403, None, None) _cors_request_and_check(requests.options, url, {'Origin': 'startend', 'Access-Control-Request-Method': 'GET'}, 200, 'startend', 'GET') _cors_request_and_check(requests.options, url, {'Origin': 'start1end', 'Access-Control-Request-Method': 'GET'}, 200, 'start1end', 'GET') _cors_request_and_check(requests.options, url, {'Origin': 'start12end', 'Access-Control-Request-Method': 'GET'}, 200, 'start12end', 'GET') _cors_request_and_check(requests.options, url, {'Origin': '0start12end', 'Access-Control-Request-Method': 'GET'}, 403, None, None) _cors_request_and_check(requests.options, url, {'Origin': 'prefix', 'Access-Control-Request-Method': 'GET'}, 200, 'prefix', 'GET') _cors_request_and_check(requests.options, url, {'Origin': 'prefix.suffix', 'Access-Control-Request-Method': 'GET'}, 200, 'prefix.suffix', 'GET') _cors_request_and_check(requests.options, url, {'Origin': 'bla.prefix', 'Access-Control-Request-Method': 'GET'}, 403, None, None) _cors_request_and_check(requests.options, url, {'Origin': 'foo.put', 'Access-Control-Request-Method': 'GET'}, 403, None, None) _cors_request_and_check(requests.options, url, {'Origin': 'foo.put', 'Access-Control-Request-Method': 'PUT'}, 200, 'foo.put', 'PUT') class FakeFile(object): """ file that simulates seek, tell, and current character """ def __init__(self, char='A', interrupt=None): self.offset = 0 self.char = char self.interrupt = interrupt def seek(self, offset, whence=os.SEEK_SET): if whence == os.SEEK_SET: self.offset = offset elif whence == os.SEEK_END: self.offset = self.size + offset; elif whence == os.SEEK_CUR: self.offset += offset def tell(self): return self.offset class FakeWriteFile(FakeFile): """ file that simulates interruptable reads of constant data """ def __init__(self, size, char='A', interrupt=None): FakeFile.__init__(self, char, interrupt) self.size = size def read(self, size=-1): if size < 0: size = self.size - self.offset count = min(size, self.size - self.offset) self.offset += count # Sneaky! do stuff before we return (the last time) if self.interrupt != None and self.offset == self.size and count > 0: self.interrupt() return self.char*count class FakeReadFile(FakeFile): """ file that simulates writes, interrupting after the second """ def __init__(self, size, char='A', interrupt=None): FakeFile.__init__(self, char, interrupt) self.interrupted = False self.size = 0 self.expected_size = size def write(self, chars): eq(chars, self.char*len(chars)) self.offset += len(chars) self.size += len(chars) # Sneaky! do stuff on the second seek if not self.interrupted and self.interrupt != None \ and self.offset > 0: self.interrupt() self.interrupted = True def close(self): eq(self.size, self.expected_size) class FakeFileVerifier(object): """ file that verifies expected data has been written """ def __init__(self, char=None): self.char = char self.size = 0 def write(self, data): size = len(data) if self.char == None: self.char = data[0] self.size += size eq(data, self.char*size) def _verify_atomic_key_data(key, size=-1, char=None): """ Make sure file is of the expected size and (simulated) content """ fp_verify = FakeFileVerifier(char) key.get_contents_to_file(fp_verify) if size >= 0: eq(fp_verify.size, size) def _test_atomic_read(file_size): """ Create a file of A's, use it to set_contents_from_file. Create a file of B's, use it to re-set_contents_from_file. Re-read the contents, and confirm we get B's """ bucket = get_new_bucket() key = bucket.new_key('testobj') # create object of <file_size> As fp_a = FakeWriteFile(file_size, 'A') key.set_contents_from_file(fp_a) read_conn = boto.s3.connection.S3Connection( aws_access_key_id=s3['main'].aws_access_key_id, aws_secret_access_key=s3['main'].aws_secret_access_key, is_secure=s3['main'].is_secure, port=s3['main'].port, host=s3['main'].host, calling_format=s3['main'].calling_format, ) read_bucket = read_conn.get_bucket(bucket.name) read_key = read_bucket.get_key('testobj') fp_b = FakeWriteFile(file_size, 'B') fp_a2 = FakeReadFile(file_size, 'A', lambda: key.set_contents_from_file(fp_b) ) # read object while writing it to it read_key.get_contents_to_file(fp_a2) fp_a2.close() _verify_atomic_key_data(key, file_size, 'B') @attr(resource='object') @attr(method='put') @attr(operation='read atomicity') @attr(assertion='1MB successful') def test_atomic_read_1mb(): _test_atomic_read(1024*1024) @attr(resource='object') @attr(method='put') @attr(operation='read atomicity') @attr(assertion='4MB successful') def test_atomic_read_4mb(): _test_atomic_read(1024*1024*4) @attr(resource='object') @attr(method='put') @attr(operation='read atomicity') @attr(assertion='8MB successful') def test_atomic_read_8mb(): _test_atomic_read(1024*1024*8) def _test_atomic_write(file_size): """ Create a file of A's, use it to set_contents_from_file. Verify the contents are all A's. Create a file of B's, use it to re-set_contents_from_file. Before re-set continues, verify content's still A's Re-read the contents, and confirm we get B's """ bucket = get_new_bucket() objname = 'testobj' key = bucket.new_key(objname) # create <file_size> file of A's fp_a = FakeWriteFile(file_size, 'A') key.set_contents_from_file(fp_a) # verify A's _verify_atomic_key_data(key, file_size, 'A') read_key = bucket.get_key(objname) # create <file_size> file of B's # but try to verify the file before we finish writing all the B's fp_b = FakeWriteFile(file_size, 'B', lambda: _verify_atomic_key_data(read_key, file_size) ) key.set_contents_from_file(fp_b) # verify B's _verify_atomic_key_data(key, file_size, 'B') @attr(resource='object') @attr(method='put') @attr(operation='write atomicity') @attr(assertion='1MB successful') def test_atomic_write_1mb(): _test_atomic_write(1024*1024) @attr(resource='object') @attr(method='put') @attr(operation='write atomicity') @attr(assertion='4MB successful') def test_atomic_write_4mb(): _test_atomic_write(1024*1024*4) @attr(resource='object') @attr(method='put') @attr(operation='write atomicity') @attr(assertion='8MB successful') def test_atomic_write_8mb(): _test_atomic_write(1024*1024*8) def _test_atomic_dual_write(file_size): """ create an object, two sessions writing different contents confirm that it is all one or the other """ bucket = get_new_bucket() objname = 'testobj' key = bucket.new_key(objname) # get a second key object (for the same key) # so both can be writing without interfering key2 = bucket.new_key(objname) # write <file_size> file of B's # but before we're done, try to write all A's fp_a = FakeWriteFile(file_size, 'A') fp_b = FakeWriteFile(file_size, 'B', lambda: key2.set_contents_from_file(fp_a, rewind=True) ) key.set_contents_from_file(fp_b) # verify the file _verify_atomic_key_data(key, file_size) @attr(resource='object') @attr(method='put') @attr(operation='write one or the other') @attr(assertion='1MB successful') def test_atomic_dual_write_1mb(): _test_atomic_dual_write(1024*1024) @attr(resource='object') @attr(method='put') @attr(operation='write one or the other') @attr(assertion='4MB successful') def test_atomic_dual_write_4mb(): _test_atomic_dual_write(1024*1024*4) @attr(resource='object') @attr(method='put') @attr(operation='write one or the other') @attr(assertion='8MB successful') def test_atomic_dual_write_8mb(): _test_atomic_dual_write(1024*1024*8) def _test_atomic_conditional_write(file_size): """ Create a file of A's, use it to set_contents_from_file. Verify the contents are all A's. Create a file of B's, use it to re-set_contents_from_file. Before re-set continues, verify content's still A's Re-read the contents, and confirm we get B's """ bucket = get_new_bucket() objname = 'testobj' key = bucket.new_key(objname) # create <file_size> file of A's fp_a = FakeWriteFile(file_size, 'A') key.set_contents_from_file(fp_a) # verify A's _verify_atomic_key_data(key, file_size, 'A') read_key = bucket.get_key(objname) # create <file_size> file of B's # but try to verify the file before we finish writing all the B's fp_b = FakeWriteFile(file_size, 'B', lambda: _verify_atomic_key_data(read_key, file_size) ) key.set_contents_from_file(fp_b, headers={'If-Match': '*'}) # verify B's _verify_atomic_key_data(key, file_size, 'B') @attr(resource='object') @attr(method='put') @attr(operation='write atomicity') @attr(assertion='1MB successful') @attr('fails_on_aws') def test_atomic_conditional_write_1mb(): _test_atomic_conditional_write(1024*1024) def _test_atomic_dual_conditional_write(file_size): """ create an object, two sessions writing different contents confirm that it is all one or the other """ bucket = get_new_bucket() objname = 'testobj' key = bucket.new_key(objname) fp_a = FakeWriteFile(file_size, 'A') key.set_contents_from_file(fp_a) _verify_atomic_key_data(key, file_size, 'A') etag_fp_a = key.etag.replace('"', '').strip() # get a second key object (for the same key) # so both can be writing without interfering key2 = bucket.new_key(objname) # write <file_size> file of C's # but before we're done, try to write all B's fp_b = FakeWriteFile(file_size, 'B') fp_c = FakeWriteFile(file_size, 'C', lambda: key2.set_contents_from_file(fp_b, rewind=True, headers={'If-Match': etag_fp_a}) ) # key.set_contents_from_file(fp_c, headers={'If-Match': etag_fp_a}) e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_file, fp_c, headers={'If-Match': etag_fp_a}) eq(e.status, 412) eq(e.reason, 'Precondition Failed') eq(e.error_code, 'PreconditionFailed') # verify the file _verify_atomic_key_data(key, file_size, 'B') @attr(resource='object') @attr(method='put') @attr(operation='write one or the other') @attr(assertion='1MB successful') @attr('fails_on_aws') def test_atomic_dual_conditional_write_1mb(): _test_atomic_dual_conditional_write(1024*1024) @attr(resource='object') @attr(method='put') @attr(operation='write file in deleted bucket') @attr(assertion='fail 404') @attr('fails_on_aws') def test_atomic_write_bucket_gone(): bucket = get_new_bucket() def remove_bucket(): bucket.delete() # create file of A's but delete the bucket it's in before we finish writing # all of them key = bucket.new_key('foo') fp_a = FakeWriteFile(1024*1024, 'A', remove_bucket) e = assert_raises(boto.exception.S3ResponseError, key.set_contents_from_file, fp_a) eq(e.status, 404) eq(e.reason, 'Not Found') eq(e.error_code, 'NoSuchBucket') @attr(resource='object') @attr(method='get') @attr(operation='range') @attr(assertion='returns correct data, 206') def test_ranged_request_response_code(): content = 'testcontent' bucket = get_new_bucket() key = bucket.new_key('testobj') key.set_contents_from_string(content) key.open('r', headers={'Range': 'bytes=4-7'}) status = key.resp.status content_range = key.resp.getheader('Content-Range') fetched_content = '' for data in key: fetched_content += data; key.close() eq(fetched_content, content[4:8]) eq(status, 206) eq(content_range, 'bytes 4-7/11') @attr(resource='object') @attr(method='get') @attr(operation='range') @attr(assertion='returns correct data, 206') def test_ranged_request_skip_leading_bytes_response_code(): content = 'testcontent' bucket = get_new_bucket() key = bucket.new_key('testobj') key.set_contents_from_string(content) # test trailing bytes key.open('r', headers={'Range': 'bytes=4-'}) status = key.resp.status content_range = key.resp.getheader('Content-Range') fetched_content = '' for data in key: fetched_content += data; key.close() eq(fetched_content, content[4:]) eq(status, 206) eq(content_range, 'bytes 4-10/11') @attr(resource='object') @attr(method='get') @attr(operation='range') @attr(assertion='returns correct data, 206') def test_ranged_request_return_trailing_bytes_response_code(): content = 'testcontent' bucket = get_new_bucket() key = bucket.new_key('testobj') key.set_contents_from_string(content) # test leading bytes key.open('r', headers={'Range': 'bytes=-7'}) status = key.resp.status content_range = key.resp.getheader('Content-Range') fetched_content = '' for data in key: fetched_content += data; key.close() eq(fetched_content, content[-7:]) eq(status, 206) eq(content_range, 'bytes 4-10/11') @attr(resource='object') @attr(method='get') @attr(operation='range') @attr(assertion='returns invalid range, 416') def test_ranged_request_invalid_range(): content = 'testcontent' bucket = get_new_bucket() key = bucket.new_key('testobj') key.set_contents_from_string(content) # test invalid range e = assert_raises(boto.exception.S3ResponseError, key.open, 'r', headers={'Range': 'bytes=40-50'}) eq(e.status, 416) eq(e.error_code, 'InvalidRange') def check_can_test_multiregion(): if not targets.main.master or len(targets.main.secondaries) == 0: raise SkipTest def create_presigned_url(conn, method, bucket_name, key_name, expiration): return conn.generate_url(expires_in=expiration, method=method, bucket=bucket_name, key=key_name, query_auth=True, ) def send_raw_http_request(conn, method, bucket_name, key_name, follow_redirects = False): url = create_presigned_url(conn, method, bucket_name, key_name, 3600) print url h = httplib2.Http() h.follow_redirects = follow_redirects return h.request(url, method) @attr(resource='bucket') @attr(method='get') @attr(operation='create on one region, access in another') @attr(assertion='can\'t access in other region') @attr('multiregion') def test_region_bucket_create_secondary_access_remove_master(): check_can_test_multiregion() master_conn = targets.main.master.connection for r in targets.main.secondaries: conn = r.connection bucket = get_new_bucket(r) r, content = send_raw_http_request(master_conn, 'GET', bucket.name, '', follow_redirects = False) eq(r.status, 301) r, content = send_raw_http_request(master_conn, 'DELETE', bucket.name, '', follow_redirects = False) eq(r.status, 301) conn.delete_bucket(bucket) @attr(resource='bucket') @attr(method='get') @attr(operation='create on one region, access in another') @attr(assertion='can\'t access in other region') @attr('multiregion') def test_region_bucket_create_master_access_remove_secondary(): check_can_test_multiregion() master = targets.main.master master_conn = master.connection for r in targets.main.secondaries: conn = r.connection bucket = get_new_bucket(master) region_sync_meta(targets.main, master) r, content = send_raw_http_request(conn, 'GET', bucket.name, '', follow_redirects = False) eq(r.status, 301) r, content = send_raw_http_request(conn, 'DELETE', bucket.name, '', follow_redirects = False) eq(r.status, 301) master_conn.delete_bucket(bucket) region_sync_meta(targets.main, master) e = assert_raises(boto.exception.S3ResponseError, conn.get_bucket, bucket.name) eq(e.status, 404) e = assert_raises(boto.exception.S3ResponseError, master_conn.get_bucket, bucket.name) eq(e.status, 404) @attr(resource='object') @attr(method='copy') @attr(operation='copy object between regions, verify') @attr(assertion='can read object') @attr('multiregion') def test_region_copy_object(): check_can_test_multiregion() for (k, dest) in targets.main.iteritems(): dest_conn = dest.connection dest_bucket = get_new_bucket(dest) print 'created new dest bucket ', dest_bucket.name region_sync_meta(targets.main, dest) if is_slow_backend(): sizes = (1024, 10 * 1024 * 1024) else: sizes = (1024, 10 * 1024 * 1024, 100 * 1024 * 1024) for file_size in sizes: for (k2, r) in targets.main.iteritems(): if r == dest_conn: continue conn = r.connection bucket = get_new_bucket(r) print 'created bucket', bucket.name region_sync_meta(targets.main, r) content = 'testcontent' print 'creating key=testobj', 'bucket=',bucket.name key = bucket.new_key('testobj') fp_a = FakeWriteFile(file_size, 'A') key.set_contents_from_file(fp_a) print 'calling region_sync_meta' region_sync_meta(targets.main, r) print 'dest_bucket=', dest_bucket.name, 'key=', key.name dest_key = dest_bucket.copy_key('testobj-dest', bucket.name, key.name) print # verify dest _verify_atomic_key_data(dest_key, file_size, 'A') bucket.delete_key(key.name) # confirm that the key was deleted as expected region_sync_meta(targets.main, r) temp_key = bucket.get_key(key.name) assert temp_key == None print 'removing bucket', bucket.name conn.delete_bucket(bucket) # confirm that the bucket was deleted as expected region_sync_meta(targets.main, r) e = assert_raises(boto.exception.S3ResponseError, conn.get_bucket, bucket.name) eq(e.status, 404) e = assert_raises(boto.exception.S3ResponseError, dest_conn.get_bucket, bucket.name) eq(e.status, 404) # confirm that the key was deleted as expected dest_bucket.delete_key(dest_key.name) temp_key = dest_bucket.get_key(dest_key.name) assert temp_key == None dest_conn.delete_bucket(dest_bucket) region_sync_meta(targets.main, dest) # ensure that dest_bucket was deleted on this host and all other hosts e = assert_raises(boto.exception.S3ResponseError, dest_conn.get_bucket, dest_bucket.name) eq(e.status, 404) for (k2, r) in targets.main.iteritems(): if r == dest_conn: continue conn = r.connection e = assert_raises(boto.exception.S3ResponseError, conn.get_bucket, dest_bucket.name) eq(e.status, 404) def check_versioning(bucket, status): try: eq(bucket.get_versioning_status()['Versioning'], status) except KeyError: eq(status, None) # amazon is eventual consistent, retry a bit if failed def check_configure_versioning_retry(bucket, status, expected_string): bucket.configure_versioning(status) read_status = None for i in xrange(5): try: read_status = bucket.get_versioning_status()['Versioning'] except KeyError: read_status = None if (expected_string == read_status): break time.sleep(1) eq(expected_string, read_status) @attr(resource='bucket') @attr(method='create') @attr(operation='create versioned bucket') @attr(assertion='can create and suspend bucket versioning') @attr('versioning') def test_versioning_bucket_create_suspend(): bucket = get_new_bucket() check_versioning(bucket, None) check_configure_versioning_retry(bucket, False, "Suspended") check_configure_versioning_retry(bucket, True, "Enabled") check_configure_versioning_retry(bucket, True, "Enabled") check_configure_versioning_retry(bucket, False, "Suspended") def check_head_obj_content(key, content): if content is not None: eq(key.get_contents_as_string(), content) else: print 'check head', key eq(key, None) def check_obj_content(key, content): if content is not None: eq(key.get_contents_as_string(), content) else: eq(isinstance(key, boto.s3.deletemarker.DeleteMarker), True) def check_obj_versions(bucket, objname, keys, contents): # check to see if object is pointing at correct version key = bucket.get_key(objname) if len(contents) > 0: print 'testing obj head', objname check_head_obj_content(key, contents[-1]) i = len(contents) for key in bucket.list_versions(): if key.name != objname: continue i -= 1 eq(keys[i].version_id or 'null', key.version_id) print 'testing obj version-id=', key.version_id check_obj_content(key, contents[i]) else: eq(key, None) def create_multiple_versions(bucket, objname, num_versions, k = None, c = None): c = c or [] k = k or [] for i in xrange(num_versions): c.append('content-{i}'.format(i=i)) key = bucket.new_key(objname) key.set_contents_from_string(c[i]) if i == 0: check_configure_versioning_retry(bucket, True, "Enabled") k_pos = len(k) i = 0 for o in bucket.list_versions(): if o.name != objname: continue i += 1 if i > num_versions: break print o, o.version_id k.insert(k_pos, o) print 'created obj name=', objname, 'version-id=', o.version_id eq(len(k), len(c)) for j in xrange(num_versions): print j, k[j], k[j].version_id check_obj_versions(bucket, objname, k, c) return (k, c) def remove_obj_version(bucket, k, c, i): # check by versioned key i = i % len(k) rmkey = k.pop(i) content = c.pop(i) if (not rmkey.delete_marker): eq(rmkey.get_contents_as_string(), content) # remove version print 'removing version_id=', rmkey.version_id bucket.delete_key(rmkey.name, version_id = rmkey.version_id) check_obj_versions(bucket, rmkey.name, k, c) def remove_obj_head(bucket, objname, k, c): print 'removing obj=', objname key = bucket.delete_key(objname) k.append(key) c.append(None) eq(key.delete_marker, True) check_obj_versions(bucket, objname, k, c) def _do_test_create_remove_versions(bucket, objname, num_versions, remove_start_idx, idx_inc): (k, c) = create_multiple_versions(bucket, objname, num_versions) idx = remove_start_idx for j in xrange(num_versions): remove_obj_version(bucket, k, c, idx) idx += idx_inc def _do_remove_versions(bucket, objname, remove_start_idx, idx_inc, head_rm_ratio, k, c): idx = remove_start_idx r = 0 total = len(k) for j in xrange(total): r += head_rm_ratio if r >= 1: r %= 1 remove_obj_head(bucket, objname, k, c) else: remove_obj_version(bucket, k, c, idx) idx += idx_inc check_obj_versions(bucket, objname, k, c) def _do_test_create_remove_versions_and_head(bucket, objname, num_versions, num_ops, remove_start_idx, idx_inc, head_rm_ratio): (k, c) = create_multiple_versions(bucket, objname, num_versions) _do_remove_versions(bucket, objname, remove_start_idx, idx_inc, head_rm_ratio, k, c) @attr(resource='object') @attr(method='create') @attr(operation='create and remove versioned object') @attr(assertion='can create access and remove appropriate versions') @attr('versioning') def test_versioning_obj_create_read_remove(): bucket = get_new_bucket() objname = 'testobj' num_vers = 5 _do_test_create_remove_versions(bucket, objname, num_vers, -1, 0) _do_test_create_remove_versions(bucket, objname, num_vers, -1, 0) _do_test_create_remove_versions(bucket, objname, num_vers, 0, 0) _do_test_create_remove_versions(bucket, objname, num_vers, 1, 0) _do_test_create_remove_versions(bucket, objname, num_vers, 4, -1) _do_test_create_remove_versions(bucket, objname, num_vers, 3, 3) @attr(resource='object') @attr(method='create') @attr(operation='create and remove versioned object and head') @attr(assertion='can create access and remove appropriate versions') @attr('versioning') def test_versioning_obj_create_read_remove_head(): bucket = get_new_bucket() objname = 'testobj' num_vers = 5 _do_test_create_remove_versions_and_head(bucket, objname, num_vers, num_vers * 2, -1, 0, 0.5) def is_null_key(k): return (k.version_id is None) or (k.version_id == 'null') def delete_suspended_versioning_obj(bucket, objname, k, c): key = bucket.delete_key(objname) i = 0 while i < len(k): if is_null_key(k[i]): k.pop(i) c.pop(i) else: i += 1 key.version_id = "null" k.append(key) c.append(None) check_obj_versions(bucket, objname, k, c) def overwrite_suspended_versioning_obj(bucket, objname, k, c, content): key = bucket.new_key(objname) key.set_contents_from_string(content) i = 0 while i < len(k): print 'kkk', i, k[i], k[i].version_id if is_null_key(k[i]): print 'null key!' k.pop(i) c.pop(i) else: i += 1 k.append(key) c.append(content) check_obj_versions(bucket, objname, k, c) @attr(resource='object') @attr(method='create') @attr(operation='suspend versioned bucket') @attr(assertion='suspended versioning behaves correctly') @attr('versioning') def test_versioning_obj_suspend_versions(): bucket = get_new_bucket() check_versioning(bucket, None) check_configure_versioning_retry(bucket, True, "Enabled") num_versions = 5 objname = 'testobj' (k, c) = create_multiple_versions(bucket, objname, num_versions) check_configure_versioning_retry(bucket, False, "Suspended") delete_suspended_versioning_obj(bucket, objname, k, c) delete_suspended_versioning_obj(bucket, objname, k, c) overwrite_suspended_versioning_obj(bucket, objname, k, c, 'null content 1') overwrite_suspended_versioning_obj(bucket, objname, k, c, 'null content 2') delete_suspended_versioning_obj(bucket, objname, k, c) overwrite_suspended_versioning_obj(bucket, objname, k, c, 'null content 3') delete_suspended_versioning_obj(bucket, objname, k, c) check_configure_versioning_retry(bucket, True, "Enabled") (k, c) = create_multiple_versions(bucket, objname, 3, k, c) _do_remove_versions(bucket, objname, 0, 5, 0.5, k, c) _do_remove_versions(bucket, objname, 0, 5, 0, k, c) eq(len(k), 0) eq(len(k), len(c)) @attr(resource='object') @attr(method='create') @attr(operation='suspend versioned bucket') @attr(assertion='suspended versioning behaves correctly') @attr('versioning') def test_versioning_obj_suspend_versions_simple(): bucket = get_new_bucket() check_versioning(bucket, None) check_configure_versioning_retry(bucket, True, "Enabled") num_versions = 1 objname = 'testobj' (k, c) = create_multiple_versions(bucket, objname, num_versions) check_configure_versioning_retry(bucket, False, "Suspended") delete_suspended_versioning_obj(bucket, objname, k, c) check_configure_versioning_retry(bucket, True, "Enabled") (k, c) = create_multiple_versions(bucket, objname, 1, k, c) for i in xrange(len(k)): print 'JJJ: ', k[i].version_id, c[i] _do_remove_versions(bucket, objname, 0, 0, 0.5, k, c) _do_remove_versions(bucket, objname, 0, 0, 0, k, c) eq(len(k), 0) eq(len(k), len(c)) @attr(resource='object') @attr(method='remove') @attr(operation='create and remove versions') @attr(assertion='everything works') @attr('versioning') def test_versioning_obj_create_versions_remove_all(): bucket = get_new_bucket() check_versioning(bucket, None) check_configure_versioning_retry(bucket, True, "Enabled") num_versions = 10 objname = 'testobj' (k, c) = create_multiple_versions(bucket, objname, num_versions) _do_remove_versions(bucket, objname, 0, 5, 0.5, k, c) _do_remove_versions(bucket, objname, 0, 5, 0, k, c) eq(len(k), 0) eq(len(k), len(c)) @attr(resource='object') @attr(method='remove') @attr(operation='create and remove versions') @attr(assertion='everything works') @attr('versioning') def test_versioning_obj_create_versions_remove_special_names(): bucket = get_new_bucket() check_versioning(bucket, None) check_configure_versioning_retry(bucket, True, "Enabled") num_versions = 10 objnames = ['_testobj', '_', ':', ' '] for objname in objnames: (k, c) = create_multiple_versions(bucket, objname, num_versions) _do_remove_versions(bucket, objname, 0, 5, 0.5, k, c) _do_remove_versions(bucket, objname, 0, 5, 0, k, c) eq(len(k), 0) eq(len(k), len(c)) @attr(resource='object') @attr(method='multipart') @attr(operation='create and test multipart object') @attr(assertion='everything works') @attr('versioning') def test_versioning_obj_create_overwrite_multipart(): bucket = get_new_bucket() check_configure_versioning_retry(bucket, True, "Enabled") objname = 'testobj' c = [] num_vers = 3 for i in xrange(num_vers): c.append(_do_test_multipart_upload_contents(bucket, objname, 3)) k = [] for key in bucket.list_versions(): k.insert(0, key) eq(len(k), num_vers) check_obj_versions(bucket, objname, k, c) _do_remove_versions(bucket, objname, 0, 3, 0.5, k, c) _do_remove_versions(bucket, objname, 0, 3, 0, k, c) eq(len(k), 0) eq(len(k), len(c)) @attr(resource='object') @attr(method='multipart') @attr(operation='list versioned objects') @attr(assertion='everything works') @attr('versioning') def test_versioning_obj_list_marker(): bucket = get_new_bucket() check_configure_versioning_retry(bucket, True, "Enabled") objname = 'testobj' objname2 = 'testobj-1' num_vers = 5 (k, c) = create_multiple_versions(bucket, objname, num_vers) (k2, c2) = create_multiple_versions(bucket, objname2, num_vers) k.reverse() k2.reverse() allkeys = k + k2 names = [] for key1, key2 in itertools.izip_longest(bucket.list_versions(), allkeys): eq(key1.version_id, key2.version_id) names.append(key1.name) for i in xrange(len(allkeys)): for key1, key2 in itertools.izip_longest(bucket.list_versions(key_marker=names[i], version_id_marker=allkeys[i].version_id), allkeys[i+1:]): eq(key1.version_id, key2.version_id) # with nonexisting version id, skip to next object for key1, key2 in itertools.izip_longest(bucket.list_versions(key_marker=objname, version_id_marker='nosuchversion'), allkeys[5:]): eq(key1.version_id, key2.version_id) @attr(resource='object') @attr(method='multipart') @attr(operation='create and test versioned object copying') @attr(assertion='everything works') @attr('versioning') def test_versioning_copy_obj_version(): bucket = get_new_bucket() check_configure_versioning_retry(bucket, True, "Enabled") num_versions = 3 objname = 'testobj' (k, c) = create_multiple_versions(bucket, objname, num_versions) # copy into the same bucket for i in xrange(num_versions): new_key_name = 'key_{i}'.format(i=i) new_key = bucket.copy_key(new_key_name, bucket.name, k[i].name, src_version_id=k[i].version_id) eq(new_key.get_contents_as_string(), c[i]) another_bucket = get_new_bucket() # copy into a different bucket for i in xrange(num_versions): new_key_name = 'key_{i}'.format(i=i) new_key = another_bucket.copy_key(new_key_name, bucket.name, k[i].name, src_version_id=k[i].version_id) eq(new_key.get_contents_as_string(), c[i]) # test copy of head object new_key = another_bucket.copy_key('new_key', bucket.name, objname) eq(new_key.get_contents_as_string(), c[num_versions - 1]) def _count_bucket_versioned_objs(bucket): k = [] for key in bucket.list_versions(): k.insert(0, key) return len(k) @attr(resource='object') @attr(method='delete') @attr(operation='delete multiple versions') @attr(assertion='deletes multiple versions of an object with a single call') @attr('versioning') def test_versioning_multi_object_delete(): bucket = get_new_bucket() check_configure_versioning_retry(bucket, True, "Enabled") keyname = 'key' key0 = bucket.new_key(keyname) key0.set_contents_from_string('foo') key1 = bucket.new_key(keyname) key1.set_contents_from_string('bar') stored_keys = [] for key in bucket.list_versions(): stored_keys.insert(0, key) eq(len(stored_keys), 2) result = bucket.delete_keys(stored_keys) eq(len(result.deleted), 2) eq(len(result.errors), 0) eq(_count_bucket_versioned_objs(bucket), 0) # now remove again, should all succeed due to idempotency result = bucket.delete_keys(stored_keys) eq(len(result.deleted), 2) eq(len(result.errors), 0) eq(_count_bucket_versioned_objs(bucket), 0) @attr(resource='object') @attr(method='delete') @attr(operation='delete multiple versions') @attr(assertion='deletes multiple versions of an object and delete marker with a single call') @attr('versioning') def test_versioning_multi_object_delete_with_marker(): bucket = get_new_bucket() check_configure_versioning_retry(bucket, True, "Enabled") keyname = 'key' key0 = bucket.new_key(keyname) key0.set_contents_from_string('foo') key1 = bucket.new_key(keyname) key1.set_contents_from_string('bar') key2 = bucket.delete_key(keyname) eq(key2.delete_marker, True) stored_keys = [] for key in bucket.list_versions(): stored_keys.insert(0, key) eq(len(stored_keys), 3) result = bucket.delete_keys(stored_keys) eq(len(result.deleted), 3) eq(len(result.errors), 0) eq(_count_bucket_versioned_objs(bucket), 0) delete_markers = [] for o in result.deleted: if o.delete_marker: delete_markers.insert(0, o) eq(len(delete_markers), 1) eq(key2.version_id, delete_markers[0].version_id) # now remove again, should all succeed due to idempotency result = bucket.delete_keys(stored_keys) eq(len(result.deleted), 3) eq(len(result.errors), 0) eq(_count_bucket_versioned_objs(bucket), 0) @attr(resource='object') @attr(method='delete') @attr(operation='multi delete create marker') @attr(assertion='returns correct marker version id') @attr('versioning') def test_versioning_multi_object_delete_with_marker_create(): bucket = get_new_bucket() check_configure_versioning_retry(bucket, True, "Enabled") keyname = 'key' rmkeys = [ bucket.new_key(keyname) ] eq(_count_bucket_versioned_objs(bucket), 0) result = bucket.delete_keys(rmkeys) eq(len(result.deleted), 1) eq(_count_bucket_versioned_objs(bucket), 1) delete_markers = [] for o in result.deleted: if o.delete_marker: delete_markers.insert(0, o) eq(len(delete_markers), 1) for o in bucket.list_versions(): eq(o.name, keyname) eq(o.version_id, delete_markers[0].delete_marker_version_id) @attr(resource='object') @attr(method='put') @attr(operation='change acl on an object version changes specific version') @attr(assertion='works') @attr('versioning') def test_versioned_object_acl(): bucket = get_new_bucket() check_configure_versioning_retry(bucket, True, "Enabled") keyname = 'foo' key0 = bucket.new_key(keyname) key0.set_contents_from_string('bar') key1 = bucket.new_key(keyname) key1.set_contents_from_string('bla') key2 = bucket.new_key(keyname) key2.set_contents_from_string('zxc') stored_keys = [] for key in bucket.list_versions(): stored_keys.insert(0, key) k1 = stored_keys[1] policy = bucket.get_acl(key_name=k1.name, version_id=k1.version_id) default_policy = [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), ] print repr(policy) check_grants(policy.acl.grants, default_policy) bucket.set_canned_acl('public-read', key_name=k1.name, version_id=k1.version_id) policy = bucket.get_acl(key_name=k1.name, version_id=k1.version_id) print repr(policy) check_grants( policy.acl.grants, [ dict( permission='FULL_CONTROL', id=policy.owner.id, display_name=policy.owner.display_name, uri=None, email_address=None, type='CanonicalUser', ), dict( permission='READ', id=None, display_name=None, uri='http://acs.amazonaws.com/groups/global/AllUsers', email_address=None, type='Group', ), ], ) k = bucket.new_key(keyname) check_grants(k.get_acl().acl.grants, default_policy) def _do_create_object(bucket, objname, i): k = bucket.new_key(objname) k.set_contents_from_string('data {i}'.format(i=i)) def _do_remove_ver(bucket, obj): bucket.delete_key(obj.name, version_id = obj.version_id) def _do_create_versioned_obj_concurrent(bucket, objname, num): t = [] for i in range(num): thr = threading.Thread(target = _do_create_object, args=(bucket, objname, i)) thr.start() t.append(thr) return t def _do_clear_versioned_bucket_concurrent(bucket): t = [] for o in bucket.list_versions(): thr = threading.Thread(target = _do_remove_ver, args=(bucket, o)) thr.start() t.append(thr) return t def _do_wait_completion(t): for thr in t: thr.join() @attr(resource='object') @attr(method='put') @attr(operation='concurrent creation of objects, concurrent removal') @attr(assertion='works') @attr('versioning') def test_versioned_concurrent_object_create_concurrent_remove(): bucket = get_new_bucket() check_configure_versioning_retry(bucket, True, "Enabled") keyname = 'myobj' num_objs = 5 for i in xrange(5): t = _do_create_versioned_obj_concurrent(bucket, keyname, num_objs) _do_wait_completion(t) eq(_count_bucket_versioned_objs(bucket), num_objs) eq(len(bucket.get_all_keys()), 1) t = _do_clear_versioned_bucket_concurrent(bucket) _do_wait_completion(t) eq(_count_bucket_versioned_objs(bucket), 0) eq(len(bucket.get_all_keys()), 0) @attr(resource='object') @attr(method='put') @attr(operation='concurrent creation and removal of objects') @attr(assertion='works') @attr('versioning') def test_versioned_concurrent_object_create_and_remove(): bucket = get_new_bucket() check_configure_versioning_retry(bucket, True, "Enabled") keyname = 'myobj' num_objs = 3 all_threads = [] for i in xrange(3): t = _do_create_versioned_obj_concurrent(bucket, keyname, num_objs) all_threads.append(t) t = _do_clear_versioned_bucket_concurrent(bucket) all_threads.append(t) for t in all_threads: _do_wait_completion(t) t = _do_clear_versioned_bucket_concurrent(bucket) _do_wait_completion(t) eq(_count_bucket_versioned_objs(bucket), 0) eq(len(bucket.get_all_keys()), 0)
mit
[ 504, 15073, 492, 5228, 199, 646, 6055, 14, 1971, 199, 646, 6055, 14, 83, 19, 14, 2105, 199, 646, 6055, 14, 83, 19, 14, 5853, 199, 646, 22219, 199, 646, 2197, 199, 646, 900, 199, 646, 3031, 14, 1208, 199, 646, 365, 364, 323, 199, 646, 11354, 199, 646, 4182, 199, 646, 2838, 199, 646, 6149, 199, 646, 747, 199, 646, 4145, 199, 646, 1300, 772, 199, 646, 20330, 199, 646, 7793, 199, 646, 15444, 199, 646, 2022, 199, 646, 8809, 18, 199, 646, 5796, 199, 646, 7975, 199, 646, 1059, 199, 646, 2196, 199, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 199, 199, 504, 8809, 492, 3101, 3225, 12, 14147, 3225, 199, 504, 7097, 492, 7097, 199, 199, 504, 11354, 14, 2537, 492, 3850, 63, 465, 3850, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 504, 11354, 14, 5265, 14, 2759, 492, 18795, 199, 199, 504, 1275, 1208, 492, 702, 63, 3536, 199, 504, 1275, 1208, 492, 3550, 63, 2355, 199, 504, 1275, 1208, 492, 4897, 63, 5186, 63, 2024, 199, 646, 24523, 2817, 199, 199, 504, 3031, 14, 1291, 492, 4849, 63, 1291, 199, 504, 7741, 807, 492, 8773, 199, 199, 504, 6055, 14, 83, 19, 14, 30967, 492, 445, 4149, 5688, 199, 199, 504, 1275, 492, 334, 272, 15699, 415, 63, 27833, 63, 15065, 12, 272, 664, 63, 1222, 63, 4623, 12, 272, 664, 63, 1222, 63, 4623, 63, 354, 12, 272, 308, 19, 12, 272, 4545, 12, 272, 1101, 12, 272, 664, 63, 1861, 12, 272, 365, 63, 14362, 63, 4620, 12, 272, 776, 421, 199, 13887, 13301, 1309, 63, 10089, 275, 283, 9105, 889, 3858, 631, 32, 68, 1091, 1102, 14, 957, 14, 3197, 7, 199, 199, 318, 440, 63, 4077, 8, 65, 12, 330, 304, 272, 702, 282, 1137, 330, 12, 2071, 82, 508, 450, 82, 2, 450, 334, 65, 12, 330, 9, 199, 199, 318, 1104, 63, 2732, 63, 28180, 8, 2324, 12, 627, 589, 12, 1011, 958, 304, 272, 325, 275, 702, 63, 3536, 8, 10914, 14, 1971, 14, 51, 19, 19712, 12, 4325, 12, 627, 589, 12, 1011, 958, 9, 272, 3850, 8, 69, 14, 1205, 12, 13269, 9, 272, 3850, 8, 69, 14, 5764, 12, 283, 17454, 358, 272, 3850, 8, 69, 14, 705, 63, 600, 12, 283, 3946, 15729, 358, 421, 199, 318, 1104, 63, 2587, 2285, 8, 7808, 12, 2934, 304, 272, 408, 272, 2670, 626, 7192, 2285, 769, 315, 4788, 4450, 314, 11196, 315, 2934, 12, 272, 315, 1263, 1865, 14, 272, 408, 272, 3850, 8, 552, 8, 7808, 395, 822, 8, 7051, 430, 272, 4788, 275, 3355, 8, 7808, 12, 790, 29, 3856, 14, 18600, 360, 344, 1333, 272, 2934, 275, 3355, 8, 7051, 12, 790, 29, 3856, 14, 20832, 360, 344, 1333, 272, 367, 486, 12, 336, 315, 3482, 8, 7808, 12, 2934, 304, 267, 336, 275, 1211, 8, 87, 9, 267, 3850, 8, 71, 14, 5693, 12, 336, 14, 1935, 360, 5693, 1333, 267, 3850, 8, 71, 14, 344, 12, 336, 14, 1935, 360, 344, 1333, 267, 3850, 8, 71, 14, 2918, 63, 354, 12, 336, 14, 1935, 360, 2918, 63, 354, 1333, 267, 3850, 8, 71, 14, 2302, 12, 336, 14, 1935, 360, 2302, 1333, 267, 3850, 8, 71, 14, 2123, 63, 1562, 12, 336, 14, 1935, 360, 2123, 63, 1562, 1333, 267, 3850, 8, 71, 14, 466, 12, 336, 14, 1935, 360, 466, 1333, 267, 3850, 8, 87, 12, 5009, 199, 199, 32, 962, 8, 1927, 534, 4623, 358, 199, 32, 962, 8, 765, 534, 362, 358, 199, 32, 962, 8, 5735, 534, 513, 358, 199, 32, 962, 8, 18487, 534, 1667, 18655, 372, 949, 4072, 358, 199, 318, 511, 63, 4623, 63, 513, 63, 1667, 837, 272, 5315, 275, 664, 63, 1222, 63, 4623, 342, 272, 634, 275, 5315, 14, 513, 342, 272, 634, 275, 769, 8, 76, 9, 272, 3850, 8, 76, 12, 3073, 199, 199, 32, 962, 8, 1927, 534, 4623, 358, 199, 32, 962, 8, 765, 534, 362, 358, 199, 32, 962, 8, 5735, 534, 513, 358, 199, 32, 962, 8, 18487, 534, 12926, 18655, 1172, 3365, 4072, 358, 199, 318, 511, 63, 4623, 63, 513, 63, 12926, 837, 272, 5315, 17, 275, 664, 63, 1222, 63, 4623, 342, 272, 5315, 18, 275, 664, 63, 1222, 63, 4623, 342, 272, 790, 275, 5315, 17, 14, 1222, 63, 498, 360, 18196, 358, 272, 790, 14, 409, 63, 4407, 63, 504, 63, 875, 360, 18196, 358, 272, 634, 275, 5315, 18, 14, 513, 342, 272, 634, 275, 769, 8, 76, 9, 272, 3850, 8, 76, 12, 3073, 199, 199, 318, 485, 981, 63, 1612, 8, 4623, 29, 403, 12, 2883, 17894, 272, 408, 272, 31731, 282, 334, 10085, 503, 892, 9, 5315, 543, 2251, 543, 272, 2013, 1561, 334, 460, 4072, 13130, 370, 3932, 1561, 680, 272, 408, 272, 340, 5315, 365, 488, 26, 267, 5315, 275, 664, 63, 1222, 63, 4623, 342, 339, 367, 308, 315, 2883, 26, 267, 790, 275, 5315, 14, 1222, 63, 498, 8, 83, 9, 267, 790, 14, 409, 63, 4407, 63, 504, 63, 875, 8, 83, 9, 339, 372, 5315, 421, 199, 318, 485, 362, 63, 1612, 63, 14124, 8, 317, 304, 272, 408, 272, 9658, 734, 1314, 402, 314, 3326, 315, 282, 769, 787, 5965, 2883, 272, 372, 5548, 402, 3326, 626, 787, 334, 1612, 9, 436, 787, 440, 334, 14124, 9, 272, 408, 272, 2883, 275, 359, 88, 367, 671, 315, 1212, 340, 1228, 8, 88, 12, 6055, 14, 83, 19, 14, 498, 14, 1197, 1874, 272, 13158, 275, 359, 88, 367, 671, 315, 1212, 340, 440, 1228, 8, 88, 12, 6055, 14, 83, 19, 14, 498, 14, 1197, 1874, 272, 372, 334, 1612, 12, 13158, 9, 421, 199, 32, 962, 8, 1927, 534, 4623, 358, 199, 32, 962, 8, 765, 534, 362, 358, 199, 32, 962, 8, 5735, 534, 513, 1006, 2883, 358, 199, 32, 962, 8, 18487, 534, 22793, 336, 15, 988, 63, 1612, 29, 18, 12, 949, 3608, 358, 199, 318, 511, 63, 4623, 63, 513, 63, 3479, 837, 272, 5315, 275, 485, 981, 63, 1612, 8, 1612, 2968, 1421, 297, 283, 1700, 297, 283, 6185, 1105, 339, 327 ]
[ 15073, 492, 5228, 199, 646, 6055, 14, 1971, 199, 646, 6055, 14, 83, 19, 14, 2105, 199, 646, 6055, 14, 83, 19, 14, 5853, 199, 646, 22219, 199, 646, 2197, 199, 646, 900, 199, 646, 3031, 14, 1208, 199, 646, 365, 364, 323, 199, 646, 11354, 199, 646, 4182, 199, 646, 2838, 199, 646, 6149, 199, 646, 747, 199, 646, 4145, 199, 646, 1300, 772, 199, 646, 20330, 199, 646, 7793, 199, 646, 15444, 199, 646, 2022, 199, 646, 8809, 18, 199, 646, 5796, 199, 646, 7975, 199, 646, 1059, 199, 646, 2196, 199, 199, 646, 2748, 14, 9464, 14, 15325, 465, 12265, 199, 199, 504, 8809, 492, 3101, 3225, 12, 14147, 3225, 199, 504, 7097, 492, 7097, 199, 199, 504, 11354, 14, 2537, 492, 3850, 63, 465, 3850, 199, 504, 11354, 14, 5265, 14, 6640, 492, 1921, 199, 504, 11354, 14, 5265, 14, 2759, 492, 18795, 199, 199, 504, 1275, 1208, 492, 702, 63, 3536, 199, 504, 1275, 1208, 492, 3550, 63, 2355, 199, 504, 1275, 1208, 492, 4897, 63, 5186, 63, 2024, 199, 646, 24523, 2817, 199, 199, 504, 3031, 14, 1291, 492, 4849, 63, 1291, 199, 504, 7741, 807, 492, 8773, 199, 199, 504, 6055, 14, 83, 19, 14, 30967, 492, 445, 4149, 5688, 199, 199, 504, 1275, 492, 334, 272, 15699, 415, 63, 27833, 63, 15065, 12, 272, 664, 63, 1222, 63, 4623, 12, 272, 664, 63, 1222, 63, 4623, 63, 354, 12, 272, 308, 19, 12, 272, 4545, 12, 272, 1101, 12, 272, 664, 63, 1861, 12, 272, 365, 63, 14362, 63, 4620, 12, 272, 776, 421, 199, 13887, 13301, 1309, 63, 10089, 275, 283, 9105, 889, 3858, 631, 32, 68, 1091, 1102, 14, 957, 14, 3197, 7, 199, 199, 318, 440, 63, 4077, 8, 65, 12, 330, 304, 272, 702, 282, 1137, 330, 12, 2071, 82, 508, 450, 82, 2, 450, 334, 65, 12, 330, 9, 199, 199, 318, 1104, 63, 2732, 63, 28180, 8, 2324, 12, 627, 589, 12, 1011, 958, 304, 272, 325, 275, 702, 63, 3536, 8, 10914, 14, 1971, 14, 51, 19, 19712, 12, 4325, 12, 627, 589, 12, 1011, 958, 9, 272, 3850, 8, 69, 14, 1205, 12, 13269, 9, 272, 3850, 8, 69, 14, 5764, 12, 283, 17454, 358, 272, 3850, 8, 69, 14, 705, 63, 600, 12, 283, 3946, 15729, 358, 421, 199, 318, 1104, 63, 2587, 2285, 8, 7808, 12, 2934, 304, 272, 408, 272, 2670, 626, 7192, 2285, 769, 315, 4788, 4450, 314, 11196, 315, 2934, 12, 272, 315, 1263, 1865, 14, 272, 408, 272, 3850, 8, 552, 8, 7808, 395, 822, 8, 7051, 430, 272, 4788, 275, 3355, 8, 7808, 12, 790, 29, 3856, 14, 18600, 360, 344, 1333, 272, 2934, 275, 3355, 8, 7051, 12, 790, 29, 3856, 14, 20832, 360, 344, 1333, 272, 367, 486, 12, 336, 315, 3482, 8, 7808, 12, 2934, 304, 267, 336, 275, 1211, 8, 87, 9, 267, 3850, 8, 71, 14, 5693, 12, 336, 14, 1935, 360, 5693, 1333, 267, 3850, 8, 71, 14, 344, 12, 336, 14, 1935, 360, 344, 1333, 267, 3850, 8, 71, 14, 2918, 63, 354, 12, 336, 14, 1935, 360, 2918, 63, 354, 1333, 267, 3850, 8, 71, 14, 2302, 12, 336, 14, 1935, 360, 2302, 1333, 267, 3850, 8, 71, 14, 2123, 63, 1562, 12, 336, 14, 1935, 360, 2123, 63, 1562, 1333, 267, 3850, 8, 71, 14, 466, 12, 336, 14, 1935, 360, 466, 1333, 267, 3850, 8, 87, 12, 5009, 199, 199, 32, 962, 8, 1927, 534, 4623, 358, 199, 32, 962, 8, 765, 534, 362, 358, 199, 32, 962, 8, 5735, 534, 513, 358, 199, 32, 962, 8, 18487, 534, 1667, 18655, 372, 949, 4072, 358, 199, 318, 511, 63, 4623, 63, 513, 63, 1667, 837, 272, 5315, 275, 664, 63, 1222, 63, 4623, 342, 272, 634, 275, 5315, 14, 513, 342, 272, 634, 275, 769, 8, 76, 9, 272, 3850, 8, 76, 12, 3073, 199, 199, 32, 962, 8, 1927, 534, 4623, 358, 199, 32, 962, 8, 765, 534, 362, 358, 199, 32, 962, 8, 5735, 534, 513, 358, 199, 32, 962, 8, 18487, 534, 12926, 18655, 1172, 3365, 4072, 358, 199, 318, 511, 63, 4623, 63, 513, 63, 12926, 837, 272, 5315, 17, 275, 664, 63, 1222, 63, 4623, 342, 272, 5315, 18, 275, 664, 63, 1222, 63, 4623, 342, 272, 790, 275, 5315, 17, 14, 1222, 63, 498, 360, 18196, 358, 272, 790, 14, 409, 63, 4407, 63, 504, 63, 875, 360, 18196, 358, 272, 634, 275, 5315, 18, 14, 513, 342, 272, 634, 275, 769, 8, 76, 9, 272, 3850, 8, 76, 12, 3073, 199, 199, 318, 485, 981, 63, 1612, 8, 4623, 29, 403, 12, 2883, 17894, 272, 408, 272, 31731, 282, 334, 10085, 503, 892, 9, 5315, 543, 2251, 543, 272, 2013, 1561, 334, 460, 4072, 13130, 370, 3932, 1561, 680, 272, 408, 272, 340, 5315, 365, 488, 26, 267, 5315, 275, 664, 63, 1222, 63, 4623, 342, 339, 367, 308, 315, 2883, 26, 267, 790, 275, 5315, 14, 1222, 63, 498, 8, 83, 9, 267, 790, 14, 409, 63, 4407, 63, 504, 63, 875, 8, 83, 9, 339, 372, 5315, 421, 199, 318, 485, 362, 63, 1612, 63, 14124, 8, 317, 304, 272, 408, 272, 9658, 734, 1314, 402, 314, 3326, 315, 282, 769, 787, 5965, 2883, 272, 372, 5548, 402, 3326, 626, 787, 334, 1612, 9, 436, 787, 440, 334, 14124, 9, 272, 408, 272, 2883, 275, 359, 88, 367, 671, 315, 1212, 340, 1228, 8, 88, 12, 6055, 14, 83, 19, 14, 498, 14, 1197, 1874, 272, 13158, 275, 359, 88, 367, 671, 315, 1212, 340, 440, 1228, 8, 88, 12, 6055, 14, 83, 19, 14, 498, 14, 1197, 1874, 272, 372, 334, 1612, 12, 13158, 9, 421, 199, 32, 962, 8, 1927, 534, 4623, 358, 199, 32, 962, 8, 765, 534, 362, 358, 199, 32, 962, 8, 5735, 534, 513, 1006, 2883, 358, 199, 32, 962, 8, 18487, 534, 22793, 336, 15, 988, 63, 1612, 29, 18, 12, 949, 3608, 358, 199, 318, 511, 63, 4623, 63, 513, 63, 3479, 837, 272, 5315, 275, 485, 981, 63, 1612, 8, 1612, 2968, 1421, 297, 283, 1700, 297, 283, 6185, 1105, 339, 327, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pachterlab/kma
inst/pre-process/tests/test_intron_ops.py
1
19345
# intron ops # Copyright (C) 2015 Harold Pimentel # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. import unittest from gtf_parser import * from intron_ops import * class TestIntronOps(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_reduce_to_gene(self): gtf_dict = gtf_parse('/Users/hjp/lmcb/unittests/3gene.gtf') gtf_list = sorted(gtf_dict.values(), key = lambda x: x.front_coordinate) g2t = reduce_to_gene(gtf_list) self.assertEqual(len(g2t), 3) self.assertEqual(len(g2t['ENSG00000124193']), 2) self.assertEqual(len(g2t['ENSG00000078399']), 5) self.assertEqual(len(g2t['ENSG00000151303']), 1) g2t, gene_len = reduce_to_gene(gtf_list, lambda x: len(x)) self.assertEqual(gene_len['ENSG00000124193'], 2) self.assertEqual(gene_len['ENSG00000078399'], 5) self.assertEqual(gene_len['ENSG00000151303'], 1) def test_get_introns(self): t1 = Transcript('t1', 'chr', '+', '.', None, 'g1') t1.add_exon((3, 10)) t1.add_exon((15, 20)) introns = get_introns(t1) self.assertEqual( len(introns), 1) self.assertEqual( introns[0], Intron('chr', 10, 15) ) t1.add_exon((21, 30) ) introns = get_introns(t1) self.assertEqual(introns, [Intron('chr', 10, 15), Intron('chr', 20, 21)]) # FIXME: after class Intron was introduced, broke this... not too difficult # to fix.. # def test_intron_all_trans(self): # t1 = Transcript('t1', 'chr', '+', '.', None, 'g1') # t1.add_exon((3, 10)) # t1.add_exon((15, 20)) # t2 = Transcript('t2', 'chr', '+', '.', None, 'g1') # t2.add_exon((3, 10)) # t2.add_exon((15, 20)) # t2.add_exon((21, 30) ) # introns = intron_all_trans([t1, t2]) # self.assertEqual(introns, [Intron('chr', 10, 15)]) # self.assertEqual(intron_all_trans([]), []) def test_intron_intersection(self): i1 = (3, 10) i2 = (2, 8) self.assertEqual(intron_intersection(i1, i2), (3,8)) i2 = (10, 12) self.assertEqual(intron_intersection(i1, i2), None) # def test_intron_all_junction_left(self): # t1 = Transcript('t1', 'chr', '+', '.', None, 'g1') # t1.add_exon((3, 10)) # t1.add_exon((15, 20)) # t2 = Transcript('t2', 'chr', '+', '.', None, 'g1') # t2.add_exon((3, 10)) # t2.add_exon((18, 25)) # intronic_regions = intron_all_junction_left([t1, t2]) # self.assertEqual(intronic_regions, [(10, 15)]) # t3 = Transcript('t3', 'chr', '+', '.', None, 'g1') # t3.add_exon((3, 10)) # t3.add_exon((16, 23)) # intronic_regions = intron_all_junction_left([t1, t2, t3]) # self.assertEqual(intronic_regions, [(10, 15)]) # # this intron shouldn't match on the left side # t1.add_exon((40, 44)) # t2.add_exon((40, 44)) # t3.add_exon((40, 44)) # intronic_regions = intron_all_junction_left([t1, t2, t3]) # self.assertEqual(intronic_regions, [(10, 15)]) # # this intron should match on the left side # t1.add_exon((49, 57)) # t2.add_exon((47, 53)) # t3.add_exon((47, 54)) # intronic_regions = intron_all_junction_left([t1, t2, t3]) # self.assertEqual(intronic_regions, [(10, 15), # (44, 47)]) # def test_intron_all_junction_left_exon_overlap(self): # # test case where exon overlaps introns # t1 = Transcript('t1', 'chr', '+', '.', None, 'g1') # t1.add_exon((3, 10)) # t1.add_exon((15, 20)) # t2 = Transcript('t2', 'chr', '+', '.', None, 'g1') # t2.add_exon((3, 10)) # t2.add_exon((18, 25)) # t3 = Transcript('t3', 'chr', '+', '.', None, 'g1') # t3.add_exon((3, 25)) # intronic_regions = intron_all_junction_left([t1, t2, t3]) # self.assertEqual(intronic_regions, []) # def test_intron_all_junction_left_no_overlap(self): # t1 = Transcript('t1', 'chr', '+', '.', None, 'g1') # t1.add_exon((3, 10)) # t1.add_exon((15, 20)) # t1.add_exon((30, 40)) # t2 = Transcript('t2', 'chr', '+', '.', None, 'g1') # t2.add_exon((18, 25)) # t2.add_exon((30, 40)) # t3 = Transcript('t3', 'chr', '+', '.', None, 'g1') # t3.add_exon((18, 25)) # t3.add_exon((30, 40)) # intronic_regions = intron_all_junction_left([t1, t2, t3]) # self.assertEqual(intronic_regions, [(10, 15)]) # intronic_regions = intron_all_junction_left([t2, t1, t3]) # self.assertEqual(intronic_regions, [(10, 15)]) # def test_intron_all_junction_left_gtf(self): # trans = gtf_parse('tests/inputs/refGene_07.23.2014_CHL1.gtf') # trans = sorted(trans.values(), key = lambda x: x.front_coordinate) # gene_to_trans, gene_to_introns = \ # reduce_to_gene(trans, intron_all_junction_left) # self.assertEqual(gene_to_introns['CHL1'][0], (238746, 239325)) # self.assertEqual(gene_to_introns['CHL1'][1], (286375, 288250)) # self.assertEqual(gene_to_introns['CHL1'][2], (361550, 367641)) # self.assertEqual(gene_to_introns['CHL1'][3], (367747, 369849)) # self.assertEqual(gene_to_introns['CHL1'][4], (370037, 382476)) # self.assertEqual(gene_to_introns['CHL1'][5], (382599, 383594)) # self.assertEqual(gene_to_introns['CHL1'][6], (383765, 384666)) # self.assertEqual(gene_to_introns['CHL1'][7], (386392, 391041)) # self.assertEqual(gene_to_introns['CHL1'][8], (391226, 396322)) # self.assertEqual(gene_to_introns['CHL1'][9], (396454, 401966)) # self.assertEqual(gene_to_introns['CHL1'][10], (402107, 403381)) # self.assertEqual(gene_to_introns['CHL1'][11], (403493, 404899)) # self.assertEqual(gene_to_introns['CHL1'][12], (405066, 407632)) # self.assertEqual(gene_to_introns['CHL1'][13], (407798, 419500)) # self.assertEqual(gene_to_introns['CHL1'][14], (419625, 423861)) # self.assertEqual(gene_to_introns['CHL1'][15], (423963, 424156)) # self.assertEqual(gene_to_introns['CHL1'][16], (424354, 425498)) # self.assertEqual(gene_to_introns['CHL1'][17], (425569, 430934)) # self.assertEqual(gene_to_introns['CHL1'][18], (431157, 432383)) # self.assertEqual(gene_to_introns['CHL1'][19], (432499, 432637)) # self.assertEqual(gene_to_introns['CHL1'][20], (432842, 433357)) # self.assertEqual(gene_to_introns['CHL1'][21], (433480, 436375)) # self.assertEqual(gene_to_introns['CHL1'][22], (436555, 439909)) # self.assertEqual(gene_to_introns['CHL1'][23], (440831, 443308)) # self.assertEqual(gene_to_introns['CHL1'][24], (443381, 447177)) def test_get_introns_gtf(self): trans = gtf_parse('tests/inputs/refGene_07.23.2014_CHL1.gtf') introns = get_introns(trans['NM_001253388']) self.assertEqual(len(introns), 24) def test_transcript_union_simple2(self): t1 = Transcript('t1', 'chr', '+', '.', None, 'g1') t1.add_exon((3, 10)) t1.add_exon((15, 20)) t1.add_exon((30, 40)) t2 = Transcript('t2', 'chr', '+', '.', None, 'g1') t2.add_exon((18, 25)) t2.add_exon((30, 40)) tu = transcript_union([t1, t2]).exons self.assertEqual(tu, [(3, 10), (15, 25), (30, 40)]) tu = transcript_union([t2, t1]).exons self.assertEqual(tu, [(3, 10), (15, 25), (30, 40)]) t2.add_exon((45, 50)) tu = transcript_union([t1, t2]).exons self.assertEqual(tu, [(3, 10), (15, 25), (30, 40), (45, 50)]) t3 = Transcript('t3', 'chr', '+', '.', None, 'g1') t3.add_exon((18, 25)) t3.add_exon((30, 40)) tu = transcript_union([t1, t2, t3]).exons self.assertEqual(tu, [(3, 10), (15, 25), (30, 40), (45, 50)]) t3 = Transcript('t3', 'chr', '+', '.', None, 'g1') t3.add_exon((12, 25)) t3.add_exon((30, 40)) tu = transcript_union([t1, t2, t3]).exons self.assertEqual(tu, [(3, 10), (12, 25), (30, 40), (45, 50)]) t3 = Transcript('t3', 'chr', '+', '.', None, 'g1') t3.add_exon((9, 25)) t3.add_exon((30, 40)) tu = transcript_union([t1, t2, t3]).exons self.assertEqual(tu, [(3, 25), (30, 40), (45, 50)]) def test_transcript_union_no_intron(self): t1 = Transcript('t1', 'chr', '+', '.', None, 'g1') t1.add_exon((3, 10)) t1.add_exon((15, 20)) t2 = Transcript('t2', 'chr', '+', '.', None, 'g1') t2.add_exon((10,15)) tu = transcript_union([t1, t2]).exons self.assertEqual(tu, [(3,20)]) def test_transcript_union_internal_exon(self): t1 = Transcript('t1', 'chr', '+', '.', None, 'g1') t1.add_exon((3, 10)) t1.add_exon((15, 20)) t2 = Transcript('t2', 'chr', '+', '.', None, 'g1') t2.add_exon((11,15)) tu = transcript_union([t1, t2]).exons self.assertEqual(tu, [(3,10), (11, 20)]) def test_transcript_union_disjoint(self): t1 = Transcript('t1', 'chr', '+', '.', None, 'g1') t1.add_exon((3, 10)) t1.add_exon((15, 20)) t2 = Transcript('t2', 'chr', '+', '.', None, 'g1') t2.add_exon((25, 30)) t2.add_exon((40, 45)) tu = transcript_union([t1, t2]).exons self.assertEqual(tu, [(3,10), (15, 20), (25, 30), (40, 45)]) def test_transcript_union_gtf(self): trans = gtf_parse('tests/inputs/refGene_07.23.2014_CHL1.gtf') trans = sorted(trans.values(), key = lambda x: x.front_coordinate) gene_to_trans, gene_to_union = \ reduce_to_gene(trans, transcript_union) chl1 = gene_to_union['CHL1'].exons self.assertEqual(chl1[0], (238278, 238746)) self.assertEqual(chl1[1], (239325, 239775)) self.assertEqual(chl1[2], (286295, 286375)) self.assertEqual(chl1[3], (288250, 290282)) self.assertEqual(chl1[4], (361365, 361550)) self.assertEqual(chl1[5], (367641, 367747)) self.assertEqual(chl1[6], (369849, 370037)) self.assertEqual(chl1[7], (382476, 382599)) self.assertEqual(chl1[8], (383594, 383765)) self.assertEqual(chl1[9], (384666, 384714)) self.assertEqual(chl1[10], (386271, 386392)) self.assertEqual(chl1[11], (391041, 391226)) self.assertEqual(chl1[12], (396322, 396454)) self.assertEqual(chl1[13], (401966, 402107)) self.assertEqual(chl1[14], (403381, 403493)) self.assertEqual(chl1[15], (404899, 405066)) self.assertEqual(chl1[16], (407632, 407798)) self.assertEqual(chl1[17], (419500, 419625)) self.assertEqual(chl1[18], (423861, 423963)) self.assertEqual(chl1[19], (424156, 424354)) self.assertEqual(chl1[20], (425498, 425569)) self.assertEqual(chl1[21], (430934, 431157)) self.assertEqual(chl1[22], (432383, 432499)) self.assertEqual(chl1[23], (432637, 432842)) self.assertEqual(chl1[24], (433357, 433480)) self.assertEqual(chl1[25], (436375, 436555)) self.assertEqual(chl1[26], (439909, 440068)) self.assertEqual(chl1[27], (440699, 440831)) self.assertEqual(chl1[28], (443308, 443381)) self.assertEqual(chl1[29], (447177, 451097)) def test_transcript_union_start(self): t1 = Transcript('t1', 'chr', '+', '.', None, 'g1') t1.add_exon((3, 10)) t1.add_exon((20, 25)) t1.add_exon((30, 35)) t2 = Transcript('t2', 'chr', '+', '.', None, 'g1') t2.add_exon((12, 17)) t2.add_exon((20, 25)) tu = transcript_union([t1, t2]).exons self.assertEqual(tu, [(3, 10), (12, 17), (20, 25), (30, 35)]) def test_transcript_union_clk1(self): trans = gtf_parse('tests/inputs/refGene_07.23.2014_CLK1.gtf') trans = sorted(trans.values(), key = lambda x: x.front_coordinate) gene_to_trans, gene_to_union = \ reduce_to_gene(trans, transcript_union) clk1 = gene_to_union['CLK1'].exons self.assertEqual(clk1[8], (201724402, 201726189)) self.assertEqual(clk1[9], (201726424,201726585)) self.assertEqual(clk1[-1], (201729286, 201729467)) self.assertEqual(clk1[-2], (201728823, 201729284)) self.assertEqual(len(clk1), 12) def test_intron_from_string(self): i1_str = "chr1:30-40" i1 = Intron.from_string(i1_str) self.assertEqual(i1[0], 30) self.assertEqual(i1[1], 40) i2 = Intron("chrX", 10, 100, 3, 2) i2_from_str = Intron.from_string(str(i2), 3, 2) self.assertEqual(str(i2), str(i2_from_str)) self.assertEqual(i2.to_string_noext(), i2_from_str.to_string_noext()) class TestTransOps(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_iterate_overlapping_transcripts(self): t1 = Transcript('t1', 'chr', '+', '.', None, 'g1') t1.add_exon((3, 35)) t2 = Transcript('t2', 'chr', '+', '.', None, 'g1') t2.add_exon((12, 17)) t2.add_exon((20, 25)) t3 = Transcript('t3', 'chr', '+', '.', None, 'g1') t3.add_exon((100, 120)) it = get_overlapping_transcripts([t3, t2, t1]) self.assertEqual(it.next(), [t1, t2]) self.assertEqual(it.next(), [t3]) self.assertRaises(StopIteration, it.next) class TestIntronTransCompat(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_intron_trans_compat_simple(self): t1 = Transcript('t1', 'chr1', '+', '.', None, 'g1') t1.add_exon((3, 35)) t1.add_exon((39, 50)) t2 = Transcript('t2', 'chr2', '+', '.', None, 'g1') t2.add_exon((3, 35)) t2.add_exon((39, 50)) i1 = Intron('chr1', 35, 39) compat = intron_trans_compat([i1], [t2, t1]) self.assertEqual(compat, {str(i1) : ['t1']}) def test_intron_trans_compat(self): # TODO: more testing required ! trans = gtf_parse('tests/inputs/refGene_07.23.2014_CHL1.gtf') trans = sorted(trans.values(), key = lambda x: x.front_coordinate) gene_to_trans, gene_to_union = \ reduce_to_gene(trans, transcript_union) introns = get_introns(gene_to_union['CHL1']) i2t = intron_trans_compat(introns, gene_to_trans['CHL1']) self.assertEqual(len(i2t), len(introns)) def test_discard_overlapping_introns_simple(self): g1 = Transcript('g1', 'chr1', '+', '.', None, 'g1') g1.add_exon( (0, 3) ) g1.add_exon( (7, 10) ) g1.add_exon( (12, 35) ) g1.add_exon( (40, 100) ) g2 = Transcript('g2', 'chr1', '+', '.', None, 'g2') g2.add_exon( (0, 4) ) g2.add_exon( (6, 9) ) g2.add_exon( (15, 30) ) g3 = Transcript('g3', 'chr1', '+', '.', None, 'g3') g3.add_exon( (80, 82) ) g3.add_exon( (87, 90) ) trans = [g2, g1, g3] g2i = discard_overlapping_introns(trans) self.assertEqual(g2i['g1'], [Intron('chr1',35, 40)]) self.assertEqual(len(g2i['g2']), 0) self.assertEqual(len(g2i['g3']), 0) g1.exons[3] = (40, 60) g2i = discard_overlapping_introns(trans) self.assertEqual(g2i['g1'], [Intron('chr1', 35, 40)]) self.assertEqual(len(g2i['g2']), 0) self.assertEqual(g2i['g3'], [Intron('chr1', 82, 87)]) # TODO: test with empty introns def test_discard_overlapping_introns_partial_overlap(self): g1 = Transcript('g1', 'chr1', '+', '.', None, 'g1') g1.add_exon( (0, 3) ) g1.add_exon( (7, 10) ) g1.add_exon( (12, 20) ) g2 = Transcript('g2', 'chr1', '+', '.', None, 'g2') g2.add_exon( (70, 72) ) g2.add_exon( (74, 81) ) g2.add_exon( (83, 85) ) g3 = Transcript('g3', 'chr1', '+', '.', None, 'g3') g3.add_exon( (80, 82) ) g3.add_exon( (87, 90) ) trans = [g2, g1, g3] g2i = discard_overlapping_introns(trans) self.assertEqual(g2i['g1'], [Intron('chr1', 3, 7), Intron('chr1', 10, 12)]) self.assertEqual(g2i['g2'], [Intron('chr1', 72, 74)]) self.assertEqual(g2i['g3'], []) def test_discard_overlapping_introns_same_coords_diff_gene(self): g1 = Transcript('g1', 'chr1', '+', '.', None, 'g1') g1.add_exon( (0, 30) ) g1.add_exon( (40, 70) ) g2 = Transcript('g2', 'chr1', '+', '.', None, 'g2') g2.add_exon( (0, 30) ) g2.add_exon( (40, 70) ) trans = [g2, g1] g2i = discard_overlapping_introns(trans) self.assertEqual(g2i['g1'], []) self.assertEqual(g2i['g2'], []) def test_discard_overlapping_introns_gtfird2(self): # In this test there are two genes that have the same exact front and # end coordinates for the gene... gtf_in = 'tests/inputs/GTF2IRD2.gtf' gtf_dict = gtf_parse(gtf_in) gtf_list = gtf_dict.values() # XXX: seems like GTFIRD2B isn't getting added to this overlap... weird g2i = discard_overlapping_introns(gtf_list) self.assertEqual(g2i['GTF2IRD2B'], []) def test_unionize_regions(self): r = [(0, 5), (10, 20)] self.assertEqual( unionize_regions(r), r ) r = [(0, 5), (3, 7), (3, 20)] self.assertEqual( unionize_regions(r), [(0, 20)] ) r = [(0, 5), (3, 7), (10, 20)] self.assertEqual( unionize_regions(r), [(0, 7), (10, 20)] ) r = [(0, 30), (3, 7), (10, 20)] self.assertEqual( unionize_regions(r), [(0, 30)] ) r = [(0, 5), (5, 7)] self.assertEqual( unionize_regions(r), [(0, 7)] ) class TestIntronClass(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_intron(self): int1 = Intron('sup', 3, 7) self.assertEqual(int1[0], 3) self.assertEqual(int1[1], 7) # self.assertRaises(Exception, int1.__getitem__, 2) def test_repr(self): int1 = Intron('hi', 2, 4) self.assertEqual(str(int1), 'hi:2-4') self.assertEqual(int1.to_string_noext(), 'hi:2-4') int1 = Intron('hi', 2, 4, 1, 1) self.assertEqual(str(int1), 'hi:1-5') self.assertEqual(int1.to_string_noext(), 'hi:2-4') def test_extension(self): i1 = Intron('hi', 2, 4, 1, 2) self.assertEqual(i1[0], 1) self.assertEqual(i1[1], 6)
gpl-2.0
[ 3, 31570, 265, 4156, 199, 3, 1898, 334, 35, 9, 6900, 25378, 1753, 510, 9001, 14146, 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, 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, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 2882, 199, 199, 504, 486, 3249, 63, 2087, 492, 627, 199, 504, 31570, 265, 63, 1483, 492, 627, 199, 199, 533, 1379, 3241, 2641, 16452, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 63, 5270, 63, 475, 63, 10654, 8, 277, 304, 267, 486, 3249, 63, 807, 275, 486, 3249, 63, 1122, 2336, 12117, 15, 72, 11538, 15, 14344, 2894, 15, 31053, 15, 19, 10654, 14, 71, 3249, 358, 267, 486, 3249, 63, 513, 275, 3355, 8, 71, 3249, 63, 807, 14, 1459, 1062, 790, 275, 2400, 671, 26, 671, 14, 14708, 63, 20493, 9, 267, 486, 18, 84, 275, 7114, 63, 475, 63, 10654, 8, 71, 3249, 63, 513, 9, 398, 291, 14, 629, 8, 552, 8, 71, 18, 84, 395, 650, 9, 267, 291, 14, 629, 8, 552, 8, 71, 18, 84, 459, 742, 4254, 19983, 1194, 13015, 3815, 499, 9, 267, 291, 14, 629, 8, 552, 8, 71, 18, 84, 459, 742, 4254, 3273, 2277, 10936, 3815, 959, 9, 267, 291, 14, 629, 8, 552, 8, 71, 18, 84, 459, 742, 4254, 993, 11164, 969, 1644, 3815, 413, 9, 398, 486, 18, 84, 12, 15599, 63, 552, 275, 7114, 63, 475, 63, 10654, 8, 71, 3249, 63, 513, 12, 2400, 671, 26, 822, 8, 88, 430, 267, 291, 14, 629, 8, 10654, 63, 552, 459, 742, 4254, 19983, 1194, 13015, 995, 499, 9, 267, 291, 14, 629, 8, 10654, 63, 552, 459, 742, 4254, 3273, 2277, 10936, 995, 959, 9, 267, 291, 14, 629, 8, 10654, 63, 552, 459, 742, 4254, 993, 11164, 969, 1644, 995, 413, 9, 339, 347, 511, 63, 362, 63, 442, 2641, 83, 8, 277, 304, 267, 307, 17, 275, 19894, 1579, 360, 84, 17, 297, 283, 10194, 297, 32278, 22608, 488, 12, 283, 71, 17, 358, 267, 307, 17, 14, 525, 63, 476, 265, 1332, 19, 12, 1616, 430, 267, 307, 17, 14, 525, 63, 476, 265, 1332, 1046, 12, 3388, 430, 398, 31570, 4654, 275, 664, 63, 442, 2641, 83, 8, 84, 17, 9, 267, 291, 14, 629, 8, 822, 8, 442, 2641, 83, 395, 413, 9, 267, 291, 14, 629, 8, 31570, 4654, 59, 16, 467, 9805, 2641, 360, 10194, 297, 1616, 12, 4114, 9, 776, 398, 307, 17, 14, 525, 63, 476, 265, 1332, 2025, 12, 4233, 9, 776, 267, 31570, 4654, 275, 664, 63, 442, 2641, 83, 8, 84, 17, 9, 398, 291, 14, 629, 8, 442, 2641, 83, 12, 359, 3241, 2641, 360, 10194, 297, 1616, 12, 4114, 395, 3521, 9805, 2641, 360, 10194, 297, 3388, 12, 7829, 3948, 339, 327, 7600, 26, 2410, 1021, 9805, 2641, 1990, 21399, 12, 330, 8742, 642, 1396, 440, 4634, 29870, 272, 327, 370, 5325, 703, 272, 327, 347, 511, 63, 442, 2641, 63, 452, 63, 1515, 8, 277, 304, 272, 327, 258, 307, 17, 275, 19894, 1579, 360, 84, 17, 297, 283, 10194, 297, 32278, 22608, 488, 12, 283, 71, 17, 358, 272, 327, 258, 307, 17, 14, 525, 63, 476, 265, 1332, 19, 12, 1616, 430, 272, 327, 258, 307, 17, 14, 525, 63, 476, 265, 1332, 1046, 12, 3388, 430, 339, 327, 258, 307, 18, 275, 19894, 1579, 360, 84, 18, 297, 283, 10194, 297, 32278, 22608, 488, 12, 283, 71, 17, 358, 272, 327, 258, 307, 18, 14, 525, 63, 476, 265, 1332, 19, 12, 1616, 430, 272, 327, 258, 307, 18, 14, 525, 63, 476, 265, 1332, 1046, 12, 3388, 430, 272, 327, 258, 307, 18, 14, 525, 63, 476, 265, 1332, 2025, 12, 4233, 9, 776, 339, 327, 258, 31570, 4654, 275, 31570, 265, 63, 452, 63, 1515, 779, 84, 17, 12, 307, 18, 566, 339, 327, 258, 291, 14, 629, 8, 442, 2641, 83, 12, 359, 3241, 2641, 360, 10194, 297, 1616, 12, 4114, 3948, 339, 327, 258, 291, 14, 629, 8, 442, 2641, 63, 452, 63, 1515, 25550, 3073, 339, 347, 511, 63, 442, 2641, 63, 12569, 8, 277, 304, 267, 284, 17, 275, 334, 19, 12, 1616, 9, 267, 284, 18, 275, 334, 18, 12, 1695, 9, 267, 291, 14, 629, 8, 442, 2641, 63, 12569, 8, 73, 17, 12, 284, 18, 395, 334, 19, 12, 24, 430, 398, 284, 18, 275, 334, 709, 12, 3144, 9, 267, 291, 14, 629, 8, 442, 2641, 63, 12569, 8, 73, 17, 12, 284, 18, 395, 488, 9, 339, 327, 347, 511, 63, 442, 2641, 63, 452, 63, 32367, 63, 3039, 8, 277, 304, 272, 327, 258, 307, 17, 275, 19894, 1579, 360, 84, 17, 297, 283, 10194, 297, 32278, 22608, 488, 12, 283, 71, 17, 358, 272, 327, 258, 307, 17, 14, 525, 63, 476, 265, 1332, 19, 12, 1616, 430, 272, 327, 258, 307, 17, 14, 525, 63, 476, 265, 1332, 1046, 12, 3388, 430, 339, 327, 258, 307, 18, 275, 19894, 1579, 360, 84, 18, 297, 283, 10194, 297, 32278, 22608, 488, 12, 283, 71, 17, 358, 272, 327, 258, 307, 18, 14, 525, 63, 476, 265, 1332, 19, 12, 1616, 430, 272, 327, 258, 307, 18, 14, 525, 63, 476, 265, 1332, 1085, 12, 5661, 430, 339, 327, 258, 31570, 12732 ]
[ 31570, 265, 4156, 199, 3, 1898, 334, 35, 9, 6900, 25378, 1753, 510, 9001, 14146, 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, 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, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 2882, 199, 199, 504, 486, 3249, 63, 2087, 492, 627, 199, 504, 31570, 265, 63, 1483, 492, 627, 199, 199, 533, 1379, 3241, 2641, 16452, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 6766, 8, 277, 304, 267, 986, 339, 347, 511, 63, 5270, 63, 475, 63, 10654, 8, 277, 304, 267, 486, 3249, 63, 807, 275, 486, 3249, 63, 1122, 2336, 12117, 15, 72, 11538, 15, 14344, 2894, 15, 31053, 15, 19, 10654, 14, 71, 3249, 358, 267, 486, 3249, 63, 513, 275, 3355, 8, 71, 3249, 63, 807, 14, 1459, 1062, 790, 275, 2400, 671, 26, 671, 14, 14708, 63, 20493, 9, 267, 486, 18, 84, 275, 7114, 63, 475, 63, 10654, 8, 71, 3249, 63, 513, 9, 398, 291, 14, 629, 8, 552, 8, 71, 18, 84, 395, 650, 9, 267, 291, 14, 629, 8, 552, 8, 71, 18, 84, 459, 742, 4254, 19983, 1194, 13015, 3815, 499, 9, 267, 291, 14, 629, 8, 552, 8, 71, 18, 84, 459, 742, 4254, 3273, 2277, 10936, 3815, 959, 9, 267, 291, 14, 629, 8, 552, 8, 71, 18, 84, 459, 742, 4254, 993, 11164, 969, 1644, 3815, 413, 9, 398, 486, 18, 84, 12, 15599, 63, 552, 275, 7114, 63, 475, 63, 10654, 8, 71, 3249, 63, 513, 12, 2400, 671, 26, 822, 8, 88, 430, 267, 291, 14, 629, 8, 10654, 63, 552, 459, 742, 4254, 19983, 1194, 13015, 995, 499, 9, 267, 291, 14, 629, 8, 10654, 63, 552, 459, 742, 4254, 3273, 2277, 10936, 995, 959, 9, 267, 291, 14, 629, 8, 10654, 63, 552, 459, 742, 4254, 993, 11164, 969, 1644, 995, 413, 9, 339, 347, 511, 63, 362, 63, 442, 2641, 83, 8, 277, 304, 267, 307, 17, 275, 19894, 1579, 360, 84, 17, 297, 283, 10194, 297, 32278, 22608, 488, 12, 283, 71, 17, 358, 267, 307, 17, 14, 525, 63, 476, 265, 1332, 19, 12, 1616, 430, 267, 307, 17, 14, 525, 63, 476, 265, 1332, 1046, 12, 3388, 430, 398, 31570, 4654, 275, 664, 63, 442, 2641, 83, 8, 84, 17, 9, 267, 291, 14, 629, 8, 822, 8, 442, 2641, 83, 395, 413, 9, 267, 291, 14, 629, 8, 31570, 4654, 59, 16, 467, 9805, 2641, 360, 10194, 297, 1616, 12, 4114, 9, 776, 398, 307, 17, 14, 525, 63, 476, 265, 1332, 2025, 12, 4233, 9, 776, 267, 31570, 4654, 275, 664, 63, 442, 2641, 83, 8, 84, 17, 9, 398, 291, 14, 629, 8, 442, 2641, 83, 12, 359, 3241, 2641, 360, 10194, 297, 1616, 12, 4114, 395, 3521, 9805, 2641, 360, 10194, 297, 3388, 12, 7829, 3948, 339, 327, 7600, 26, 2410, 1021, 9805, 2641, 1990, 21399, 12, 330, 8742, 642, 1396, 440, 4634, 29870, 272, 327, 370, 5325, 703, 272, 327, 347, 511, 63, 442, 2641, 63, 452, 63, 1515, 8, 277, 304, 272, 327, 258, 307, 17, 275, 19894, 1579, 360, 84, 17, 297, 283, 10194, 297, 32278, 22608, 488, 12, 283, 71, 17, 358, 272, 327, 258, 307, 17, 14, 525, 63, 476, 265, 1332, 19, 12, 1616, 430, 272, 327, 258, 307, 17, 14, 525, 63, 476, 265, 1332, 1046, 12, 3388, 430, 339, 327, 258, 307, 18, 275, 19894, 1579, 360, 84, 18, 297, 283, 10194, 297, 32278, 22608, 488, 12, 283, 71, 17, 358, 272, 327, 258, 307, 18, 14, 525, 63, 476, 265, 1332, 19, 12, 1616, 430, 272, 327, 258, 307, 18, 14, 525, 63, 476, 265, 1332, 1046, 12, 3388, 430, 272, 327, 258, 307, 18, 14, 525, 63, 476, 265, 1332, 2025, 12, 4233, 9, 776, 339, 327, 258, 31570, 4654, 275, 31570, 265, 63, 452, 63, 1515, 779, 84, 17, 12, 307, 18, 566, 339, 327, 258, 291, 14, 629, 8, 442, 2641, 83, 12, 359, 3241, 2641, 360, 10194, 297, 1616, 12, 4114, 3948, 339, 327, 258, 291, 14, 629, 8, 442, 2641, 63, 452, 63, 1515, 25550, 3073, 339, 347, 511, 63, 442, 2641, 63, 12569, 8, 277, 304, 267, 284, 17, 275, 334, 19, 12, 1616, 9, 267, 284, 18, 275, 334, 18, 12, 1695, 9, 267, 291, 14, 629, 8, 442, 2641, 63, 12569, 8, 73, 17, 12, 284, 18, 395, 334, 19, 12, 24, 430, 398, 284, 18, 275, 334, 709, 12, 3144, 9, 267, 291, 14, 629, 8, 442, 2641, 63, 12569, 8, 73, 17, 12, 284, 18, 395, 488, 9, 339, 327, 347, 511, 63, 442, 2641, 63, 452, 63, 32367, 63, 3039, 8, 277, 304, 272, 327, 258, 307, 17, 275, 19894, 1579, 360, 84, 17, 297, 283, 10194, 297, 32278, 22608, 488, 12, 283, 71, 17, 358, 272, 327, 258, 307, 17, 14, 525, 63, 476, 265, 1332, 19, 12, 1616, 430, 272, 327, 258, 307, 17, 14, 525, 63, 476, 265, 1332, 1046, 12, 3388, 430, 339, 327, 258, 307, 18, 275, 19894, 1579, 360, 84, 18, 297, 283, 10194, 297, 32278, 22608, 488, 12, 283, 71, 17, 358, 272, 327, 258, 307, 18, 14, 525, 63, 476, 265, 1332, 19, 12, 1616, 430, 272, 327, 258, 307, 18, 14, 525, 63, 476, 265, 1332, 1085, 12, 5661, 430, 339, 327, 258, 31570, 12732, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ar7z1/ansible
lib/ansible/modules/cloud/openstack/os_subnets_facts.py
24
4467
#!/usr/bin/python # Copyright (c) 2015 Hewlett-Packard Development Company, L.P. # 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: os_subnets_facts short_description: Retrieve facts about one or more OpenStack subnets. version_added: "2.0" author: "Davide Agnello (@dagnello)" description: - Retrieve facts about one or more subnets from OpenStack. requirements: - "python >= 2.7" - "openstacksdk" options: subnet: description: - Name or ID of the subnet required: false filters: description: - A dictionary of meta data to use for further filtering. Elements of this dictionary may be additional dictionaries. required: false availability_zone: description: - Ignored. Present for backwards compatibility required: false extends_documentation_fragment: openstack ''' EXAMPLES = ''' - name: Gather facts about previously created subnets os_subnets_facts: auth: auth_url: https://identity.example.com username: user password: password project_name: someproject - name: Show openstack subnets debug: var: openstack_subnets - name: Gather facts about a previously created subnet by name os_subnets_facts: auth: auth_url: https://identity.example.com username: user password: password project_name: someproject name: subnet1 - name: Show openstack subnets debug: var: openstack_subnets - name: Gather facts about a previously created subnet with filter # Note: name and filters parameters are not mutually exclusive os_subnets_facts: auth: auth_url: https://identity.example.com username: user password: password project_name: someproject filters: tenant_id: 55e2ce24b2a245b09f181bf025724cbe - name: Show openstack subnets debug: var: openstack_subnets ''' RETURN = ''' openstack_subnets: description: has all the openstack facts about the subnets returned: always, but can be null type: complex contains: id: description: Unique UUID. returned: success type: string name: description: Name given to the subnet. returned: success type: string network_id: description: Network ID this subnet belongs in. returned: success type: string cidr: description: Subnet's CIDR. returned: success type: string gateway_ip: description: Subnet's gateway ip. returned: success type: string enable_dhcp: description: DHCP enable flag for this subnet. returned: success type: bool ip_version: description: IP version for this subnet. returned: success type: int tenant_id: description: Tenant id associated with this subnet. returned: success type: string dns_nameservers: description: DNS name servers for this subnet. returned: success type: list of strings allocation_pools: description: Allocation pools associated with this subnet. returned: success type: list of dicts ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module def main(): argument_spec = openstack_full_argument_spec( name=dict(required=False, default=None), filters=dict(required=False, type='dict', default=None) ) module = AnsibleModule(argument_spec) sdk, cloud = openstack_cloud_from_module(module) try: subnets = cloud.search_subnets(module.params['name'], module.params['filters']) module.exit_json(changed=False, ansible_facts=dict( openstack_subnets=subnets)) except sdk.exceptions.OpenStackCloudException as e: module.fail_json(msg=str(e)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 334, 67, 9, 6900, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 747, 63, 14967, 63, 5047, 199, 3612, 63, 1802, 26, 13939, 9036, 3595, 1373, 503, 1655, 14260, 18709, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 298, 25014, 5624, 437, 784, 3312, 8593, 7406, 2715, 320, 2924, 199, 1802, 26, 272, 446, 13939, 9036, 3595, 1373, 503, 1655, 18709, 687, 14260, 14, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 23, 2, 272, 446, 298, 8512, 9277, 2, 199, 1419, 26, 2043, 6303, 26, 1362, 1369, 26, 267, 446, 2812, 503, 2870, 402, 314, 6303, 1362, 1415, 26, 3055, 2043, 4766, 26, 1362, 1369, 26, 267, 446, 437, 2600, 402, 3404, 666, 370, 675, 367, 9848, 14545, 14, 221, 6566, 83, 402, 881, 642, 2600, 1443, 506, 4722, 11196, 14, 1362, 1415, 26, 3055, 2043, 14962, 63, 2619, 26, 1362, 1369, 26, 2126, 446, 27662, 14, 5543, 1150, 367, 8552, 7163, 1362, 1415, 26, 3055, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 19634, 9036, 3595, 10889, 2737, 18709, 523, 747, 63, 14967, 63, 5047, 26, 272, 1790, 26, 489, 1790, 63, 633, 26, 4178, 921, 5582, 14, 2694, 14, 957, 489, 3434, 26, 922, 489, 2505, 26, 2505, 489, 2199, 63, 354, 26, 2005, 1715, 199, 199, 13, 536, 26, 12968, 13869, 18709, 523, 3105, 26, 272, 2729, 26, 13869, 63, 14967, 199, 199, 13, 536, 26, 19634, 9036, 3595, 282, 10889, 2737, 6303, 701, 536, 523, 747, 63, 14967, 63, 5047, 26, 272, 1790, 26, 489, 1790, 63, 633, 26, 4178, 921, 5582, 14, 2694, 14, 957, 489, 3434, 26, 922, 489, 2505, 26, 2505, 489, 2199, 63, 354, 26, 2005, 1715, 272, 536, 26, 6303, 17, 199, 199, 13, 536, 26, 12968, 13869, 18709, 523, 3105, 26, 272, 2729, 26, 13869, 63, 14967, 199, 199, 13, 536, 26, 19634, 9036, 3595, 282, 10889, 2737, 6303, 543, 2457, 523, 327, 3390, 26, 536, 436, 4766, 2633, 787, 440, 16108, 13914, 523, 747, 63, 14967, 63, 5047, 26, 272, 1790, 26, 489, 1790, 63, 633, 26, 4178, 921, 5582, 14, 2694, 14, 957, 489, 3434, 26, 922, 489, 2505, 26, 2505, 489, 2199, 63, 354, 26, 2005, 1715, 272, 4766, 26, 489, 8261, 63, 344, 26, 12766, 69, 18, 301, 1194, 66, 18, 65, 11677, 66, 1643, 70, 12851, 4361, 16, 11551, 1194, 67, 1235, 199, 199, 13, 536, 26, 12968, 13869, 18709, 523, 3105, 26, 272, 2729, 26, 13869, 63, 14967, 199, 2344, 199, 199, 9677, 275, 1449, 199, 8512, 63, 14967, 26, 272, 1369, 26, 965, 1006, 314, 13869, 9036, 3595, 314, 18709, 272, 2138, 26, 3544, 12, 1325, 883, 506, 2973, 272, 730, 26, 6114, 272, 3509, 26, 267, 1305, 26, 288, 1369, 26, 18276, 11134, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 536, 26, 288, 1369, 26, 2812, 1627, 370, 314, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 2784, 63, 344, 26, 288, 1369, 26, 7220, 2870, 642, 6303, 15006, 315, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 16770, 26, 288, 1369, 26, 4804, 846, 1159, 29215, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 10391, 63, 711, 26, 288, 1369, 26, 4804, 846, 1159, 10391, 3384, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 4756, 63, 10801, 26, 288, 1369, 26, 26821, 4756, 3305, 367, 642, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 2155, 267, 3384, 63, 1023, 26, 288, 1369, 26, 3531, 1015, 367, 642, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 1109, 267, 8261, 63, 344, 26, 288, 1369, 26, 377, 287, 867, 1305, 4568, 543, 642, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 6715, 63, 28620, 26, 288, 1369, 26, 10237, 536, 8037, 367, 642, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 769, 402, 3326, 267, 18723, 63, 12406, 26, 288, 1369, 26, 4580, 1985, 20092, 4568, 543, 642, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 769, 402, 10809, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 8512, 492, 13869, 63, 2861, 63, 2094, 63, 1650, 12, 13869, 63, 578, 63, 958, 12, 13869, 63, 4091, 63, 504, 63, 578, 421, 199, 318, 2446, 837, 339, 1423, 63, 1650, 275, 13869, 63, 2861, 63, 2094, 63, 1650, 8, 267, 536, 29, 807, 8, 2427, 29, 797, 12, 849, 29, 403, 395, 267, 4766, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 807, 297, 849, 29, 403, 9, 272, 776, 272, 859, 275, 6953, 8, 2094, 63, 1650, 9, 339, 13628, 12, 8002, 275, 13869, 63, 4091, 63, 504, 63, 578, 8, 578, 9, 272, 862, 26, 267, 18709, 275, 8002, 14, 1733, 63, 14967, 8, 578, 14, 1162, 459, 354, 995, 4318, 859, 14, 1162, 459, 4273, 1105, 267, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 3242, 63, 5047, 29, 807, 8, 288, 13869, 63, 14967, 29, 14967, 430, 339, 871, 13628, 14, 3924, 14, 26208, 9089, 1726, 465, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 495, 8, 69, 430, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 1898, 334, 67, 9, 6900, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 747, 63, 14967, 63, 5047, 199, 3612, 63, 1802, 26, 13939, 9036, 3595, 1373, 503, 1655, 14260, 18709, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 298, 25014, 5624, 437, 784, 3312, 8593, 7406, 2715, 320, 2924, 199, 1802, 26, 272, 446, 13939, 9036, 3595, 1373, 503, 1655, 18709, 687, 14260, 14, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 23, 2, 272, 446, 298, 8512, 9277, 2, 199, 1419, 26, 2043, 6303, 26, 1362, 1369, 26, 267, 446, 2812, 503, 2870, 402, 314, 6303, 1362, 1415, 26, 3055, 2043, 4766, 26, 1362, 1369, 26, 267, 446, 437, 2600, 402, 3404, 666, 370, 675, 367, 9848, 14545, 14, 221, 6566, 83, 402, 881, 642, 2600, 1443, 506, 4722, 11196, 14, 1362, 1415, 26, 3055, 2043, 14962, 63, 2619, 26, 1362, 1369, 26, 2126, 446, 27662, 14, 5543, 1150, 367, 8552, 7163, 1362, 1415, 26, 3055, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 19634, 9036, 3595, 10889, 2737, 18709, 523, 747, 63, 14967, 63, 5047, 26, 272, 1790, 26, 489, 1790, 63, 633, 26, 4178, 921, 5582, 14, 2694, 14, 957, 489, 3434, 26, 922, 489, 2505, 26, 2505, 489, 2199, 63, 354, 26, 2005, 1715, 199, 199, 13, 536, 26, 12968, 13869, 18709, 523, 3105, 26, 272, 2729, 26, 13869, 63, 14967, 199, 199, 13, 536, 26, 19634, 9036, 3595, 282, 10889, 2737, 6303, 701, 536, 523, 747, 63, 14967, 63, 5047, 26, 272, 1790, 26, 489, 1790, 63, 633, 26, 4178, 921, 5582, 14, 2694, 14, 957, 489, 3434, 26, 922, 489, 2505, 26, 2505, 489, 2199, 63, 354, 26, 2005, 1715, 272, 536, 26, 6303, 17, 199, 199, 13, 536, 26, 12968, 13869, 18709, 523, 3105, 26, 272, 2729, 26, 13869, 63, 14967, 199, 199, 13, 536, 26, 19634, 9036, 3595, 282, 10889, 2737, 6303, 543, 2457, 523, 327, 3390, 26, 536, 436, 4766, 2633, 787, 440, 16108, 13914, 523, 747, 63, 14967, 63, 5047, 26, 272, 1790, 26, 489, 1790, 63, 633, 26, 4178, 921, 5582, 14, 2694, 14, 957, 489, 3434, 26, 922, 489, 2505, 26, 2505, 489, 2199, 63, 354, 26, 2005, 1715, 272, 4766, 26, 489, 8261, 63, 344, 26, 12766, 69, 18, 301, 1194, 66, 18, 65, 11677, 66, 1643, 70, 12851, 4361, 16, 11551, 1194, 67, 1235, 199, 199, 13, 536, 26, 12968, 13869, 18709, 523, 3105, 26, 272, 2729, 26, 13869, 63, 14967, 199, 2344, 199, 199, 9677, 275, 1449, 199, 8512, 63, 14967, 26, 272, 1369, 26, 965, 1006, 314, 13869, 9036, 3595, 314, 18709, 272, 2138, 26, 3544, 12, 1325, 883, 506, 2973, 272, 730, 26, 6114, 272, 3509, 26, 267, 1305, 26, 288, 1369, 26, 18276, 11134, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 536, 26, 288, 1369, 26, 2812, 1627, 370, 314, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 2784, 63, 344, 26, 288, 1369, 26, 7220, 2870, 642, 6303, 15006, 315, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 16770, 26, 288, 1369, 26, 4804, 846, 1159, 29215, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 10391, 63, 711, 26, 288, 1369, 26, 4804, 846, 1159, 10391, 3384, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 4756, 63, 10801, 26, 288, 1369, 26, 26821, 4756, 3305, 367, 642, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 2155, 267, 3384, 63, 1023, 26, 288, 1369, 26, 3531, 1015, 367, 642, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 1109, 267, 8261, 63, 344, 26, 288, 1369, 26, 377, 287, 867, 1305, 4568, 543, 642, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 1059, 267, 6715, 63, 28620, 26, 288, 1369, 26, 10237, 536, 8037, 367, 642, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 769, 402, 3326, 267, 18723, 63, 12406, 26, 288, 1369, 26, 4580, 1985, 20092, 4568, 543, 642, 6303, 14, 288, 2138, 26, 3182, 288, 730, 26, 769, 402, 10809, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 8512, 492, 13869, 63, 2861, 63, 2094, 63, 1650, 12, 13869, 63, 578, 63, 958, 12, 13869, 63, 4091, 63, 504, 63, 578, 421, 199, 318, 2446, 837, 339, 1423, 63, 1650, 275, 13869, 63, 2861, 63, 2094, 63, 1650, 8, 267, 536, 29, 807, 8, 2427, 29, 797, 12, 849, 29, 403, 395, 267, 4766, 29, 807, 8, 2427, 29, 797, 12, 730, 534, 807, 297, 849, 29, 403, 9, 272, 776, 272, 859, 275, 6953, 8, 2094, 63, 1650, 9, 339, 13628, 12, 8002, 275, 13869, 63, 4091, 63, 504, 63, 578, 8, 578, 9, 272, 862, 26, 267, 18709, 275, 8002, 14, 1733, 63, 14967, 8, 578, 14, 1162, 459, 354, 995, 4318, 859, 14, 1162, 459, 4273, 1105, 267, 859, 14, 2224, 63, 1001, 8, 2489, 29, 797, 12, 3242, 63, 5047, 29, 807, 8, 288, 13869, 63, 14967, 29, 14967, 430, 339, 871, 13628, 14, 3924, 14, 26208, 9089, 1726, 465, 325, 26, 267, 859, 14, 1633, 63, 1001, 8, 1328, 29, 495, 8, 69, 430, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
tisnik/fabric8-analytics-common
dashboard/src/jacoco_to_codecov.py
1
4579
"""Module to convert JaCoCo coverage report into the report compatible with Pycov utility.""" import csv def format_coverage_line(text, statements, missed, coverage, missed_lines=False): """Format one line with code coverage report of one class or for a summary.""" format_string = "{:80} {:3d} {:3d} {:3d}%" if missed_lines: format_string += " N/A" return format_string.format(text, statements, missed, coverage) def compute_coverage(statements, covered): """Compute code coverage based on number of all statemts and number of covered statements.""" return 100.0 * covered / statements class JavaClassCoverageReport: """Class representing code coverage report for one Java class.""" def __init__(self, record): """Initialize the object by using record read from the CSV file.""" self.group = record[0] self.package = record[1] self.class_name = record[2] self.missed = int(record[7]) self.covered = int(record[8]) self.statements = self.covered + self.missed self.coverage = compute_coverage(self.statements, self.covered) def __str__(self): """Return readable text representation compatible with Pycov utility output.""" pc = "{package}/{class_name}".format(package=self.package, class_name=self.class_name) return format_coverage_line(pc, self.statements, self.missed, int(self.coverage)) class ProjectCoverageReport: """Class to perform conversion from JaCoCo output to report compatible with Pycov utility.""" def __init__(self, csv_input_file_name): """Initialize the object, store the name of input (CSV) file.""" self.csv_input_file_name = csv_input_file_name @staticmethod def read_csv(csv_input_file_name, skip_first_line=False): """Read the given CSV file, parse it, and return as list of records.""" output = [] with open(csv_input_file_name, 'r') as fin: csv_content = csv.reader(fin, delimiter=',') if skip_first_line: next(csv_content, None) for row in csv_content: output.append(row) return output @staticmethod def write_horizontal_rule(fout): """Write horizontal rule into the output file.""" fout.write("-" * 108) fout.write("\n") @staticmethod def write_coverage_report_header(fout): """Write header compatible with Pycov to the output file.""" fout.write("{:80} {:5} {:4} {:5} {}\n".format( "Name", "Stmts", "Miss", "Cover", "Missing")) ProjectCoverageReport.write_horizontal_rule(fout) @staticmethod def write_coverage_report_summary(fout, statements, missed, coverage): """Write summary compatible with Pycov to the output file.""" ProjectCoverageReport.write_horizontal_rule(fout) fout.write(format_coverage_line("TOTAL", statements, missed, int(coverage))) fout.write("\n") def read_java_classes(self): """Read and parse into about Java classes from JaCoCo results.""" data = ProjectCoverageReport.read_csv(self.csv_input_file_name, True) return [JavaClassCoverageReport(record) for record in data] def convert_code_coverage_report(self, output_file_name): """Convert code coverage report that would be compatible with PyCov output.""" java_classes = self.read_java_classes() statements, missed, coverage = ProjectCoverageReport.compute_total(java_classes) with open(output_file_name, "w") as fout: ProjectCoverageReport.write_coverage_report_header(fout) for java_class in java_classes: fout.write(str(java_class) + "\n") ProjectCoverageReport.write_coverage_report_summary(fout, statements, missed, coverage) @staticmethod def compute_total(records): """Compute total/summary from all Java class coverage reports.""" statements = 0 covered = 0 missed = 0 for record in records: statements += record.statements covered += record.covered missed += record.missed coverage = compute_coverage(statements, covered) return statements, missed, coverage def main(): """Just a test ATM.""" p = ProjectCoverageReport("fabric8-analytics-jenkins-plugin.coverage.csv") p.convert_code_coverage_report("fabric8-analytics-jenkins-plugin.coverage.txt") if __name__ == "__main__": # execute only if run as a script main()
apache-2.0
[ 624, 2377, 370, 3957, 1603, 65, 967, 967, 11745, 3622, 1901, 314, 3622, 9025, 543, 1611, 8695, 11420, 1041, 199, 199, 646, 7392, 421, 199, 318, 1475, 63, 10828, 63, 604, 8, 505, 12, 9834, 12, 3201, 939, 12, 11745, 12, 3201, 939, 63, 1278, 29, 797, 304, 272, 408, 3484, 1373, 1004, 543, 1233, 11745, 3622, 402, 1373, 1021, 503, 367, 282, 6212, 1041, 272, 1475, 63, 875, 275, 5310, 26, 1257, 93, 257, 19850, 19, 68, 93, 221, 19850, 19, 68, 93, 257, 19850, 19, 68, 22109, 2, 272, 340, 3201, 939, 63, 1278, 26, 267, 1475, 63, 875, 847, 298, 257, 653, 15, 33, 2, 272, 372, 1475, 63, 875, 14, 908, 8, 505, 12, 9834, 12, 3201, 939, 12, 11745, 9, 421, 199, 318, 4526, 63, 10828, 8, 15384, 12, 24295, 304, 272, 408, 8564, 1233, 11745, 4079, 641, 1329, 402, 1006, 1174, 22862, 436, 1329, 402, 24295, 9834, 1041, 272, 372, 2948, 14, 16, 627, 24295, 1182, 9834, 421, 199, 533, 9586, 2543, 27444, 7457, 26, 272, 408, 2543, 6144, 1233, 11745, 3622, 367, 1373, 9586, 1021, 1041, 339, 347, 636, 826, 721, 277, 12, 2777, 304, 267, 408, 9345, 314, 909, 701, 1808, 2777, 1586, 687, 314, 14689, 570, 1041, 267, 291, 14, 923, 275, 2777, 59, 16, 61, 267, 291, 14, 2491, 275, 2777, 59, 17, 61, 267, 291, 14, 533, 63, 354, 275, 2777, 59, 18, 61, 267, 291, 14, 1292, 939, 275, 1109, 8, 3059, 59, 23, 566, 267, 291, 14, 13560, 275, 1109, 8, 3059, 59, 24, 566, 267, 291, 14, 15384, 275, 291, 14, 13560, 435, 291, 14, 1292, 939, 267, 291, 14, 10828, 275, 4526, 63, 10828, 8, 277, 14, 15384, 12, 291, 14, 13560, 9, 339, 347, 636, 495, 721, 277, 304, 267, 408, 1767, 12701, 1318, 6025, 9025, 543, 1611, 8695, 11420, 1072, 1041, 267, 13171, 275, 5310, 2491, 16152, 533, 63, 354, 5469, 908, 8, 2491, 29, 277, 14, 2491, 12, 1021, 63, 354, 29, 277, 14, 533, 63, 354, 9, 267, 372, 1475, 63, 10828, 63, 604, 8, 2352, 12, 291, 14, 15384, 12, 291, 14, 1292, 939, 12, 1109, 8, 277, 14, 10828, 430, 421, 199, 533, 7290, 27444, 7457, 26, 272, 408, 2543, 370, 5147, 8603, 687, 1603, 65, 967, 967, 1072, 370, 3622, 9025, 543, 1611, 8695, 11420, 1041, 339, 347, 636, 826, 721, 277, 12, 7392, 63, 1210, 63, 493, 63, 354, 304, 267, 408, 9345, 314, 909, 12, 3877, 314, 536, 402, 1324, 334, 19018, 9, 570, 1041, 267, 291, 14, 4737, 63, 1210, 63, 493, 63, 354, 275, 7392, 63, 1210, 63, 493, 63, 354, 339, 768, 4639, 272, 347, 1586, 63, 4737, 8, 4737, 63, 1210, 63, 493, 63, 354, 12, 3372, 63, 2246, 63, 604, 29, 797, 304, 267, 408, 3284, 314, 1627, 14689, 570, 12, 2198, 652, 12, 436, 372, 465, 769, 402, 5767, 1041, 267, 1072, 275, 942, 267, 543, 1551, 8, 4737, 63, 1210, 63, 493, 63, 354, 12, 283, 82, 358, 465, 2583, 26, 288, 7392, 63, 1317, 275, 7392, 14, 5503, 8, 2408, 12, 11172, 4009, 358, 288, 340, 3372, 63, 2246, 63, 604, 26, 355, 2163, 8, 4737, 63, 1317, 12, 488, 9, 288, 367, 1962, 315, 7392, 63, 1317, 26, 355, 1072, 14, 740, 8, 1143, 9, 267, 372, 1072, 339, 768, 4639, 272, 347, 2218, 63, 11392, 63, 2200, 8, 30762, 304, 267, 408, 3534, 17528, 2332, 1901, 314, 1072, 570, 1041, 267, 17863, 14, 952, 6096, 2, 627, 24579, 9, 267, 17863, 14, 952, 4582, 78, 531, 339, 768, 4639, 272, 347, 2218, 63, 10828, 63, 3070, 63, 1291, 8, 30762, 304, 267, 408, 3534, 1406, 9025, 543, 1611, 8695, 370, 314, 1072, 570, 1041, 267, 17863, 14, 952, 13076, 26, 1257, 93, 19850, 21, 93, 19850, 20, 93, 221, 19850, 21, 93, 257, 22902, 78, 1674, 908, 8, 288, 298, 985, 401, 298, 933, 22862, 401, 298, 5829, 83, 401, 298, 31048, 401, 298, 7718, 2237, 267, 7290, 27444, 7457, 14, 952, 63, 11392, 63, 2200, 8, 30762, 9, 339, 768, 4639, 272, 347, 2218, 63, 10828, 63, 3070, 63, 4705, 8, 30762, 12, 9834, 12, 3201, 939, 12, 11745, 304, 267, 408, 3534, 6212, 9025, 543, 1611, 8695, 370, 314, 1072, 570, 1041, 267, 7290, 27444, 7457, 14, 952, 63, 11392, 63, 2200, 8, 30762, 9, 267, 17863, 14, 952, 8, 908, 63, 10828, 63, 604, 480, 15386, 401, 9834, 12, 3201, 939, 12, 1109, 8, 10828, 1724, 267, 17863, 14, 952, 4582, 78, 531, 339, 347, 1586, 63, 6138, 63, 2888, 8, 277, 304, 267, 408, 3284, 436, 2198, 1901, 3595, 9586, 3992, 687, 1603, 65, 967, 967, 2058, 1041, 267, 666, 275, 7290, 27444, 7457, 14, 739, 63, 4737, 8, 277, 14, 4737, 63, 1210, 63, 493, 63, 354, 12, 715, 9, 267, 372, 359, 12576, 2543, 27444, 7457, 8, 3059, 9, 367, 2777, 315, 666, 61, 339, 347, 3957, 63, 600, 63, 10828, 63, 3070, 8, 277, 12, 1072, 63, 493, 63, 354, 304, 267, 408, 7306, 1233, 11745, 3622, 626, 3955, 506, 9025, 543, 1611, 967, 86, 1072, 1041, 267, 12120, 63, 2888, 275, 291, 14, 739, 63, 6138, 63, 2888, 342, 267, 9834, 12, 3201, 939, 12, 11745, 275, 7290, 27444, 7457, 14, 3357, 63, 2923, 8, 6138, 63, 2888, 9, 267, 543, 1551, 8, 1199, 63, 493, 63, 354, 12, 298, 87, 531, 465, 17863, 26, 288, 7290, 27444, 7457, 14, 952, 63, 10828, 63, 3070, 63, 1291, 8, 30762, 9, 288, 367, 12120, 63, 533, 315, 12120, 63, 2888, 26, 355, 17863, 14, 952, 8, 495, 8, 6138, 63, 533, 9, 435, 1867, 78, 531, 288, 7290, 27444, 7457, 14, 952, 63, 10828, 63, 3070, 63, 4705, 8, 30762, 12, 9834, 12, 3201, 939, 12, 11745, 9, 339, 768, 4639, 272, 347, 4526, 63, 2923, 8, 6502, 304, 267, 408, 8564, 3141, 15, 4705, 687, 1006, 9586, 1021, 11745, 13924, 1041, 267, 9834, 275, 378, 267, 24295, 275, 378, 267, 3201, 939, 275, 378, 267, 367, 2777, 315, 5767, 26, 288, 9834, 847, 2777, 14, 15384, 288, 24295, 847, 2777, 14, 13560, 288, 3201, 939, 847, 2777, 14, 1292, 939, 267, 11745 ]
[ 2377, 370, 3957, 1603, 65, 967, 967, 11745, 3622, 1901, 314, 3622, 9025, 543, 1611, 8695, 11420, 1041, 199, 199, 646, 7392, 421, 199, 318, 1475, 63, 10828, 63, 604, 8, 505, 12, 9834, 12, 3201, 939, 12, 11745, 12, 3201, 939, 63, 1278, 29, 797, 304, 272, 408, 3484, 1373, 1004, 543, 1233, 11745, 3622, 402, 1373, 1021, 503, 367, 282, 6212, 1041, 272, 1475, 63, 875, 275, 5310, 26, 1257, 93, 257, 19850, 19, 68, 93, 221, 19850, 19, 68, 93, 257, 19850, 19, 68, 22109, 2, 272, 340, 3201, 939, 63, 1278, 26, 267, 1475, 63, 875, 847, 298, 257, 653, 15, 33, 2, 272, 372, 1475, 63, 875, 14, 908, 8, 505, 12, 9834, 12, 3201, 939, 12, 11745, 9, 421, 199, 318, 4526, 63, 10828, 8, 15384, 12, 24295, 304, 272, 408, 8564, 1233, 11745, 4079, 641, 1329, 402, 1006, 1174, 22862, 436, 1329, 402, 24295, 9834, 1041, 272, 372, 2948, 14, 16, 627, 24295, 1182, 9834, 421, 199, 533, 9586, 2543, 27444, 7457, 26, 272, 408, 2543, 6144, 1233, 11745, 3622, 367, 1373, 9586, 1021, 1041, 339, 347, 636, 826, 721, 277, 12, 2777, 304, 267, 408, 9345, 314, 909, 701, 1808, 2777, 1586, 687, 314, 14689, 570, 1041, 267, 291, 14, 923, 275, 2777, 59, 16, 61, 267, 291, 14, 2491, 275, 2777, 59, 17, 61, 267, 291, 14, 533, 63, 354, 275, 2777, 59, 18, 61, 267, 291, 14, 1292, 939, 275, 1109, 8, 3059, 59, 23, 566, 267, 291, 14, 13560, 275, 1109, 8, 3059, 59, 24, 566, 267, 291, 14, 15384, 275, 291, 14, 13560, 435, 291, 14, 1292, 939, 267, 291, 14, 10828, 275, 4526, 63, 10828, 8, 277, 14, 15384, 12, 291, 14, 13560, 9, 339, 347, 636, 495, 721, 277, 304, 267, 408, 1767, 12701, 1318, 6025, 9025, 543, 1611, 8695, 11420, 1072, 1041, 267, 13171, 275, 5310, 2491, 16152, 533, 63, 354, 5469, 908, 8, 2491, 29, 277, 14, 2491, 12, 1021, 63, 354, 29, 277, 14, 533, 63, 354, 9, 267, 372, 1475, 63, 10828, 63, 604, 8, 2352, 12, 291, 14, 15384, 12, 291, 14, 1292, 939, 12, 1109, 8, 277, 14, 10828, 430, 421, 199, 533, 7290, 27444, 7457, 26, 272, 408, 2543, 370, 5147, 8603, 687, 1603, 65, 967, 967, 1072, 370, 3622, 9025, 543, 1611, 8695, 11420, 1041, 339, 347, 636, 826, 721, 277, 12, 7392, 63, 1210, 63, 493, 63, 354, 304, 267, 408, 9345, 314, 909, 12, 3877, 314, 536, 402, 1324, 334, 19018, 9, 570, 1041, 267, 291, 14, 4737, 63, 1210, 63, 493, 63, 354, 275, 7392, 63, 1210, 63, 493, 63, 354, 339, 768, 4639, 272, 347, 1586, 63, 4737, 8, 4737, 63, 1210, 63, 493, 63, 354, 12, 3372, 63, 2246, 63, 604, 29, 797, 304, 267, 408, 3284, 314, 1627, 14689, 570, 12, 2198, 652, 12, 436, 372, 465, 769, 402, 5767, 1041, 267, 1072, 275, 942, 267, 543, 1551, 8, 4737, 63, 1210, 63, 493, 63, 354, 12, 283, 82, 358, 465, 2583, 26, 288, 7392, 63, 1317, 275, 7392, 14, 5503, 8, 2408, 12, 11172, 4009, 358, 288, 340, 3372, 63, 2246, 63, 604, 26, 355, 2163, 8, 4737, 63, 1317, 12, 488, 9, 288, 367, 1962, 315, 7392, 63, 1317, 26, 355, 1072, 14, 740, 8, 1143, 9, 267, 372, 1072, 339, 768, 4639, 272, 347, 2218, 63, 11392, 63, 2200, 8, 30762, 304, 267, 408, 3534, 17528, 2332, 1901, 314, 1072, 570, 1041, 267, 17863, 14, 952, 6096, 2, 627, 24579, 9, 267, 17863, 14, 952, 4582, 78, 531, 339, 768, 4639, 272, 347, 2218, 63, 10828, 63, 3070, 63, 1291, 8, 30762, 304, 267, 408, 3534, 1406, 9025, 543, 1611, 8695, 370, 314, 1072, 570, 1041, 267, 17863, 14, 952, 13076, 26, 1257, 93, 19850, 21, 93, 19850, 20, 93, 221, 19850, 21, 93, 257, 22902, 78, 1674, 908, 8, 288, 298, 985, 401, 298, 933, 22862, 401, 298, 5829, 83, 401, 298, 31048, 401, 298, 7718, 2237, 267, 7290, 27444, 7457, 14, 952, 63, 11392, 63, 2200, 8, 30762, 9, 339, 768, 4639, 272, 347, 2218, 63, 10828, 63, 3070, 63, 4705, 8, 30762, 12, 9834, 12, 3201, 939, 12, 11745, 304, 267, 408, 3534, 6212, 9025, 543, 1611, 8695, 370, 314, 1072, 570, 1041, 267, 7290, 27444, 7457, 14, 952, 63, 11392, 63, 2200, 8, 30762, 9, 267, 17863, 14, 952, 8, 908, 63, 10828, 63, 604, 480, 15386, 401, 9834, 12, 3201, 939, 12, 1109, 8, 10828, 1724, 267, 17863, 14, 952, 4582, 78, 531, 339, 347, 1586, 63, 6138, 63, 2888, 8, 277, 304, 267, 408, 3284, 436, 2198, 1901, 3595, 9586, 3992, 687, 1603, 65, 967, 967, 2058, 1041, 267, 666, 275, 7290, 27444, 7457, 14, 739, 63, 4737, 8, 277, 14, 4737, 63, 1210, 63, 493, 63, 354, 12, 715, 9, 267, 372, 359, 12576, 2543, 27444, 7457, 8, 3059, 9, 367, 2777, 315, 666, 61, 339, 347, 3957, 63, 600, 63, 10828, 63, 3070, 8, 277, 12, 1072, 63, 493, 63, 354, 304, 267, 408, 7306, 1233, 11745, 3622, 626, 3955, 506, 9025, 543, 1611, 967, 86, 1072, 1041, 267, 12120, 63, 2888, 275, 291, 14, 739, 63, 6138, 63, 2888, 342, 267, 9834, 12, 3201, 939, 12, 11745, 275, 7290, 27444, 7457, 14, 3357, 63, 2923, 8, 6138, 63, 2888, 9, 267, 543, 1551, 8, 1199, 63, 493, 63, 354, 12, 298, 87, 531, 465, 17863, 26, 288, 7290, 27444, 7457, 14, 952, 63, 10828, 63, 3070, 63, 1291, 8, 30762, 9, 288, 367, 12120, 63, 533, 315, 12120, 63, 2888, 26, 355, 17863, 14, 952, 8, 495, 8, 6138, 63, 533, 9, 435, 1867, 78, 531, 288, 7290, 27444, 7457, 14, 952, 63, 10828, 63, 3070, 63, 4705, 8, 30762, 12, 9834, 12, 3201, 939, 12, 11745, 9, 339, 768, 4639, 272, 347, 4526, 63, 2923, 8, 6502, 304, 267, 408, 8564, 3141, 15, 4705, 687, 1006, 9586, 1021, 11745, 13924, 1041, 267, 9834, 275, 378, 267, 24295, 275, 378, 267, 3201, 939, 275, 378, 267, 367, 2777, 315, 5767, 26, 288, 9834, 847, 2777, 14, 15384, 288, 24295, 847, 2777, 14, 13560, 288, 3201, 939, 847, 2777, 14, 1292, 939, 267, 11745, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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__ import unicode_literals import os import sys from os.path import abspath, dirname, join as pjoin import django from django.conf import settings def runtests(verbosity=1, interactive=True, failfast=True, settings_module='settings.default'): here = abspath(dirname(__file__)) root = pjoin(here, os.pardir) sys.path[0:0] = [here, root, pjoin(root, 'sorl')] os.environ['DJANGO_SETTINGS_MODULE'] = settings_module if django.VERSION >= (1, 7): django.setup() from django.test.utils import get_runner sys.stdout.write("Running tests for '%s' \n" % settings_module) TestRunner = get_runner(settings) test_runner = TestRunner( verbosity=verbosity, interactive=interactive, failfast=failfast ) return test_runner.run_tests(settings.INSTALLED_APPS) if __name__ == '__main__': import argparse parser = argparse.ArgumentParser( description='Runs the test suite for sorl-thumbnail.' ) parser.add_argument( '--settings', dest='settings_module', action='store', default='settings.default', help='Specify settings module.') parser.add_argument( '--noinput', dest='interactive', action='store_false', default=True, help='Do not prompt the user for input of any kind.') parser.add_argument( '--failfast', dest='failfast', action='store_true', default=False, help='Stop running the test suite after first failed test.') args = parser.parse_args() failures = runtests( verbosity=2, interactive=args.interactive, failfast=args.failfast, settings_module=args.settings_module ) if failures: sys.exit(bool(failures))
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 747, 199, 646, 984, 199, 504, 747, 14, 515, 492, 19529, 12, 9017, 12, 4263, 465, 299, 904, 199, 199, 646, 1639, 199, 504, 1639, 14, 2190, 492, 2202, 421, 199, 318, 1255, 2219, 8, 9833, 29, 17, 12, 12777, 29, 549, 12, 1433, 20803, 29, 549, 12, 2202, 63, 578, 534, 1751, 14, 885, 735, 272, 2348, 275, 19529, 8, 3475, 3460, 493, 8964, 272, 1738, 275, 299, 904, 8, 1681, 12, 747, 14, 21386, 9, 339, 984, 14, 515, 59, 16, 26, 16, 61, 275, 359, 1681, 12, 1738, 12, 299, 904, 8, 1231, 12, 283, 1509, 76, 5440, 272, 747, 14, 2314, 459, 22848, 63, 13931, 63, 10001, 418, 275, 2202, 63, 578, 339, 340, 1639, 14, 4612, 2356, 334, 17, 12, 1520, 304, 267, 1639, 14, 2758, 342, 339, 687, 1639, 14, 396, 14, 1208, 492, 664, 63, 5933, 339, 984, 14, 2703, 14, 952, 480, 9602, 2295, 367, 1543, 83, 7, 971, 78, 2, 450, 2202, 63, 578, 9, 339, 1379, 7446, 275, 664, 63, 5933, 8, 1751, 9, 339, 511, 63, 5933, 275, 1379, 7446, 8, 267, 8661, 29, 9833, 12, 267, 12777, 29, 13543, 12, 267, 1433, 20803, 29, 25829, 272, 776, 339, 372, 511, 63, 5933, 14, 1065, 63, 2219, 8, 1751, 14, 15942, 63, 14219, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 7534, 339, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 534, 16291, 314, 511, 5241, 367, 308, 269, 76, 13, 8311, 3530, 272, 776, 339, 1798, 14, 525, 63, 2094, 8, 267, 2850, 1751, 297, 267, 2053, 534, 1751, 63, 578, 297, 267, 1595, 534, 1617, 297, 267, 849, 534, 1751, 14, 885, 297, 267, 1720, 534, 17768, 2202, 859, 2659, 339, 1798, 14, 525, 63, 2094, 8, 267, 2850, 889, 1210, 297, 267, 2053, 534, 13543, 297, 267, 1595, 534, 1617, 63, 3910, 297, 267, 849, 29, 549, 12, 267, 1720, 534, 2585, 440, 8457, 314, 922, 367, 1324, 402, 1263, 4928, 2659, 339, 1798, 14, 525, 63, 2094, 8, 267, 2850, 25829, 297, 267, 2053, 534, 25829, 297, 267, 1595, 534, 1617, 63, 2052, 297, 267, 849, 29, 797, 12, 267, 1720, 534, 6293, 3879, 314, 511, 5241, 2410, 1642, 3405, 511, 2659, 339, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 9081, 275, 1255, 2219, 8, 267, 8661, 29, 18, 12, 267, 12777, 29, 589, 14, 13543, 12, 267, 1433, 20803, 29, 589, 14, 25829, 12, 267, 2202, 63, 578, 29, 589, 14, 1751, 63, 578, 272, 776, 339, 340, 9081, 26, 267, 984, 14, 2224, 8, 2245, 8, 9968, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 747, 199, 646, 984, 199, 504, 747, 14, 515, 492, 19529, 12, 9017, 12, 4263, 465, 299, 904, 199, 199, 646, 1639, 199, 504, 1639, 14, 2190, 492, 2202, 421, 199, 318, 1255, 2219, 8, 9833, 29, 17, 12, 12777, 29, 549, 12, 1433, 20803, 29, 549, 12, 2202, 63, 578, 534, 1751, 14, 885, 735, 272, 2348, 275, 19529, 8, 3475, 3460, 493, 8964, 272, 1738, 275, 299, 904, 8, 1681, 12, 747, 14, 21386, 9, 339, 984, 14, 515, 59, 16, 26, 16, 61, 275, 359, 1681, 12, 1738, 12, 299, 904, 8, 1231, 12, 283, 1509, 76, 5440, 272, 747, 14, 2314, 459, 22848, 63, 13931, 63, 10001, 418, 275, 2202, 63, 578, 339, 340, 1639, 14, 4612, 2356, 334, 17, 12, 1520, 304, 267, 1639, 14, 2758, 342, 339, 687, 1639, 14, 396, 14, 1208, 492, 664, 63, 5933, 339, 984, 14, 2703, 14, 952, 480, 9602, 2295, 367, 1543, 83, 7, 971, 78, 2, 450, 2202, 63, 578, 9, 339, 1379, 7446, 275, 664, 63, 5933, 8, 1751, 9, 339, 511, 63, 5933, 275, 1379, 7446, 8, 267, 8661, 29, 9833, 12, 267, 12777, 29, 13543, 12, 267, 1433, 20803, 29, 25829, 272, 776, 339, 372, 511, 63, 5933, 14, 1065, 63, 2219, 8, 1751, 14, 15942, 63, 14219, 9, 421, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 7534, 339, 1798, 275, 7534, 14, 10730, 8, 267, 1369, 534, 16291, 314, 511, 5241, 367, 308, 269, 76, 13, 8311, 3530, 272, 776, 339, 1798, 14, 525, 63, 2094, 8, 267, 2850, 1751, 297, 267, 2053, 534, 1751, 63, 578, 297, 267, 1595, 534, 1617, 297, 267, 849, 534, 1751, 14, 885, 297, 267, 1720, 534, 17768, 2202, 859, 2659, 339, 1798, 14, 525, 63, 2094, 8, 267, 2850, 889, 1210, 297, 267, 2053, 534, 13543, 297, 267, 1595, 534, 1617, 63, 3910, 297, 267, 849, 29, 549, 12, 267, 1720, 534, 2585, 440, 8457, 314, 922, 367, 1324, 402, 1263, 4928, 2659, 339, 1798, 14, 525, 63, 2094, 8, 267, 2850, 25829, 297, 267, 2053, 534, 25829, 297, 267, 1595, 534, 1617, 63, 2052, 297, 267, 849, 29, 797, 12, 267, 1720, 534, 6293, 3879, 314, 511, 5241, 2410, 1642, 3405, 511, 2659, 339, 1249, 275, 1798, 14, 1122, 63, 589, 342, 339, 9081, 275, 1255, 2219, 8, 267, 8661, 29, 18, 12, 267, 12777, 29, 589, 14, 13543, 12, 267, 1433, 20803, 29, 589, 14, 25829, 12, 267, 2202, 63, 578, 29, 589, 14, 1751, 63, 578, 272, 776, 339, 340, 9081, 26, 267, 984, 14, 2224, 8, 2245, 8, 9968, 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, 0 ]
[ 1, 1, 1, 1, 1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osswalk
build/android/pylib/instrumentation/instrumentation_parser_test.py
79
4061
#!/usr/bin/env python # Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Unit tests for instrumentation.InstrumentationParser.""" import unittest from pylib.instrumentation import instrumentation_parser class InstrumentationParserTest(unittest.TestCase): def testInstrumentationParser_nothing(self): parser = instrumentation_parser.InstrumentationParser(['']) statuses = list(parser.IterStatus()) code, bundle = parser.GetResult() self.assertEqual(None, code) self.assertEqual({}, bundle) self.assertEqual([], statuses) def testInstrumentationParser_noMatchingStarts(self): raw_output = [ '', 'this.is.a.test.package.TestClass:.', 'Test result for =.', 'Time: 1.234', '', 'OK (1 test)', ] parser = instrumentation_parser.InstrumentationParser(raw_output) statuses = list(parser.IterStatus()) code, bundle = parser.GetResult() self.assertEqual(None, code) self.assertEqual({}, bundle) self.assertEqual([], statuses) def testInstrumentationParser_resultAndCode(self): raw_output = [ 'INSTRUMENTATION_RESULT: shortMsg=foo bar', 'INSTRUMENTATION_RESULT: longMsg=a foo', 'walked into', 'a bar', 'INSTRUMENTATION_CODE: -1', ] parser = instrumentation_parser.InstrumentationParser(raw_output) statuses = list(parser.IterStatus()) code, bundle = parser.GetResult() self.assertEqual(-1, code) self.assertEqual( {'shortMsg': 'foo bar', 'longMsg': 'a foo\nwalked into\na bar'}, bundle) self.assertEqual([], statuses) def testInstrumentationParser_oneStatus(self): raw_output = [ 'INSTRUMENTATION_STATUS: foo=1', 'INSTRUMENTATION_STATUS: bar=hello', 'INSTRUMENTATION_STATUS: world=false', 'INSTRUMENTATION_STATUS: class=this.is.a.test.package.TestClass', 'INSTRUMENTATION_STATUS: test=testMethod', 'INSTRUMENTATION_STATUS_CODE: 0', ] parser = instrumentation_parser.InstrumentationParser(raw_output) statuses = list(parser.IterStatus()) expected = [ (0, { 'foo': '1', 'bar': 'hello', 'world': 'false', 'class': 'this.is.a.test.package.TestClass', 'test': 'testMethod', }) ] self.assertEqual(expected, statuses) def testInstrumentationParser_multiStatus(self): raw_output = [ 'INSTRUMENTATION_STATUS: class=foo', 'INSTRUMENTATION_STATUS: test=bar', 'INSTRUMENTATION_STATUS_CODE: 1', 'INSTRUMENTATION_STATUS: test_skipped=true', 'INSTRUMENTATION_STATUS_CODE: 0', 'INSTRUMENTATION_STATUS: class=hello', 'INSTRUMENTATION_STATUS: test=world', 'INSTRUMENTATION_STATUS: stack=', 'foo/bar.py (27)', 'hello/world.py (42)', 'test/file.py (1)', 'INSTRUMENTATION_STATUS_CODE: -1', ] parser = instrumentation_parser.InstrumentationParser(raw_output) statuses = list(parser.IterStatus()) expected = [ (1, {'class': 'foo', 'test': 'bar',}), (0, {'test_skipped': 'true'}), (-1, { 'class': 'hello', 'test': 'world', 'stack': '\nfoo/bar.py (27)\nhello/world.py (42)\ntest/file.py (1)', }), ] self.assertEqual(expected, statuses) def testInstrumentationParser_statusResultAndCode(self): raw_output = [ 'INSTRUMENTATION_STATUS: class=foo', 'INSTRUMENTATION_STATUS: test=bar', 'INSTRUMENTATION_STATUS_CODE: 1', 'INSTRUMENTATION_RESULT: result=hello', 'world', '', '', 'INSTRUMENTATION_CODE: 0', ] parser = instrumentation_parser.InstrumentationParser(raw_output) statuses = list(parser.IterStatus()) code, bundle = parser.GetResult() self.assertEqual(0, code) self.assertEqual({'result': 'hello\nworld\n\n'}, bundle) self.assertEqual([(1, {'class': 'foo', 'test': 'bar'})], statuses) if __name__ == '__main__': unittest.main(verbosity=2)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6900, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 421, 199, 624, 5072, 2295, 367, 14498, 425, 14, 14915, 425, 2842, 1041, 199, 199, 646, 2882, 199, 199, 504, 29219, 14, 13321, 425, 492, 14498, 425, 63, 2087, 421, 199, 533, 25767, 425, 2842, 774, 8, 2796, 14, 1746, 304, 819, 347, 511, 14915, 425, 2842, 63, 16323, 8, 277, 304, 272, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 2941, 1105, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 272, 1233, 12, 8844, 275, 1798, 14, 1002, 2889, 342, 272, 291, 14, 629, 8, 403, 12, 1233, 9, 272, 291, 14, 629, 16037, 8844, 9, 272, 291, 14, 629, 8798, 24498, 9, 819, 347, 511, 14915, 425, 2842, 63, 889, 14215, 32142, 8, 277, 304, 272, 3066, 63, 1199, 275, 359, 489, 3260, 489, 283, 3749, 14, 374, 14, 65, 14, 396, 14, 2491, 14, 22009, 26, 3130, 489, 283, 774, 754, 367, 275, 3130, 489, 283, 1366, 26, 413, 14, 5533, 297, 489, 3260, 489, 283, 3593, 334, 17, 511, 3196, 272, 1622, 339, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 8, 1773, 63, 1199, 9, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 272, 1233, 12, 8844, 275, 1798, 14, 1002, 2889, 342, 272, 291, 14, 629, 8, 403, 12, 1233, 9, 272, 291, 14, 629, 16037, 8844, 9, 272, 291, 14, 629, 8798, 24498, 9, 819, 347, 511, 14915, 425, 2842, 63, 1099, 3325, 3034, 8, 277, 304, 272, 3066, 63, 1199, 275, 359, 489, 283, 26347, 18272, 2594, 63, 9517, 26, 3974, 6173, 29, 1421, 4681, 297, 489, 283, 26347, 18272, 2594, 63, 9517, 26, 1846, 6173, 29, 65, 3925, 297, 489, 283, 7757, 379, 1901, 297, 489, 283, 65, 4681, 297, 489, 283, 26347, 18272, 2594, 63, 6012, 26, 446, 17, 297, 272, 1622, 339, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 8, 1773, 63, 1199, 9, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 272, 1233, 12, 8844, 275, 1798, 14, 1002, 2889, 342, 272, 291, 14, 629, 2801, 17, 12, 1233, 9, 272, 291, 14, 629, 8, 267, 791, 3612, 6173, 356, 283, 1421, 4681, 297, 283, 2809, 6173, 356, 283, 65, 3925, 60, 78, 7757, 379, 1901, 60, 3540, 4681, 2267, 8844, 9, 272, 291, 14, 629, 8798, 24498, 9, 819, 347, 511, 14915, 425, 2842, 63, 368, 3694, 8, 277, 304, 272, 3066, 63, 1199, 275, 359, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 3925, 29, 17, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 4681, 29, 5006, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 6701, 29, 3910, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 1021, 29, 3749, 14, 374, 14, 65, 14, 396, 14, 2491, 14, 22009, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 511, 29, 25008, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 63, 6012, 26, 378, 297, 272, 1622, 339, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 8, 1773, 63, 1199, 9, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 339, 1420, 275, 359, 489, 334, 16, 12, 469, 267, 283, 1421, 356, 283, 17, 297, 267, 283, 1700, 356, 283, 5006, 297, 267, 283, 7617, 356, 283, 3910, 297, 267, 283, 533, 356, 283, 3749, 14, 374, 14, 65, 14, 396, 14, 2491, 14, 22009, 297, 267, 283, 396, 356, 283, 25008, 297, 489, 3828, 272, 1622, 272, 291, 14, 629, 8, 2062, 12, 24498, 9, 819, 347, 511, 14915, 425, 2842, 63, 3029, 3694, 8, 277, 304, 272, 3066, 63, 1199, 275, 359, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 1021, 29, 1421, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 511, 29, 1700, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 63, 6012, 26, 413, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 511, 63, 11962, 29, 2052, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 63, 6012, 26, 378, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 1021, 29, 5006, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 511, 29, 7617, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 3464, 4009, 489, 283, 1421, 15, 1700, 14, 647, 334, 1465, 3196, 489, 283, 5006, 15, 7617, 14, 647, 334, 2260, 3196, 489, 283, 396, 15, 493, 14, 647, 334, 17, 3196, 489, 283, 26347, 18272, 2594, 63, 6305, 63, 6012, 26, 446, 17, 297, 272, 1622, 339, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 8, 1773, 63, 1199, 9, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 339, 1420, 275, 359, 489, 334, 17, 12, 791, 533, 356, 283, 1421, 297, 283, 396, 356, 283, 1700, 297, 8688, 489, 334, 16, 12, 791, 396, 63, 11962, 356, 283, 2052, 1604, 489, 5868, 17, 12, 469, 267, 283, 533, 356, 283, 5006, 297, 267, 283, 396, 356, 283, 7617, 297, 267, 283, 2340, 356, 1557, 78, 1421, 15, 1700, 14, 647, 334, 1465, 2862, 78, 5006, 15, 7617, 14, 647, 334, 2260, 2862, 78, 396, 15, 493, 14, 647, 334, 17, 3196, 489, 9998, 272, 1622, 272, 291, 14, 629, 8, 2062, 12, 24498, 9, 819, 347, 511, 14915, 425, 2842, 63, 1205, 2889, 3325, 3034, 8, 277, 304, 272, 3066, 63, 1199, 275, 359, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 1021, 29, 1421, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 511, 29, 1700, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 63, 6012, 26, 413, 297, 489, 283, 26347, 18272, 2594, 63, 9517, 26, 754, 29, 5006, 297, 489, 283, 7617, 297, 489, 3260, 489, 3260, 489, 283, 26347, 18272, 2594, 63, 6012, 26, 378, 297, 272, 1622, 339, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 8, 1773, 63, 1199, 9, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 272, 1233, 12, 8844 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 6900, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 421, 199, 624, 5072, 2295, 367, 14498, 425, 14, 14915, 425, 2842, 1041, 199, 199, 646, 2882, 199, 199, 504, 29219, 14, 13321, 425, 492, 14498, 425, 63, 2087, 421, 199, 533, 25767, 425, 2842, 774, 8, 2796, 14, 1746, 304, 819, 347, 511, 14915, 425, 2842, 63, 16323, 8, 277, 304, 272, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 2941, 1105, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 272, 1233, 12, 8844, 275, 1798, 14, 1002, 2889, 342, 272, 291, 14, 629, 8, 403, 12, 1233, 9, 272, 291, 14, 629, 16037, 8844, 9, 272, 291, 14, 629, 8798, 24498, 9, 819, 347, 511, 14915, 425, 2842, 63, 889, 14215, 32142, 8, 277, 304, 272, 3066, 63, 1199, 275, 359, 489, 3260, 489, 283, 3749, 14, 374, 14, 65, 14, 396, 14, 2491, 14, 22009, 26, 3130, 489, 283, 774, 754, 367, 275, 3130, 489, 283, 1366, 26, 413, 14, 5533, 297, 489, 3260, 489, 283, 3593, 334, 17, 511, 3196, 272, 1622, 339, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 8, 1773, 63, 1199, 9, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 272, 1233, 12, 8844, 275, 1798, 14, 1002, 2889, 342, 272, 291, 14, 629, 8, 403, 12, 1233, 9, 272, 291, 14, 629, 16037, 8844, 9, 272, 291, 14, 629, 8798, 24498, 9, 819, 347, 511, 14915, 425, 2842, 63, 1099, 3325, 3034, 8, 277, 304, 272, 3066, 63, 1199, 275, 359, 489, 283, 26347, 18272, 2594, 63, 9517, 26, 3974, 6173, 29, 1421, 4681, 297, 489, 283, 26347, 18272, 2594, 63, 9517, 26, 1846, 6173, 29, 65, 3925, 297, 489, 283, 7757, 379, 1901, 297, 489, 283, 65, 4681, 297, 489, 283, 26347, 18272, 2594, 63, 6012, 26, 446, 17, 297, 272, 1622, 339, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 8, 1773, 63, 1199, 9, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 272, 1233, 12, 8844, 275, 1798, 14, 1002, 2889, 342, 272, 291, 14, 629, 2801, 17, 12, 1233, 9, 272, 291, 14, 629, 8, 267, 791, 3612, 6173, 356, 283, 1421, 4681, 297, 283, 2809, 6173, 356, 283, 65, 3925, 60, 78, 7757, 379, 1901, 60, 3540, 4681, 2267, 8844, 9, 272, 291, 14, 629, 8798, 24498, 9, 819, 347, 511, 14915, 425, 2842, 63, 368, 3694, 8, 277, 304, 272, 3066, 63, 1199, 275, 359, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 3925, 29, 17, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 4681, 29, 5006, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 6701, 29, 3910, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 1021, 29, 3749, 14, 374, 14, 65, 14, 396, 14, 2491, 14, 22009, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 511, 29, 25008, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 63, 6012, 26, 378, 297, 272, 1622, 339, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 8, 1773, 63, 1199, 9, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 339, 1420, 275, 359, 489, 334, 16, 12, 469, 267, 283, 1421, 356, 283, 17, 297, 267, 283, 1700, 356, 283, 5006, 297, 267, 283, 7617, 356, 283, 3910, 297, 267, 283, 533, 356, 283, 3749, 14, 374, 14, 65, 14, 396, 14, 2491, 14, 22009, 297, 267, 283, 396, 356, 283, 25008, 297, 489, 3828, 272, 1622, 272, 291, 14, 629, 8, 2062, 12, 24498, 9, 819, 347, 511, 14915, 425, 2842, 63, 3029, 3694, 8, 277, 304, 272, 3066, 63, 1199, 275, 359, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 1021, 29, 1421, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 511, 29, 1700, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 63, 6012, 26, 413, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 511, 63, 11962, 29, 2052, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 63, 6012, 26, 378, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 1021, 29, 5006, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 511, 29, 7617, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 3464, 4009, 489, 283, 1421, 15, 1700, 14, 647, 334, 1465, 3196, 489, 283, 5006, 15, 7617, 14, 647, 334, 2260, 3196, 489, 283, 396, 15, 493, 14, 647, 334, 17, 3196, 489, 283, 26347, 18272, 2594, 63, 6305, 63, 6012, 26, 446, 17, 297, 272, 1622, 339, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 8, 1773, 63, 1199, 9, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 339, 1420, 275, 359, 489, 334, 17, 12, 791, 533, 356, 283, 1421, 297, 283, 396, 356, 283, 1700, 297, 8688, 489, 334, 16, 12, 791, 396, 63, 11962, 356, 283, 2052, 1604, 489, 5868, 17, 12, 469, 267, 283, 533, 356, 283, 5006, 297, 267, 283, 396, 356, 283, 7617, 297, 267, 283, 2340, 356, 1557, 78, 1421, 15, 1700, 14, 647, 334, 1465, 2862, 78, 5006, 15, 7617, 14, 647, 334, 2260, 2862, 78, 396, 15, 493, 14, 647, 334, 17, 3196, 489, 9998, 272, 1622, 272, 291, 14, 629, 8, 2062, 12, 24498, 9, 819, 347, 511, 14915, 425, 2842, 63, 1205, 2889, 3325, 3034, 8, 277, 304, 272, 3066, 63, 1199, 275, 359, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 1021, 29, 1421, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 26, 511, 29, 1700, 297, 489, 283, 26347, 18272, 2594, 63, 6305, 63, 6012, 26, 413, 297, 489, 283, 26347, 18272, 2594, 63, 9517, 26, 754, 29, 5006, 297, 489, 283, 7617, 297, 489, 3260, 489, 3260, 489, 283, 26347, 18272, 2594, 63, 6012, 26, 378, 297, 272, 1622, 339, 1798, 275, 14498, 425, 63, 2087, 14, 14915, 425, 2842, 8, 1773, 63, 1199, 9, 272, 24498, 275, 769, 8, 2087, 14, 3315, 3694, 1012, 272, 1233, 12, 8844, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
benthomasson/ansible
lib/ansible/modules/network/cloudengine/ce_bfd_view.py
7
20499
#!/usr/bin/python # # 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: ce_bfd_view version_added: "2.4" short_description: Manages BFD session view configuration on HUAWEI CloudEngine devices. description: - Manages BFD session view configuration on HUAWEI CloudEngine devices. author: QijunPan (@CloudEngine-Ansible) options: session_name: description: - Specifies the name of a BFD session. The value is a string of 1 to 15 case-sensitive characters without spaces. required: true default: null local_discr: description: - Specifies the local discriminator of a BFD session. The value is an integer that ranges from 1 to 16384. required: false default: null remote_discr: description: - Specifies the remote discriminator of a BFD session. The value is an integer that ranges from 1 to 4294967295. required: false default: null min_tx_interval: description: - Specifies the minimum interval for receiving BFD packets. The value is an integer that ranges from 50 to 1000, in milliseconds. required: false default: null min_rx_interval: description: - Specifies the minimum interval for sending BFD packets. The value is an integer that ranges from 50 to 1000, in milliseconds. required: false default: null detect_multi: description: - Specifies the local detection multiplier of a BFD session. The value is an integer that ranges from 3 to 50. required: false default: null wtr_interval: description: - Specifies the WTR time of a BFD session. The value is an integer that ranges from 1 to 60, in minutes. The default value is 0. required: false default: null tos_exp: description: - Specifies a priority for BFD control packets. The value is an integer ranging from 0 to 7. The default value is 7, which is the highest priority. required: false default: null admin_down: description: - Enables the BFD session to enter the AdminDown state. By default, a BFD session is enabled. The default value is bool type. required: false default: false description: description: - Specifies the description of a BFD session. The value is a string of 1 to 51 case-sensitive characters with spaces. required: false default: null state: description: - Determines whether the config should be present or not on the device. required: false default: present choices: ['present', 'absent'] """ EXAMPLES = ''' - name: bfd view module test hosts: cloudengine connection: local gather_facts: no vars: cli: host: "{{ inventory_hostname }}" port: "{{ ansible_ssh_port }}" username: "{{ username }}" password: "{{ password }}" transport: cli tasks: - name: Set the local discriminator of a BFD session to 80 and the remote discriminator to 800 ce_bfd_view: session_name: atob local_discr: 80 remote_discr: 800 state: present provider: '{{ cli }}' - name: Set the minimum interval for receiving BFD packets to 500 ms ce_bfd_view: session_name: atob min_rx_interval: 500 state: present provider: '{{ cli }}' ''' RETURN = ''' proposed: description: k/v pairs of parameters passed into module returned: always type: dict sample: { "admin_down": false, "description": null, "detect_multi": null, "local_discr": 80, "min_rx_interval": null, "min_tx_interval": null, "remote_discr": 800, "session_name": "atob", "state": "present", "tos_exp": null, "wtr_interval": null } existing: description: k/v pairs of existing configuration returned: always type: dict sample: { "session": { "adminDown": "false", "createType": "SESS_STATIC", "description": null, "detectMulti": "3", "localDiscr": null, "minRxInt": null, "minTxInt": null, "remoteDiscr": null, "sessName": "atob", "tosExp": null, "wtrTimerInt": null } } end_state: description: k/v pairs of configuration after module execution returned: always type: dict sample: { "session": { "adminDown": "false", "createType": "SESS_STATIC", "description": null, "detectMulti": "3", "localDiscr": "80", "minRxInt": null, "minTxInt": null, "remoteDiscr": "800", "sessName": "atob", "tosExp": null, "wtrTimerInt": null } } updates: description: commands sent to the device returned: always type: list sample: [ "bfd atob", "discriminator local 80", "discriminator remote 800" ] changed: description: check to see if a change was made on the device returned: always type: boolean sample: true ''' import sys from xml.etree import ElementTree from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.ce import get_nc_config, set_nc_config, ce_argument_spec CE_NC_GET_BFD = """ <filter type="subtree"> <bfd xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0"> %s </bfd> </filter> """ CE_NC_GET_BFD_GLB = """ <bfdSchGlobal> <bfdEnable></bfdEnable> </bfdSchGlobal> """ CE_NC_GET_BFD_SESSION = """ <bfdCfgSessions> <bfdCfgSession> <sessName>%s</sessName> <createType></createType> <localDiscr></localDiscr> <remoteDiscr></remoteDiscr> <minTxInt></minTxInt> <minRxInt></minRxInt> <detectMulti></detectMulti> <wtrTimerInt></wtrTimerInt> <tosExp></tosExp> <adminDown></adminDown> <description></description> </bfdCfgSession> </bfdCfgSessions> """ class BfdView(object): """Manages BFD View""" def __init__(self, argument_spec): self.spec = argument_spec self.module = None self.__init_module__() # module input info self.session_name = self.module.params['session_name'] self.local_discr = self.module.params['local_discr'] self.remote_discr = self.module.params['remote_discr'] self.min_tx_interval = self.module.params['min_tx_interval'] self.min_rx_interval = self.module.params['min_rx_interval'] self.detect_multi = self.module.params['detect_multi'] self.wtr_interval = self.module.params['wtr_interval'] self.tos_exp = self.module.params['tos_exp'] self.admin_down = self.module.params['admin_down'] self.description = self.module.params['description'] self.state = self.module.params['state'] # host info self.host = self.module.params['host'] self.username = self.module.params['username'] self.port = self.module.params['port'] # state self.changed = False self.bfd_dict = dict() self.updates_cmd = list() self.commands = list() self.results = dict() self.proposed = dict() self.existing = dict() self.end_state = dict() def __init_module__(self): """init module""" self.module = AnsibleModule(argument_spec=self.spec, supports_check_mode=True) def get_bfd_dict(self): """bfd config dict""" bfd_dict = dict() bfd_dict["global"] = dict() bfd_dict["session"] = dict() conf_str = CE_NC_GET_BFD % (CE_NC_GET_BFD_GLB + (CE_NC_GET_BFD_SESSION % self.session_name)) xml_str = get_nc_config(self.module, conf_str) if "<data/>" in xml_str: return bfd_dict xml_str = xml_str.replace('\r', '').replace('\n', '').\ replace('xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"', "").\ replace('xmlns="http://www.huawei.com/netconf/vrp"', "") root = ElementTree.fromstring(xml_str) # get bfd global info glb = root.find("data/bfd/bfdSchGlobal") if glb: for attr in glb: bfd_dict["global"][attr.tag] = attr.text # get bfd session info sess = root.find("data/bfd/bfdCfgSessions/bfdCfgSession") if sess: for attr in sess: bfd_dict["session"][attr.tag] = attr.text return bfd_dict def config_session(self): """configures bfd session""" xml_str = "" cmd_list = list() cmd_session = "" if not self.session_name: return xml_str if self.bfd_dict["global"].get("bfdEnable", "false") != "true": self.module.fail_json(msg="Error: Please enable BFD globally first.") if not self.bfd_dict["session"]: self.module.fail_json(msg="Error: BFD session is not exist.") session = self.bfd_dict["session"] xml_str = "<sessName>%s</sessName>" % self.session_name cmd_session = "bfd %s" % self.session_name # BFD session view if self.local_discr is not None: if self.state == "present" and str(self.local_discr) != session.get("localDiscr"): xml_str += "<localDiscr>%s</localDiscr>" % self.local_discr cmd_list.append("discriminator local %s" % self.local_discr) elif self.state == "absent" and str(self.local_discr) == session.get("localDiscr"): xml_str += "<localDiscr/>" cmd_list.append("undo discriminator local") if self.remote_discr is not None: if self.state == "present" and str(self.remote_discr) != session.get("remoteDiscr"): xml_str += "<remoteDiscr>%s</remoteDiscr>" % self.remote_discr cmd_list.append("discriminator remote %s" % self.remote_discr) elif self.state == "absent" and str(self.remote_discr) == session.get("remoteDiscr"): xml_str += "<remoteDiscr/>" cmd_list.append("undo discriminator remote") if self.min_tx_interval is not None: if self.state == "present" and str(self.min_tx_interval) != session.get("minTxInt"): xml_str += "<minTxInt>%s</minTxInt>" % self.min_tx_interval cmd_list.append("min-tx-interval %s" % self.min_tx_interval) elif self.state == "absent" and str(self.min_tx_interval) == session.get("minTxInt"): xml_str += "<minTxInt/>" cmd_list.append("undo min-tx-interval") if self.min_rx_interval is not None: if self.state == "present" and str(self.min_rx_interval) != session.get("minRxInt"): xml_str += "<minRxInt>%s</minRxInt>" % self.min_rx_interval cmd_list.append("min-rx-interval %s" % self.min_rx_interval) elif self.state == "absent" and str(self.min_rx_interval) == session.get("minRxInt"): xml_str += "<minRxInt/>" cmd_list.append("undo min-rx-interval") if self.detect_multi is not None: if self.state == "present" and str(self.detect_multi) != session.get("detectMulti"): xml_str += " <detectMulti>%s</detectMulti>" % self.detect_multi cmd_list.append("detect-multiplier %s" % self.detect_multi) elif self.state == "absent" and str(self.detect_multi) == session.get("detectMulti"): xml_str += " <detectMulti/>" cmd_list.append("undo detect-multiplier") if self.wtr_interval is not None: if self.state == "present" and str(self.wtr_interval) != session.get("wtrTimerInt"): xml_str += " <wtrTimerInt>%s</wtrTimerInt>" % self.wtr_interval cmd_list.append("wtr %s" % self.wtr_interval) elif self.state == "absent" and str(self.wtr_interval) == session.get("wtrTimerInt"): xml_str += " <wtrTimerInt/>" cmd_list.append("undo wtr") if self.tos_exp is not None: if self.state == "present" and str(self.tos_exp) != session.get("tosExp"): xml_str += " <tosExp>%s</tosExp>" % self.tos_exp cmd_list.append("tos-exp %s" % self.tos_exp) elif self.state == "absent" and str(self.tos_exp) == session.get("tosExp"): xml_str += " <tosExp/>" cmd_list.append("undo tos-exp") if self.admin_down and session.get("adminDown", "false") == "false": xml_str += " <adminDown>true</adminDown>" cmd_list.append("shutdown") elif not self.admin_down and session.get("adminDown", "false") == "true": xml_str += " <adminDown>false</adminDown>" cmd_list.append("undo shutdown") if self.description: if self.state == "present" and self.description != session.get("description"): xml_str += "<description>%s</description>" % self.description cmd_list.append("description %s" % self.description) elif self.state == "absent" and self.description == session.get("description"): xml_str += "<description/>" cmd_list.append("undo description") if xml_str.endswith("</sessName>"): # no config update return "" else: cmd_list.insert(0, cmd_session) self.updates_cmd.extend(cmd_list) return '<bfdCfgSessions><bfdCfgSession operation="merge">' + xml_str\ + '</bfdCfgSession></bfdCfgSessions>' def netconf_load_config(self, xml_str): """load bfd config by netconf""" if not xml_str: return xml_cfg = """ <config> <bfd xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0"> %s </bfd> </config>""" % xml_str set_nc_config(self.min_rx_interval, xml_cfg) self.changed = True def check_params(self): """Check all input params""" # check session_name if not self.session_name: self.module.fail_json(msg="Error: Missing required arguments: session_name.") if self.session_name: if len(self.session_name) < 1 or len(self.session_name) > 15: self.module.fail_json(msg="Error: Session name is invalid.") # check local_discr if self.local_discr is not None: if self.local_discr < 1 or self.local_discr > 16384: self.module.fail_json(msg="Error: Session local_discr is not ranges from 1 to 16384.") # check remote_discr if self.remote_discr is not None: if self.remote_discr < 1 or self.remote_discr > 4294967295: self.module.fail_json(msg="Error: Session remote_discr is not ranges from 1 to 4294967295.") # check min_tx_interval if self.min_tx_interval is not None: if self.min_tx_interval < 50 or self.min_tx_interval > 1000: self.module.fail_json(msg="Error: Session min_tx_interval is not ranges from 50 to 1000.") # check min_rx_interval if self.min_rx_interval is not None: if self.min_rx_interval < 50 or self.min_rx_interval > 1000: self.module.fail_json(msg="Error: Session min_rx_interval is not ranges from 50 to 1000.") # check detect_multi if self.detect_multi is not None: if self.detect_multi < 3 or self.detect_multi > 50: self.module.fail_json(msg="Error: Session detect_multi is not ranges from 3 to 50.") # check wtr_interval if self.wtr_interval is not None: if self.wtr_interval < 1 or self.wtr_interval > 60: self.module.fail_json(msg="Error: Session wtr_interval is not ranges from 1 to 60.") # check tos_exp if self.tos_exp is not None: if self.tos_exp < 0 or self.tos_exp > 7: self.module.fail_json(msg="Error: Session tos_exp is not ranges from 0 to 7.") # check description if self.description: if len(self.description) < 1 or len(self.description) > 51: self.module.fail_json(msg="Error: Session description is invalid.") def get_proposed(self): """get proposed info""" # base config self.proposed["session_name"] = self.session_name self.proposed["local_discr"] = self.local_discr self.proposed["remote_discr"] = self.remote_discr self.proposed["min_tx_interval"] = self.min_tx_interval self.proposed["min_rx_interval"] = self.min_rx_interval self.proposed["detect_multi"] = self.detect_multi self.proposed["wtr_interval"] = self.wtr_interval self.proposed["tos_exp"] = self.tos_exp self.proposed["admin_down"] = self.admin_down self.proposed["description"] = self.description self.proposed["state"] = self.state def get_existing(self): """get existing info""" if not self.bfd_dict: return self.existing["session"] = self.bfd_dict.get("session") def get_end_state(self): """get end state info""" bfd_dict = self.get_bfd_dict() if not bfd_dict: return self.end_state["session"] = bfd_dict.get("session") def work(self): """worker""" self.check_params() self.bfd_dict = self.get_bfd_dict() self.get_existing() self.get_proposed() # deal present or absent xml_str = '' if self.session_name: xml_str += self.config_session() # update to device if xml_str: self.netconf_load_config(xml_str) self.changed = True self.get_end_state() self.results['changed'] = self.changed self.results['proposed'] = self.proposed self.results['existing'] = self.existing self.results['end_state'] = self.end_state if self.changed: self.results['updates'] = self.updates_cmd else: self.results['updates'] = list() self.module.exit_json(**self.results) def main(): """Module main""" argument_spec = dict( session_name=dict(required=True, type='str'), local_discr=dict(required=False, type='int'), remote_discr=dict(required=False, type='int'), min_tx_interval=dict(required=False, type='int'), min_rx_interval=dict(required=False, type='int'), detect_multi=dict(required=False, type='int'), wtr_interval=dict(required=False, type='int'), tos_exp=dict(required=False, type='int'), admin_down=dict(required=False, type='bool', default=False), description=dict(required=False, type='str'), state=dict(required=False, default='present', choices=['present', 'absent']) ) argument_spec.update(ce_argument_spec) module = BfdView(argument_spec) module.work() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 10142, 63, 21090, 63, 1345, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 3612, 63, 1802, 26, 21612, 699, 7902, 2351, 2455, 2897, 641, 869, 21659, 5408, 41, 8142, 8524, 7256, 14, 199, 1802, 26, 272, 446, 21612, 699, 7902, 2351, 2455, 2897, 641, 869, 21659, 5408, 41, 8142, 8524, 7256, 14, 199, 2502, 26, 1413, 7879, 324, 19266, 8593, 9089, 8524, 13, 10047, 9, 199, 1419, 26, 272, 2351, 63, 354, 26, 267, 1369, 26, 288, 446, 11015, 314, 536, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 282, 1059, 402, 413, 370, 4114, 1930, 13, 7361, 4110, 1928, 7883, 14, 267, 1415, 26, 2549, 267, 849, 26, 2973, 272, 2257, 63, 6409, 82, 26, 267, 1369, 26, 288, 446, 11015, 314, 2257, 487, 24565, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 413, 370, 24619, 1349, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 3982, 63, 6409, 82, 26, 267, 1369, 26, 288, 446, 11015, 314, 3982, 487, 24565, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 413, 370, 21504, 11405, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 1748, 63, 2347, 63, 4284, 26, 267, 1369, 26, 288, 446, 11015, 314, 7481, 6252, 367, 18390, 699, 7902, 14593, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 5238, 370, 5198, 12, 315, 21131, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 1748, 63, 6872, 63, 4284, 26, 267, 1369, 26, 288, 446, 11015, 314, 7481, 6252, 367, 10209, 699, 7902, 14593, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 5238, 370, 5198, 12, 315, 21131, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 9696, 63, 3029, 26, 267, 1369, 26, 288, 446, 11015, 314, 2257, 15212, 22215, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 650, 370, 5238, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 336, 454, 63, 4284, 26, 267, 1369, 26, 288, 446, 11015, 314, 644, 1766, 900, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 413, 370, 5212, 12, 315, 9395, 14, 1598, 710, 849, 574, 365, 378, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 370, 83, 63, 1474, 26, 267, 1369, 26, 288, 446, 11015, 282, 7464, 367, 699, 7902, 3304, 14593, 14, 1598, 710, 574, 365, 376, 3000, 519, 8544, 687, 378, 370, 1520, 14, 1598, 710, 849, 574, 365, 1520, 12, 1314, 365, 314, 15356, 7464, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 4628, 63, 2110, 26, 267, 1369, 26, 288, 446, 3447, 5921, 314, 699, 7902, 2351, 370, 9509, 314, 9516, 3514, 1174, 14, 1598, 4885, 849, 12, 282, 699, 7902, 2351, 365, 5223, 14, 1598, 710, 849, 574, 365, 2155, 730, 14, 267, 1415, 26, 3055, 267, 849, 26, 3055, 272, 1369, 26, 267, 1369, 26, 288, 446, 11015, 314, 1369, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 282, 1059, 402, 413, 370, 8026, 1930, 13, 7361, 4110, 543, 7883, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 1174, 26, 267, 1369, 26, 288, 446, 22391, 3775, 314, 1101, 1077, 506, 3451, 503, 440, 641, 314, 2243, 14, 267, 1415, 26, 3055, 267, 849, 26, 3451, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 199, 624, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 330, 2592, 2455, 859, 511, 523, 7057, 26, 2463, 85, 848, 2598, 523, 1950, 26, 2257, 523, 13082, 63, 5047, 26, 949, 523, 6802, 26, 272, 5053, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 7820, 489, 1844, 26, 7370, 3242, 63, 5510, 63, 719, 7820, 489, 3434, 26, 7370, 3434, 7820, 489, 2505, 26, 7370, 2505, 7820, 489, 7773, 26, 5053, 819, 6527, 26, 523, 446, 536, 26, 2494, 314, 2257, 487, 24565, 402, 282, 699, 7902, 2351, 370, 5939, 436, 314, 3982, 487, 24565, 370, 23466, 272, 10142, 63, 21090, 63, 1345, 26, 489, 2351, 63, 354, 26, 282, 475, 66, 489, 2257, 63, 6409, 82, 26, 5939, 489, 3982, 63, 6409, 82, 26, 23466, 489, 1174, 26, 3451, 489, 5022, 26, 11400, 5053, 16339, 819, 446, 536, 26, 2494, 314, 7481, 6252, 367, 18390, 699, 7902, 14593, 370, 6891, 6605, 272, 10142, 63, 21090, 63, 1345, 26, 489, 2351, 63, 354, 26, 282, 475, 66, 489, 1748, 63, 6872, 63, 4284, 26, 6891, 489, 1174, 26, 3451, 489, 5022, 26, 11400, 5053, 16339, 199, 2344, 199, 199, 9677, 275, 1449, 199, 15676, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 2633, 3032, 1901, 859, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 469, 267, 298, 2113, 63, 2110, 582, 3055, 12, 267, 298, 1802, 582, 2973, 12, 267, 298, 13552, 63, 3029, 582, 2973 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 408, 199, 2595, 199, 578, 26, 10142, 63, 21090, 63, 1345, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 3612, 63, 1802, 26, 21612, 699, 7902, 2351, 2455, 2897, 641, 869, 21659, 5408, 41, 8142, 8524, 7256, 14, 199, 1802, 26, 272, 446, 21612, 699, 7902, 2351, 2455, 2897, 641, 869, 21659, 5408, 41, 8142, 8524, 7256, 14, 199, 2502, 26, 1413, 7879, 324, 19266, 8593, 9089, 8524, 13, 10047, 9, 199, 1419, 26, 272, 2351, 63, 354, 26, 267, 1369, 26, 288, 446, 11015, 314, 536, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 282, 1059, 402, 413, 370, 4114, 1930, 13, 7361, 4110, 1928, 7883, 14, 267, 1415, 26, 2549, 267, 849, 26, 2973, 272, 2257, 63, 6409, 82, 26, 267, 1369, 26, 288, 446, 11015, 314, 2257, 487, 24565, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 413, 370, 24619, 1349, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 3982, 63, 6409, 82, 26, 267, 1369, 26, 288, 446, 11015, 314, 3982, 487, 24565, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 413, 370, 21504, 11405, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 1748, 63, 2347, 63, 4284, 26, 267, 1369, 26, 288, 446, 11015, 314, 7481, 6252, 367, 18390, 699, 7902, 14593, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 5238, 370, 5198, 12, 315, 21131, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 1748, 63, 6872, 63, 4284, 26, 267, 1369, 26, 288, 446, 11015, 314, 7481, 6252, 367, 10209, 699, 7902, 14593, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 5238, 370, 5198, 12, 315, 21131, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 9696, 63, 3029, 26, 267, 1369, 26, 288, 446, 11015, 314, 2257, 15212, 22215, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 650, 370, 5238, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 336, 454, 63, 4284, 26, 267, 1369, 26, 288, 446, 11015, 314, 644, 1766, 900, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 376, 3000, 626, 12271, 687, 413, 370, 5212, 12, 315, 9395, 14, 1598, 710, 849, 574, 365, 378, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 370, 83, 63, 1474, 26, 267, 1369, 26, 288, 446, 11015, 282, 7464, 367, 699, 7902, 3304, 14593, 14, 1598, 710, 574, 365, 376, 3000, 519, 8544, 687, 378, 370, 1520, 14, 1598, 710, 849, 574, 365, 1520, 12, 1314, 365, 314, 15356, 7464, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 4628, 63, 2110, 26, 267, 1369, 26, 288, 446, 3447, 5921, 314, 699, 7902, 2351, 370, 9509, 314, 9516, 3514, 1174, 14, 1598, 4885, 849, 12, 282, 699, 7902, 2351, 365, 5223, 14, 1598, 710, 849, 574, 365, 2155, 730, 14, 267, 1415, 26, 3055, 267, 849, 26, 3055, 272, 1369, 26, 267, 1369, 26, 288, 446, 11015, 314, 1369, 402, 282, 699, 7902, 2351, 14, 1598, 710, 574, 365, 282, 1059, 402, 413, 370, 8026, 1930, 13, 7361, 4110, 543, 7883, 14, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 1174, 26, 267, 1369, 26, 288, 446, 22391, 3775, 314, 1101, 1077, 506, 3451, 503, 440, 641, 314, 2243, 14, 267, 1415, 26, 3055, 267, 849, 26, 3451, 267, 3415, 26, 788, 1881, 297, 283, 5575, 418, 199, 624, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 330, 2592, 2455, 859, 511, 523, 7057, 26, 2463, 85, 848, 2598, 523, 1950, 26, 2257, 523, 13082, 63, 5047, 26, 949, 523, 6802, 26, 272, 5053, 26, 489, 1591, 26, 7370, 8200, 63, 4269, 7820, 489, 1844, 26, 7370, 3242, 63, 5510, 63, 719, 7820, 489, 3434, 26, 7370, 3434, 7820, 489, 2505, 26, 7370, 2505, 7820, 489, 7773, 26, 5053, 819, 6527, 26, 523, 446, 536, 26, 2494, 314, 2257, 487, 24565, 402, 282, 699, 7902, 2351, 370, 5939, 436, 314, 3982, 487, 24565, 370, 23466, 272, 10142, 63, 21090, 63, 1345, 26, 489, 2351, 63, 354, 26, 282, 475, 66, 489, 2257, 63, 6409, 82, 26, 5939, 489, 3982, 63, 6409, 82, 26, 23466, 489, 1174, 26, 3451, 489, 5022, 26, 11400, 5053, 16339, 819, 446, 536, 26, 2494, 314, 7481, 6252, 367, 18390, 699, 7902, 14593, 370, 6891, 6605, 272, 10142, 63, 21090, 63, 1345, 26, 489, 2351, 63, 354, 26, 282, 475, 66, 489, 1748, 63, 6872, 63, 4284, 26, 6891, 489, 1174, 26, 3451, 489, 5022, 26, 11400, 5053, 16339, 199, 2344, 199, 199, 9677, 275, 1449, 199, 15676, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 2633, 3032, 1901, 859, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 469, 267, 298, 2113, 63, 2110, 582, 3055, 12, 267, 298, 1802, 582, 2973, 12, 267, 298, 13552, 63, 3029, 582, 2973, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
dimara/ganeti
lib/outils.py
10
5229
# # # Copyright (C) 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: # # 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 for object related utils.""" #: Supported container types for serialization/de-serialization (must be a #: tuple as it's used as a parameter for C{isinstance}) _SEQUENCE_TYPES = (list, tuple, set, frozenset) class AutoSlots(type): """Meta base class for __slots__ definitions. """ def __new__(mcs, name, bases, attrs): """Called when a class should be created. @param mcs: The meta class @param name: Name of created class @param bases: Base classes @type attrs: dict @param attrs: Class attributes """ assert "__slots__" not in attrs, \ "Class '%s' defines __slots__ when it should not" % name attrs["__slots__"] = mcs._GetSlots(attrs) return type.__new__(mcs, name, bases, attrs) @classmethod def _GetSlots(mcs, attrs): """Used to get the list of defined slots. @param attrs: The attributes of the class """ raise NotImplementedError class ValidatedSlots(object): """Sets and validates slots. """ __slots__ = [] def __init__(self, **kwargs): """Constructor for BaseOpCode. The constructor takes only keyword arguments and will set attributes on this object based on the passed arguments. As such, it means that you should not pass arguments which are not in the __slots__ attribute for this class. """ slots = self.GetAllSlots() for (key, value) in kwargs.items(): if key not in slots: raise TypeError("Object %s doesn't support the parameter '%s'" % (self.__class__.__name__, key)) setattr(self, key, value) @classmethod def GetAllSlots(cls): """Compute the list of all declared slots for a class. """ slots = [] for parent in cls.__mro__: slots.extend(getattr(parent, "__slots__", [])) return slots def Validate(self): """Validates the slots. This method returns L{None} if the validation succeeds, or raises an exception otherwise. @rtype: NoneType @return: L{None}, if the validation succeeds @raise Exception: validation fails This method must be implemented by the child classes. """ raise NotImplementedError def ContainerToDicts(container): """Convert the elements of a container to standard Python types. This method converts a container with elements to standard Python types. If the input container is of the type C{dict}, only its values are touched. Those values, as well as all elements of input sequences, must support a C{ToDict} method returning a serialized version. @type container: dict or sequence (see L{_SEQUENCE_TYPES}) """ if isinstance(container, dict): ret = dict([(k, v.ToDict()) for k, v in container.items()]) elif isinstance(container, _SEQUENCE_TYPES): ret = [elem.ToDict() for elem in container] else: raise TypeError("Unknown container type '%s'" % type(container)) return ret def ContainerFromDicts(source, c_type, e_type): """Convert a container from standard python types. This method converts a container with standard Python types to objects. If the container is a dict, we don't touch the keys, only the values. @type source: None, dict or sequence (see L{_SEQUENCE_TYPES}) @param source: Input data @type c_type: type class @param c_type: Desired type for returned container @type e_type: element type class @param e_type: Item type for elements in returned container (must have a C{FromDict} class method) """ if not isinstance(c_type, type): raise TypeError("Container type '%s' is not a type" % type(c_type)) if source is None: source = c_type() if c_type is dict: ret = dict([(k, e_type.FromDict(v)) for k, v in source.items()]) elif c_type in _SEQUENCE_TYPES: ret = c_type(map(e_type.FromDict, source)) else: raise TypeError("Unknown container type '%s'" % c_type) return ret
bsd-2-clause
[ 3, 199, 3, 199, 199, 3, 1898, 334, 35, 9, 6029, 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, 199, 199, 624, 2377, 367, 909, 4048, 3778, 1041, 421, 199, 12573, 26167, 3970, 2943, 367, 16953, 15, 271, 13, 12161, 334, 7790, 506, 282, 199, 12573, 2008, 465, 652, 1159, 1202, 465, 282, 2725, 367, 445, 91, 6074, 1552, 199, 63, 16585, 63, 7893, 275, 334, 513, 12, 2008, 12, 663, 12, 9522, 9, 421, 199, 533, 9195, 26492, 8, 466, 304, 523, 408, 3396, 1300, 1021, 367, 636, 7257, 363, 10269, 14, 819, 408, 523, 347, 636, 1222, 721, 77, 1259, 12, 536, 12, 9768, 12, 3290, 304, 272, 408, 10474, 1380, 282, 1021, 1077, 506, 2737, 14, 339, 768, 635, 333, 1259, 26, 710, 3404, 1021, 272, 768, 635, 536, 26, 2812, 402, 2737, 1021, 272, 768, 635, 9768, 26, 3523, 3992, 272, 768, 466, 3290, 26, 1211, 272, 768, 635, 3290, 26, 8089, 3004, 339, 408, 272, 702, 4396, 7257, 16526, 440, 315, 3290, 12, 971, 489, 298, 2543, 1543, 83, 7, 7890, 636, 7257, 363, 1380, 652, 1077, 440, 2, 450, 536, 339, 3290, 31313, 7257, 363, 937, 275, 333, 1259, 423, 17526, 4555, 8, 3288, 9, 339, 372, 730, 855, 1222, 721, 77, 1259, 12, 536, 12, 9768, 12, 3290, 9, 819, 768, 3744, 523, 347, 485, 17526, 4555, 8, 77, 1259, 12, 3290, 304, 272, 408, 9167, 370, 664, 314, 769, 402, 3247, 14319, 14, 339, 768, 635, 3290, 26, 710, 3004, 402, 314, 1021, 339, 408, 272, 746, 4279, 421, 199, 533, 4821, 972, 26492, 8, 785, 304, 523, 408, 9899, 436, 29280, 14319, 14, 819, 408, 523, 636, 7257, 363, 275, 942, 819, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 272, 408, 11447, 367, 3523, 4619, 3034, 14, 339, 710, 3787, 6181, 1454, 4252, 2368, 436, 911, 663, 272, 3004, 641, 642, 909, 4079, 641, 314, 3032, 2368, 14, 3709, 4066, 12, 272, 652, 4910, 626, 1265, 1077, 440, 986, 2368, 1314, 787, 440, 315, 314, 272, 636, 7257, 363, 2225, 367, 642, 1021, 14, 339, 408, 272, 14319, 275, 291, 14, 24578, 26492, 342, 272, 367, 334, 498, 12, 574, 9, 315, 2074, 14, 1744, 837, 489, 340, 790, 440, 315, 14319, 26, 267, 746, 3146, 480, 1692, 450, 83, 3181, 1133, 2291, 314, 2725, 1543, 83, 4065, 450, 717, 334, 277, 855, 533, 4914, 354, 3108, 790, 430, 489, 5371, 8, 277, 12, 790, 12, 574, 9, 819, 768, 3744, 523, 347, 2372, 2422, 26492, 8, 1886, 304, 272, 408, 8564, 314, 769, 402, 1006, 14290, 14319, 367, 282, 1021, 14, 339, 408, 272, 14319, 275, 942, 272, 367, 1676, 315, 843, 855, 17335, 10651, 489, 14319, 14, 2880, 8, 5675, 8, 1708, 12, 4396, 7257, 13915, 15927, 272, 372, 14319, 819, 347, 12134, 8, 277, 304, 272, 408, 3490, 2335, 314, 14319, 14, 339, 961, 1083, 2529, 491, 91, 403, 93, 340, 314, 6411, 24611, 12, 503, 6534, 272, 376, 1919, 4257, 14, 339, 768, 4500, 26, 488, 804, 272, 768, 1107, 26, 491, 91, 403, 1386, 340, 314, 6411, 24611, 339, 768, 3730, 2186, 26, 6411, 6918, 339, 961, 1083, 1471, 506, 6366, 701, 314, 1982, 3992, 14, 339, 408, 272, 746, 4279, 421, 199, 318, 15395, 1378, 27279, 8, 3600, 304, 523, 408, 7306, 314, 4008, 402, 282, 3970, 370, 4465, 2018, 2943, 14, 819, 961, 1083, 15373, 282, 3970, 543, 4008, 370, 4465, 2018, 2943, 14, 982, 523, 314, 1324, 3970, 365, 402, 314, 730, 445, 91, 807, 1386, 1454, 2399, 1338, 787, 370, 22821, 14, 523, 18049, 261, 1338, 12, 465, 5521, 465, 1006, 4008, 402, 1324, 8013, 12, 1471, 2291, 282, 523, 445, 91, 1378, 2141, 93, 1083, 8152, 282, 6380, 1015, 14, 819, 768, 466, 3970, 26, 1211, 503, 3414, 334, 3239, 491, 26975, 16585, 63, 7893, 1552, 819, 408, 523, 340, 1228, 8, 3600, 12, 1211, 304, 272, 2203, 275, 1211, 7694, 75, 12, 373, 14, 1378, 2141, 1012, 367, 1022, 12, 373, 315, 3970, 14, 1744, 9383, 523, 916, 1228, 8, 3600, 12, 485, 16585, 63, 7893, 304, 272, 2203, 275, 359, 6086, 14, 1378, 2141, 342, 367, 6193, 315, 3970, 61, 523, 587, 26, 272, 746, 3146, 480, 5912, 3970, 730, 1543, 83, 4065, 450, 730, 8, 3600, 430, 819, 372, 2203, 421, 199, 318, 15395, 2532, 27279, 8, 1365, 12, 286, 63, 466, 12, 325, 63, 466, 304, 523, 408, 7306, 282, 3970, 687, 4465, 2366, 2943, 14, 819, 961, 1083, 15373, 282, 3970, 543, 4465, 2018, 2943, 370, 2251, 14, 982 ]
[ 199, 3, 199, 199, 3, 1898, 334, 35, 9, 6029, 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, 199, 199, 624, 2377, 367, 909, 4048, 3778, 1041, 421, 199, 12573, 26167, 3970, 2943, 367, 16953, 15, 271, 13, 12161, 334, 7790, 506, 282, 199, 12573, 2008, 465, 652, 1159, 1202, 465, 282, 2725, 367, 445, 91, 6074, 1552, 199, 63, 16585, 63, 7893, 275, 334, 513, 12, 2008, 12, 663, 12, 9522, 9, 421, 199, 533, 9195, 26492, 8, 466, 304, 523, 408, 3396, 1300, 1021, 367, 636, 7257, 363, 10269, 14, 819, 408, 523, 347, 636, 1222, 721, 77, 1259, 12, 536, 12, 9768, 12, 3290, 304, 272, 408, 10474, 1380, 282, 1021, 1077, 506, 2737, 14, 339, 768, 635, 333, 1259, 26, 710, 3404, 1021, 272, 768, 635, 536, 26, 2812, 402, 2737, 1021, 272, 768, 635, 9768, 26, 3523, 3992, 272, 768, 466, 3290, 26, 1211, 272, 768, 635, 3290, 26, 8089, 3004, 339, 408, 272, 702, 4396, 7257, 16526, 440, 315, 3290, 12, 971, 489, 298, 2543, 1543, 83, 7, 7890, 636, 7257, 363, 1380, 652, 1077, 440, 2, 450, 536, 339, 3290, 31313, 7257, 363, 937, 275, 333, 1259, 423, 17526, 4555, 8, 3288, 9, 339, 372, 730, 855, 1222, 721, 77, 1259, 12, 536, 12, 9768, 12, 3290, 9, 819, 768, 3744, 523, 347, 485, 17526, 4555, 8, 77, 1259, 12, 3290, 304, 272, 408, 9167, 370, 664, 314, 769, 402, 3247, 14319, 14, 339, 768, 635, 3290, 26, 710, 3004, 402, 314, 1021, 339, 408, 272, 746, 4279, 421, 199, 533, 4821, 972, 26492, 8, 785, 304, 523, 408, 9899, 436, 29280, 14319, 14, 819, 408, 523, 636, 7257, 363, 275, 942, 819, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 272, 408, 11447, 367, 3523, 4619, 3034, 14, 339, 710, 3787, 6181, 1454, 4252, 2368, 436, 911, 663, 272, 3004, 641, 642, 909, 4079, 641, 314, 3032, 2368, 14, 3709, 4066, 12, 272, 652, 4910, 626, 1265, 1077, 440, 986, 2368, 1314, 787, 440, 315, 314, 272, 636, 7257, 363, 2225, 367, 642, 1021, 14, 339, 408, 272, 14319, 275, 291, 14, 24578, 26492, 342, 272, 367, 334, 498, 12, 574, 9, 315, 2074, 14, 1744, 837, 489, 340, 790, 440, 315, 14319, 26, 267, 746, 3146, 480, 1692, 450, 83, 3181, 1133, 2291, 314, 2725, 1543, 83, 4065, 450, 717, 334, 277, 855, 533, 4914, 354, 3108, 790, 430, 489, 5371, 8, 277, 12, 790, 12, 574, 9, 819, 768, 3744, 523, 347, 2372, 2422, 26492, 8, 1886, 304, 272, 408, 8564, 314, 769, 402, 1006, 14290, 14319, 367, 282, 1021, 14, 339, 408, 272, 14319, 275, 942, 272, 367, 1676, 315, 843, 855, 17335, 10651, 489, 14319, 14, 2880, 8, 5675, 8, 1708, 12, 4396, 7257, 13915, 15927, 272, 372, 14319, 819, 347, 12134, 8, 277, 304, 272, 408, 3490, 2335, 314, 14319, 14, 339, 961, 1083, 2529, 491, 91, 403, 93, 340, 314, 6411, 24611, 12, 503, 6534, 272, 376, 1919, 4257, 14, 339, 768, 4500, 26, 488, 804, 272, 768, 1107, 26, 491, 91, 403, 1386, 340, 314, 6411, 24611, 339, 768, 3730, 2186, 26, 6411, 6918, 339, 961, 1083, 1471, 506, 6366, 701, 314, 1982, 3992, 14, 339, 408, 272, 746, 4279, 421, 199, 318, 15395, 1378, 27279, 8, 3600, 304, 523, 408, 7306, 314, 4008, 402, 282, 3970, 370, 4465, 2018, 2943, 14, 819, 961, 1083, 15373, 282, 3970, 543, 4008, 370, 4465, 2018, 2943, 14, 982, 523, 314, 1324, 3970, 365, 402, 314, 730, 445, 91, 807, 1386, 1454, 2399, 1338, 787, 370, 22821, 14, 523, 18049, 261, 1338, 12, 465, 5521, 465, 1006, 4008, 402, 1324, 8013, 12, 1471, 2291, 282, 523, 445, 91, 1378, 2141, 93, 1083, 8152, 282, 6380, 1015, 14, 819, 768, 466, 3970, 26, 1211, 503, 3414, 334, 3239, 491, 26975, 16585, 63, 7893, 1552, 819, 408, 523, 340, 1228, 8, 3600, 12, 1211, 304, 272, 2203, 275, 1211, 7694, 75, 12, 373, 14, 1378, 2141, 1012, 367, 1022, 12, 373, 315, 3970, 14, 1744, 9383, 523, 916, 1228, 8, 3600, 12, 485, 16585, 63, 7893, 304, 272, 2203, 275, 359, 6086, 14, 1378, 2141, 342, 367, 6193, 315, 3970, 61, 523, 587, 26, 272, 746, 3146, 480, 5912, 3970, 730, 1543, 83, 4065, 450, 730, 8, 3600, 430, 819, 372, 2203, 421, 199, 318, 15395, 2532, 27279, 8, 1365, 12, 286, 63, 466, 12, 325, 63, 466, 304, 523, 408, 7306, 282, 3970, 687, 4465, 2366, 2943, 14, 819, 961, 1083, 15373, 282, 3970, 543, 4465, 2018, 2943, 370, 2251, 14, 982, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cesarmarinhorj/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/style/checkers/png_unittest.py
124
5663
# Copyright (C) 2012 Balazs Ankes (bank@inf.u-szeged.hu) University of Szeged # # 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 # 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. """Unit test for png.py.""" import unittest2 as unittest from png import PNGChecker from webkitpy.common.system.filesystem_mock import MockFileSystem from webkitpy.common.system.systemhost_mock import MockSystemHost class MockSCMDetector(object): def __init__(self, scm, prop=None): self._scm = scm self._prop = prop def display_name(self): return self._scm def propget(self, pname, path): return self._prop class PNGCheckerTest(unittest.TestCase): """Tests PNGChecker class.""" def test_init(self): """Test __init__() method.""" def mock_handle_style_error(self): pass checker = PNGChecker("test/config", mock_handle_style_error, MockSCMDetector('git'), MockSystemHost()) self.assertEqual(checker._file_path, "test/config") self.assertEqual(checker._handle_style_error, mock_handle_style_error) def test_check(self): errors = [] def mock_handle_style_error(line_number, category, confidence, message): error = (line_number, category, confidence, message) errors.append(error) file_path = '' fs = MockFileSystem() scm = MockSCMDetector('svn') checker = PNGChecker(file_path, mock_handle_style_error, scm, MockSystemHost(filesystem=fs)) checker.check() self.assertEqual(len(errors), 1) self.assertEqual(errors[0], (0, 'image/png', 5, 'Set the svn:mime-type property (svn propset svn:mime-type image/png ).')) files = {'/Users/mock/.subversion/config': 'enable-auto-props = yes\n*.png = svn:mime-type=image/png'} fs = MockFileSystem(files) scm = MockSCMDetector('git') errors = [] checker = PNGChecker("config", mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs)) checker.check() self.assertEqual(len(errors), 0) files = {'/Users/mock/.subversion/config': '#enable-auto-props = yes'} fs = MockFileSystem(files) scm = MockSCMDetector('git') errors = [] checker = PNGChecker("config", mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs)) checker.check() self.assertEqual(len(errors), 1) files = {'/Users/mock/.subversion/config': 'enable-auto-props = yes\n#enable-auto-props = yes\n*.png = svn:mime-type=image/png'} fs = MockFileSystem(files) scm = MockSCMDetector('git') errors = [] checker = PNGChecker("config", mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs)) checker.check() self.assertEqual(len(errors), 0) files = {'/Users/mock/.subversion/config': '#enable-auto-props = yes\nenable-auto-props = yes\n*.png = svn:mime-type=image/png'} fs = MockFileSystem(files) scm = MockSCMDetector('git') errors = [] checker = PNGChecker("config", mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs)) checker.check() self.assertEqual(len(errors), 0) files = {'/Users/mock/.subversion/config': 'enable-auto-props = no'} fs = MockFileSystem(files) scm = MockSCMDetector('git') errors = [] checker = PNGChecker("config", mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs)) checker.check() self.assertEqual(len(errors), 1) file_path = "foo.png" fs.write_binary_file(file_path, "Dummy binary data") scm = MockSCMDetector('git') errors = [] checker = PNGChecker(file_path, mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs)) checker.check() self.assertEqual(len(errors), 1) file_path = "foo-expected.png" fs.write_binary_file(file_path, "Dummy binary data") scm = MockSCMDetector('git') errors = [] checker = PNGChecker(file_path, mock_handle_style_error, scm, MockSystemHost(os_name='linux', filesystem=fs)) checker.check() self.assertEqual(len(errors), 2) self.assertEqual(errors[0], (0, 'image/png', 5, 'Image lacks a checksum. Generate pngs using run-webkit-tests to ensure they have a checksum.'))
bsd-3-clause
[ 3, 1898, 334, 35, 9, 6029, 23928, 4651, 83, 1626, 9246, 334, 9860, 32, 4904, 14, 85, 13, 83, 806, 3046, 14, 10616, 9, 15904, 402, 428, 806, 3046, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 413, 14, 221, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 221, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 258, 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, 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, 5072, 511, 367, 25296, 14, 647, 1041, 199, 199, 646, 2882, 18, 465, 2882, 199, 504, 25296, 492, 26951, 3048, 199, 504, 18007, 14, 2330, 14, 2253, 14, 11381, 63, 1805, 492, 4420, 17521, 199, 504, 18007, 14, 2330, 14, 2253, 14, 2253, 1102, 63, 1805, 492, 4420, 3989, 4965, 421, 199, 533, 4420, 5153, 45, 24402, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 25811, 12, 5931, 29, 403, 304, 267, 291, 423, 17143, 275, 25811, 267, 291, 423, 4469, 275, 5931, 339, 347, 2929, 63, 354, 8, 277, 304, 267, 372, 291, 423, 17143, 339, 347, 5931, 362, 8, 277, 12, 27700, 12, 931, 304, 267, 372, 291, 423, 4469, 421, 199, 533, 26951, 3048, 774, 8, 2796, 14, 1746, 304, 272, 408, 2925, 26951, 3048, 1021, 1041, 339, 347, 511, 63, 826, 8, 277, 304, 267, 408, 774, 636, 826, 4533, 1083, 1041, 398, 347, 1683, 63, 2479, 63, 2487, 63, 705, 8, 277, 304, 288, 986, 398, 7739, 275, 26951, 3048, 480, 396, 15, 888, 401, 1683, 63, 2479, 63, 2487, 63, 705, 12, 4420, 5153, 45, 24402, 360, 3187, 659, 4420, 3989, 4965, 1012, 267, 291, 14, 629, 8, 6743, 423, 493, 63, 515, 12, 298, 396, 15, 888, 531, 267, 291, 14, 629, 8, 6743, 423, 2479, 63, 2487, 63, 705, 12, 1683, 63, 2479, 63, 2487, 63, 705, 9, 339, 347, 511, 63, 1074, 8, 277, 304, 267, 2552, 275, 942, 398, 347, 1683, 63, 2479, 63, 2487, 63, 705, 8, 604, 63, 1955, 12, 4637, 12, 15197, 12, 1245, 304, 288, 1125, 275, 334, 604, 63, 1955, 12, 4637, 12, 15197, 12, 1245, 9, 288, 2552, 14, 740, 8, 705, 9, 398, 570, 63, 515, 275, 2125, 398, 7449, 275, 4420, 17521, 342, 398, 25811, 275, 4420, 5153, 45, 24402, 360, 6836, 358, 267, 7739, 275, 26951, 3048, 8, 493, 63, 515, 12, 1683, 63, 2479, 63, 2487, 63, 705, 12, 25811, 12, 4420, 3989, 4965, 8, 11381, 29, 2319, 430, 267, 7739, 14, 1074, 342, 267, 291, 14, 629, 8, 552, 8, 2550, 395, 413, 9, 267, 291, 14, 629, 8, 2550, 59, 16, 467, 2079, 334, 16, 12, 283, 1569, 15, 4524, 297, 959, 12, 283, 1084, 314, 11327, 26, 7626, 13, 466, 3324, 334, 6836, 5931, 409, 11327, 26, 7626, 13, 466, 1834, 15, 4524, 7092, 1333, 398, 1584, 275, 791, 15, 12117, 15, 1805, 8083, 954, 1023, 15, 888, 356, 283, 4296, 13, 2495, 13, 6750, 275, 9456, 60, 78, 4856, 4524, 275, 11327, 26, 7626, 13, 466, 29, 1569, 15, 4524, 936, 267, 7449, 275, 4420, 17521, 8, 1725, 9, 267, 25811, 275, 4420, 5153, 45, 24402, 360, 3187, 358, 267, 2552, 275, 942, 267, 7739, 275, 26951, 3048, 480, 888, 401, 1683, 63, 2479, 63, 2487, 63, 705, 12, 25811, 12, 4420, 3989, 4965, 8, 736, 63, 354, 534, 5135, 297, 10036, 29, 2319, 430, 267, 7739, 14, 1074, 342, 267, 291, 14, 629, 8, 552, 8, 2550, 395, 378, 9, 398, 1584, 275, 791, 15, 12117, 15, 1805, 8083, 954, 1023, 15, 888, 356, 3943, 4296, 13, 2495, 13, 6750, 275, 9456, 936, 267, 7449, 275, 4420, 17521, 8, 1725, 9, 267, 25811, 275, 4420, 5153, 45, 24402, 360, 3187, 358, 267, 2552, 275, 942, 267, 7739, 275, 26951, 3048, 480, 888, 401, 1683, 63, 2479, 63, 2487, 63, 705, 12, 25811, 12, 4420, 3989, 4965, 8, 736, 63, 354, 534, 5135, 297, 10036, 29, 2319, 430, 267, 7739, 14, 1074, 342, 267, 291, 14, 629, 8, 552, 8, 2550, 395, 413, 9, 398, 1584, 275, 791, 15, 12117, 15, 1805, 8083, 954, 1023, 15, 888, 356, 283, 4296, 13, 2495, 13, 6750, 275, 9456, 60, 78, 3, 4296, 13, 2495, 13, 6750, 275, 9456, 60, 78, 4856, 4524, 275, 11327, 26, 7626, 13, 466, 29, 1569, 15, 4524, 936, 267, 7449, 275, 4420, 17521, 8, 1725, 9, 267, 25811, 275, 4420, 5153, 45, 24402, 360, 3187, 358, 267, 2552, 275, 942, 267, 7739, 275, 26951, 3048, 480, 888, 401, 1683, 63, 2479, 63, 2487, 63, 705, 12, 25811, 12, 4420, 3989, 4965, 8, 736, 63, 354, 534, 5135, 297, 10036, 29, 2319, 430, 267, 7739, 14, 1074, 342, 267, 291, 14, 629, 8, 552, 8, 2550, 395, 378, 9, 398, 1584, 275, 791, 15, 12117, 15, 1805, 8083, 954, 1023, 15, 888, 356, 3943, 4296 ]
[ 1898, 334, 35, 9, 6029, 23928, 4651, 83, 1626, 9246, 334, 9860, 32, 4904, 14, 85, 13, 83, 806, 3046, 14, 10616, 9, 15904, 402, 428, 806, 3046, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 413, 14, 221, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 221, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 258, 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, 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, 5072, 511, 367, 25296, 14, 647, 1041, 199, 199, 646, 2882, 18, 465, 2882, 199, 504, 25296, 492, 26951, 3048, 199, 504, 18007, 14, 2330, 14, 2253, 14, 11381, 63, 1805, 492, 4420, 17521, 199, 504, 18007, 14, 2330, 14, 2253, 14, 2253, 1102, 63, 1805, 492, 4420, 3989, 4965, 421, 199, 533, 4420, 5153, 45, 24402, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 25811, 12, 5931, 29, 403, 304, 267, 291, 423, 17143, 275, 25811, 267, 291, 423, 4469, 275, 5931, 339, 347, 2929, 63, 354, 8, 277, 304, 267, 372, 291, 423, 17143, 339, 347, 5931, 362, 8, 277, 12, 27700, 12, 931, 304, 267, 372, 291, 423, 4469, 421, 199, 533, 26951, 3048, 774, 8, 2796, 14, 1746, 304, 272, 408, 2925, 26951, 3048, 1021, 1041, 339, 347, 511, 63, 826, 8, 277, 304, 267, 408, 774, 636, 826, 4533, 1083, 1041, 398, 347, 1683, 63, 2479, 63, 2487, 63, 705, 8, 277, 304, 288, 986, 398, 7739, 275, 26951, 3048, 480, 396, 15, 888, 401, 1683, 63, 2479, 63, 2487, 63, 705, 12, 4420, 5153, 45, 24402, 360, 3187, 659, 4420, 3989, 4965, 1012, 267, 291, 14, 629, 8, 6743, 423, 493, 63, 515, 12, 298, 396, 15, 888, 531, 267, 291, 14, 629, 8, 6743, 423, 2479, 63, 2487, 63, 705, 12, 1683, 63, 2479, 63, 2487, 63, 705, 9, 339, 347, 511, 63, 1074, 8, 277, 304, 267, 2552, 275, 942, 398, 347, 1683, 63, 2479, 63, 2487, 63, 705, 8, 604, 63, 1955, 12, 4637, 12, 15197, 12, 1245, 304, 288, 1125, 275, 334, 604, 63, 1955, 12, 4637, 12, 15197, 12, 1245, 9, 288, 2552, 14, 740, 8, 705, 9, 398, 570, 63, 515, 275, 2125, 398, 7449, 275, 4420, 17521, 342, 398, 25811, 275, 4420, 5153, 45, 24402, 360, 6836, 358, 267, 7739, 275, 26951, 3048, 8, 493, 63, 515, 12, 1683, 63, 2479, 63, 2487, 63, 705, 12, 25811, 12, 4420, 3989, 4965, 8, 11381, 29, 2319, 430, 267, 7739, 14, 1074, 342, 267, 291, 14, 629, 8, 552, 8, 2550, 395, 413, 9, 267, 291, 14, 629, 8, 2550, 59, 16, 467, 2079, 334, 16, 12, 283, 1569, 15, 4524, 297, 959, 12, 283, 1084, 314, 11327, 26, 7626, 13, 466, 3324, 334, 6836, 5931, 409, 11327, 26, 7626, 13, 466, 1834, 15, 4524, 7092, 1333, 398, 1584, 275, 791, 15, 12117, 15, 1805, 8083, 954, 1023, 15, 888, 356, 283, 4296, 13, 2495, 13, 6750, 275, 9456, 60, 78, 4856, 4524, 275, 11327, 26, 7626, 13, 466, 29, 1569, 15, 4524, 936, 267, 7449, 275, 4420, 17521, 8, 1725, 9, 267, 25811, 275, 4420, 5153, 45, 24402, 360, 3187, 358, 267, 2552, 275, 942, 267, 7739, 275, 26951, 3048, 480, 888, 401, 1683, 63, 2479, 63, 2487, 63, 705, 12, 25811, 12, 4420, 3989, 4965, 8, 736, 63, 354, 534, 5135, 297, 10036, 29, 2319, 430, 267, 7739, 14, 1074, 342, 267, 291, 14, 629, 8, 552, 8, 2550, 395, 378, 9, 398, 1584, 275, 791, 15, 12117, 15, 1805, 8083, 954, 1023, 15, 888, 356, 3943, 4296, 13, 2495, 13, 6750, 275, 9456, 936, 267, 7449, 275, 4420, 17521, 8, 1725, 9, 267, 25811, 275, 4420, 5153, 45, 24402, 360, 3187, 358, 267, 2552, 275, 942, 267, 7739, 275, 26951, 3048, 480, 888, 401, 1683, 63, 2479, 63, 2487, 63, 705, 12, 25811, 12, 4420, 3989, 4965, 8, 736, 63, 354, 534, 5135, 297, 10036, 29, 2319, 430, 267, 7739, 14, 1074, 342, 267, 291, 14, 629, 8, 552, 8, 2550, 395, 413, 9, 398, 1584, 275, 791, 15, 12117, 15, 1805, 8083, 954, 1023, 15, 888, 356, 283, 4296, 13, 2495, 13, 6750, 275, 9456, 60, 78, 3, 4296, 13, 2495, 13, 6750, 275, 9456, 60, 78, 4856, 4524, 275, 11327, 26, 7626, 13, 466, 29, 1569, 15, 4524, 936, 267, 7449, 275, 4420, 17521, 8, 1725, 9, 267, 25811, 275, 4420, 5153, 45, 24402, 360, 3187, 358, 267, 2552, 275, 942, 267, 7739, 275, 26951, 3048, 480, 888, 401, 1683, 63, 2479, 63, 2487, 63, 705, 12, 25811, 12, 4420, 3989, 4965, 8, 736, 63, 354, 534, 5135, 297, 10036, 29, 2319, 430, 267, 7739, 14, 1074, 342, 267, 291, 14, 629, 8, 552, 8, 2550, 395, 378, 9, 398, 1584, 275, 791, 15, 12117, 15, 1805, 8083, 954, 1023, 15, 888, 356, 3943, 4296, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
huiyiqun/check_mk
cmk_base/core.py
1
9266
#!/usr/bin/python # -*- encoding: utf-8; py-indent-offset: 4 -*- # +------------------------------------------------------------------+ # | ____ _ _ __ __ _ __ | # | / ___| |__ ___ ___| | __ | \/ | |/ / | # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | # | | |___| | | | __/ (__| < | | | | . \ | # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | # | | # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de | # +------------------------------------------------------------------+ # # This file is part of Check_MK. # The official homepage is at http://mathias-kettner.de/check_mk. # # check_mk 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 in version 2. check_mk is distributed # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU General Public License for more de- # tails. You should have received a copy of the GNU General Public # License along with GNU Make; see the file COPYING. If not, write # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA. """All core related things like direct communication with the running core""" import fcntl import os import socket import subprocess import sys import cmk.paths import cmk.debug import cmk.tty as tty import livestatus from cmk.exceptions import MKGeneralException import cmk_base.console as console import cmk_base.config as config import cmk_base.core_config as core_config import cmk_base.core_nagios as core_nagios from cmk_base.exceptions import MKTimeout from cmk_base import config_cache try: import cmk_base.cee.core_cmc as core_cmc except ImportError: core_cmc = None _restart_lock_fd = None #. # .--Control-------------------------------------------------------------. # | ____ _ _ | # | / ___|___ _ __ | |_ _ __ ___ | | | # | | | / _ \| '_ \| __| '__/ _ \| | | # | | |__| (_) | | | | |_| | | (_) | | | # | \____\___/|_| |_|\__|_| \___/|_| | # | | # +----------------------------------------------------------------------+ # | Invoke actions affecting the core like reload/restart | # '----------------------------------------------------------------------' def do_reload(): do_restart(True) # TODO: Cleanup duplicate code with automation_restart() def do_restart(only_reload = False): try: backup_path = None if try_get_activation_lock(): # TODO: Replace by MKBailOut()/MKTerminate()? console.error("Other restart currently in progress. Aborting.\n") sys.exit(1) # Save current configuration if os.path.exists(cmk.paths.nagios_objects_file): backup_path = cmk.paths.nagios_objects_file + ".save" console.verbose("Renaming %s to %s\n", cmk.paths.nagios_objects_file, backup_path, stream=sys.stderr) os.rename(cmk.paths.nagios_objects_file, backup_path) else: backup_path = None try: core_config.do_create_config(with_agents=True) except Exception, e: # TODO: Replace by MKBailOut()/MKTerminate()? console.error("Error creating configuration: %s\n" % e) if backup_path: os.rename(backup_path, cmk.paths.nagios_objects_file) if cmk.debug.enabled(): raise sys.exit(1) if config.monitoring_core == "cmc" or core_nagios.do_check_nagiosconfig(): if backup_path: os.remove(backup_path) core_config.precompile() do_core_action(only_reload and "reload" or "restart") else: # TODO: Replace by MKBailOut()/MKTerminate()? console.error("Configuration for monitoring core is invalid. Rolling back.\n") broken_config_path = "%s/check_mk_objects.cfg.broken" % cmk.paths.tmp_dir file(broken_config_path, "w").write(file(cmk.paths.nagios_objects_file).read()) console.error("The broken file has been copied to \"%s\" for analysis.\n" % broken_config_path) if backup_path: os.rename(backup_path, cmk.paths.nagios_objects_file) else: os.remove(cmk.paths.nagios_objects_file) sys.exit(1) except Exception, e: try: if backup_path and os.path.exists(backup_path): os.remove(backup_path) except: pass if cmk.debug.enabled(): raise # TODO: Replace by MKBailOut()/MKTerminate()? console.error("An error occurred: %s\n" % e) sys.exit(1) def try_get_activation_lock(): global _restart_lock_fd # In some bizarr cases (as cmk -RR) we need to avoid duplicate locking! if config.restart_locking and _restart_lock_fd == None: lock_file = cmk.paths.default_config_dir + "/main.mk" _restart_lock_fd = os.open(lock_file, os.O_RDONLY) # Make sure that open file is not inherited to monitoring core! fcntl.fcntl(_restart_lock_fd, fcntl.F_SETFD, fcntl.FD_CLOEXEC) try: console.verbose("Waiting for exclusive lock on %s.\n" % lock_file, stream=sys.stderr) fcntl.flock(_restart_lock_fd, fcntl.LOCK_EX | ( config.restart_locking == "abort" and fcntl.LOCK_NB or 0)) except: return True return False # Action can be restart, reload, start or stop def do_core_action(action, quiet=False): if not quiet: console.output("%sing monitoring core..." % action.title()) if config.monitoring_core == "nagios": os.putenv("CORE_NOVERIFY", "yes") command = [ "%s/etc/init.d/core" % cmk.paths.omd_root, action ] else: command = [ "omd", action, "cmc" ] p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) result = p.wait() if result != 0: output = p.stdout.read() if not quiet: console.output("ERROR: %s\n" % output) raise MKGeneralException("Cannot %s the monitoring core: %s" % (action, output)) else: if not quiet: console.output(tty.ok + "\n") #. # .--Timeperiods---------------------------------------------------------. # | _____ _ _ _ | # | |_ _(_)_ __ ___ ___ _ __ ___ _ __(_) ___ __| |___ | # | | | | | '_ ` _ \ / _ \ '_ \ / _ \ '__| |/ _ \ / _` / __| | # | | | | | | | | | | __/ |_) | __/ | | | (_) | (_| \__ \ | # | |_| |_|_| |_| |_|\___| .__/ \___|_| |_|\___/ \__,_|___/ | # | |_| | # +----------------------------------------------------------------------+ # | Fetching timeperiods from the core | # '----------------------------------------------------------------------' # Check if a timeperiod is currently active. We have no other way than # doing a Livestatus query. This is not really nice, but if you have a better # idea, please tell me... def check_timeperiod(timeperiod): # Let exceptions happen, they will be handled upstream. try: update_timeperiods_cache() except MKTimeout: raise except: if cmk.debug.enabled(): raise # If the query is not successful better skip this check then fail return True # Note: This also returns True when the timeperiod is unknown # The following function timeperiod_active handles this differently return config_cache.get_dict("timeperiods_cache").get(timeperiod, True) == True # Returns # True : active # False: inactive # None : unknown timeperiod # # Raises an exception if e.g. a timeout or connection error appears. # This way errors can be handled upstream. def timeperiod_active(timeperiod): update_timeperiods_cache() return config_cache.get_dict("timeperiods_cache").get(timeperiod) def update_timeperiods_cache(): # { "last_update": 1498820128, "timeperiods": [{"24x7": True}] } # The value is store within the config cache since we need a fresh start on reload tp_cache = config_cache.get_dict("timeperiods_cache") if not tp_cache: response = livestatus.LocalConnection().query("GET timeperiods\nColumns: name in") for tp_name, tp_active in response: tp_cache[tp_name] = bool(tp_active) def cleanup_timeperiod_caches(): config_cache.get_dict("timeperiods_cache").clear()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2644, 26, 2774, 13, 24, 27, 1134, 13, 3724, 13, 2743, 26, 841, 1882, 199, 3, 435, 3606, 12557, 199, 3, 1204, 3777, 636, 363, 485, 5185, 485, 263, 636, 221, 636, 485, 221, 636, 3698, 1204, 199, 3, 1204, 3322, 1182, 31111, 92, 1204, 363, 257, 31111, 221, 31111, 92, 1204, 636, 257, 1204, 221, 971, 15, 221, 1204, 1204, 15, 1182, 3698, 1204, 199, 3, 1204, 3698, 1204, 1204, 257, 1204, 2513, 971, 1182, 485, 971, 15, 636, 92, 1204, 15, 1182, 257, 1204, 12196, 15, 92, 1204, 283, 1182, 3322, 1204, 199, 3, 1204, 3698, 1204, 1204, 8989, 92, 1204, 1204, 1204, 221, 636, 15, 25373, 92, 257, 665, 259, 1204, 1204, 221, 1204, 1204, 1275, 971, 3322, 1204, 199, 3, 1204, 3322, 971, 4741, 30007, 92, 1204, 63, 6113, 8989, 6113, 8989, 30007, 6113, 18005, 8989, 30007, 92, 221, 1204, 63, 30007, 6113, 18005, 3698, 1204, 199, 3, 1204, 6208, 221, 1204, 199, 3, 1204, 1898, 21066, 2241, 1804, 386, 84, 1372, 6927, 3777, 9199, 32, 3442, 2241, 13, 75, 386, 84, 1372, 14, 271, 1204, 199, 3, 435, 3606, 12557, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2670, 63, 18379, 14, 199, 3, 710, 25410, 26586, 365, 737, 1455, 921, 3442, 2241, 13, 75, 386, 84, 1372, 14, 271, 15, 1074, 63, 3880, 14, 199, 3, 199, 3, 1104, 63, 3880, 365, 2867, 2032, 27, 221, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 221, 2895, 402, 314, 221, 1664, 1696, 1684, 844, 221, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 315, 1015, 499, 14, 221, 1104, 63, 3880, 365, 221, 1854, 199, 3, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 221, 543, 13, 199, 3, 734, 2755, 314, 2478, 3750, 402, 221, 3169, 221, 503, 221, 3092, 2381, 437, 199, 3, 3115, 3104, 14, 1666, 314, 221, 1664, 1696, 1684, 844, 367, 1655, 477, 13, 199, 3, 9483, 83, 14, 2047, 1077, 1172, 221, 3086, 221, 282, 1331, 402, 314, 221, 1664, 221, 1696, 1684, 199, 3, 844, 3180, 543, 1664, 4155, 27, 1937, 314, 570, 221, 9685, 14, 221, 982, 221, 440, 12, 221, 2218, 199, 3, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 221, 12066, 11844, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 199, 624, 2422, 6170, 4048, 7645, 2839, 4125, 23506, 543, 314, 3879, 6170, 624, 199, 199, 646, 12871, 199, 646, 747, 199, 646, 2838, 199, 646, 3873, 199, 646, 984, 199, 199, 646, 286, 3880, 14, 3771, 199, 646, 286, 3880, 14, 1757, 199, 646, 286, 3880, 14, 4707, 465, 21862, 199, 646, 12166, 1205, 199, 504, 286, 3880, 14, 3924, 492, 603, 43, 14109, 1726, 199, 199, 646, 286, 3880, 63, 1095, 14, 6614, 465, 8559, 199, 646, 286, 3880, 63, 1095, 14, 888, 465, 1101, 199, 646, 286, 3880, 63, 1095, 14, 1018, 63, 888, 465, 6170, 63, 888, 199, 646, 286, 3880, 63, 1095, 14, 1018, 63, 28084, 465, 6170, 63, 28084, 199, 504, 286, 3880, 63, 1095, 14, 3924, 492, 603, 43, 6372, 199, 504, 286, 3880, 63, 1095, 492, 1101, 63, 1637, 199, 199, 893, 26, 272, 492, 286, 3880, 63, 1095, 14, 29377, 14, 1018, 63, 4400, 67, 465, 6170, 63, 4400, 67, 199, 2590, 3545, 26, 272, 6170, 63, 4400, 67, 275, 488, 199, 199, 63, 10506, 63, 831, 63, 2592, 275, 488, 199, 199, 31827, 199, 3, 257, 1275, 306, 3717, 6489, 8684, 14, 199, 3, 257, 1204, 7861, 636, 363, 3322, 485, 3777, 485, 8540, 1204, 199, 3, 257, 1204, 8295, 1182, 31111, 92, 8989, 221, 485, 636, 1204, 1204, 63, 485, 636, 31111, 1204, 1204, 7861, 1204, 199, 3, 257, 1204, 463, 1204, 1204, 257, 1182, 485, 971, 92, 2513, 971, 92, 636, 92, 2560, 15, 485, 971, 92, 1204, 7861, 1204, 199, 3, 257, 1204, 463, 1204, 1204, 363, 92, 334, 4602, 1204, 1204, 1204, 1204, 1204, 63, 92, 1204, 1204, 334, 4602, 1204, 1204, 7861, 1204, 199, 3, 257, 1204, 8295, 971, 4741, 60, 8989, 15, 30007, 92, 1204, 63, 6113, 363, 30007, 92, 221, 971, 8989, 15, 30007, 92, 7861, 1204, 199, 3, 257, 1204, 6208, 420, 1204, 199, 3, 257, 435, 3606, 28712, 199, 3, 257, 1204, 31049, 5445, 12787, 316, 314, 6170, 2839, 13101, 15, 10506, 4483, 1204, 199, 3, 257, 283, 3606, 8648, 7, 199, 199, 318, 886, 63, 9233, 837, 272, 886, 63, 10506, 8, 549, 9, 421, 199, 3, 3254, 26, 30022, 9250, 1233, 543, 25461, 63, 10506, 342, 199, 318, 886, 63, 10506, 8, 2118, 63, 9233, 275, 756, 304, 272, 862, 26, 267, 6902, 63, 515, 275, 488, 398, 340, 862, 63, 362, 63, 12312, 63, 831, 837, 288, 327, 3254, 26, 14402, 701, 603, 12780, 1054, 2204, 29728, 18379, 12154, 323, 342, 31, 288, 8559, 14, 705, 480, 8632, 11004, 5544, 315, 6696, 14, 31455, 316, 3134, 78, 531, 288, 984, 14, 2224, 8, 17, 9, 398, 327, 11063, 1453, 2897, 267, 340, 747, 14, 515, 14, 2444, 8, 67, 3880, 14, 3771, 14, 28084, 63, 1462, 63, 493, 304, 288, 6902, 63, 515, 275, 286, 3880, 14, 3771, 14, 28084, 63, 1462, 63, 493, 435, 3680, 2117, 2, 288, 8559, 14, 3832, 480, 5349, 9568, 450, 83, 370, 450, 83, 60, 78, 401, 286, 3880, 14, 3771, 14, 28084, 63, 1462, 63, 493, 12, 6902, 63, 515, 12, 2547, 29, 1274, 14, 3083, 9, 288, 747, 14, 8165, 8, 67, 3880, 14, 3771, 14, 28084, 63, 1462, 63, 493, 12, 6902, 63, 515, 9, 267, 587, 26, 288, 6902, 63, 515, 275, 488, 398, 862, 26, 288, 6170, 63, 888, 14, 1117, 63, 981, 63, 888, 8, 1045, 63, 14250, 29, 549, 9, 267, 871, 2186, 12, 325, 26, 288, 327, 3254, 26, 14402, 701, 603, 12780, 1054, 2204, 29728, 18379, 12154, 323, 342, 31, 288, 8559, 14, 705, 480, 547, 6425, 2897, 26, 450, 83, 60, 78, 2, 450, 325, 9, 288, 340, 6902, 63, 515, 26, 355, 747, 14, 8165, 8, 5751, 63, 515 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2644, 26, 2774, 13, 24, 27, 1134, 13, 3724, 13, 2743, 26, 841, 1882, 199, 3, 435, 3606, 12557, 199, 3, 1204, 3777, 636, 363, 485, 5185, 485, 263, 636, 221, 636, 485, 221, 636, 3698, 1204, 199, 3, 1204, 3322, 1182, 31111, 92, 1204, 363, 257, 31111, 221, 31111, 92, 1204, 636, 257, 1204, 221, 971, 15, 221, 1204, 1204, 15, 1182, 3698, 1204, 199, 3, 1204, 3698, 1204, 1204, 257, 1204, 2513, 971, 1182, 485, 971, 15, 636, 92, 1204, 15, 1182, 257, 1204, 12196, 15, 92, 1204, 283, 1182, 3322, 1204, 199, 3, 1204, 3698, 1204, 1204, 8989, 92, 1204, 1204, 1204, 221, 636, 15, 25373, 92, 257, 665, 259, 1204, 1204, 221, 1204, 1204, 1275, 971, 3322, 1204, 199, 3, 1204, 3322, 971, 4741, 30007, 92, 1204, 63, 6113, 8989, 6113, 8989, 30007, 6113, 18005, 8989, 30007, 92, 221, 1204, 63, 30007, 6113, 18005, 3698, 1204, 199, 3, 1204, 6208, 221, 1204, 199, 3, 1204, 1898, 21066, 2241, 1804, 386, 84, 1372, 6927, 3777, 9199, 32, 3442, 2241, 13, 75, 386, 84, 1372, 14, 271, 1204, 199, 3, 435, 3606, 12557, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2670, 63, 18379, 14, 199, 3, 710, 25410, 26586, 365, 737, 1455, 921, 3442, 2241, 13, 75, 386, 84, 1372, 14, 271, 15, 1074, 63, 3880, 14, 199, 3, 199, 3, 1104, 63, 3880, 365, 2867, 2032, 27, 221, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 1334, 314, 221, 2895, 402, 314, 221, 1664, 1696, 1684, 844, 221, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 315, 1015, 499, 14, 221, 1104, 63, 3880, 365, 221, 1854, 199, 3, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 221, 543, 13, 199, 3, 734, 2755, 314, 2478, 3750, 402, 221, 3169, 221, 503, 221, 3092, 2381, 437, 199, 3, 3115, 3104, 14, 1666, 314, 221, 1664, 1696, 1684, 844, 367, 1655, 477, 13, 199, 3, 9483, 83, 14, 2047, 1077, 1172, 221, 3086, 221, 282, 1331, 402, 314, 221, 1664, 221, 1696, 1684, 199, 3, 844, 3180, 543, 1664, 4155, 27, 1937, 314, 570, 221, 9685, 14, 221, 982, 221, 440, 12, 221, 2218, 199, 3, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 1933, 12, 221, 12066, 11844, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 199, 624, 2422, 6170, 4048, 7645, 2839, 4125, 23506, 543, 314, 3879, 6170, 624, 199, 199, 646, 12871, 199, 646, 747, 199, 646, 2838, 199, 646, 3873, 199, 646, 984, 199, 199, 646, 286, 3880, 14, 3771, 199, 646, 286, 3880, 14, 1757, 199, 646, 286, 3880, 14, 4707, 465, 21862, 199, 646, 12166, 1205, 199, 504, 286, 3880, 14, 3924, 492, 603, 43, 14109, 1726, 199, 199, 646, 286, 3880, 63, 1095, 14, 6614, 465, 8559, 199, 646, 286, 3880, 63, 1095, 14, 888, 465, 1101, 199, 646, 286, 3880, 63, 1095, 14, 1018, 63, 888, 465, 6170, 63, 888, 199, 646, 286, 3880, 63, 1095, 14, 1018, 63, 28084, 465, 6170, 63, 28084, 199, 504, 286, 3880, 63, 1095, 14, 3924, 492, 603, 43, 6372, 199, 504, 286, 3880, 63, 1095, 492, 1101, 63, 1637, 199, 199, 893, 26, 272, 492, 286, 3880, 63, 1095, 14, 29377, 14, 1018, 63, 4400, 67, 465, 6170, 63, 4400, 67, 199, 2590, 3545, 26, 272, 6170, 63, 4400, 67, 275, 488, 199, 199, 63, 10506, 63, 831, 63, 2592, 275, 488, 199, 199, 31827, 199, 3, 257, 1275, 306, 3717, 6489, 8684, 14, 199, 3, 257, 1204, 7861, 636, 363, 3322, 485, 3777, 485, 8540, 1204, 199, 3, 257, 1204, 8295, 1182, 31111, 92, 8989, 221, 485, 636, 1204, 1204, 63, 485, 636, 31111, 1204, 1204, 7861, 1204, 199, 3, 257, 1204, 463, 1204, 1204, 257, 1182, 485, 971, 92, 2513, 971, 92, 636, 92, 2560, 15, 485, 971, 92, 1204, 7861, 1204, 199, 3, 257, 1204, 463, 1204, 1204, 363, 92, 334, 4602, 1204, 1204, 1204, 1204, 1204, 63, 92, 1204, 1204, 334, 4602, 1204, 1204, 7861, 1204, 199, 3, 257, 1204, 8295, 971, 4741, 60, 8989, 15, 30007, 92, 1204, 63, 6113, 363, 30007, 92, 221, 971, 8989, 15, 30007, 92, 7861, 1204, 199, 3, 257, 1204, 6208, 420, 1204, 199, 3, 257, 435, 3606, 28712, 199, 3, 257, 1204, 31049, 5445, 12787, 316, 314, 6170, 2839, 13101, 15, 10506, 4483, 1204, 199, 3, 257, 283, 3606, 8648, 7, 199, 199, 318, 886, 63, 9233, 837, 272, 886, 63, 10506, 8, 549, 9, 421, 199, 3, 3254, 26, 30022, 9250, 1233, 543, 25461, 63, 10506, 342, 199, 318, 886, 63, 10506, 8, 2118, 63, 9233, 275, 756, 304, 272, 862, 26, 267, 6902, 63, 515, 275, 488, 398, 340, 862, 63, 362, 63, 12312, 63, 831, 837, 288, 327, 3254, 26, 14402, 701, 603, 12780, 1054, 2204, 29728, 18379, 12154, 323, 342, 31, 288, 8559, 14, 705, 480, 8632, 11004, 5544, 315, 6696, 14, 31455, 316, 3134, 78, 531, 288, 984, 14, 2224, 8, 17, 9, 398, 327, 11063, 1453, 2897, 267, 340, 747, 14, 515, 14, 2444, 8, 67, 3880, 14, 3771, 14, 28084, 63, 1462, 63, 493, 304, 288, 6902, 63, 515, 275, 286, 3880, 14, 3771, 14, 28084, 63, 1462, 63, 493, 435, 3680, 2117, 2, 288, 8559, 14, 3832, 480, 5349, 9568, 450, 83, 370, 450, 83, 60, 78, 401, 286, 3880, 14, 3771, 14, 28084, 63, 1462, 63, 493, 12, 6902, 63, 515, 12, 2547, 29, 1274, 14, 3083, 9, 288, 747, 14, 8165, 8, 67, 3880, 14, 3771, 14, 28084, 63, 1462, 63, 493, 12, 6902, 63, 515, 9, 267, 587, 26, 288, 6902, 63, 515, 275, 488, 398, 862, 26, 288, 6170, 63, 888, 14, 1117, 63, 981, 63, 888, 8, 1045, 63, 14250, 29, 549, 9, 267, 871, 2186, 12, 325, 26, 288, 327, 3254, 26, 14402, 701, 603, 12780, 1054, 2204, 29728, 18379, 12154, 323, 342, 31, 288, 8559, 14, 705, 480, 547, 6425, 2897, 26, 450, 83, 60, 78, 2, 450, 325, 9, 288, 340, 6902, 63, 515, 26, 355, 747, 14, 8165, 8, 5751, 63, 515, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
keithlee/shakeAppPyDev
django/http/multipartparser.py
87
22774
""" Multi-part parsing for file uploads. Exposes one class, ``MultiPartParser``, which feeds chunks of uploaded data to file upload handlers for processing. """ import cgi from django.conf import settings from django.core.exceptions import SuspiciousOperation from django.utils.datastructures import MultiValueDict from django.utils.encoding import force_unicode from django.utils.text import unescape_entities from django.core.files.uploadhandler import StopUpload, SkipFile, StopFutureHandlers __all__ = ('MultiPartParser', 'MultiPartParserError', 'InputStreamExhausted') class MultiPartParserError(Exception): pass class InputStreamExhausted(Exception): """ No more reads are allowed from this device. """ pass RAW = "raw" FILE = "file" FIELD = "field" class MultiPartParser(object): """ A rfc2388 multipart/form-data parser. ``MultiValueDict.parse()`` reads the input stream in ``chunk_size`` chunks and returns a tuple of ``(MultiValueDict(POST), MultiValueDict(FILES))``. If """ def __init__(self, META, input_data, upload_handlers, encoding=None): """ Initialize the MultiPartParser object. :META: The standard ``META`` dictionary in Django request objects. :input_data: The raw post data, as a file-like object. :upload_handler: An UploadHandler instance that performs operations on the uploaded data. :encoding: The encoding with which to treat the incoming data. """ # # Content-Type should containt multipart and the boundary information. # content_type = META.get('HTTP_CONTENT_TYPE', META.get('CONTENT_TYPE', '')) if not content_type.startswith('multipart/'): raise MultiPartParserError('Invalid Content-Type: %s' % content_type) # Parse the header to get the boundary to split the parts. ctypes, opts = parse_header(content_type) boundary = opts.get('boundary') if not boundary or not cgi.valid_boundary(boundary): raise MultiPartParserError('Invalid boundary in multipart: %s' % boundary) # # Content-Length should contain the length of the body we are about # to receive. # try: content_length = int(META.get('HTTP_CONTENT_LENGTH', META.get('CONTENT_LENGTH',0))) except (ValueError, TypeError): # For now set it to 0; we'll try again later on down. content_length = 0 if content_length <= 0: # This means we shouldn't continue...raise an error. raise MultiPartParserError("Invalid content length: %r" % content_length) self._boundary = boundary self._input_data = input_data # For compatibility with low-level network APIs (with 32-bit integers), # the chunk size should be < 2^31, but still divisible by 4. possible_sizes = [x.chunk_size for x in upload_handlers if x.chunk_size] self._chunk_size = min([2**31-4] + possible_sizes) self._meta = META self._encoding = encoding or settings.DEFAULT_CHARSET self._content_length = content_length self._upload_handlers = upload_handlers def parse(self): """ Parse the POST data and break it into a FILES MultiValueDict and a POST MultiValueDict. Returns a tuple containing the POST and FILES dictionary, respectively. """ # We have to import QueryDict down here to avoid a circular import. from django.http import QueryDict encoding = self._encoding handlers = self._upload_handlers limited_input_data = LimitBytes(self._input_data, self._content_length) # See if the handler will want to take care of the parsing. # This allows overriding everything if somebody wants it. for handler in handlers: result = handler.handle_raw_input(limited_input_data, self._meta, self._content_length, self._boundary, encoding) if result is not None: return result[0], result[1] # Create the data structures to be used later. self._post = QueryDict('', mutable=True) self._files = MultiValueDict() # Instantiate the parser and stream: stream = LazyStream(ChunkIter(limited_input_data, self._chunk_size)) # Whether or not to signal a file-completion at the beginning of the loop. old_field_name = None counters = [0] * len(handlers) try: for item_type, meta_data, field_stream in Parser(stream, self._boundary): if old_field_name: # We run this at the beginning of the next loop # since we cannot be sure a file is complete until # we hit the next boundary/part of the multipart content. self.handle_file_complete(old_field_name, counters) old_field_name = None try: disposition = meta_data['content-disposition'][1] field_name = disposition['name'].strip() except (KeyError, IndexError, AttributeError): continue transfer_encoding = meta_data.get('content-transfer-encoding') field_name = force_unicode(field_name, encoding, errors='replace') if item_type == FIELD: # This is a post field, we can just set it in the post if transfer_encoding == 'base64': raw_data = field_stream.read() try: data = str(raw_data).decode('base64') except: data = raw_data else: data = field_stream.read() self._post.appendlist(field_name, force_unicode(data, encoding, errors='replace')) elif item_type == FILE: # This is a file, use the handler... file_name = disposition.get('filename') if not file_name: continue file_name = force_unicode(file_name, encoding, errors='replace') file_name = self.IE_sanitize(unescape_entities(file_name)) content_type = meta_data.get('content-type', ('',))[0].strip() content_type_extra = meta_data.get('content-type', (0,{}))[1] if content_type_extra is None: content_type_extra = {} try: charset = content_type_extra.get('charset', None) except: charset = None try: content_length = int(meta_data.get('content-length')[0]) except (IndexError, TypeError, ValueError): content_length = None counters = [0] * len(handlers) try: for handler in handlers: try: handler.new_file(field_name, file_name, content_type, content_length, charset, content_type_extra.copy()) except StopFutureHandlers: break for chunk in field_stream: if transfer_encoding == 'base64': # We only special-case base64 transfer encoding try: chunk = str(chunk).decode('base64') except Exception, e: # Since this is only a chunk, any error is an unfixable error. raise MultiPartParserError("Could not decode base64 data: %r" % e) for i, handler in enumerate(handlers): chunk_length = len(chunk) chunk = handler.receive_data_chunk(chunk, counters[i]) counters[i] += chunk_length if chunk is None: # If the chunk received by the handler is None, then don't continue. break except SkipFile, e: # Just use up the rest of this file... exhaust(field_stream) else: # Handle file upload completions on next iteration. old_field_name = field_name else: # If this is neither a FIELD or a FILE, just exhaust the stream. exhaust(stream) except StopUpload, e: if not e.connection_reset: exhaust(limited_input_data) else: # Make sure that the request data is all fed exhaust(limited_input_data) # Signal that the upload has completed. for handler in handlers: retval = handler.upload_complete() if retval: break return self._post, self._files def handle_file_complete(self, old_field_name, counters): """ Handle all the signalling that takes place when a file is complete. """ for i, handler in enumerate(self._upload_handlers): file_obj = handler.file_complete(counters[i]) if file_obj: # If it returns a file object, then set the files dict. self._files.appendlist(force_unicode(old_field_name, self._encoding, errors='replace'), file_obj) break def IE_sanitize(self, filename): """Cleanup filename from Internet Explorer full paths.""" return filename and filename[filename.rfind("\\")+1:].strip() class LazyStream(object): """ The LazyStream wrapper allows one to get and "unget" bytes from a stream. Given a producer object (an iterator that yields bytestrings), the LazyStream object will support iteration, reading, and keeping a "look-back" variable in case you need to "unget" some bytes. """ def __init__(self, producer, length=None): """ Every LazyStream must have a producer when instantiated. A producer is an iterable that returns a string each time it is called. """ self._producer = producer self._empty = False self._leftover = '' self.length = length self.position = 0 self._remaining = length self._unget_history = [] def tell(self): return self.position def read(self, size=None): def parts(): remaining = (size is not None and [size] or [self._remaining])[0] # do the whole thing in one shot if no limit was provided. if remaining is None: yield ''.join(self) return # otherwise do some bookkeeping to return exactly enough # of the stream and stashing any extra content we get from # the producer while remaining != 0: assert remaining > 0, 'remaining bytes to read should never go negative' chunk = self.next() emitting = chunk[:remaining] self.unget(chunk[remaining:]) remaining -= len(emitting) yield emitting out = ''.join(parts()) return out def next(self): """ Used when the exact number of bytes to read is unimportant. This procedure just returns whatever is chunk is conveniently returned from the iterator instead. Useful to avoid unnecessary bookkeeping if performance is an issue. """ if self._leftover: output = self._leftover self._leftover = '' else: output = self._producer.next() self._unget_history = [] self.position += len(output) return output def close(self): """ Used to invalidate/disable this lazy stream. Replaces the producer with an empty list. Any leftover bytes that have already been read will still be reported upon read() and/or next(). """ self._producer = [] def __iter__(self): return self def unget(self, bytes): """ Places bytes back onto the front of the lazy stream. Future calls to read() will return those bytes first. The stream position and thus tell() will be rewound. """ if not bytes: return self._update_unget_history(len(bytes)) self.position -= len(bytes) self._leftover = ''.join([bytes, self._leftover]) def _update_unget_history(self, num_bytes): """ Updates the unget history as a sanity check to see if we've pushed back the same number of bytes in one chunk. If we keep ungetting the same number of bytes many times (here, 50), we're mostly likely in an infinite loop of some sort. This is usually caused by a maliciously-malformed MIME request. """ self._unget_history = [num_bytes] + self._unget_history[:49] number_equal = len([current_number for current_number in self._unget_history if current_number == num_bytes]) if number_equal > 40: raise SuspiciousOperation( "The multipart parser got stuck, which shouldn't happen with" " normal uploaded files. Check for malicious upload activity;" " if there is none, report this to the Django developers." ) class ChunkIter(object): """ An iterable that will yield chunks of data. Given a file-like object as the constructor, this object will yield chunks of read operations from that object. """ def __init__(self, flo, chunk_size=64 * 1024): self.flo = flo self.chunk_size = chunk_size def next(self): try: data = self.flo.read(self.chunk_size) except InputStreamExhausted: raise StopIteration() if data: return data else: raise StopIteration() def __iter__(self): return self class LimitBytes(object): """ Limit bytes for a file object. """ def __init__(self, fileobject, length): self._file = fileobject self.remaining = length def read(self, num_bytes=None): """ Read data from the underlying file. If you ask for too much or there isn't anything left, this will raise an InputStreamExhausted error. """ if self.remaining <= 0: raise InputStreamExhausted() if num_bytes is None: num_bytes = self.remaining else: num_bytes = min(num_bytes, self.remaining) self.remaining -= num_bytes return self._file.read(num_bytes) class InterBoundaryIter(object): """ A Producer that will iterate over boundaries. """ def __init__(self, stream, boundary): self._stream = stream self._boundary = boundary def __iter__(self): return self def next(self): try: return LazyStream(BoundaryIter(self._stream, self._boundary)) except InputStreamExhausted: raise StopIteration() class BoundaryIter(object): """ A Producer that is sensitive to boundaries. Will happily yield bytes until a boundary is found. Will yield the bytes before the boundary, throw away the boundary bytes themselves, and push the post-boundary bytes back on the stream. The future calls to .next() after locating the boundary will raise a StopIteration exception. """ def __init__(self, stream, boundary): self._stream = stream self._boundary = boundary self._done = False # rollback an additional six bytes because the format is like # this: CRLF<boundary>[--CRLF] self._rollback = len(boundary) + 6 # Try to use mx fast string search if available. Otherwise # use Python find. Wrap the latter for consistency. unused_char = self._stream.read(1) if not unused_char: raise InputStreamExhausted() self._stream.unget(unused_char) try: from mx.TextTools import FS self._fs = FS(boundary).find except ImportError: self._fs = lambda data: data.find(boundary) def __iter__(self): return self def next(self): if self._done: raise StopIteration() stream = self._stream rollback = self._rollback bytes_read = 0 chunks = [] for bytes in stream: bytes_read += len(bytes) chunks.append(bytes) if bytes_read > rollback: break if not bytes: break else: self._done = True if not chunks: raise StopIteration() chunk = ''.join(chunks) boundary = self._find_boundary(chunk, len(chunk) < self._rollback) if boundary: end, next = boundary stream.unget(chunk[next:]) self._done = True return chunk[:end] else: # make sure we dont treat a partial boundary (and # its separators) as data if not chunk[:-rollback]:# and len(chunk) >= (len(self._boundary) + 6): # There's nothing left, we should just return and mark as done. self._done = True return chunk else: stream.unget(chunk[-rollback:]) return chunk[:-rollback] def _find_boundary(self, data, eof = False): """ Finds a multipart boundary in data. Should no boundry exist in the data None is returned instead. Otherwise a tuple containing the indices of the following are returned: * the end of current encapsulation * the start of the next encapsulation """ index = self._fs(data) if index < 0: return None else: end = index next = index + len(self._boundary) # backup over CRLF if data[max(0,end-1)] == '\n': end -= 1 if data[max(0,end-1)] == '\r': end -= 1 return end, next def exhaust(stream_or_iterable): """ Completely exhausts an iterator or stream. Raise a MultiPartParserError if the argument is not a stream or an iterable. """ iterator = None try: iterator = iter(stream_or_iterable) except TypeError: iterator = ChunkIter(stream_or_iterable, 16384) if iterator is None: raise MultiPartParserError('multipartparser.exhaust() was passed a non-iterable or stream parameter') for __ in iterator: pass def parse_boundary_stream(stream, max_header_size): """ Parses one and exactly one stream that encapsulates a boundary. """ # Stream at beginning of header, look for end of header # and parse it if found. The header must fit within one # chunk. chunk = stream.read(max_header_size) # 'find' returns the top of these four bytes, so we'll # need to munch them later to prevent them from polluting # the payload. header_end = chunk.find('\r\n\r\n') def _parse_header(line): main_value_pair, params = parse_header(line) try: name, value = main_value_pair.split(':', 1) except: raise ValueError("Invalid header: %r" % line) return name, (value, params) if header_end == -1: # we find no header, so we just mark this fact and pass on # the stream verbatim stream.unget(chunk) return (RAW, {}, stream) header = chunk[:header_end] # here we place any excess chunk back onto the stream, as # well as throwing away the CRLFCRLF bytes from above. stream.unget(chunk[header_end + 4:]) TYPE = RAW outdict = {} # Eliminate blank lines for line in header.split('\r\n'): # This terminology ("main value" and "dictionary of # parameters") is from the Python docs. try: name, (value, params) = _parse_header(line) except: continue if name == 'content-disposition': TYPE = FIELD if params.get('filename'): TYPE = FILE outdict[name] = value, params if TYPE == RAW: stream.unget(chunk) return (TYPE, outdict, stream) class Parser(object): def __init__(self, stream, boundary): self._stream = stream self._separator = '--' + boundary def __iter__(self): boundarystream = InterBoundaryIter(self._stream, self._separator) for sub_stream in boundarystream: # Iterate over each part yield parse_boundary_stream(sub_stream, 1024) def parse_header(line): """ Parse the header into a key-value. """ plist = _parse_header_params(';' + line) key = plist.pop(0).lower() pdict = {} for p in plist: i = p.find('=') if i >= 0: name = p[:i].strip().lower() value = p[i+1:].strip() if len(value) >= 2 and value[0] == value[-1] == '"': value = value[1:-1] value = value.replace('\\\\', '\\').replace('\\"', '"') pdict[name] = value return key, pdict def _parse_header_params(s): plist = [] while s[:1] == ';': s = s[1:] end = s.find(';') while end > 0 and s.count('"', 0, end) % 2: end = s.find(';', end + 1) if end < 0: end = len(s) f = s[:end] plist.append(f.strip()) s = s[end:] return plist
bsd-3-clause
[ 624, 199, 3947, 13, 2064, 6057, 367, 570, 26598, 14, 199, 199, 920, 10553, 1373, 1021, 12, 1124, 3947, 8416, 2842, 4542, 1314, 22295, 8291, 402, 14238, 666, 370, 199, 493, 5802, 8297, 367, 6661, 14, 199, 624, 199, 199, 646, 16004, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 428, 28651, 6044, 199, 504, 1639, 14, 1208, 14, 23004, 492, 6879, 24811, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 199, 504, 1639, 14, 1208, 14, 505, 492, 22221, 63, 8327, 199, 504, 1639, 14, 1018, 14, 1725, 14, 5064, 2232, 492, 8015, 10301, 12, 8232, 1173, 12, 8015, 14224, 25096, 199, 199, 363, 452, 363, 275, 661, 3947, 8416, 2842, 297, 283, 3947, 8416, 21811, 297, 283, 27611, 920, 2411, 7274, 358, 199, 199, 533, 6879, 8416, 21811, 8, 1726, 304, 272, 986, 199, 199, 533, 6924, 3296, 920, 2411, 7274, 8, 1726, 304, 272, 408, 272, 3091, 1655, 11597, 787, 4370, 687, 642, 2243, 14, 272, 408, 272, 986, 199, 199, 4307, 275, 298, 1773, 2, 199, 3817, 275, 298, 493, 2, 199, 8609, 275, 298, 698, 2, 199, 199, 533, 6879, 8416, 2842, 8, 785, 304, 272, 408, 272, 437, 18158, 1789, 1299, 15193, 15, 964, 13, 576, 1798, 14, 339, 1124, 3947, 24811, 14, 1122, 8497, 11597, 314, 1324, 2547, 315, 1124, 4604, 63, 890, 1040, 8291, 272, 436, 2529, 282, 2008, 402, 15475, 3947, 24811, 8, 4030, 395, 6879, 24811, 8, 9472, 430, 4345, 982, 272, 408, 272, 347, 636, 826, 721, 277, 12, 603, 15808, 12, 1324, 63, 576, 12, 5802, 63, 5586, 12, 2644, 29, 403, 304, 267, 408, 267, 11578, 314, 6879, 8416, 2842, 909, 14, 398, 520, 10614, 26, 288, 710, 4465, 1124, 10614, 1040, 2600, 315, 5634, 1056, 2251, 14, 267, 520, 1210, 63, 576, 26, 288, 710, 3066, 2963, 666, 12, 465, 282, 570, 13, 2930, 909, 14, 267, 520, 5064, 63, 2232, 26, 288, 1626, 19149, 2461, 1256, 626, 18628, 5331, 641, 314, 14238, 288, 666, 14, 267, 520, 2991, 26, 288, 710, 2644, 543, 1314, 370, 14312, 314, 12467, 666, 14, 267, 408, 398, 327, 267, 327, 6646, 13, 804, 1077, 406, 502, 442, 15193, 436, 314, 8424, 2556, 14, 267, 327, 398, 1564, 63, 466, 275, 603, 15808, 14, 362, 360, 2856, 63, 9663, 63, 2711, 297, 603, 15808, 14, 362, 360, 9663, 63, 2711, 297, 12381, 267, 340, 440, 1564, 63, 466, 14, 2460, 360, 10123, 26985, 288, 746, 6879, 8416, 21811, 360, 3364, 6646, 13, 804, 26, 450, 83, 7, 450, 1564, 63, 466, 9, 398, 327, 6077, 314, 1406, 370, 664, 314, 8424, 370, 3715, 314, 4184, 14, 267, 5577, 12, 3999, 275, 2198, 63, 1291, 8, 1317, 63, 466, 9, 267, 8424, 275, 3999, 14, 362, 360, 9891, 358, 267, 340, 440, 8424, 503, 440, 16004, 14, 1078, 63, 9891, 8, 9891, 304, 288, 746, 6879, 8416, 21811, 360, 3364, 8424, 315, 15193, 26, 450, 83, 7, 450, 8424, 9, 7318, 327, 267, 327, 6646, 13, 4625, 1077, 1395, 314, 2582, 402, 314, 2396, 781, 787, 3595, 267, 327, 370, 9128, 14, 267, 327, 267, 862, 26, 288, 1564, 63, 1267, 275, 1109, 8, 10614, 14, 362, 360, 2856, 63, 9663, 63, 9127, 297, 603, 15808, 14, 362, 360, 9663, 63, 9127, 297, 16, 1724, 267, 871, 334, 3393, 12, 3146, 304, 288, 327, 2104, 3063, 663, 652, 370, 378, 27, 781, 7171, 862, 4020, 2945, 641, 3224, 14, 288, 1564, 63, 1267, 275, 378, 398, 340, 1564, 63, 1267, 2695, 378, 26, 288, 327, 961, 4910, 781, 9296, 1133, 1980, 1396, 3730, 376, 1125, 14, 288, 746, 6879, 8416, 21811, 480, 3364, 1564, 2582, 26, 450, 82, 2, 450, 1564, 63, 1267, 9, 398, 291, 423, 9891, 275, 8424, 267, 291, 423, 1210, 63, 576, 275, 1324, 63, 576, 398, 327, 2104, 7163, 543, 6465, 13, 1896, 2784, 15913, 334, 1045, 4337, 13, 2075, 9446, 395, 267, 327, 314, 3728, 1568, 1077, 506, 665, 499, 62, 2192, 12, 1325, 5139, 487, 6604, 701, 841, 14, 267, 3962, 63, 7723, 275, 359, 88, 14, 4604, 63, 890, 367, 671, 315, 5802, 63, 5586, 340, 671, 14, 4604, 63, 890, 61, 267, 291, 423, 4604, 63, 890, 275, 1748, 779, 18, 538, 2192, 13, 20, 61, 435, 3962, 63, 7723, 9, 398, 291, 423, 2024, 275, 603, 15808, 267, 291, 423, 2991, 275, 2644, 503, 2202, 14, 3472, 63, 23969, 267, 291, 423, 1317, 63, 1267, 275, 1564, 63, 1267, 267, 291, 423, 5064, 63, 5586, 275, 5802, 63, 5586, 339, 347, 2198, 8, 277, 304, 267, 408, 267, 6077, 314, 8761, 666, 436, 2059, 652, 1901, 282, 16444, 654, 6879, 24811, 436, 282, 8761, 267, 6879, 24811, 14, 398, 1803, 282, 2008, 3035, 314, 8761, 436, 16444, 654, 2600, 12, 17342, 14, 267, 408, 267, 327, 2136, 1172, 370, 492, 8133, 2141, 3224, 2348, 370, 5126, 282, 15032, 492, 14, 267, 687, 1639, 14, 1014, 492, 8133, 2141, 398, 2644, 275, 291, 423, 2991, 267, 8297, 275, 291, 423, 5064, 63, 5586, 398, 13988, 63, 1210, 63, 576, 275, 22672, 5571, 8, 277, 423, 1210, 63, 576, 12, 291, 423, 1317, 63, 1267, 9, 398, 327, 1666, 340, 314, 3016, 911, 2934, 370, 5452, 10296, 402, 314, 6057, 14, 267, 327, 961, 6127, 18972, 8137, 340, 2005, 2030, 15061, 652, 14, 267, 367, 3016, 315, 8297, 26, 288, 754, 275, 3016, 14, 2479, 63, 1773, 63, 1210, 8, 14136, 63, 1210, 63, 576, 12, 6343, 291, 423, 2024, 12, 6343, 291, 423, 1317, 63, 1267, 12, 6343, 291, 423, 9891, 12, 6343, 2644, 9, 288, 340, 754, 365, 440, 488, 26, 355, 372, 754, 59, 16, 467, 754, 59, 17, 61, 398, 327, 2790, 314, 666, 13955, 370, 506, 1202, 2945, 14, 267, 291, 423, 1932, 275, 8133, 2141, 8594, 17194, 29, 549, 9, 267, 291, 423, 1725, 275, 6879, 24811, 342, 398, 327, 32092, 314, 1798, 436, 2547, 26, 267, 2547, 275, 22373, 3296, 8, 9856, 3315, 8, 14136, 63, 1210, 63, 576, 12, 291, 423, 4604, 63, 890, 430, 398, 327, 7480, 503, 440, 370, 4673, 282, 570, 13, 13207, 737, 314, 9608 ]
[ 199, 3947, 13, 2064, 6057, 367, 570, 26598, 14, 199, 199, 920, 10553, 1373, 1021, 12, 1124, 3947, 8416, 2842, 4542, 1314, 22295, 8291, 402, 14238, 666, 370, 199, 493, 5802, 8297, 367, 6661, 14, 199, 624, 199, 199, 646, 16004, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 428, 28651, 6044, 199, 504, 1639, 14, 1208, 14, 23004, 492, 6879, 24811, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 199, 504, 1639, 14, 1208, 14, 505, 492, 22221, 63, 8327, 199, 504, 1639, 14, 1018, 14, 1725, 14, 5064, 2232, 492, 8015, 10301, 12, 8232, 1173, 12, 8015, 14224, 25096, 199, 199, 363, 452, 363, 275, 661, 3947, 8416, 2842, 297, 283, 3947, 8416, 21811, 297, 283, 27611, 920, 2411, 7274, 358, 199, 199, 533, 6879, 8416, 21811, 8, 1726, 304, 272, 986, 199, 199, 533, 6924, 3296, 920, 2411, 7274, 8, 1726, 304, 272, 408, 272, 3091, 1655, 11597, 787, 4370, 687, 642, 2243, 14, 272, 408, 272, 986, 199, 199, 4307, 275, 298, 1773, 2, 199, 3817, 275, 298, 493, 2, 199, 8609, 275, 298, 698, 2, 199, 199, 533, 6879, 8416, 2842, 8, 785, 304, 272, 408, 272, 437, 18158, 1789, 1299, 15193, 15, 964, 13, 576, 1798, 14, 339, 1124, 3947, 24811, 14, 1122, 8497, 11597, 314, 1324, 2547, 315, 1124, 4604, 63, 890, 1040, 8291, 272, 436, 2529, 282, 2008, 402, 15475, 3947, 24811, 8, 4030, 395, 6879, 24811, 8, 9472, 430, 4345, 982, 272, 408, 272, 347, 636, 826, 721, 277, 12, 603, 15808, 12, 1324, 63, 576, 12, 5802, 63, 5586, 12, 2644, 29, 403, 304, 267, 408, 267, 11578, 314, 6879, 8416, 2842, 909, 14, 398, 520, 10614, 26, 288, 710, 4465, 1124, 10614, 1040, 2600, 315, 5634, 1056, 2251, 14, 267, 520, 1210, 63, 576, 26, 288, 710, 3066, 2963, 666, 12, 465, 282, 570, 13, 2930, 909, 14, 267, 520, 5064, 63, 2232, 26, 288, 1626, 19149, 2461, 1256, 626, 18628, 5331, 641, 314, 14238, 288, 666, 14, 267, 520, 2991, 26, 288, 710, 2644, 543, 1314, 370, 14312, 314, 12467, 666, 14, 267, 408, 398, 327, 267, 327, 6646, 13, 804, 1077, 406, 502, 442, 15193, 436, 314, 8424, 2556, 14, 267, 327, 398, 1564, 63, 466, 275, 603, 15808, 14, 362, 360, 2856, 63, 9663, 63, 2711, 297, 603, 15808, 14, 362, 360, 9663, 63, 2711, 297, 12381, 267, 340, 440, 1564, 63, 466, 14, 2460, 360, 10123, 26985, 288, 746, 6879, 8416, 21811, 360, 3364, 6646, 13, 804, 26, 450, 83, 7, 450, 1564, 63, 466, 9, 398, 327, 6077, 314, 1406, 370, 664, 314, 8424, 370, 3715, 314, 4184, 14, 267, 5577, 12, 3999, 275, 2198, 63, 1291, 8, 1317, 63, 466, 9, 267, 8424, 275, 3999, 14, 362, 360, 9891, 358, 267, 340, 440, 8424, 503, 440, 16004, 14, 1078, 63, 9891, 8, 9891, 304, 288, 746, 6879, 8416, 21811, 360, 3364, 8424, 315, 15193, 26, 450, 83, 7, 450, 8424, 9, 7318, 327, 267, 327, 6646, 13, 4625, 1077, 1395, 314, 2582, 402, 314, 2396, 781, 787, 3595, 267, 327, 370, 9128, 14, 267, 327, 267, 862, 26, 288, 1564, 63, 1267, 275, 1109, 8, 10614, 14, 362, 360, 2856, 63, 9663, 63, 9127, 297, 603, 15808, 14, 362, 360, 9663, 63, 9127, 297, 16, 1724, 267, 871, 334, 3393, 12, 3146, 304, 288, 327, 2104, 3063, 663, 652, 370, 378, 27, 781, 7171, 862, 4020, 2945, 641, 3224, 14, 288, 1564, 63, 1267, 275, 378, 398, 340, 1564, 63, 1267, 2695, 378, 26, 288, 327, 961, 4910, 781, 9296, 1133, 1980, 1396, 3730, 376, 1125, 14, 288, 746, 6879, 8416, 21811, 480, 3364, 1564, 2582, 26, 450, 82, 2, 450, 1564, 63, 1267, 9, 398, 291, 423, 9891, 275, 8424, 267, 291, 423, 1210, 63, 576, 275, 1324, 63, 576, 398, 327, 2104, 7163, 543, 6465, 13, 1896, 2784, 15913, 334, 1045, 4337, 13, 2075, 9446, 395, 267, 327, 314, 3728, 1568, 1077, 506, 665, 499, 62, 2192, 12, 1325, 5139, 487, 6604, 701, 841, 14, 267, 3962, 63, 7723, 275, 359, 88, 14, 4604, 63, 890, 367, 671, 315, 5802, 63, 5586, 340, 671, 14, 4604, 63, 890, 61, 267, 291, 423, 4604, 63, 890, 275, 1748, 779, 18, 538, 2192, 13, 20, 61, 435, 3962, 63, 7723, 9, 398, 291, 423, 2024, 275, 603, 15808, 267, 291, 423, 2991, 275, 2644, 503, 2202, 14, 3472, 63, 23969, 267, 291, 423, 1317, 63, 1267, 275, 1564, 63, 1267, 267, 291, 423, 5064, 63, 5586, 275, 5802, 63, 5586, 339, 347, 2198, 8, 277, 304, 267, 408, 267, 6077, 314, 8761, 666, 436, 2059, 652, 1901, 282, 16444, 654, 6879, 24811, 436, 282, 8761, 267, 6879, 24811, 14, 398, 1803, 282, 2008, 3035, 314, 8761, 436, 16444, 654, 2600, 12, 17342, 14, 267, 408, 267, 327, 2136, 1172, 370, 492, 8133, 2141, 3224, 2348, 370, 5126, 282, 15032, 492, 14, 267, 687, 1639, 14, 1014, 492, 8133, 2141, 398, 2644, 275, 291, 423, 2991, 267, 8297, 275, 291, 423, 5064, 63, 5586, 398, 13988, 63, 1210, 63, 576, 275, 22672, 5571, 8, 277, 423, 1210, 63, 576, 12, 291, 423, 1317, 63, 1267, 9, 398, 327, 1666, 340, 314, 3016, 911, 2934, 370, 5452, 10296, 402, 314, 6057, 14, 267, 327, 961, 6127, 18972, 8137, 340, 2005, 2030, 15061, 652, 14, 267, 367, 3016, 315, 8297, 26, 288, 754, 275, 3016, 14, 2479, 63, 1773, 63, 1210, 8, 14136, 63, 1210, 63, 576, 12, 6343, 291, 423, 2024, 12, 6343, 291, 423, 1317, 63, 1267, 12, 6343, 291, 423, 9891, 12, 6343, 2644, 9, 288, 340, 754, 365, 440, 488, 26, 355, 372, 754, 59, 16, 467, 754, 59, 17, 61, 398, 327, 2790, 314, 666, 13955, 370, 506, 1202, 2945, 14, 267, 291, 423, 1932, 275, 8133, 2141, 8594, 17194, 29, 549, 9, 267, 291, 423, 1725, 275, 6879, 24811, 342, 398, 327, 32092, 314, 1798, 436, 2547, 26, 267, 2547, 275, 22373, 3296, 8, 9856, 3315, 8, 14136, 63, 1210, 63, 576, 12, 291, 423, 4604, 63, 890, 430, 398, 327, 7480, 503, 440, 370, 4673, 282, 570, 13, 13207, 737, 314, 9608, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pfalcon/picotui
picotui/editorext.py
1
5118
# # Extended VT100 terminal text editor, etc. widgets # Copyright (c) 2015 Paul Sokolovsky # Distributed under MIT License # import sys import os from .editor import * # Edit single line, quit on Enter/Esc class LineEditor(Editor): def handle_cursor_keys(self, key): if super().handle_cursor_keys(key): self.just_started = False return True return False def handle_key(self, key): if key in (KEY_ENTER, KEY_ESC): return key if self.just_started: # Overwrite initial string with new content self.set_lines([""]) self.col = 0 self.just_started = False return super().handle_key(key) def edit(self, line): self.set_lines([line]) self.col = len(line) self.adjust_cursor_eol() self.just_started = True key = self.loop() if key == KEY_ENTER: return self.content[0] return None class Viewer(Editor): def handle_key(self, key): if key in (KEY_ENTER, KEY_ESC): return key if super().handle_cursor_keys(key): return True # Viewer with colored lines, (whole line same color) class LineColorViewer(Viewer): def show_line(self, l, i): if self.is_dict_color: c = self.lines_c.get(i, self.def_c) else: try: c = self.lines_c[i] except IndexError: c = self.def_c self.attr_color(c) super().show_line(l, i) self.attr_reset() def set_line_colors(self, default_color, color_list={}): self.def_c = default_color self.lines_c = color_list self.is_dict_color = isinstance(color_list, dict) # Viewer with color support, (echo line may consist of spans # of different colors) class CharColorViewer(Viewer): def show_line(self, l, i): # TODO: handle self.margin, self.width length = 0 for span in l: if isinstance(span, tuple): span, c = span else: c = self.def_c self.attr_color(c) self.wr(span) length += len(span) self.attr_color(self.def_c) self.clear_num_pos(self.width - length) self.attr_reset() def set_def_color(self, default_color): self.def_c = default_color class EditorExt(Editor): screen_width = 80 def __init__(self, left=0, top=0, width=80, height=24): super().__init__(left, top, width, height) # +1 assumes there's a border around editor pane self.status_y = top + height + 1 def get_cur_line(self): return self.content[self.cur_line] def line_visible(self, no): return self.top_line <= no < self.top_line + self.height # If line "no" is already on screen, just reposition cursor to it and # return False. Otherwise, show needed line either at the center of # screen or at the top, and return True. def goto_line(self, no, col=None, center=True): self.cur_line = no if self.line_visible(no): self.row = no - self.top_line if col is not None: self.col = col if self.adjust_cursor_eol(): self.redraw() self.set_cursor() return False if center: c = self.height // 2 if no > c: self.top_line = no - c self.row = c else: self.top_line = 0 self.row = no else: self.top_line = no self.row = 0 if col is not None: self.col = col self.adjust_cursor_eol() self.redraw() return True def show_status(self, msg): self.cursor(False) self.goto(0, self.status_y) self.wr(msg) self.clear_to_eol() self.set_cursor() self.cursor(True) def show_cursor_status(self): self.cursor(False) self.goto(0, 31) self.wr("% 3d:% 3d" % (self.cur_line, self.col + self.margin)) self.set_cursor() self.cursor(True) def dialog_edit_line(self, left=None, top=8, width=40, height=3, line="", title=""): if left is None: left = (self.screen_width - width) / 2 self.dialog_box(left, top, width, height, title) e = LineEditor(left + 1, top + 1, width - 2, height - 2) return e.edit(line) if __name__ == "__main__": with open(sys.argv[1]) as f: content = f.read().splitlines() #content = f.readlines() #os.write(1, b"\x1b[18t") #key = os.read(0, 32) #print(repr(key)) #key = os.read(0, 32) #print(repr(key)) #1/0 e = EditorExt(left=1, top=1, width=60, height=25) e.init_tty() e.enable_mouse() s = e.dialog_edit_line(10, 5, 40, 3, title="Enter name:", line="test") e.cls() e.deinit_tty() print() print(s) 1/0 # e.cls() e.draw_box(0, 0, 62, 27) e.set_lines(content) e.loop() e.deinit_tty()
mit
[ 3, 199, 3, 13706, 812, 52, 1960, 11167, 1318, 8823, 12, 5423, 14, 11114, 199, 3, 1898, 334, 67, 9, 6900, 28574, 428, 745, 79, 32555, 12267, 199, 3, 17484, 1334, 10697, 844, 199, 3, 199, 646, 984, 199, 646, 747, 199, 504, 1275, 7515, 492, 627, 421, 199, 3, 16407, 2849, 1004, 12, 17242, 641, 16401, 15, 37, 551, 199, 533, 7030, 10423, 8, 10423, 304, 339, 347, 2429, 63, 3937, 63, 1612, 8, 277, 12, 790, 304, 267, 340, 1613, 1252, 2479, 63, 3937, 63, 1612, 8, 498, 304, 288, 291, 14, 4764, 63, 8924, 275, 756, 288, 372, 715, 267, 372, 756, 339, 347, 2429, 63, 498, 8, 277, 12, 790, 304, 267, 340, 790, 315, 334, 3078, 63, 12533, 12, 9301, 63, 654, 35, 304, 288, 372, 790, 267, 340, 291, 14, 4764, 63, 8924, 26, 288, 327, 7259, 952, 2536, 1059, 543, 892, 1564, 288, 291, 14, 409, 63, 1278, 779, 341, 566, 288, 291, 14, 761, 275, 378, 288, 291, 14, 4764, 63, 8924, 275, 756, 398, 372, 1613, 1252, 2479, 63, 498, 8, 498, 9, 339, 347, 5283, 8, 277, 12, 1004, 304, 267, 291, 14, 409, 63, 1278, 779, 604, 566, 267, 291, 14, 761, 275, 822, 8, 604, 9, 267, 291, 14, 10917, 63, 3937, 63, 20470, 342, 267, 291, 14, 4764, 63, 8924, 275, 715, 267, 790, 275, 291, 14, 3813, 342, 267, 340, 790, 508, 9301, 63, 12533, 26, 288, 372, 291, 14, 1317, 59, 16, 61, 267, 372, 488, 421, 199, 533, 10935, 281, 8, 10423, 304, 339, 347, 2429, 63, 498, 8, 277, 12, 790, 304, 267, 340, 790, 315, 334, 3078, 63, 12533, 12, 9301, 63, 654, 35, 304, 288, 372, 790, 267, 340, 1613, 1252, 2479, 63, 3937, 63, 1612, 8, 498, 304, 288, 372, 715, 421, 199, 3, 10935, 281, 543, 32076, 2385, 12, 334, 21224, 1004, 2011, 3164, 9, 199, 533, 7030, 4117, 22347, 8, 22347, 304, 339, 347, 2498, 63, 604, 8, 277, 12, 634, 12, 284, 304, 267, 340, 291, 14, 374, 63, 807, 63, 2326, 26, 288, 286, 275, 291, 14, 1278, 63, 67, 14, 362, 8, 73, 12, 291, 14, 318, 63, 67, 9, 267, 587, 26, 288, 862, 26, 355, 286, 275, 291, 14, 1278, 63, 67, 59, 73, 61, 288, 871, 7888, 26, 355, 286, 275, 291, 14, 318, 63, 67, 267, 291, 14, 962, 63, 2326, 8, 67, 9, 267, 1613, 1252, 2384, 63, 604, 8, 76, 12, 284, 9, 267, 291, 14, 962, 63, 3958, 342, 339, 347, 663, 63, 604, 63, 7120, 8, 277, 12, 849, 63, 2326, 12, 3164, 63, 513, 16420, 267, 291, 14, 318, 63, 67, 275, 849, 63, 2326, 267, 291, 14, 1278, 63, 67, 275, 3164, 63, 513, 267, 291, 14, 374, 63, 807, 63, 2326, 275, 1228, 8, 2326, 63, 513, 12, 1211, 9, 421, 199, 3, 10935, 281, 543, 3164, 2291, 12, 334, 7878, 1004, 1443, 17568, 402, 2249, 796, 199, 3, 402, 3365, 9229, 9, 199, 533, 6659, 4117, 22347, 8, 22347, 304, 339, 347, 2498, 63, 604, 8, 277, 12, 634, 12, 284, 304, 267, 327, 3254, 26, 2429, 291, 14, 9650, 12, 291, 14, 2063, 267, 2582, 275, 378, 267, 367, 13598, 315, 634, 26, 288, 340, 1228, 8, 3751, 12, 2008, 304, 355, 13598, 12, 286, 275, 13598, 288, 587, 26, 355, 286, 275, 291, 14, 318, 63, 67, 288, 291, 14, 962, 63, 2326, 8, 67, 9, 288, 291, 14, 17097, 8, 3751, 9, 288, 2582, 847, 822, 8, 3751, 9, 267, 291, 14, 962, 63, 2326, 8, 277, 14, 318, 63, 67, 9, 267, 291, 14, 3584, 63, 1507, 63, 1712, 8, 277, 14, 2063, 446, 2582, 9, 267, 291, 14, 962, 63, 3958, 342, 339, 347, 663, 63, 318, 63, 2326, 8, 277, 12, 849, 63, 2326, 304, 267, 291, 14, 318, 63, 67, 275, 849, 63, 2326, 421, 199, 533, 30318, 4942, 8, 10423, 304, 339, 6426, 63, 2063, 275, 5939, 339, 347, 636, 826, 721, 277, 12, 3602, 29, 16, 12, 2746, 29, 16, 12, 3462, 29, 1257, 12, 4569, 29, 1194, 304, 267, 1613, 11027, 826, 721, 3039, 12, 2746, 12, 3462, 12, 4569, 9, 267, 327, 435, 17, 15194, 2337, 1159, 282, 9162, 6818, 8823, 299, 5865, 267, 291, 14, 1205, 63, 89, 275, 2746, 435, 4569, 435, 413, 339, 347, 664, 63, 895, 63, 604, 8, 277, 304, 267, 372, 291, 14, 1317, 59, 277, 14, 895, 63, 604, 61, 339, 347, 1004, 63, 6604, 8, 277, 12, 949, 304, 267, 372, 291, 14, 2119, 63, 604, 2695, 949, 665, 291, 14, 2119, 63, 604, 435, 291, 14, 3333, 339, 327, 982, 1004, 298, 889, 2, 365, 2575, 641, 6426, 12, 2951, 295, 3124, 3920, 370, 652, 436, 272, 327, 372, 756, 14, 6630, 12, 2498, 4346, 1004, 1902, 737, 314, 8126, 402, 272, 327, 6426, 503, 737, 314, 2746, 12, 436, 372, 715, 14, 272, 347, 18878, 63, 604, 8, 277, 12, 949, 12, 1048, 29, 403, 12, 8126, 29, 549, 304, 267, 291, 14, 895, 63, 604, 275, 949, 398, 340, 291, 14, 604, 63, 6604, 8, 889, 304, 288, 291, 14, 1143, 275, 949, 446, 291, 14, 2119, 63, 604, 288, 340, 1048, 365, 440, 488, 26, 355, 291, 14, 761, 275, 1048, 355, 340, 291, 14, 10917, 63, 3937, 63, 20470, 837, 490, 291, 14, 581, 1773, 342, 288, 291, 14, 409, 63, 3937, 342, 288, 372, 756, 398, 340, 8126, 26, 288, 286, 275, 291, 14, 3333, 5001, 499, 288, 340, 949, 690, 286, 26, 355, 291, 14, 2119, 63, 604, 275, 949, 446, 286, 355, 291, 14, 1143, 275, 286, 288, 587, 26, 355, 291, 14, 2119, 63, 604, 275, 378, 355, 291, 14, 1143, 275, 949, 267, 587, 26, 288, 291, 14, 2119, 63, 604, 275, 949, 288, 291, 14, 1143, 275, 378, 398, 340, 1048, 365, 440, 488, 26, 288, 291, 14, 761, 275, 1048, 288, 291, 14, 10917, 63, 3937, 63, 20470, 342, 267, 291, 14, 581, 1773, 342, 267, 372, 715, 339, 347, 2498, 63, 1205, 8, 277, 12, 1499, 304, 267, 291, 14, 3937, 8, 797, 9, 267 ]
[ 199, 3, 13706, 812, 52, 1960, 11167, 1318, 8823, 12, 5423, 14, 11114, 199, 3, 1898, 334, 67, 9, 6900, 28574, 428, 745, 79, 32555, 12267, 199, 3, 17484, 1334, 10697, 844, 199, 3, 199, 646, 984, 199, 646, 747, 199, 504, 1275, 7515, 492, 627, 421, 199, 3, 16407, 2849, 1004, 12, 17242, 641, 16401, 15, 37, 551, 199, 533, 7030, 10423, 8, 10423, 304, 339, 347, 2429, 63, 3937, 63, 1612, 8, 277, 12, 790, 304, 267, 340, 1613, 1252, 2479, 63, 3937, 63, 1612, 8, 498, 304, 288, 291, 14, 4764, 63, 8924, 275, 756, 288, 372, 715, 267, 372, 756, 339, 347, 2429, 63, 498, 8, 277, 12, 790, 304, 267, 340, 790, 315, 334, 3078, 63, 12533, 12, 9301, 63, 654, 35, 304, 288, 372, 790, 267, 340, 291, 14, 4764, 63, 8924, 26, 288, 327, 7259, 952, 2536, 1059, 543, 892, 1564, 288, 291, 14, 409, 63, 1278, 779, 341, 566, 288, 291, 14, 761, 275, 378, 288, 291, 14, 4764, 63, 8924, 275, 756, 398, 372, 1613, 1252, 2479, 63, 498, 8, 498, 9, 339, 347, 5283, 8, 277, 12, 1004, 304, 267, 291, 14, 409, 63, 1278, 779, 604, 566, 267, 291, 14, 761, 275, 822, 8, 604, 9, 267, 291, 14, 10917, 63, 3937, 63, 20470, 342, 267, 291, 14, 4764, 63, 8924, 275, 715, 267, 790, 275, 291, 14, 3813, 342, 267, 340, 790, 508, 9301, 63, 12533, 26, 288, 372, 291, 14, 1317, 59, 16, 61, 267, 372, 488, 421, 199, 533, 10935, 281, 8, 10423, 304, 339, 347, 2429, 63, 498, 8, 277, 12, 790, 304, 267, 340, 790, 315, 334, 3078, 63, 12533, 12, 9301, 63, 654, 35, 304, 288, 372, 790, 267, 340, 1613, 1252, 2479, 63, 3937, 63, 1612, 8, 498, 304, 288, 372, 715, 421, 199, 3, 10935, 281, 543, 32076, 2385, 12, 334, 21224, 1004, 2011, 3164, 9, 199, 533, 7030, 4117, 22347, 8, 22347, 304, 339, 347, 2498, 63, 604, 8, 277, 12, 634, 12, 284, 304, 267, 340, 291, 14, 374, 63, 807, 63, 2326, 26, 288, 286, 275, 291, 14, 1278, 63, 67, 14, 362, 8, 73, 12, 291, 14, 318, 63, 67, 9, 267, 587, 26, 288, 862, 26, 355, 286, 275, 291, 14, 1278, 63, 67, 59, 73, 61, 288, 871, 7888, 26, 355, 286, 275, 291, 14, 318, 63, 67, 267, 291, 14, 962, 63, 2326, 8, 67, 9, 267, 1613, 1252, 2384, 63, 604, 8, 76, 12, 284, 9, 267, 291, 14, 962, 63, 3958, 342, 339, 347, 663, 63, 604, 63, 7120, 8, 277, 12, 849, 63, 2326, 12, 3164, 63, 513, 16420, 267, 291, 14, 318, 63, 67, 275, 849, 63, 2326, 267, 291, 14, 1278, 63, 67, 275, 3164, 63, 513, 267, 291, 14, 374, 63, 807, 63, 2326, 275, 1228, 8, 2326, 63, 513, 12, 1211, 9, 421, 199, 3, 10935, 281, 543, 3164, 2291, 12, 334, 7878, 1004, 1443, 17568, 402, 2249, 796, 199, 3, 402, 3365, 9229, 9, 199, 533, 6659, 4117, 22347, 8, 22347, 304, 339, 347, 2498, 63, 604, 8, 277, 12, 634, 12, 284, 304, 267, 327, 3254, 26, 2429, 291, 14, 9650, 12, 291, 14, 2063, 267, 2582, 275, 378, 267, 367, 13598, 315, 634, 26, 288, 340, 1228, 8, 3751, 12, 2008, 304, 355, 13598, 12, 286, 275, 13598, 288, 587, 26, 355, 286, 275, 291, 14, 318, 63, 67, 288, 291, 14, 962, 63, 2326, 8, 67, 9, 288, 291, 14, 17097, 8, 3751, 9, 288, 2582, 847, 822, 8, 3751, 9, 267, 291, 14, 962, 63, 2326, 8, 277, 14, 318, 63, 67, 9, 267, 291, 14, 3584, 63, 1507, 63, 1712, 8, 277, 14, 2063, 446, 2582, 9, 267, 291, 14, 962, 63, 3958, 342, 339, 347, 663, 63, 318, 63, 2326, 8, 277, 12, 849, 63, 2326, 304, 267, 291, 14, 318, 63, 67, 275, 849, 63, 2326, 421, 199, 533, 30318, 4942, 8, 10423, 304, 339, 6426, 63, 2063, 275, 5939, 339, 347, 636, 826, 721, 277, 12, 3602, 29, 16, 12, 2746, 29, 16, 12, 3462, 29, 1257, 12, 4569, 29, 1194, 304, 267, 1613, 11027, 826, 721, 3039, 12, 2746, 12, 3462, 12, 4569, 9, 267, 327, 435, 17, 15194, 2337, 1159, 282, 9162, 6818, 8823, 299, 5865, 267, 291, 14, 1205, 63, 89, 275, 2746, 435, 4569, 435, 413, 339, 347, 664, 63, 895, 63, 604, 8, 277, 304, 267, 372, 291, 14, 1317, 59, 277, 14, 895, 63, 604, 61, 339, 347, 1004, 63, 6604, 8, 277, 12, 949, 304, 267, 372, 291, 14, 2119, 63, 604, 2695, 949, 665, 291, 14, 2119, 63, 604, 435, 291, 14, 3333, 339, 327, 982, 1004, 298, 889, 2, 365, 2575, 641, 6426, 12, 2951, 295, 3124, 3920, 370, 652, 436, 272, 327, 372, 756, 14, 6630, 12, 2498, 4346, 1004, 1902, 737, 314, 8126, 402, 272, 327, 6426, 503, 737, 314, 2746, 12, 436, 372, 715, 14, 272, 347, 18878, 63, 604, 8, 277, 12, 949, 12, 1048, 29, 403, 12, 8126, 29, 549, 304, 267, 291, 14, 895, 63, 604, 275, 949, 398, 340, 291, 14, 604, 63, 6604, 8, 889, 304, 288, 291, 14, 1143, 275, 949, 446, 291, 14, 2119, 63, 604, 288, 340, 1048, 365, 440, 488, 26, 355, 291, 14, 761, 275, 1048, 355, 340, 291, 14, 10917, 63, 3937, 63, 20470, 837, 490, 291, 14, 581, 1773, 342, 288, 291, 14, 409, 63, 3937, 342, 288, 372, 756, 398, 340, 8126, 26, 288, 286, 275, 291, 14, 3333, 5001, 499, 288, 340, 949, 690, 286, 26, 355, 291, 14, 2119, 63, 604, 275, 949, 446, 286, 355, 291, 14, 1143, 275, 286, 288, 587, 26, 355, 291, 14, 2119, 63, 604, 275, 378, 355, 291, 14, 1143, 275, 949, 267, 587, 26, 288, 291, 14, 2119, 63, 604, 275, 949, 288, 291, 14, 1143, 275, 378, 398, 340, 1048, 365, 440, 488, 26, 288, 291, 14, 761, 275, 1048, 288, 291, 14, 10917, 63, 3937, 63, 20470, 342, 267, 291, 14, 581, 1773, 342, 267, 372, 715, 339, 347, 2498, 63, 1205, 8, 277, 12, 1499, 304, 267, 291, 14, 3937, 8, 797, 9, 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, 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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 ]
edespino/gpdb
src/test/tinc/tincrepo/mpp/gpdb/tests/storage/walrepl/crash/test_failover_recovery_mode.py
7
8700
""" Copyright (c) 2004-Present Pivotal Software, Inc. This program and the accompanying materials are made available under the terms of the under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import os import socket import tinctest import unittest2 as unittest from tinctest.models.scenario import ScenarioTestCase from mpp.gpdb.tests.storage.walrepl.gpactivatestandby import GpactivateStandby from mpp.gpdb.tests.storage.walrepl.gpinitstandby import GpinitStandby from mpp.gpdb.tests.storage.walrepl.crash import WalReplKillProcessTestCase from mpp.gpdb.tests.storage.walrepl.lib.pg_util import GpUtility from mpp.gpdb.tests.storage.walrepl import lib as walrepl pgutil = GpUtility() class WalReplKillProcessScenarioTestCase(ScenarioTestCase): origin_mdd = os.environ.get('MASTER_DATA_DIRECTORY') def __init__(self, methodName): self.standby_dir = os.environ.get('MASTER_DATA_DIRECTORY') self.pgdatabase = self.pgdatabase = os.environ.get('PGDATABASE') super(WalReplKillProcessScenarioTestCase,self).__init__(methodName) def setUp(self): pgutil.check_and_start_gpdb() # We should forcibly recreate standby, as it might has been promoted. # here we need to install locally, otherwise can not run remote sql pgutil.remove_standby() pgutil.install_standby(new_stdby_host=socket.gethostname()) gpact_stdby = GpactivateStandby() gpinit_stdb = GpinitStandby() WalReplKillProcessTestCase.stdby_port = gpact_stdby.get_standby_port() WalReplKillProcessTestCase.stdby_host = gpinit_stdb.get_standbyhost() self.standby_dir = gpact_stdby.get_standby_dd() def tearDown(self): walrepl.cleanupFilespaces(dbname=os.environ.get('PGDATABASE')) @classmethod def setUpClass(cls): pgutil.check_and_start_gpdb() gp_walrepl = WalReplKillProcessTestCase('initial_setup') gp_walrepl.initial_setup() @classmethod def tearDownClass(cls): pgutil.remove_standby() def test_failover_run__workload(self): ''' activate the standby, run workload, check master and standby integrity, currently support local standby, can not run workload remotely ''' activatestdby = GpactivateStandby() activatestdby.activate() with walrepl.NewEnv(MASTER_DATA_DIRECTORY=self.standby_dir, PGPORT=WalReplKillProcessTestCase.stdby_port, PGDATABASE=self.pgdatabase) as env: test_case_list1 = [] test_case_list1.append("mpp.gpdb.tests.storage.walrepl.crash.dml.test_dml.DMLTestCase") test_case_list1.append("mpp.gpdb.tests.storage.walrepl.crash.ddl.test_ddl.DDLTestCase") self.test_case_scenario.append(test_case_list1) test_case_list2 = [] test_case_list2.append("mpp.gpdb.tests.storage.walrepl.crash.WalReplKillProcessTestCase.check_mirror_seg") self.test_case_scenario.append(test_case_list2) test_case_list3 = [] test_case_list3.append("mpp.gpdb.tests.storage.walrepl.crash.verify.verify.DataVerifyTestCase") self.test_case_scenario.append(test_case_list3) pgutil.failback_to_original_master(self.origin_mdd, WalReplKillProcessTestCase.stdby_host, self.standby_dir,WalReplKillProcessTestCase.stdby_port) def test_initstandby_run_workload(self): #run workload while initstandby, check master mirror integrity pgutil.remove_standby() test_case_list0 = [] test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.WalReplKillProcessTestCase.gpinitstandby_helper") test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.dml.test_dml.DMLTestCase") test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.ddl.test_ddl.DDLTestCase") self.test_case_scenario.append(test_case_list0) test_case_list1 = [] test_case_list1.append("mpp.gpdb.tests.storage.walrepl.crash.WalReplKillProcessTestCase.check_mirror_seg") self.test_case_scenario.append(test_case_list1) test_case_list2 = [] test_case_list2.append("mpp.gpdb.tests.storage.walrepl.crash.verify.verify.DataVerifyTestCase") self.test_case_scenario.append(test_case_list2) def test_initstandby_after_run_workload(self): #run workload before initstandby, check master mirror integrity pgutil.remove_standby() test_case_list0 = [] test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.dml.test_dml.DMLTestCase") test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.ddl.test_ddl.DDLTestCase") self.test_case_scenario.append(test_case_list0) test_case_list1 = [] test_case_list1.append("mpp.gpdb.tests.storage.walrepl.crash.WalReplKillProcessTestCase.gpinitstandby_helper") self.test_case_scenario.append(test_case_list1) test_case_list2 = [] test_case_list2.append("mpp.gpdb.tests.storage.walrepl.crash.WalReplKillProcessTestCase.check_mirror_seg") self.test_case_scenario.append(test_case_list2) test_case_list3 = [] test_case_list3.append("mpp.gpdb.tests.storage.walrepl.crash.verify.verify.DataVerifyTestCase") self.test_case_scenario.append(test_case_list3) def test_run_workload_with_standby(self): #run workload while initstandby already installed, check master mirror integrity test_case_list0 = [] test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.dml.test_dml.DMLTestCase") test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.ddl.test_ddl.DDLTestCase") self.test_case_scenario.append(test_case_list0) test_case_list1 = [] test_case_list1.append("mpp.gpdb.tests.storage.walrepl.crash.WalReplKillProcessTestCase.check_mirror_seg") self.test_case_scenario.append(test_case_list1) test_case_list2 = [] test_case_list2.append("mpp.gpdb.tests.storage.walrepl.crash.verify.verify.DataVerifyTestCase") self.test_case_scenario.append(test_case_list2) def test_run_workload_remove_standby(self): #run workload while removing initstandby, check master mirror integrity test_case_list0 = [] test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.WalReplKillProcessTestCase.removestandby_helper") test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.dml.test_dml.DMLTestCase") test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.ddl.test_ddl.DDLTestCase") self.test_case_scenario.append(test_case_list0) test_case_list1 = [] test_case_list1.append("mpp.gpdb.tests.storage.walrepl.crash.WalReplKillProcessTestCase.check_mirror_seg") self.test_case_scenario.append(test_case_list1) test_case_list2 = [] test_case_list2.append("mpp.gpdb.tests.storage.walrepl.crash.verify.verify.DataVerifyTestCase") self.test_case_scenario.append(test_case_list2) def test_run_workload_before_activate_standby(self): #run workload while removing initstandby, check master mirror integrity activatestdby = GpactivateStandby() test_case_list0 = [] test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.dml.test_dml.DMLTestCase") test_case_list0.append("mpp.gpdb.tests.storage.walrepl.crash.ddl.test_ddl.DDLTestCase") self.test_case_scenario.append(test_case_list0) activatestdby.activate() test_case_list1 = [] test_case_list1.append("mpp.gpdb.tests.storage.walrepl.crash.WalReplKillProcessTestCase.check_mirror_seg") self.test_case_scenario.append(test_case_list1) test_case_list2 = [] test_case_list2.append("mpp.gpdb.tests.storage.walrepl.crash.verify.verify.DataVerifyTestCase") self.test_case_scenario.append(test_case_list2) pgutil.failback_to_original_master(self.origin_mdd,WalReplKillProcessTestCase.stdby_host, self.standby_dir,WalReplKillProcessTestCase.stdby_port)
apache-2.0
[ 624, 199, 7384, 334, 67, 9, 8353, 13, 19794, 510, 1003, 1735, 2290, 12, 3277, 14, 199, 199, 2765, 2240, 436, 314, 23073, 8418, 787, 6326, 2808, 1334, 199, 1589, 2895, 402, 314, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 199, 1014, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 199, 646, 747, 199, 646, 2838, 199, 199, 646, 307, 6559, 396, 199, 646, 2882, 18, 465, 2882, 199, 504, 307, 6559, 396, 14, 992, 14, 13444, 492, 22840, 1746, 199, 504, 6118, 80, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 71, 28582, 280, 2409, 26071, 492, 598, 28582, 280, 2409, 31060, 199, 504, 6118, 80, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 4927, 826, 26071, 492, 598, 80, 826, 31060, 199, 504, 6118, 80, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 14807, 492, 644, 279, 497, 1168, 31464, 3498, 1746, 199, 504, 6118, 80, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 773, 14, 4198, 63, 1974, 492, 598, 80, 17505, 199, 504, 6118, 80, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 492, 1973, 465, 336, 279, 16349, 199, 199, 4198, 1974, 275, 598, 80, 17505, 342, 199, 533, 644, 279, 497, 1168, 31464, 3498, 12327, 6936, 1746, 8, 12327, 6936, 1746, 304, 339, 6330, 63, 77, 617, 275, 747, 14, 2314, 14, 362, 360, 25050, 63, 3998, 63, 16436, 358, 272, 347, 636, 826, 721, 277, 12, 23352, 304, 267, 291, 14, 26071, 63, 694, 275, 747, 14, 2314, 14, 362, 360, 25050, 63, 3998, 63, 16436, 358, 267, 291, 14, 4198, 4659, 275, 291, 14, 4198, 4659, 275, 747, 14, 2314, 14, 362, 360, 11115, 17873, 358, 267, 1613, 8, 55, 279, 497, 1168, 31464, 3498, 12327, 6936, 1746, 12, 277, 2843, 826, 721, 765, 985, 9, 2378, 347, 3613, 8, 277, 304, 267, 10275, 1974, 14, 1074, 63, 460, 63, 928, 63, 4927, 697, 342, 267, 327, 2136, 1077, 367, 559, 66, 590, 23959, 10584, 991, 12, 465, 652, 5594, 965, 2757, 8023, 5731, 14, 267, 327, 2348, 781, 1929, 370, 3907, 17738, 12, 4257, 883, 440, 1255, 3982, 3875, 267, 10275, 1974, 14, 2168, 63, 26071, 342, 267, 10275, 1974, 14, 3174, 63, 26071, 8, 1222, 63, 270, 28332, 63, 1102, 29, 3450, 14, 29789, 1012, 267, 486, 387, 319, 63, 270, 28332, 275, 598, 28582, 280, 2409, 31060, 342, 267, 15852, 826, 63, 270, 697, 275, 598, 80, 826, 31060, 342, 267, 644, 279, 497, 1168, 31464, 3498, 1746, 14, 270, 28332, 63, 719, 275, 486, 387, 319, 63, 270, 28332, 14, 362, 63, 26071, 63, 719, 342, 267, 644, 279, 497, 1168, 31464, 3498, 1746, 14, 270, 28332, 63, 1102, 275, 15852, 826, 63, 270, 697, 14, 362, 63, 26071, 1102, 342, 267, 291, 14, 26071, 63, 694, 275, 486, 387, 319, 63, 270, 28332, 14, 362, 63, 26071, 63, 617, 342, 339, 347, 6766, 8, 277, 304, 267, 336, 279, 16349, 14, 7661, 1173, 10749, 8, 13238, 29, 736, 14, 2314, 14, 362, 360, 11115, 17873, 1333, 18407, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 10275, 1974, 14, 1074, 63, 460, 63, 928, 63, 4927, 697, 342, 267, 15852, 63, 20877, 16349, 275, 644, 279, 497, 1168, 31464, 3498, 1746, 360, 2747, 63, 2758, 358, 267, 15852, 63, 20877, 16349, 14, 2747, 63, 2758, 342, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 10275, 1974, 14, 2168, 63, 26071, 342, 2378, 347, 511, 63, 667, 23165, 63, 1065, 363, 800, 912, 8, 277, 304, 267, 1449, 15422, 314, 10584, 991, 12, 1255, 1736, 912, 12, 1104, 5288, 436, 10584, 991, 268, 4661, 12997, 12, 5544, 2291, 2257, 10584, 991, 12, 883, 440, 1255, 1736, 912, 268, 3982, 590, 267, 1449, 523, 267, 15422, 270, 28332, 275, 598, 28582, 280, 2409, 31060, 342, 267, 15422, 270, 28332, 14, 8222, 342, 2126, 267, 543, 336, 279, 16349, 14, 4665, 7744, 8, 25050, 63, 3998, 63, 16436, 29, 277, 14, 26071, 63, 694, 12, 2490, 26595, 3657, 29, 55, 279, 497, 1168, 31464, 3498, 1746, 14, 270, 28332, 63, 719, 12, 2490, 26595, 17873, 29, 277, 14, 4198, 4659, 9, 465, 2589, 26, 288, 511, 63, 2546, 63, 513, 17, 275, 942, 288, 511, 63, 2546, 63, 513, 17, 14, 740, 480, 17901, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 14807, 14, 68, 757, 14, 396, 63, 68, 757, 14, 36, 1698, 1746, 531, 288, 511, 63, 2546, 63, 513, 17, 14, 740, 480, 17901, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 14807, 14, 17102, 14, 396, 63, 17102, 14, 31868, 1746, 531, 288, 291, 14, 396, 63, 2546, 63, 13444, 14, 740, 8, 396, 63, 2546, 63, 513, 17, 9, 953, 511, 63, 2546, 63, 513, 18, 275, 942, 288, 511, 63, 2546, 63, 513, 18, 14, 740, 480, 17901, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 14807, 14, 55, 279, 497, 1168, 31464, 3498, 1746, 14, 1074, 63, 12324, 63, 8359, 531, 288, 291, 14, 396, 63, 2546, 63, 13444, 14, 740, 8, 396, 63, 2546, 63, 513, 18, 9, 953, 511, 63, 2546, 63, 513, 19, 275, 942, 288, 511, 63, 2546, 63, 513, 19, 14, 740, 480, 17901, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 14807, 14, 4712, 14, 4712, 14, 1451, 7496, 1746, 531, 288, 291, 14, 396, 63, 2546, 63, 13444, 14, 740, 8, 396, 63, 2546, 63, 513, 19, 9, 267, 10275 ]
[ 199, 7384, 334, 67, 9, 8353, 13, 19794, 510, 1003, 1735, 2290, 12, 3277, 14, 199, 199, 2765, 2240, 436, 314, 23073, 8418, 787, 6326, 2808, 1334, 199, 1589, 2895, 402, 314, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 13297, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 5556, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 199, 1014, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 199, 5524, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 16832, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 29946, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 9295, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3097, 1298, 1334, 314, 844, 14, 199, 624, 199, 199, 646, 747, 199, 646, 2838, 199, 199, 646, 307, 6559, 396, 199, 646, 2882, 18, 465, 2882, 199, 504, 307, 6559, 396, 14, 992, 14, 13444, 492, 22840, 1746, 199, 504, 6118, 80, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 71, 28582, 280, 2409, 26071, 492, 598, 28582, 280, 2409, 31060, 199, 504, 6118, 80, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 4927, 826, 26071, 492, 598, 80, 826, 31060, 199, 504, 6118, 80, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 14807, 492, 644, 279, 497, 1168, 31464, 3498, 1746, 199, 504, 6118, 80, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 773, 14, 4198, 63, 1974, 492, 598, 80, 17505, 199, 504, 6118, 80, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 492, 1973, 465, 336, 279, 16349, 199, 199, 4198, 1974, 275, 598, 80, 17505, 342, 199, 533, 644, 279, 497, 1168, 31464, 3498, 12327, 6936, 1746, 8, 12327, 6936, 1746, 304, 339, 6330, 63, 77, 617, 275, 747, 14, 2314, 14, 362, 360, 25050, 63, 3998, 63, 16436, 358, 272, 347, 636, 826, 721, 277, 12, 23352, 304, 267, 291, 14, 26071, 63, 694, 275, 747, 14, 2314, 14, 362, 360, 25050, 63, 3998, 63, 16436, 358, 267, 291, 14, 4198, 4659, 275, 291, 14, 4198, 4659, 275, 747, 14, 2314, 14, 362, 360, 11115, 17873, 358, 267, 1613, 8, 55, 279, 497, 1168, 31464, 3498, 12327, 6936, 1746, 12, 277, 2843, 826, 721, 765, 985, 9, 2378, 347, 3613, 8, 277, 304, 267, 10275, 1974, 14, 1074, 63, 460, 63, 928, 63, 4927, 697, 342, 267, 327, 2136, 1077, 367, 559, 66, 590, 23959, 10584, 991, 12, 465, 652, 5594, 965, 2757, 8023, 5731, 14, 267, 327, 2348, 781, 1929, 370, 3907, 17738, 12, 4257, 883, 440, 1255, 3982, 3875, 267, 10275, 1974, 14, 2168, 63, 26071, 342, 267, 10275, 1974, 14, 3174, 63, 26071, 8, 1222, 63, 270, 28332, 63, 1102, 29, 3450, 14, 29789, 1012, 267, 486, 387, 319, 63, 270, 28332, 275, 598, 28582, 280, 2409, 31060, 342, 267, 15852, 826, 63, 270, 697, 275, 598, 80, 826, 31060, 342, 267, 644, 279, 497, 1168, 31464, 3498, 1746, 14, 270, 28332, 63, 719, 275, 486, 387, 319, 63, 270, 28332, 14, 362, 63, 26071, 63, 719, 342, 267, 644, 279, 497, 1168, 31464, 3498, 1746, 14, 270, 28332, 63, 1102, 275, 15852, 826, 63, 270, 697, 14, 362, 63, 26071, 1102, 342, 267, 291, 14, 26071, 63, 694, 275, 486, 387, 319, 63, 270, 28332, 14, 362, 63, 26071, 63, 617, 342, 339, 347, 6766, 8, 277, 304, 267, 336, 279, 16349, 14, 7661, 1173, 10749, 8, 13238, 29, 736, 14, 2314, 14, 362, 360, 11115, 17873, 1333, 18407, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 10275, 1974, 14, 1074, 63, 460, 63, 928, 63, 4927, 697, 342, 267, 15852, 63, 20877, 16349, 275, 644, 279, 497, 1168, 31464, 3498, 1746, 360, 2747, 63, 2758, 358, 267, 15852, 63, 20877, 16349, 14, 2747, 63, 2758, 342, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 10275, 1974, 14, 2168, 63, 26071, 342, 2378, 347, 511, 63, 667, 23165, 63, 1065, 363, 800, 912, 8, 277, 304, 267, 1449, 15422, 314, 10584, 991, 12, 1255, 1736, 912, 12, 1104, 5288, 436, 10584, 991, 268, 4661, 12997, 12, 5544, 2291, 2257, 10584, 991, 12, 883, 440, 1255, 1736, 912, 268, 3982, 590, 267, 1449, 523, 267, 15422, 270, 28332, 275, 598, 28582, 280, 2409, 31060, 342, 267, 15422, 270, 28332, 14, 8222, 342, 2126, 267, 543, 336, 279, 16349, 14, 4665, 7744, 8, 25050, 63, 3998, 63, 16436, 29, 277, 14, 26071, 63, 694, 12, 2490, 26595, 3657, 29, 55, 279, 497, 1168, 31464, 3498, 1746, 14, 270, 28332, 63, 719, 12, 2490, 26595, 17873, 29, 277, 14, 4198, 4659, 9, 465, 2589, 26, 288, 511, 63, 2546, 63, 513, 17, 275, 942, 288, 511, 63, 2546, 63, 513, 17, 14, 740, 480, 17901, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 14807, 14, 68, 757, 14, 396, 63, 68, 757, 14, 36, 1698, 1746, 531, 288, 511, 63, 2546, 63, 513, 17, 14, 740, 480, 17901, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 14807, 14, 17102, 14, 396, 63, 17102, 14, 31868, 1746, 531, 288, 291, 14, 396, 63, 2546, 63, 13444, 14, 740, 8, 396, 63, 2546, 63, 513, 17, 9, 953, 511, 63, 2546, 63, 513, 18, 275, 942, 288, 511, 63, 2546, 63, 513, 18, 14, 740, 480, 17901, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 14807, 14, 55, 279, 497, 1168, 31464, 3498, 1746, 14, 1074, 63, 12324, 63, 8359, 531, 288, 291, 14, 396, 63, 2546, 63, 13444, 14, 740, 8, 396, 63, 2546, 63, 513, 18, 9, 953, 511, 63, 2546, 63, 513, 19, 275, 942, 288, 511, 63, 2546, 63, 513, 19, 14, 740, 480, 17901, 14, 4927, 697, 14, 2219, 14, 3494, 14, 20877, 16349, 14, 14807, 14, 4712, 14, 4712, 14, 1451, 7496, 1746, 531, 288, 291, 14, 396, 63, 2546, 63, 13444, 14, 740, 8, 396, 63, 2546, 63, 513, 19, 9, 267, 10275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jfisher-usgs/DigitalLibrary
files/form_addFolder.py
1
1306
## Script (Python) "form_addFolder" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## request = container.REQUEST REQUEST = context.REQUEST publicStatus = '' if not context.anonymousHasPermission(context): publicStatus = 'DISABLED' print context.standard_html_header(context, request) print '<form action="' + REQUEST['URL1'] + '" method="post" enctype="multipart/form-data">' print '<h1>New Folder</h1>' print '<fieldset>' print '<ol>' print '<li>' print '<label for="new_folder">Name</label>' print '<input type="text" value="" name="new_folder" id="new_folder" size="30" />' print '<input type="checkbox" name="public_folder" title="Grant anonymous users view/access permissions" ' + publicStatus + ' />Public' print '<input type="checkbox" name="image_folder" title="Add image gallery" />Image' print '</li>' print '</ol>' print '</fieldset>' print '<fieldset class="submit">' print '<input type="submit" name="action" value=" Add " />' print '<input type="submit" name="action" value="Cancel" />' print '</fieldset>' print '</form>' print '<script type="text/javascript">setDefaultFocus(\'new_folder\');</script>' print context.standard_html_footer(context, request) return printed
gpl-2.0
[ 309, 14914, 334, 4718, 9, 298, 964, 63, 525, 7850, 2, 199, 309, 3409, 3970, 29, 3600, 199, 309, 3409, 1067, 29, 1100, 199, 309, 3409, 3231, 29, 199, 309, 3409, 2884, 29, 1579, 199, 309, 3409, 25582, 29, 23650, 63, 954, 515, 199, 309, 3214, 29, 199, 309, 1213, 29, 199, 309, 199, 1069, 221, 275, 3970, 14, 6780, 199, 6780, 221, 275, 1067, 14, 6780, 199, 199, 3455, 3694, 275, 2125, 199, 692, 440, 1067, 14, 12628, 6362, 7980, 8, 1100, 304, 272, 4575, 3694, 275, 283, 16205, 7, 1362, 199, 1361, 1067, 14, 6807, 63, 1360, 63, 1291, 8, 1100, 12, 1056, 9, 199, 199, 1361, 2650, 964, 1595, 26957, 435, 31325, 459, 2632, 17, 418, 435, 5522, 1083, 628, 1932, 2, 655, 3667, 628, 10123, 15, 964, 13, 576, 15603, 199, 199, 1361, 2650, 72, 17, 30, 4665, 29121, 1108, 72, 17, 3524, 199, 199, 1361, 2650, 698, 409, 3524, 199, 1361, 2650, 393, 3524, 199, 199, 1361, 2650, 317, 3524, 199, 1361, 2650, 1302, 367, 628, 1222, 63, 3741, 1743, 985, 1108, 1302, 3524, 199, 1361, 2650, 1210, 730, 628, 505, 2, 574, 9287, 536, 628, 1222, 63, 3741, 2, 1305, 628, 1222, 63, 3741, 2, 1568, 628, 1216, 2, 22294, 199, 1361, 2650, 1210, 730, 628, 13456, 2, 536, 628, 3455, 63, 3741, 2, 2538, 628, 39, 17633, 16535, 4390, 2455, 15, 2732, 3443, 2, 283, 435, 4575, 3694, 435, 283, 7082, 9885, 7, 199, 1361, 2650, 1210, 730, 628, 13456, 2, 536, 628, 1569, 63, 3741, 2, 2538, 628, 1123, 1834, 486, 17787, 2, 7082, 3491, 7, 199, 1361, 11936, 317, 3524, 199, 199, 1361, 11936, 393, 3524, 199, 1361, 11936, 698, 409, 3524, 199, 199, 1361, 2650, 698, 409, 1021, 628, 7275, 15603, 199, 1361, 2650, 1210, 730, 628, 7275, 2, 536, 628, 1287, 2, 574, 628, 2654, 298, 22294, 199, 1361, 2650, 1210, 730, 628, 7275, 2, 536, 628, 1287, 2, 574, 628, 9083, 2, 22294, 199, 1361, 11936, 698, 409, 3524, 199, 199, 1361, 11936, 964, 3524, 199, 199, 1361, 2650, 1579, 730, 628, 505, 15, 9554, 1743, 409, 2698, 17310, 30338, 1222, 63, 3741, 60, 11339, 1108, 1579, 3524, 199, 199, 1361, 1067, 14, 6807, 63, 1360, 63, 12781, 8, 1100, 12, 1056, 9, 199, 199, 1107, 12487, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 14914, 334, 4718, 9, 298, 964, 63, 525, 7850, 2, 199, 309, 3409, 3970, 29, 3600, 199, 309, 3409, 1067, 29, 1100, 199, 309, 3409, 3231, 29, 199, 309, 3409, 2884, 29, 1579, 199, 309, 3409, 25582, 29, 23650, 63, 954, 515, 199, 309, 3214, 29, 199, 309, 1213, 29, 199, 309, 199, 1069, 221, 275, 3970, 14, 6780, 199, 6780, 221, 275, 1067, 14, 6780, 199, 199, 3455, 3694, 275, 2125, 199, 692, 440, 1067, 14, 12628, 6362, 7980, 8, 1100, 304, 272, 4575, 3694, 275, 283, 16205, 7, 1362, 199, 1361, 1067, 14, 6807, 63, 1360, 63, 1291, 8, 1100, 12, 1056, 9, 199, 199, 1361, 2650, 964, 1595, 26957, 435, 31325, 459, 2632, 17, 418, 435, 5522, 1083, 628, 1932, 2, 655, 3667, 628, 10123, 15, 964, 13, 576, 15603, 199, 199, 1361, 2650, 72, 17, 30, 4665, 29121, 1108, 72, 17, 3524, 199, 199, 1361, 2650, 698, 409, 3524, 199, 1361, 2650, 393, 3524, 199, 199, 1361, 2650, 317, 3524, 199, 1361, 2650, 1302, 367, 628, 1222, 63, 3741, 1743, 985, 1108, 1302, 3524, 199, 1361, 2650, 1210, 730, 628, 505, 2, 574, 9287, 536, 628, 1222, 63, 3741, 2, 1305, 628, 1222, 63, 3741, 2, 1568, 628, 1216, 2, 22294, 199, 1361, 2650, 1210, 730, 628, 13456, 2, 536, 628, 3455, 63, 3741, 2, 2538, 628, 39, 17633, 16535, 4390, 2455, 15, 2732, 3443, 2, 283, 435, 4575, 3694, 435, 283, 7082, 9885, 7, 199, 1361, 2650, 1210, 730, 628, 13456, 2, 536, 628, 1569, 63, 3741, 2, 2538, 628, 1123, 1834, 486, 17787, 2, 7082, 3491, 7, 199, 1361, 11936, 317, 3524, 199, 199, 1361, 11936, 393, 3524, 199, 1361, 11936, 698, 409, 3524, 199, 199, 1361, 2650, 698, 409, 1021, 628, 7275, 15603, 199, 1361, 2650, 1210, 730, 628, 7275, 2, 536, 628, 1287, 2, 574, 628, 2654, 298, 22294, 199, 1361, 2650, 1210, 730, 628, 7275, 2, 536, 628, 1287, 2, 574, 628, 9083, 2, 22294, 199, 1361, 11936, 698, 409, 3524, 199, 199, 1361, 11936, 964, 3524, 199, 199, 1361, 2650, 1579, 730, 628, 505, 15, 9554, 1743, 409, 2698, 17310, 30338, 1222, 63, 3741, 60, 11339, 1108, 1579, 3524, 199, 199, 1361, 1067, 14, 6807, 63, 1360, 63, 12781, 8, 1100, 12, 1056, 9, 199, 199, 1107, 12487, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
balister/gnuradio
gr-blocks/python/blocks/qa_tag_gate.py
39
1480
#!/usr/bin/env python # # Copyright 2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio 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, or (at your option) # any later version. # # GNU Radio 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 GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. # from gnuradio import gr, gr_unittest, blocks import pmt class qa_tag_gate (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () def tearDown (self): self.tb = None def test_001_t (self): tag = gr.tag_t() tag.key = pmt.string_to_symbol('key') tag.value = pmt.from_long(42) tag.offset = 0 src = blocks.vector_source_f(range(20), False, 1, (tag,)) gate = blocks.tag_gate(gr.sizeof_float, False) sink = blocks.vector_sink_f() self.tb.run () self.assertEqual(len(sink.tags()), 0) if __name__ == '__main__': gr_unittest.run(qa_tag_gate, "qa_tag_gate.xml")
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6171, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 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, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 504, 24526, 492, 7192, 12, 7192, 63, 2796, 12, 5664, 199, 646, 30961, 421, 199, 533, 31879, 63, 1450, 63, 3237, 334, 2587, 63, 2796, 14, 1746, 304, 339, 347, 3613, 334, 277, 304, 267, 291, 14, 5842, 275, 7192, 14, 2119, 63, 1457, 6248, 339, 347, 6766, 334, 277, 304, 267, 291, 14, 5842, 275, 488, 339, 347, 511, 63, 4587, 63, 84, 334, 277, 304, 267, 1947, 275, 7192, 14, 1450, 63, 84, 342, 267, 1947, 14, 498, 275, 30961, 14, 875, 63, 475, 63, 5155, 360, 498, 358, 267, 1947, 14, 585, 275, 30961, 14, 504, 63, 2809, 8, 2260, 9, 267, 1947, 14, 2743, 275, 378, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 70, 8, 1842, 8, 1165, 395, 756, 12, 413, 12, 334, 1450, 4641, 267, 17036, 275, 5664, 14, 1450, 63, 3237, 8, 2587, 14, 12590, 63, 1609, 12, 756, 9, 267, 19241, 275, 5664, 14, 4106, 63, 11279, 63, 70, 342, 267, 291, 14, 5842, 14, 1065, 6248, 267, 291, 14, 629, 8, 552, 8, 11279, 14, 2969, 4000, 378, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 7192, 63, 2796, 14, 1065, 8, 7096, 63, 1450, 63, 3237, 12, 298, 7096, 63, 1450, 63, 3237, 14, 1652, 531, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6171, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 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, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 504, 24526, 492, 7192, 12, 7192, 63, 2796, 12, 5664, 199, 646, 30961, 421, 199, 533, 31879, 63, 1450, 63, 3237, 334, 2587, 63, 2796, 14, 1746, 304, 339, 347, 3613, 334, 277, 304, 267, 291, 14, 5842, 275, 7192, 14, 2119, 63, 1457, 6248, 339, 347, 6766, 334, 277, 304, 267, 291, 14, 5842, 275, 488, 339, 347, 511, 63, 4587, 63, 84, 334, 277, 304, 267, 1947, 275, 7192, 14, 1450, 63, 84, 342, 267, 1947, 14, 498, 275, 30961, 14, 875, 63, 475, 63, 5155, 360, 498, 358, 267, 1947, 14, 585, 275, 30961, 14, 504, 63, 2809, 8, 2260, 9, 267, 1947, 14, 2743, 275, 378, 267, 2928, 275, 5664, 14, 4106, 63, 1365, 63, 70, 8, 1842, 8, 1165, 395, 756, 12, 413, 12, 334, 1450, 4641, 267, 17036, 275, 5664, 14, 1450, 63, 3237, 8, 2587, 14, 12590, 63, 1609, 12, 756, 9, 267, 19241, 275, 5664, 14, 4106, 63, 11279, 63, 70, 342, 267, 291, 14, 5842, 14, 1065, 6248, 267, 291, 14, 629, 8, 552, 8, 11279, 14, 2969, 4000, 378, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 7192, 63, 2796, 14, 1065, 8, 7096, 63, 1450, 63, 3237, 12, 298, 7096, 63, 1450, 63, 3237, 14, 1652, 531, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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migrations import markupfield.fields import django.utils.timezone from django.conf import settings class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('companies', '0001_initial'), ] operations = [ migrations.CreateModel( name='Job', fields=[ ('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')), ('created', models.DateTimeField(db_index=True, default=django.utils.timezone.now, blank=True)), ('updated', models.DateTimeField(blank=True)), ('company_name', models.CharField(max_length=100, blank=True, null=True)), ('company_description', markupfield.fields.MarkupField(rendered_field=True, blank=True)), ('job_title', models.CharField(max_length=100)), ('company_description_markup_type', models.CharField(max_length=30, choices=[('', '--'), ('html', 'html'), ('plain', 'plain'), ('markdown', 'markdown'), ('restructuredtext', 'restructuredtext')], default='restructuredtext', blank=True)), ('_company_description_rendered', models.TextField(editable=False)), ('city', models.CharField(max_length=100)), ('region', models.CharField(max_length=100)), ('country', models.CharField(max_length=100, db_index=True)), ('location_slug', models.SlugField(max_length=350, editable=False)), ('country_slug', models.SlugField(max_length=100, editable=False)), ('description', markupfield.fields.MarkupField(rendered_field=True, blank=True)), ('description_markup_type', models.CharField(max_length=30, choices=[('', '--'), ('html', 'html'), ('plain', 'plain'), ('markdown', 'markdown'), ('restructuredtext', 'restructuredtext')], default='restructuredtext', blank=True)), ('requirements', markupfield.fields.MarkupField(rendered_field=True, blank=True)), ('contact', models.CharField(max_length=100, blank=True, null=True)), ('_description_rendered', models.TextField(editable=False)), ('requirements_markup_type', models.CharField(max_length=30, choices=[('', '--'), ('html', 'html'), ('plain', 'plain'), ('markdown', 'markdown'), ('restructuredtext', 'restructuredtext')], default='restructuredtext', blank=True)), ('_requirements_rendered', models.TextField(editable=False)), ('email', models.EmailField(max_length=75)), ('url', models.URLField(verbose_name='URL', blank=True, null=True)), ('status', models.CharField(max_length=20, choices=[('draft', 'draft'), ('review', 'review'), ('approved', 'approved'), ('rejected', 'rejected'), ('archived', 'archived'), ('removed', 'removed'), ('expired', 'expired')], default='review', db_index=True)), ('dt_start', models.DateTimeField(null=True, verbose_name='Job start date', blank=True)), ('dt_end', models.DateTimeField(null=True, verbose_name='Job end date', blank=True)), ('telecommuting', models.BooleanField(default=False)), ('agencies', models.BooleanField(default=True)), ('is_featured', models.BooleanField(db_index=True, default=False)), ], options={ 'verbose_name': 'job', 'permissions': [('can_moderate_jobs', 'Can moderate Job listings')], 'verbose_name_plural': 'jobs', 'ordering': ('-created',), 'get_latest_by': 'created', }, bases=(models.Model,), ), migrations.CreateModel( name='JobCategory', fields=[ ('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=200)), ('slug', models.SlugField(unique=True)), ], options={ 'verbose_name': 'job category', 'verbose_name_plural': 'job categories', 'ordering': ('name',), }, bases=(models.Model,), ), migrations.CreateModel( name='JobType', fields=[ ('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=200)), ('slug', models.SlugField(unique=True)), ], options={ 'verbose_name': 'job technologies', 'verbose_name_plural': 'job technologies', 'ordering': ('name',), }, bases=(models.Model,), ), migrations.AddField( model_name='job', name='category', field=models.ForeignKey(to='jobs.JobCategory', related_name='jobs'), preserve_default=True, ), migrations.AddField( model_name='job', name='company', field=models.ForeignKey(help_text='Choose a specific company here or enter Name and Description Below', null=True, to='companies.Company', related_name='jobs', blank=True), preserve_default=True, ), migrations.AddField( model_name='job', name='creator', field=models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='jobs_job_creator', blank=True), preserve_default=True, ), migrations.AddField( model_name='job', name='job_types', field=models.ManyToManyField(to='jobs.JobType', verbose_name='Job technologies', related_name='jobs', blank=True), preserve_default=True, ), migrations.AddField( model_name='job', name='last_modified_by', field=models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL, related_name='jobs_job_modified', blank=True), preserve_default=True, ), ]
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 199, 646, 9189, 698, 14, 955, 199, 646, 1639, 14, 1208, 14, 7145, 199, 504, 1639, 14, 2190, 492, 2202, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 6180, 14, 31925, 63, 8575, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 395, 267, 661, 863, 23461, 297, 283, 4183, 63, 2747, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 6694, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 12, 2599, 63, 3966, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 3966, 297, 1709, 14, 4626, 8, 697, 63, 1080, 29, 549, 12, 849, 29, 1176, 14, 1208, 14, 7145, 14, 2131, 12, 4596, 29, 549, 1826, 355, 661, 5334, 297, 1709, 14, 4626, 8, 2500, 29, 549, 1826, 355, 661, 4627, 63, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 4596, 29, 549, 12, 2973, 29, 549, 1826, 355, 661, 4627, 63, 1802, 297, 9189, 698, 14, 955, 14, 23393, 792, 8, 16841, 63, 698, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 2423, 63, 1213, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 1826, 355, 661, 4627, 63, 1802, 63, 10131, 63, 466, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 12, 3415, 1524, 8594, 2850, 659, 661, 1360, 297, 283, 1360, 659, 661, 6104, 297, 283, 6104, 659, 661, 15653, 297, 283, 15653, 659, 661, 26854, 297, 283, 26854, 2665, 849, 534, 26854, 297, 4596, 29, 549, 1826, 355, 12331, 4627, 63, 1802, 63, 16841, 297, 1709, 14, 6254, 8, 10820, 29, 797, 1826, 355, 661, 3690, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 1826, 355, 661, 4551, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 1826, 355, 661, 6063, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 1592, 63, 1080, 29, 549, 1826, 355, 661, 1985, 63, 5464, 297, 1709, 14, 17315, 8, 988, 63, 1267, 29, 13595, 12, 14783, 29, 797, 1826, 355, 661, 6063, 63, 5464, 297, 1709, 14, 17315, 8, 988, 63, 1267, 29, 1960, 12, 14783, 29, 797, 1826, 355, 661, 1802, 297, 9189, 698, 14, 955, 14, 23393, 792, 8, 16841, 63, 698, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 1802, 63, 10131, 63, 466, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 12, 3415, 1524, 8594, 2850, 659, 661, 1360, 297, 283, 1360, 659, 661, 6104, 297, 283, 6104, 659, 661, 15653, 297, 283, 15653, 659, 661, 26854, 297, 283, 26854, 2665, 849, 534, 26854, 297, 4596, 29, 549, 1826, 355, 661, 7538, 297, 9189, 698, 14, 955, 14, 23393, 792, 8, 16841, 63, 698, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 7811, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 4596, 29, 549, 12, 2973, 29, 549, 1826, 355, 12331, 1802, 63, 16841, 297, 1709, 14, 6254, 8, 10820, 29, 797, 1826, 355, 661, 7538, 63, 10131, 63, 466, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 12, 3415, 1524, 8594, 2850, 659, 661, 1360, 297, 283, 1360, 659, 661, 6104, 297, 283, 6104, 659, 661, 15653, 297, 283, 15653, 659, 661, 26854, 297, 283, 26854, 2665, 849, 534, 26854, 297, 4596, 29, 549, 1826, 355, 12331, 7538, 63, 16841, 297, 1709, 14, 6254, 8, 10820, 29, 797, 1826, 355, 661, 2123, 297, 1709, 14, 16577, 8, 988, 63, 1267, 29, 2194, 1826, 355, 661, 633, 297, 1709, 14, 17363, 8, 3832, 63, 354, 534, 2632, 297, 4596, 29, 549, 12, 2973, 29, 549, 1826, 355, 661, 1205, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 12, 3415, 11699, 7185, 297, 283, 7185, 659, 661, 8578, 297, 283, 8578, 659, 661, 21556, 297, 283, 21556, 659, 661, 24054, 297, 283, 24054, 659, 661, 1047, 12905, 297, 283, 1047, 12905, 659, 661, 10649, 297, 283, 10649, 659, 661, 16340, 297, 283, 16340, 2665, 849, 534, 8578, 297, 1592, 63, 1080, 29, 549, 1826, 355, 661, 3583, 63, 928, 297, 1709, 14, 4626, 8, 2307, 29, 549, 12, 3376, 63, 354, 534, 6694, 1343, 1434, 297, 4596, 29, 549, 1826, 355, 661, 3583, 63, 500, 297, 1709, 14, 4626, 8, 2307, 29, 549, 12, 3376, 63, 354, 534, 6694, 1284, 1434, 297, 4596, 29, 549, 1826, 355, 661, 15253, 1404, 4655, 297, 1709, 14, 5036, 8, 885, 29, 797, 1826, 355, 661, 24758, 2578, 297, 1709, 14, 5036, 8, 885, 29, 549, 1826, 355, 661, 374, 63, 30779, 297, 1709, 14, 5036, 8, 697, 63, 1080, 29, 549, 12, 849, 29, 797, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 3832, 63, 354, 356, 283, 2423, 297, 355, 283, 6060, 356, 4274, 2425, 63, 632, 1866, 63, 6920, 297, 283, 6049, 818, 1866, 15057, 769, 780, 2665, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 6920, 297, 355, 283, 7128, 356, 12291, 3966, 5529, 355, 283, 362, 63, 7410, 63, 991, 356, 283, 3966, 297, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 6694, 7841, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 12, 2599, 63, 3966, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 1826, 355, 661, 5464, 297, 1709, 14, 17315, 8, 3235, 29, 549, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 3832, 63, 354, 356, 283, 2423, 4637, 297, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 2423, 9695, 297, 355, 283, 7128, 356, 661, 354, 5529, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 6694, 804, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 12 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 199, 646, 9189, 698, 14, 955, 199, 646, 1639, 14, 1208, 14, 7145, 199, 504, 1639, 14, 2190, 492, 2202, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 6180, 14, 31925, 63, 8575, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 395, 267, 661, 863, 23461, 297, 283, 4183, 63, 2747, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 6694, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 12, 2599, 63, 3966, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 3966, 297, 1709, 14, 4626, 8, 697, 63, 1080, 29, 549, 12, 849, 29, 1176, 14, 1208, 14, 7145, 14, 2131, 12, 4596, 29, 549, 1826, 355, 661, 5334, 297, 1709, 14, 4626, 8, 2500, 29, 549, 1826, 355, 661, 4627, 63, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 4596, 29, 549, 12, 2973, 29, 549, 1826, 355, 661, 4627, 63, 1802, 297, 9189, 698, 14, 955, 14, 23393, 792, 8, 16841, 63, 698, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 2423, 63, 1213, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 1826, 355, 661, 4627, 63, 1802, 63, 10131, 63, 466, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 12, 3415, 1524, 8594, 2850, 659, 661, 1360, 297, 283, 1360, 659, 661, 6104, 297, 283, 6104, 659, 661, 15653, 297, 283, 15653, 659, 661, 26854, 297, 283, 26854, 2665, 849, 534, 26854, 297, 4596, 29, 549, 1826, 355, 12331, 4627, 63, 1802, 63, 16841, 297, 1709, 14, 6254, 8, 10820, 29, 797, 1826, 355, 661, 3690, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 1826, 355, 661, 4551, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 1826, 355, 661, 6063, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 1592, 63, 1080, 29, 549, 1826, 355, 661, 1985, 63, 5464, 297, 1709, 14, 17315, 8, 988, 63, 1267, 29, 13595, 12, 14783, 29, 797, 1826, 355, 661, 6063, 63, 5464, 297, 1709, 14, 17315, 8, 988, 63, 1267, 29, 1960, 12, 14783, 29, 797, 1826, 355, 661, 1802, 297, 9189, 698, 14, 955, 14, 23393, 792, 8, 16841, 63, 698, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 1802, 63, 10131, 63, 466, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 12, 3415, 1524, 8594, 2850, 659, 661, 1360, 297, 283, 1360, 659, 661, 6104, 297, 283, 6104, 659, 661, 15653, 297, 283, 15653, 659, 661, 26854, 297, 283, 26854, 2665, 849, 534, 26854, 297, 4596, 29, 549, 1826, 355, 661, 7538, 297, 9189, 698, 14, 955, 14, 23393, 792, 8, 16841, 63, 698, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 7811, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 4596, 29, 549, 12, 2973, 29, 549, 1826, 355, 12331, 1802, 63, 16841, 297, 1709, 14, 6254, 8, 10820, 29, 797, 1826, 355, 661, 7538, 63, 10131, 63, 466, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1216, 12, 3415, 1524, 8594, 2850, 659, 661, 1360, 297, 283, 1360, 659, 661, 6104, 297, 283, 6104, 659, 661, 15653, 297, 283, 15653, 659, 661, 26854, 297, 283, 26854, 2665, 849, 534, 26854, 297, 4596, 29, 549, 1826, 355, 12331, 7538, 63, 16841, 297, 1709, 14, 6254, 8, 10820, 29, 797, 1826, 355, 661, 2123, 297, 1709, 14, 16577, 8, 988, 63, 1267, 29, 2194, 1826, 355, 661, 633, 297, 1709, 14, 17363, 8, 3832, 63, 354, 534, 2632, 297, 4596, 29, 549, 12, 2973, 29, 549, 1826, 355, 661, 1205, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 12, 3415, 11699, 7185, 297, 283, 7185, 659, 661, 8578, 297, 283, 8578, 659, 661, 21556, 297, 283, 21556, 659, 661, 24054, 297, 283, 24054, 659, 661, 1047, 12905, 297, 283, 1047, 12905, 659, 661, 10649, 297, 283, 10649, 659, 661, 16340, 297, 283, 16340, 2665, 849, 534, 8578, 297, 1592, 63, 1080, 29, 549, 1826, 355, 661, 3583, 63, 928, 297, 1709, 14, 4626, 8, 2307, 29, 549, 12, 3376, 63, 354, 534, 6694, 1343, 1434, 297, 4596, 29, 549, 1826, 355, 661, 3583, 63, 500, 297, 1709, 14, 4626, 8, 2307, 29, 549, 12, 3376, 63, 354, 534, 6694, 1284, 1434, 297, 4596, 29, 549, 1826, 355, 661, 15253, 1404, 4655, 297, 1709, 14, 5036, 8, 885, 29, 797, 1826, 355, 661, 24758, 2578, 297, 1709, 14, 5036, 8, 885, 29, 549, 1826, 355, 661, 374, 63, 30779, 297, 1709, 14, 5036, 8, 697, 63, 1080, 29, 549, 12, 849, 29, 797, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 3832, 63, 354, 356, 283, 2423, 297, 355, 283, 6060, 356, 4274, 2425, 63, 632, 1866, 63, 6920, 297, 283, 6049, 818, 1866, 15057, 769, 780, 2665, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 6920, 297, 355, 283, 7128, 356, 12291, 3966, 5529, 355, 283, 362, 63, 7410, 63, 991, 356, 283, 3966, 297, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 6694, 7841, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 12, 2599, 63, 3966, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 661, 354, 297, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 1826, 355, 661, 5464, 297, 1709, 14, 17315, 8, 3235, 29, 549, 1826, 288, 2156, 288, 1511, 3126, 355, 283, 3832, 63, 354, 356, 283, 2423, 4637, 297, 355, 283, 3832, 63, 354, 63, 10019, 356, 283, 2423, 9695, 297, 355, 283, 7128, 356, 661, 354, 5529, 288, 1660, 288, 9768, 2687, 992, 14, 1685, 4706, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 6694, 804, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
anthropo-lab/XP
EPHEMER/insider_trading_project/insider_trading/consumers.py
1
7993
from channels import Group as channelsGroup from channels.sessions import channel_session import random from .models import Group as OtreeGroup, Subsession as OtreeSubsession, Constants import json import channels import logging from otree import constants_internal import django.test from otree.common_internal import (get_admin_secret_code) from threading import Event import time client = django.test.Client() ADMIN_SECRET_CODE = get_admin_secret_code() ############################################# ############################################# # Connected to websocket.connect def ws_admin_connect(message): print("*********CONNECT************") channelsGroup("adminreport").add(message.reply_channel) # Connected to websocket.receive def ws_admin_message(message): print("*********RECEIVE************") # Decrypt the url: No info in the url in this app # Decrypt the received message jsonmessage = json.loads(message.content['text']) subsession_pk = jsonmessage['subsession_pk'] mysubsession = OtreeSubsession.objects.get(pk=subsession_pk) if 'order' in jsonmessage: order = jsonmessage['order'] if order == "push_all_players_on_page": page_name = jsonmessage['page_name'] round_nb = jsonmessage['round_nb'] for p in mysubsession.get_players(): if ((str(p.participant._current_page_name) == page_name) & (p.participant._round_number == round_nb)): # This player is one of those who needs to be advanced try: if p.participant._current_form_page_url: resp = client.post( p.participant._current_form_page_url, data={ constants_internal.timeout_happened: True, constants_internal.admin_secret_code: ADMIN_SECRET_CODE }, follow=True ) else: resp = client.get(p.participant._start_url(), follow=True) except: logging.exception("Failed to advance participant.") raise assert resp.status_code < 400 p.participant.vars['participant_was_pushed'] = 'True' p.participant.save() channels.Group( 'auto-advance-{}'.format(p.participant.code) ).send( {'text': json.dumps( {'auto_advanced': True})} ) elif order == "push_active_players_on_page": group_pk = jsonmessage['group_pk'] mygroup = OtreeGroup.objects.get(pk=group_pk) page_name = jsonmessage['page_name'] round_nb = jsonmessage['round_nb'] for p in mygroup.get_players(): if ((str(p.participant._current_page_name) == page_name) & (p.participant._round_number == round_nb) & (p.participant.vars['active_flag'] != 'Inactive')): # This player is one of those who needs to be advanced try: if p.participant._current_form_page_url: resp = client.post( p.participant._current_form_page_url, data={ constants_internal.timeout_happened: True, constants_internal.admin_secret_code: ADMIN_SECRET_CODE }, follow=True ) else: resp = client.get(p.participant._start_url(), follow=True) except: logging.exception("Failed to advance participant.") raise assert resp.status_code < 400 p.participant.vars['participant_was_pushed'] = 'True' p.participant.save() channels.Group( 'auto-advance-{}'.format(p.participant.code) ).send( {'text': json.dumps( {'auto_advanced': True})} ) elif order == "push_inactive_players_on_page": group_pk = jsonmessage['group_pk'] mygroup = OtreeGroup.objects.get(pk=group_pk) page_name = jsonmessage['page_name'] round_nb = jsonmessage['round_nb'] for p in mygroup.get_players(): if ((str(p.participant._current_page_name) == page_name) & (p.participant._round_number == round_nb) & (p.participant.vars['active_flag'] == 'Inactive')): # This player is one of those who needs to be advanced try: if p.participant._current_form_page_url: resp = client.post( p.participant._current_form_page_url, data={ constants_internal.timeout_happened: True, constants_internal.admin_secret_code: ADMIN_SECRET_CODE }, follow=True ) else: resp = client.get(p.participant._start_url(), follow=True) except: logging.exception("Failed to advance participant.") raise assert resp.status_code < 400 p.participant.vars['participant_was_pushed'] = 'True' p.participant.save() channels.Group( 'auto-advance-{}'.format(p.participant.code) ).send( {'text': json.dumps( {'auto_advanced': True})} ) elif order == "deactivate_all_group_on_page": group_pk = jsonmessage['group_pk'] mygroup = OtreeGroup.objects.get(pk=group_pk) page_name = jsonmessage['page_name'] round_nb = jsonmessage['round_nb'] for p in mygroup.get_players(): if ((str(p.participant._current_page_name) == page_name) & (p.participant._round_number == round_nb)): p.participant.vars['active_flag'] = 'Inactive' p.participant.save() elif order == "reactivate_all_group_on_page": group_pk = jsonmessage['group_pk'] mygroup = OtreeGroup.objects.get(pk=group_pk) page_name = jsonmessage['page_name'] round_nb = jsonmessage['round_nb'] for p in mygroup.get_players(): if ((str(p.participant._current_page_name) == page_name) & (p.participant._round_number == round_nb)): p.participant.vars['active_flag'] = 'Playing_No_Change_Game' p.participant.save() elif order == "make_grouping_phase1": mysubsession.make_grouping_phase1() elif order == "make_grouping_phase2": mysubsession.make_grouping_phase2() ############################################# # Give feedback channelsGroup("adminreport").send({'text': json.dumps( {"order": "refresh"})} ) # Connected to websocket.disconnect def ws_admin_disconnect(message): print("*********DISCONNECT************") channelsGroup("adminreport").discard(message.reply_channel)
gpl-3.0
[ 504, 9245, 492, 5611, 465, 9245, 2448, 199, 504, 9245, 14, 11676, 492, 3623, 63, 1730, 199, 646, 2196, 199, 504, 1275, 992, 492, 5611, 465, 593, 2350, 2448, 12, 4804, 1730, 465, 593, 2350, 2610, 1730, 12, 22296, 199, 646, 2022, 199, 646, 9245, 199, 646, 2050, 199, 199, 504, 312, 2350, 492, 5262, 63, 4672, 199, 646, 1639, 14, 396, 199, 504, 312, 2350, 14, 2330, 63, 4672, 492, 334, 362, 63, 2113, 63, 4731, 63, 600, 9, 199, 199, 504, 5796, 492, 6763, 199, 646, 900, 199, 199, 1258, 275, 1639, 14, 396, 14, 3041, 342, 199, 14288, 63, 12961, 63, 6012, 275, 664, 63, 2113, 63, 4731, 63, 600, 342, 421, 199, 26634, 8776, 199, 26634, 8776, 199, 3, 1448, 4636, 370, 24897, 14, 2242, 199, 318, 10900, 63, 2113, 63, 2242, 8, 1188, 304, 272, 870, 480, 1801, 10, 14657, 1801, 1116, 531, 272, 9245, 2448, 480, 2113, 3070, 3471, 525, 8, 1188, 14, 8102, 63, 2775, 9, 421, 199, 3, 1448, 4636, 370, 24897, 14, 9391, 199, 318, 10900, 63, 2113, 63, 1188, 8, 1188, 304, 272, 870, 480, 1801, 10, 28467, 5399, 1801, 1116, 531, 272, 327, 13966, 13656, 314, 1166, 26, 3091, 2256, 315, 314, 1166, 315, 642, 1145, 272, 327, 13966, 13656, 314, 3086, 1245, 272, 2022, 1188, 275, 2022, 14, 3640, 8, 1188, 14, 1317, 459, 505, 1105, 272, 1007, 1730, 63, 2051, 275, 2022, 1188, 459, 954, 1730, 63, 2051, 418, 272, 333, 588, 456, 1730, 275, 593, 2350, 2610, 1730, 14, 1462, 14, 362, 8, 2051, 29, 954, 1730, 63, 2051, 9, 272, 340, 283, 1648, 7, 315, 2022, 1188, 26, 267, 1865, 275, 2022, 1188, 459, 1648, 418, 267, 340, 1865, 508, 298, 5335, 63, 452, 63, 20716, 63, 265, 63, 1606, 582, 288, 2034, 63, 354, 275, 2022, 1188, 459, 1606, 63, 354, 418, 288, 6168, 63, 4994, 275, 2022, 1188, 459, 2363, 63, 4994, 418, 288, 367, 299, 315, 333, 588, 456, 1730, 14, 362, 63, 20716, 837, 355, 340, 3666, 495, 8, 80, 14, 29253, 423, 1818, 63, 1606, 63, 354, 9, 508, 2034, 63, 354, 9, 717, 1253, 334, 80, 14, 29253, 423, 2363, 63, 1955, 508, 6168, 63, 4994, 2298, 490, 327, 961, 7748, 365, 1373, 402, 5204, 3963, 4839, 370, 506, 19472, 490, 862, 26, 717, 340, 299, 14, 29253, 423, 1818, 63, 964, 63, 1606, 63, 633, 26, 1169, 3085, 275, 1890, 14, 1932, 8, 1816, 299, 14, 29253, 423, 1818, 63, 964, 63, 1606, 63, 633, 12, 1816, 666, 3126, 2511, 5262, 63, 4672, 14, 2593, 63, 72, 5435, 379, 26, 715, 12, 2511, 5262, 63, 4672, 14, 2113, 63, 4731, 63, 600, 26, 29948, 63, 12961, 63, 6012, 1816, 1660, 1816, 2035, 29, 549, 1169, 776, 717, 587, 26, 1169, 3085, 275, 1890, 14, 362, 8, 80, 14, 29253, 423, 928, 63, 633, 1062, 2035, 29, 549, 9, 490, 871, 26, 717, 2050, 14, 1971, 480, 4276, 370, 18695, 623, 16448, 2685, 717, 746, 4951, 702, 3085, 14, 1205, 63, 600, 665, 8290, 490, 299, 14, 29253, 14, 2936, 459, 29253, 63, 10274, 63, 5335, 379, 418, 275, 283, 549, 7, 490, 299, 14, 29253, 14, 2117, 342, 490, 9245, 14, 2448, 8, 717, 283, 2495, 13, 21195, 13, 11123, 908, 8, 80, 14, 29253, 14, 600, 9, 490, 7092, 2254, 8, 717, 791, 505, 356, 2022, 14, 4180, 8, 1169, 791, 2495, 63, 14652, 356, 715, 1552, 93, 490, 776, 267, 916, 1865, 508, 298, 5335, 63, 2682, 63, 20716, 63, 265, 63, 1606, 582, 288, 1572, 63, 2051, 275, 2022, 1188, 459, 923, 63, 2051, 418, 288, 3002, 923, 275, 593, 2350, 2448, 14, 1462, 14, 362, 8, 2051, 29, 923, 63, 2051, 9, 288, 2034, 63, 354, 275, 2022, 1188, 459, 1606, 63, 354, 418, 288, 6168, 63, 4994, 275, 2022, 1188, 459, 2363, 63, 4994, 418, 288, 367, 299, 315, 3002, 923, 14, 362, 63, 20716, 837, 355, 340, 3666, 495, 8, 80, 14, 29253, 423, 1818, 63, 1606, 63, 354, 9, 508, 2034, 63, 354, 9, 717, 1253, 334, 80, 14, 29253, 423, 2363, 63, 1955, 508, 6168, 63, 4994, 9, 717, 1253, 334, 80, 14, 29253, 14, 2936, 459, 2682, 63, 4173, 418, 1137, 283, 31047, 8109, 490, 327, 961, 7748, 365, 1373, 402, 5204, 3963, 4839, 370, 506, 19472, 490, 862, 26, 717, 340, 299, 14, 29253, 423, 1818, 63, 964, 63, 1606, 63, 633, 26, 1169, 3085, 275, 1890, 14, 1932, 8, 1816, 299, 14, 29253, 423, 1818, 63, 964, 63, 1606, 63, 633, 12, 1816, 666, 3126, 2511, 5262, 63, 4672, 14, 2593, 63, 72, 5435, 379, 26, 715, 12, 2511, 5262, 63, 4672, 14, 2113, 63, 4731, 63, 600, 26, 29948, 63, 12961, 63, 6012, 1816, 1660, 1816, 2035, 29, 549, 1169, 776, 717, 587, 26, 1169, 3085, 275, 1890, 14, 362, 8, 80, 14, 29253, 423, 928, 63, 633, 1062, 2035, 29, 549, 9, 490, 871, 26, 717, 2050, 14, 1971, 480, 4276, 370, 18695, 623, 16448, 2685, 717, 746, 4951, 702, 3085, 14, 1205, 63, 600, 665, 8290, 490, 299, 14, 29253, 14, 2936, 459, 29253, 63, 10274, 63, 5335, 379, 418, 275, 283, 549, 7, 490, 299, 14, 29253, 14, 2117, 342, 490, 9245, 14, 2448, 8, 717, 283, 2495, 13, 21195, 13, 11123, 908, 8, 80, 14, 29253, 14, 600, 9, 490, 7092, 2254, 8, 717, 791, 505, 356, 2022, 14, 4180, 8, 1169, 791, 2495, 63, 14652, 356, 715, 1552, 93, 490, 776, 267, 916, 1865, 508, 298, 5335, 63, 16856, 63, 20716, 63, 265, 63, 1606, 582, 288, 1572, 63, 2051, 275, 2022, 1188, 459, 923, 63, 2051, 418, 288, 3002, 923, 275, 593, 2350, 2448, 14, 1462, 14, 362, 8, 2051, 29, 923, 63, 2051, 9, 288, 2034, 63, 354, 275, 2022, 1188, 459, 1606, 63, 354, 418, 288, 6168, 63, 4994, 275, 2022, 1188, 459, 2363, 63, 4994, 418, 288, 367, 299, 315, 3002, 923, 14, 362, 63, 20716, 837, 355, 340, 3666, 495, 8, 80, 14, 29253, 423, 1818, 63, 1606, 63, 354, 9, 508, 2034, 63, 354, 9, 717, 1253, 334, 80, 14, 29253, 423, 2363, 63, 1955, 508, 6168, 63, 4994 ]
[ 9245, 492, 5611, 465, 9245, 2448, 199, 504, 9245, 14, 11676, 492, 3623, 63, 1730, 199, 646, 2196, 199, 504, 1275, 992, 492, 5611, 465, 593, 2350, 2448, 12, 4804, 1730, 465, 593, 2350, 2610, 1730, 12, 22296, 199, 646, 2022, 199, 646, 9245, 199, 646, 2050, 199, 199, 504, 312, 2350, 492, 5262, 63, 4672, 199, 646, 1639, 14, 396, 199, 504, 312, 2350, 14, 2330, 63, 4672, 492, 334, 362, 63, 2113, 63, 4731, 63, 600, 9, 199, 199, 504, 5796, 492, 6763, 199, 646, 900, 199, 199, 1258, 275, 1639, 14, 396, 14, 3041, 342, 199, 14288, 63, 12961, 63, 6012, 275, 664, 63, 2113, 63, 4731, 63, 600, 342, 421, 199, 26634, 8776, 199, 26634, 8776, 199, 3, 1448, 4636, 370, 24897, 14, 2242, 199, 318, 10900, 63, 2113, 63, 2242, 8, 1188, 304, 272, 870, 480, 1801, 10, 14657, 1801, 1116, 531, 272, 9245, 2448, 480, 2113, 3070, 3471, 525, 8, 1188, 14, 8102, 63, 2775, 9, 421, 199, 3, 1448, 4636, 370, 24897, 14, 9391, 199, 318, 10900, 63, 2113, 63, 1188, 8, 1188, 304, 272, 870, 480, 1801, 10, 28467, 5399, 1801, 1116, 531, 272, 327, 13966, 13656, 314, 1166, 26, 3091, 2256, 315, 314, 1166, 315, 642, 1145, 272, 327, 13966, 13656, 314, 3086, 1245, 272, 2022, 1188, 275, 2022, 14, 3640, 8, 1188, 14, 1317, 459, 505, 1105, 272, 1007, 1730, 63, 2051, 275, 2022, 1188, 459, 954, 1730, 63, 2051, 418, 272, 333, 588, 456, 1730, 275, 593, 2350, 2610, 1730, 14, 1462, 14, 362, 8, 2051, 29, 954, 1730, 63, 2051, 9, 272, 340, 283, 1648, 7, 315, 2022, 1188, 26, 267, 1865, 275, 2022, 1188, 459, 1648, 418, 267, 340, 1865, 508, 298, 5335, 63, 452, 63, 20716, 63, 265, 63, 1606, 582, 288, 2034, 63, 354, 275, 2022, 1188, 459, 1606, 63, 354, 418, 288, 6168, 63, 4994, 275, 2022, 1188, 459, 2363, 63, 4994, 418, 288, 367, 299, 315, 333, 588, 456, 1730, 14, 362, 63, 20716, 837, 355, 340, 3666, 495, 8, 80, 14, 29253, 423, 1818, 63, 1606, 63, 354, 9, 508, 2034, 63, 354, 9, 717, 1253, 334, 80, 14, 29253, 423, 2363, 63, 1955, 508, 6168, 63, 4994, 2298, 490, 327, 961, 7748, 365, 1373, 402, 5204, 3963, 4839, 370, 506, 19472, 490, 862, 26, 717, 340, 299, 14, 29253, 423, 1818, 63, 964, 63, 1606, 63, 633, 26, 1169, 3085, 275, 1890, 14, 1932, 8, 1816, 299, 14, 29253, 423, 1818, 63, 964, 63, 1606, 63, 633, 12, 1816, 666, 3126, 2511, 5262, 63, 4672, 14, 2593, 63, 72, 5435, 379, 26, 715, 12, 2511, 5262, 63, 4672, 14, 2113, 63, 4731, 63, 600, 26, 29948, 63, 12961, 63, 6012, 1816, 1660, 1816, 2035, 29, 549, 1169, 776, 717, 587, 26, 1169, 3085, 275, 1890, 14, 362, 8, 80, 14, 29253, 423, 928, 63, 633, 1062, 2035, 29, 549, 9, 490, 871, 26, 717, 2050, 14, 1971, 480, 4276, 370, 18695, 623, 16448, 2685, 717, 746, 4951, 702, 3085, 14, 1205, 63, 600, 665, 8290, 490, 299, 14, 29253, 14, 2936, 459, 29253, 63, 10274, 63, 5335, 379, 418, 275, 283, 549, 7, 490, 299, 14, 29253, 14, 2117, 342, 490, 9245, 14, 2448, 8, 717, 283, 2495, 13, 21195, 13, 11123, 908, 8, 80, 14, 29253, 14, 600, 9, 490, 7092, 2254, 8, 717, 791, 505, 356, 2022, 14, 4180, 8, 1169, 791, 2495, 63, 14652, 356, 715, 1552, 93, 490, 776, 267, 916, 1865, 508, 298, 5335, 63, 2682, 63, 20716, 63, 265, 63, 1606, 582, 288, 1572, 63, 2051, 275, 2022, 1188, 459, 923, 63, 2051, 418, 288, 3002, 923, 275, 593, 2350, 2448, 14, 1462, 14, 362, 8, 2051, 29, 923, 63, 2051, 9, 288, 2034, 63, 354, 275, 2022, 1188, 459, 1606, 63, 354, 418, 288, 6168, 63, 4994, 275, 2022, 1188, 459, 2363, 63, 4994, 418, 288, 367, 299, 315, 3002, 923, 14, 362, 63, 20716, 837, 355, 340, 3666, 495, 8, 80, 14, 29253, 423, 1818, 63, 1606, 63, 354, 9, 508, 2034, 63, 354, 9, 717, 1253, 334, 80, 14, 29253, 423, 2363, 63, 1955, 508, 6168, 63, 4994, 9, 717, 1253, 334, 80, 14, 29253, 14, 2936, 459, 2682, 63, 4173, 418, 1137, 283, 31047, 8109, 490, 327, 961, 7748, 365, 1373, 402, 5204, 3963, 4839, 370, 506, 19472, 490, 862, 26, 717, 340, 299, 14, 29253, 423, 1818, 63, 964, 63, 1606, 63, 633, 26, 1169, 3085, 275, 1890, 14, 1932, 8, 1816, 299, 14, 29253, 423, 1818, 63, 964, 63, 1606, 63, 633, 12, 1816, 666, 3126, 2511, 5262, 63, 4672, 14, 2593, 63, 72, 5435, 379, 26, 715, 12, 2511, 5262, 63, 4672, 14, 2113, 63, 4731, 63, 600, 26, 29948, 63, 12961, 63, 6012, 1816, 1660, 1816, 2035, 29, 549, 1169, 776, 717, 587, 26, 1169, 3085, 275, 1890, 14, 362, 8, 80, 14, 29253, 423, 928, 63, 633, 1062, 2035, 29, 549, 9, 490, 871, 26, 717, 2050, 14, 1971, 480, 4276, 370, 18695, 623, 16448, 2685, 717, 746, 4951, 702, 3085, 14, 1205, 63, 600, 665, 8290, 490, 299, 14, 29253, 14, 2936, 459, 29253, 63, 10274, 63, 5335, 379, 418, 275, 283, 549, 7, 490, 299, 14, 29253, 14, 2117, 342, 490, 9245, 14, 2448, 8, 717, 283, 2495, 13, 21195, 13, 11123, 908, 8, 80, 14, 29253, 14, 600, 9, 490, 7092, 2254, 8, 717, 791, 505, 356, 2022, 14, 4180, 8, 1169, 791, 2495, 63, 14652, 356, 715, 1552, 93, 490, 776, 267, 916, 1865, 508, 298, 5335, 63, 16856, 63, 20716, 63, 265, 63, 1606, 582, 288, 1572, 63, 2051, 275, 2022, 1188, 459, 923, 63, 2051, 418, 288, 3002, 923, 275, 593, 2350, 2448, 14, 1462, 14, 362, 8, 2051, 29, 923, 63, 2051, 9, 288, 2034, 63, 354, 275, 2022, 1188, 459, 1606, 63, 354, 418, 288, 6168, 63, 4994, 275, 2022, 1188, 459, 2363, 63, 4994, 418, 288, 367, 299, 315, 3002, 923, 14, 362, 63, 20716, 837, 355, 340, 3666, 495, 8, 80, 14, 29253, 423, 1818, 63, 1606, 63, 354, 9, 508, 2034, 63, 354, 9, 717, 1253, 334, 80, 14, 29253, 423, 2363, 63, 1955, 508, 6168, 63, 4994, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
PulsePod/evepod
lib/python2.7/site-packages/pip/vcs/git.py
473
7898
import tempfile import re import os.path from pip.util import call_subprocess from pip.util import display_path, rmtree from pip.vcs import vcs, VersionControl from pip.log import logger from pip.backwardcompat import url2pathname, urlparse urlsplit = urlparse.urlsplit urlunsplit = urlparse.urlunsplit class Git(VersionControl): name = 'git' dirname = '.git' repo_name = 'clone' schemes = ('git', 'git+http', 'git+https', 'git+ssh', 'git+git', 'git+file') bundle_file = 'git-clone.txt' guide = ('# This was a Git repo; to make it a repo again run:\n' 'git init\ngit remote add origin %(url)s -f\ngit checkout %(rev)s\n') def __init__(self, url=None, *args, **kwargs): # Works around an apparent Git bug # (see http://article.gmane.org/gmane.comp.version-control.git/146500) if url: scheme, netloc, path, query, fragment = urlsplit(url) if scheme.endswith('file'): initial_slashes = path[:-len(path.lstrip('/'))] newpath = initial_slashes + url2pathname(path).replace('\\', '/').lstrip('/') url = urlunsplit((scheme, netloc, newpath, query, fragment)) after_plus = scheme.find('+') + 1 url = scheme[:after_plus] + urlunsplit((scheme[after_plus:], netloc, newpath, query, fragment)) super(Git, self).__init__(url, *args, **kwargs) def parse_vcs_bundle_file(self, content): url = rev = None for line in content.splitlines(): if not line.strip() or line.strip().startswith('#'): continue url_match = re.search(r'git\s*remote\s*add\s*origin(.*)\s*-f', line) if url_match: url = url_match.group(1).strip() rev_match = re.search(r'^git\s*checkout\s*-q\s*(.*)\s*', line) if rev_match: rev = rev_match.group(1).strip() if url and rev: return url, rev return None, None def export(self, location): """Export the Git repository at the url to the destination location""" temp_dir = tempfile.mkdtemp('-export', 'pip-') self.unpack(temp_dir) try: if not location.endswith('/'): location = location + '/' call_subprocess( [self.cmd, 'checkout-index', '-a', '-f', '--prefix', location], filter_stdout=self._filter, show_stdout=False, cwd=temp_dir) finally: rmtree(temp_dir) def check_rev_options(self, rev, dest, rev_options): """Check the revision options before checkout to compensate that tags and branches may need origin/ as a prefix. Returns the SHA1 of the branch or tag if found. """ revisions = self.get_refs(dest) origin_rev = 'origin/%s' % rev if origin_rev in revisions: # remote branch return [revisions[origin_rev]] elif rev in revisions: # a local tag or branch name return [revisions[rev]] else: logger.warn("Could not find a tag or branch '%s', assuming commit." % rev) return rev_options def switch(self, dest, url, rev_options): call_subprocess( [self.cmd, 'config', 'remote.origin.url', url], cwd=dest) call_subprocess( [self.cmd, 'checkout', '-q'] + rev_options, cwd=dest) self.update_submodules(dest) def update(self, dest, rev_options): # First fetch changes from the default remote call_subprocess([self.cmd, 'fetch', '-q'], cwd=dest) # Then reset to wanted revision (maby even origin/master) if rev_options: rev_options = self.check_rev_options(rev_options[0], dest, rev_options) call_subprocess([self.cmd, 'reset', '--hard', '-q'] + rev_options, cwd=dest) #: update submodules self.update_submodules(dest) def obtain(self, dest): url, rev = self.get_url_rev() if rev: rev_options = [rev] rev_display = ' (to %s)' % rev else: rev_options = ['origin/master'] rev_display = '' if self.check_destination(dest, url, rev_options, rev_display): logger.notify('Cloning %s%s to %s' % (url, rev_display, display_path(dest))) call_subprocess([self.cmd, 'clone', '-q', url, dest]) #: repo may contain submodules self.update_submodules(dest) if rev: rev_options = self.check_rev_options(rev, dest, rev_options) # Only do a checkout if rev_options differs from HEAD if not self.get_revision(dest).startswith(rev_options[0]): call_subprocess([self.cmd, 'checkout', '-q'] + rev_options, cwd=dest) def get_url(self, location): url = call_subprocess( [self.cmd, 'config', 'remote.origin.url'], show_stdout=False, cwd=location) return url.strip() def get_revision(self, location): current_rev = call_subprocess( [self.cmd, 'rev-parse', 'HEAD'], show_stdout=False, cwd=location) return current_rev.strip() def get_refs(self, location): """Return map of named refs (branches or tags) to commit hashes.""" output = call_subprocess([self.cmd, 'show-ref'], show_stdout=False, cwd=location) rv = {} for line in output.strip().splitlines(): commit, ref = line.split(' ', 1) ref = ref.strip() ref_name = None if ref.startswith('refs/remotes/'): ref_name = ref[len('refs/remotes/'):] elif ref.startswith('refs/heads/'): ref_name = ref[len('refs/heads/'):] elif ref.startswith('refs/tags/'): ref_name = ref[len('refs/tags/'):] if ref_name is not None: rv[ref_name] = commit.strip() return rv def get_src_requirement(self, dist, location, find_tags): repo = self.get_url(location) if not repo.lower().startswith('git:'): repo = 'git+' + repo egg_project_name = dist.egg_name().split('-', 1)[0] if not repo: return None current_rev = self.get_revision(location) refs = self.get_refs(location) # refs maps names to commit hashes; we need the inverse # if multiple names map to a single commit, this arbitrarily picks one names_by_commit = dict((commit, ref) for ref, commit in refs.items()) if current_rev in names_by_commit: # It's a tag full_egg_name = '%s-%s' % (egg_project_name, names_by_commit[current_rev]) else: full_egg_name = '%s-dev' % egg_project_name return '%s@%s#egg=%s' % (repo, current_rev, full_egg_name) def get_url_rev(self): """ Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'. That's required because although they use SSH they sometimes doesn't work with a ssh:// scheme (e.g. Github). But we need a scheme for parsing. Hence we remove it again afterwards and return it as a stub. """ if not '://' in self.url: assert not 'file:' in self.url self.url = self.url.replace('git+', 'git+ssh://') url, rev = super(Git, self).get_url_rev() url = url.replace('ssh://', '') else: url, rev = super(Git, self).get_url_rev() return url, rev def update_submodules(self, location): if not os.path.exists(os.path.join(location, '.gitmodules')): return call_subprocess([self.cmd, 'submodule', 'update', '--init', '--recursive', '-q'], cwd=location) vcs.register(Git)
apache-2.0
[ 646, 5549, 199, 646, 295, 199, 646, 747, 14, 515, 199, 504, 7305, 14, 1974, 492, 1240, 63, 5781, 199, 504, 7305, 14, 1974, 492, 2929, 63, 515, 12, 20978, 199, 504, 7305, 14, 15525, 492, 19827, 12, 3394, 3717, 199, 504, 7305, 14, 793, 492, 2512, 199, 504, 7305, 14, 15457, 5819, 492, 1166, 18, 12445, 12, 7097, 199, 29491, 275, 7097, 14, 29491, 199, 633, 30038, 275, 7097, 14, 633, 30038, 421, 199, 533, 12579, 8, 3353, 3717, 304, 272, 536, 275, 283, 3187, 7, 272, 9017, 275, 1987, 3187, 7, 272, 3831, 63, 354, 275, 283, 6311, 7, 272, 21149, 275, 661, 3187, 297, 283, 3187, 11, 1014, 297, 283, 3187, 11, 2859, 297, 283, 3187, 11, 5510, 297, 283, 3187, 11, 3187, 297, 283, 3187, 11, 493, 358, 272, 8844, 63, 493, 275, 283, 3187, 13, 6311, 14, 2424, 7, 272, 22885, 275, 22870, 961, 1990, 282, 12579, 3831, 27, 370, 1852, 652, 282, 3831, 4020, 1255, 3427, 78, 7, 267, 283, 3187, 4205, 60, 2753, 390, 3982, 1050, 6330, 2818, 633, 9, 83, 446, 70, 60, 2753, 390, 15243, 2818, 4964, 9, 83, 60, 78, 358, 339, 347, 636, 826, 721, 277, 12, 1166, 29, 403, 12, 627, 589, 12, 1011, 958, 304, 398, 327, 28099, 6818, 376, 27241, 12579, 6519, 267, 327, 334, 3239, 1455, 921, 6934, 14, 71, 1237, 69, 14, 1308, 15, 71, 1237, 69, 14, 863, 14, 1023, 13, 2785, 14, 3187, 15, 1079, 2182, 383, 9, 267, 340, 1166, 26, 288, 5687, 12, 10154, 12, 931, 12, 1827, 12, 7956, 275, 29596, 8, 633, 9, 288, 340, 5687, 14, 4130, 360, 493, 735, 355, 2536, 63, 24032, 275, 931, 4439, 552, 8, 515, 14, 10124, 2336, 27738, 355, 30965, 275, 2536, 63, 24032, 435, 1166, 18, 12445, 8, 515, 680, 1814, 20786, 1994, 1959, 10124, 7825, 355, 1166, 275, 1166, 30038, 1332, 5512, 12, 10154, 12, 30965, 12, 1827, 12, 7956, 430, 355, 2410, 63, 6666, 275, 5687, 14, 1623, 360, 13854, 435, 413, 355, 1166, 275, 5687, 1491, 4399, 63, 6666, 61, 435, 1166, 30038, 1332, 5512, 59, 4399, 63, 6666, 8429, 10154, 12, 30965, 12, 1827, 12, 7956, 430, 398, 1613, 8, 14686, 12, 291, 2843, 826, 721, 633, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 2198, 63, 15525, 63, 6469, 63, 493, 8, 277, 12, 1564, 304, 267, 1166, 275, 6822, 275, 488, 267, 367, 1004, 315, 1564, 14, 7644, 837, 288, 340, 440, 1004, 14, 1913, 342, 503, 1004, 14, 1913, 1252, 2460, 7863, 735, 355, 1980, 288, 1166, 63, 1431, 275, 295, 14, 1733, 8, 82, 7, 3187, 60, 83, 10, 3846, 60, 83, 10, 525, 60, 83, 10, 6493, 19276, 2862, 83, 1837, 70, 297, 1004, 9, 288, 340, 1166, 63, 1431, 26, 355, 1166, 275, 1166, 63, 1431, 14, 923, 8, 17, 680, 1913, 342, 288, 6822, 63, 1431, 275, 295, 14, 1733, 8, 82, 4289, 3187, 60, 83, 10, 12891, 60, 83, 1837, 81, 60, 83, 5830, 2795, 2862, 83, 7693, 1004, 9, 288, 340, 6822, 63, 1431, 26, 355, 6822, 275, 6822, 63, 1431, 14, 923, 8, 17, 680, 1913, 342, 288, 340, 1166, 436, 6822, 26, 355, 372, 1166, 12, 6822, 267, 372, 488, 12, 488, 339, 347, 4843, 8, 277, 12, 2909, 304, 267, 408, 11399, 314, 12579, 7611, 737, 314, 1166, 370, 314, 5724, 2909, 624, 267, 2388, 63, 694, 275, 5549, 14, 11983, 3654, 3790, 297, 283, 9983, 25815, 267, 291, 14, 5301, 8, 808, 63, 694, 9, 267, 862, 26, 288, 340, 440, 2909, 14, 4130, 18265, 355, 2909, 275, 2909, 435, 7324, 288, 1240, 63, 5781, 8, 355, 359, 277, 14, 1760, 12, 283, 12891, 13, 1080, 297, 2475, 65, 297, 2475, 70, 297, 2850, 1861, 297, 2909, 467, 355, 2457, 63, 2703, 29, 277, 423, 1541, 12, 2498, 63, 2703, 29, 797, 12, 8288, 29, 808, 63, 694, 9, 267, 3753, 26, 288, 20978, 8, 808, 63, 694, 9, 339, 347, 1104, 63, 4964, 63, 1419, 8, 277, 12, 6822, 12, 2053, 12, 6822, 63, 1419, 304, 267, 408, 1799, 314, 6974, 1511, 2544, 15243, 370, 1013, 8764, 323, 626, 3762, 267, 436, 17347, 1443, 1929, 6330, 15, 465, 282, 2403, 14, 267, 1803, 314, 12002, 17, 402, 314, 5246, 503, 1947, 340, 1911, 14, 267, 408, 267, 22164, 275, 291, 14, 362, 63, 7655, 8, 2614, 9, 398, 6330, 63, 4964, 275, 283, 6493, 3149, 83, 7, 450, 6822, 267, 340, 6330, 63, 4964, 315, 22164, 26, 288, 327, 3982, 5246, 288, 372, 359, 23449, 59, 6493, 63, 4964, 2677, 267, 916, 6822, 315, 22164, 26, 288, 327, 282, 2257, 1947, 503, 5246, 536, 288, 372, 359, 23449, 59, 4964, 2677, 267, 587, 26, 288, 2512, 14, 4050, 480, 6531, 440, 2342, 282, 1947, 503, 5246, 1543, 83, 297, 18002, 5532, 2122, 450, 6822, 9, 288, 372, 6822, 63, 1419, 339, 347, 6258, 8, 277, 12, 2053, 12, 1166, 12, 6822, 63, 1419, 304, 267, 1240, 63, 5781, 8, 288, 359, 277, 14, 1760, 12, 283, 888, 297, 283, 3846, 14, 6493, 14, 633, 297, 1166, 467, 8288, 29, 2614, 9, 267, 1240, 63, 5781, 8, 288, 359, 277, 14, 1760, 12, 283, 12891, 297, 2475, 81, 418, 435, 6822, 63, 1419, 12, 8288, 29, 2614, 9, 398, 291, 14, 873, 63, 954, 3112, 8, 2614, 9, 339, 347, 1678, 8, 277, 12, 2053, 12, 6822, 63, 1419, 304, 267, 327, 7758, 5267, 4493, 687, 314, 849, 3982, 267, 1240, 63, 5781, 779, 277, 14, 1760, 12, 283, 3535, 297, 2475, 81, 995, 8288, 29, 2614, 9, 267, 327, 9442, 5305, 370, 13632, 6974, 334, 77, 17585, 2755, 6330, 15, 4133, 9, 267, 340, 6822, 63, 1419, 26, 288, 6822, 63, 1419, 275, 291, 14, 1074, 63, 4964, 63, 1419, 8, 4964, 63, 1419, 59, 16, 467, 2053, 12, 6822, 63, 1419, 9, 267, 1240, 63, 5781, 779, 277, 14, 1760, 12, 283, 3958, 297, 2850, 8726, 297, 2475, 81, 418, 435, 6822, 63, 1419, 12, 8288, 29, 2614, 9, 267, 6079, 1678, 29449, 267, 291, 14, 873, 63, 954, 3112, 8, 2614, 9, 339, 347, 3332, 8, 277, 12, 2053, 304, 267, 1166, 12 ]
[ 5549, 199, 646, 295, 199, 646, 747, 14, 515, 199, 504, 7305, 14, 1974, 492, 1240, 63, 5781, 199, 504, 7305, 14, 1974, 492, 2929, 63, 515, 12, 20978, 199, 504, 7305, 14, 15525, 492, 19827, 12, 3394, 3717, 199, 504, 7305, 14, 793, 492, 2512, 199, 504, 7305, 14, 15457, 5819, 492, 1166, 18, 12445, 12, 7097, 199, 29491, 275, 7097, 14, 29491, 199, 633, 30038, 275, 7097, 14, 633, 30038, 421, 199, 533, 12579, 8, 3353, 3717, 304, 272, 536, 275, 283, 3187, 7, 272, 9017, 275, 1987, 3187, 7, 272, 3831, 63, 354, 275, 283, 6311, 7, 272, 21149, 275, 661, 3187, 297, 283, 3187, 11, 1014, 297, 283, 3187, 11, 2859, 297, 283, 3187, 11, 5510, 297, 283, 3187, 11, 3187, 297, 283, 3187, 11, 493, 358, 272, 8844, 63, 493, 275, 283, 3187, 13, 6311, 14, 2424, 7, 272, 22885, 275, 22870, 961, 1990, 282, 12579, 3831, 27, 370, 1852, 652, 282, 3831, 4020, 1255, 3427, 78, 7, 267, 283, 3187, 4205, 60, 2753, 390, 3982, 1050, 6330, 2818, 633, 9, 83, 446, 70, 60, 2753, 390, 15243, 2818, 4964, 9, 83, 60, 78, 358, 339, 347, 636, 826, 721, 277, 12, 1166, 29, 403, 12, 627, 589, 12, 1011, 958, 304, 398, 327, 28099, 6818, 376, 27241, 12579, 6519, 267, 327, 334, 3239, 1455, 921, 6934, 14, 71, 1237, 69, 14, 1308, 15, 71, 1237, 69, 14, 863, 14, 1023, 13, 2785, 14, 3187, 15, 1079, 2182, 383, 9, 267, 340, 1166, 26, 288, 5687, 12, 10154, 12, 931, 12, 1827, 12, 7956, 275, 29596, 8, 633, 9, 288, 340, 5687, 14, 4130, 360, 493, 735, 355, 2536, 63, 24032, 275, 931, 4439, 552, 8, 515, 14, 10124, 2336, 27738, 355, 30965, 275, 2536, 63, 24032, 435, 1166, 18, 12445, 8, 515, 680, 1814, 20786, 1994, 1959, 10124, 7825, 355, 1166, 275, 1166, 30038, 1332, 5512, 12, 10154, 12, 30965, 12, 1827, 12, 7956, 430, 355, 2410, 63, 6666, 275, 5687, 14, 1623, 360, 13854, 435, 413, 355, 1166, 275, 5687, 1491, 4399, 63, 6666, 61, 435, 1166, 30038, 1332, 5512, 59, 4399, 63, 6666, 8429, 10154, 12, 30965, 12, 1827, 12, 7956, 430, 398, 1613, 8, 14686, 12, 291, 2843, 826, 721, 633, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 2198, 63, 15525, 63, 6469, 63, 493, 8, 277, 12, 1564, 304, 267, 1166, 275, 6822, 275, 488, 267, 367, 1004, 315, 1564, 14, 7644, 837, 288, 340, 440, 1004, 14, 1913, 342, 503, 1004, 14, 1913, 1252, 2460, 7863, 735, 355, 1980, 288, 1166, 63, 1431, 275, 295, 14, 1733, 8, 82, 7, 3187, 60, 83, 10, 3846, 60, 83, 10, 525, 60, 83, 10, 6493, 19276, 2862, 83, 1837, 70, 297, 1004, 9, 288, 340, 1166, 63, 1431, 26, 355, 1166, 275, 1166, 63, 1431, 14, 923, 8, 17, 680, 1913, 342, 288, 6822, 63, 1431, 275, 295, 14, 1733, 8, 82, 4289, 3187, 60, 83, 10, 12891, 60, 83, 1837, 81, 60, 83, 5830, 2795, 2862, 83, 7693, 1004, 9, 288, 340, 6822, 63, 1431, 26, 355, 6822, 275, 6822, 63, 1431, 14, 923, 8, 17, 680, 1913, 342, 288, 340, 1166, 436, 6822, 26, 355, 372, 1166, 12, 6822, 267, 372, 488, 12, 488, 339, 347, 4843, 8, 277, 12, 2909, 304, 267, 408, 11399, 314, 12579, 7611, 737, 314, 1166, 370, 314, 5724, 2909, 624, 267, 2388, 63, 694, 275, 5549, 14, 11983, 3654, 3790, 297, 283, 9983, 25815, 267, 291, 14, 5301, 8, 808, 63, 694, 9, 267, 862, 26, 288, 340, 440, 2909, 14, 4130, 18265, 355, 2909, 275, 2909, 435, 7324, 288, 1240, 63, 5781, 8, 355, 359, 277, 14, 1760, 12, 283, 12891, 13, 1080, 297, 2475, 65, 297, 2475, 70, 297, 2850, 1861, 297, 2909, 467, 355, 2457, 63, 2703, 29, 277, 423, 1541, 12, 2498, 63, 2703, 29, 797, 12, 8288, 29, 808, 63, 694, 9, 267, 3753, 26, 288, 20978, 8, 808, 63, 694, 9, 339, 347, 1104, 63, 4964, 63, 1419, 8, 277, 12, 6822, 12, 2053, 12, 6822, 63, 1419, 304, 267, 408, 1799, 314, 6974, 1511, 2544, 15243, 370, 1013, 8764, 323, 626, 3762, 267, 436, 17347, 1443, 1929, 6330, 15, 465, 282, 2403, 14, 267, 1803, 314, 12002, 17, 402, 314, 5246, 503, 1947, 340, 1911, 14, 267, 408, 267, 22164, 275, 291, 14, 362, 63, 7655, 8, 2614, 9, 398, 6330, 63, 4964, 275, 283, 6493, 3149, 83, 7, 450, 6822, 267, 340, 6330, 63, 4964, 315, 22164, 26, 288, 327, 3982, 5246, 288, 372, 359, 23449, 59, 6493, 63, 4964, 2677, 267, 916, 6822, 315, 22164, 26, 288, 327, 282, 2257, 1947, 503, 5246, 536, 288, 372, 359, 23449, 59, 4964, 2677, 267, 587, 26, 288, 2512, 14, 4050, 480, 6531, 440, 2342, 282, 1947, 503, 5246, 1543, 83, 297, 18002, 5532, 2122, 450, 6822, 9, 288, 372, 6822, 63, 1419, 339, 347, 6258, 8, 277, 12, 2053, 12, 1166, 12, 6822, 63, 1419, 304, 267, 1240, 63, 5781, 8, 288, 359, 277, 14, 1760, 12, 283, 888, 297, 283, 3846, 14, 6493, 14, 633, 297, 1166, 467, 8288, 29, 2614, 9, 267, 1240, 63, 5781, 8, 288, 359, 277, 14, 1760, 12, 283, 12891, 297, 2475, 81, 418, 435, 6822, 63, 1419, 12, 8288, 29, 2614, 9, 398, 291, 14, 873, 63, 954, 3112, 8, 2614, 9, 339, 347, 1678, 8, 277, 12, 2053, 12, 6822, 63, 1419, 304, 267, 327, 7758, 5267, 4493, 687, 314, 849, 3982, 267, 1240, 63, 5781, 779, 277, 14, 1760, 12, 283, 3535, 297, 2475, 81, 995, 8288, 29, 2614, 9, 267, 327, 9442, 5305, 370, 13632, 6974, 334, 77, 17585, 2755, 6330, 15, 4133, 9, 267, 340, 6822, 63, 1419, 26, 288, 6822, 63, 1419, 275, 291, 14, 1074, 63, 4964, 63, 1419, 8, 4964, 63, 1419, 59, 16, 467, 2053, 12, 6822, 63, 1419, 9, 267, 1240, 63, 5781, 779, 277, 14, 1760, 12, 283, 3958, 297, 2850, 8726, 297, 2475, 81, 418, 435, 6822, 63, 1419, 12, 8288, 29, 2614, 9, 267, 6079, 1678, 29449, 267, 291, 14, 873, 63, 954, 3112, 8, 2614, 9, 339, 347, 3332, 8, 277, 12, 2053, 304, 267, 1166, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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<acme@redhat.com> # Licensed under the terms of the GNU GPL License version 2 # # Translation of: # # http://sourceware.org/systemtap/wiki/WSFutexContention # # to perf python scripting. # # Measures futex contention import os, sys sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from Util import * process_names = {} thread_thislock = {} thread_blocktime = {} lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time process_names = {} # long-lived pid-to-execname mapping def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, nr, uaddr, op, val, utime, uaddr2, val3): cmd = op & FUTEX_CMD_MASK if cmd != FUTEX_WAIT: return # we don't care about originators of WAKE events process_names[tid] = comm thread_thislock[tid] = uaddr thread_blocktime[tid] = nsecs(s, ns) def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, nr, ret): if thread_blocktime.has_key(tid): elapsed = nsecs(s, ns) - thread_blocktime[tid] add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed) del thread_blocktime[tid] del thread_thislock[tid] def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): for (tid, lock) in lock_waits: min, max, avg, count = lock_waits[tid, lock] print "%s[%d] lock %x contended %d times, %d avg ns" % \ (process_names[tid], tid, lock, count, avg)
gpl-2.0
[ 3, 289, 18173, 406, 9553, 199, 3, 334, 67, 9, 7129, 12, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 25224, 402, 26, 199, 3, 199, 3, 1455, 921, 1365, 1068, 14, 1308, 15, 2253, 16609, 15, 6797, 15, 5035, 38, 18173, 714, 9553, 199, 3, 199, 3, 370, 8582, 2366, 2884, 316, 14, 199, 3, 199, 3, 3194, 305, 1482, 289, 18173, 406, 9553, 199, 199, 646, 747, 12, 984, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 1994, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 504, 21248, 492, 627, 199, 199, 1412, 63, 1247, 275, 1052, 199, 2671, 63, 3749, 831, 275, 1052, 199, 2671, 63, 1457, 521, 275, 1052, 199, 199, 831, 63, 758, 1405, 275, 1052, 327, 1846, 13, 317, 1354, 5020, 641, 334, 5700, 12, 831, 9, 1853, 474, 14439, 900, 199, 1412, 63, 1247, 275, 1052, 327, 1846, 13, 317, 1354, 4422, 13, 475, 13, 1628, 354, 4412, 199, 199, 318, 19473, 363, 1274, 63, 4200, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 420, 14762, 12, 399, 2697, 12, 1687, 12, 1139, 12, 399, 521, 12, 399, 2697, 18, 12, 1139, 19, 304, 199, 198, 1760, 275, 1687, 1253, 481, 934, 1438, 63, 9744, 63, 12880, 199, 198, 692, 2088, 1137, 481, 934, 1438, 63, 12458, 26, 507, 198, 1107, 327, 781, 2793, 1133, 10296, 3595, 6330, 2750, 402, 644, 22339, 4474, 421, 198, 1412, 63, 1247, 59, 5700, 61, 275, 1923, 199, 198, 2671, 63, 3749, 831, 59, 5700, 61, 275, 399, 2697, 199, 198, 2671, 63, 1457, 521, 59, 5700, 61, 275, 13781, 8, 83, 12, 700, 9, 199, 199, 318, 19473, 363, 1274, 63, 2224, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 258, 14762, 12, 2203, 304, 199, 198, 692, 2462, 63, 1457, 521, 14, 1989, 63, 498, 8, 5700, 304, 507, 198, 16691, 275, 13781, 8, 83, 12, 700, 9, 446, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 525, 63, 3200, 8, 831, 63, 758, 1405, 12, 334, 5700, 12, 2462, 63, 3749, 831, 59, 5700, 2522, 14439, 9, 507, 198, 2264, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 2264, 2462, 63, 3749, 831, 59, 5700, 61, 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, 509, 334, 5700, 12, 4650, 9, 315, 4650, 63, 758, 1405, 26, 507, 198, 827, 12, 1390, 12, 12402, 12, 2338, 275, 4650, 63, 758, 1405, 59, 5700, 12, 4650, 61, 507, 198, 1361, 2071, 83, 9722, 68, 61, 4650, 450, 88, 406, 6943, 450, 68, 5431, 12, 450, 68, 12402, 700, 2, 450, 971, 686, 420, 334, 1412, 63, 1247, 59, 5700, 467, 11559, 12, 4650, 12, 2338, 12, 12402, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 289, 18173, 406, 9553, 199, 3, 334, 67, 9, 7129, 12, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 25224, 402, 26, 199, 3, 199, 3, 1455, 921, 1365, 1068, 14, 1308, 15, 2253, 16609, 15, 6797, 15, 5035, 38, 18173, 714, 9553, 199, 3, 199, 3, 370, 8582, 2366, 2884, 316, 14, 199, 3, 199, 3, 3194, 305, 1482, 289, 18173, 406, 9553, 199, 199, 646, 747, 12, 984, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 1994, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 504, 21248, 492, 627, 199, 199, 1412, 63, 1247, 275, 1052, 199, 2671, 63, 3749, 831, 275, 1052, 199, 2671, 63, 1457, 521, 275, 1052, 199, 199, 831, 63, 758, 1405, 275, 1052, 327, 1846, 13, 317, 1354, 5020, 641, 334, 5700, 12, 831, 9, 1853, 474, 14439, 900, 199, 1412, 63, 1247, 275, 1052, 327, 1846, 13, 317, 1354, 4422, 13, 475, 13, 1628, 354, 4412, 199, 199, 318, 19473, 363, 1274, 63, 4200, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 420, 14762, 12, 399, 2697, 12, 1687, 12, 1139, 12, 399, 521, 12, 399, 2697, 18, 12, 1139, 19, 304, 199, 198, 1760, 275, 1687, 1253, 481, 934, 1438, 63, 9744, 63, 12880, 199, 198, 692, 2088, 1137, 481, 934, 1438, 63, 12458, 26, 507, 198, 1107, 327, 781, 2793, 1133, 10296, 3595, 6330, 2750, 402, 644, 22339, 4474, 421, 198, 1412, 63, 1247, 59, 5700, 61, 275, 1923, 199, 198, 2671, 63, 3749, 831, 59, 5700, 61, 275, 399, 2697, 199, 198, 2671, 63, 1457, 521, 59, 5700, 61, 275, 13781, 8, 83, 12, 700, 9, 199, 199, 318, 19473, 363, 1274, 63, 2224, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1585, 258, 14762, 12, 2203, 304, 199, 198, 692, 2462, 63, 1457, 521, 14, 1989, 63, 498, 8, 5700, 304, 507, 198, 16691, 275, 13781, 8, 83, 12, 700, 9, 446, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 525, 63, 3200, 8, 831, 63, 758, 1405, 12, 334, 5700, 12, 2462, 63, 3749, 831, 59, 5700, 2522, 14439, 9, 507, 198, 2264, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 2264, 2462, 63, 3749, 831, 59, 5700, 61, 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, 509, 334, 5700, 12, 4650, 9, 315, 4650, 63, 758, 1405, 26, 507, 198, 827, 12, 1390, 12, 12402, 12, 2338, 275, 4650, 63, 758, 1405, 59, 5700, 12, 4650, 61, 507, 198, 1361, 2071, 83, 9722, 68, 61, 4650, 450, 88, 406, 6943, 450, 68, 5431, 12, 450, 68, 12402, 700, 2, 450, 971, 686, 420, 334, 1412, 63, 1247, 59, 5700, 467, 11559, 12, 4650, 12, 2338, 12, 12402, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 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1
10564
# Copyright (C) 2009, Tomeu Vizoso # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import logging import time import json from gi.repository import GObject from gi.repository import Gtk from gettext import gettext as _ from sugar3.graphics.xocolor import XoColor from sugar3.graphics import style from sugar3 import util from jarabe.journal import model from jarabe.journal import misc DS_DBUS_SERVICE = 'org.laptop.sugar.DataStore' DS_DBUS_INTERFACE = 'org.laptop.sugar.DataStore' DS_DBUS_PATH = '/org/laptop/sugar/DataStore' class ListModel(GObject.GObject, Gtk.TreeModel, Gtk.TreeDragSource): __gtype_name__ = 'JournalListModel' __gsignals__ = { 'ready': (GObject.SignalFlags.RUN_FIRST, None, ([])), 'progress': (GObject.SignalFlags.RUN_FIRST, None, ([])), } COLUMN_UID = 0 COLUMN_FAVORITE = 1 COLUMN_ICON = 2 COLUMN_ICON_COLOR = 3 COLUMN_TITLE = 4 COLUMN_TIMESTAMP = 5 COLUMN_CREATION_TIME = 6 COLUMN_FILESIZE = 7 COLUMN_PROGRESS = 8 COLUMN_BUDDY_1 = 9 COLUMN_BUDDY_2 = 10 COLUMN_BUDDY_3 = 11 COLUMN_SELECT = 12 _COLUMN_TYPES = { COLUMN_UID: str, COLUMN_FAVORITE: bool, COLUMN_ICON: str, COLUMN_ICON_COLOR: object, COLUMN_TITLE: str, COLUMN_TIMESTAMP: str, COLUMN_CREATION_TIME: str, COLUMN_FILESIZE: str, COLUMN_PROGRESS: int, COLUMN_BUDDY_1: object, COLUMN_BUDDY_3: object, COLUMN_BUDDY_2: object, COLUMN_SELECT: bool, } _PAGE_SIZE = 10 def __init__(self, query): GObject.GObject.__init__(self) self._last_requested_index = None self._temp_drag_file_uid = None self._cached_row = None self._query = query self._all_ids = [] t = time.time() self._result_set = model.find(query, ListModel._PAGE_SIZE) logging.debug('init resultset: %r', time.time() - t) self._temp_drag_file_path = None self._selected = [] # HACK: The view will tell us that it is resizing so the model can # avoid hitting D-Bus and disk. self.view_is_resizing = False # Store the changes originated in the treeview so we do not need # to regenerate the model and stuff up the scroll position self._updated_entries = {} self._result_set.ready.connect(self.__result_set_ready_cb) self._result_set.progress.connect(self.__result_set_progress_cb) def get_all_ids(self): return self._all_ids def __result_set_ready_cb(self, **kwargs): t = time.time() self._all_ids = self._result_set.find_ids(self._query) logging.debug('get all ids: %r', time.time() - t) self.emit('ready') def __result_set_progress_cb(self, **kwargs): self.emit('progress') def setup(self, updated_callback=None): self._result_set.setup() self._updated_callback = updated_callback def stop(self): self._result_set.stop() def get_metadata(self, path): return model.get(self[path][ListModel.COLUMN_UID]) def do_get_n_columns(self): return len(ListModel._COLUMN_TYPES) def do_get_column_type(self, index): return ListModel._COLUMN_TYPES[index] def do_iter_n_children(self, iterator): if iterator is None: return self._result_set.length else: return 0 def set_value(self, iterator, column, value): index = iterator.user_data self._result_set.seek(index) metadata = self._result_set.read() if column == ListModel.COLUMN_FAVORITE: metadata['keep'] = value if column == ListModel.COLUMN_TITLE: metadata['title'] = value self._updated_entries[metadata['uid']] = metadata if self._updated_callback is not None: model.updated.disconnect(self._updated_callback) model.write(metadata, update_mtime=False, ready_callback=self.__reconnect_updates_cb) def __reconnect_updates_cb(self, metadata, filepath, uid): logging.error('__reconnect_updates_cb') if self._updated_callback is not None: model.updated.connect(self._updated_callback) def do_get_value(self, iterator, column): if self.view_is_resizing: return None index = iterator.user_data if index == self._last_requested_index: return self._cached_row[column] if index >= self._result_set.length: return None self._result_set.seek(index) metadata = self._result_set.read() metadata.update(self._updated_entries.get(metadata['uid'], {})) self._last_requested_index = index self._cached_row = [] self._cached_row.append(metadata['uid']) self._cached_row.append(metadata.get('keep', '0') == '1') self._cached_row.append(misc.get_icon_name(metadata)) if misc.is_activity_bundle(metadata): xo_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(), style.COLOR_TRANSPARENT.get_svg())) else: xo_color = misc.get_icon_color(metadata) self._cached_row.append(xo_color) title = GObject.markup_escape_text(metadata.get('title', _('Untitled'))) self._cached_row.append('<b>%s</b>' % (title, )) try: timestamp = float(metadata.get('timestamp', 0)) except (TypeError, ValueError): timestamp_content = _('Unknown') else: timestamp_content = util.timestamp_to_elapsed_string(timestamp) self._cached_row.append(timestamp_content) try: creation_time = float(metadata.get('creation_time')) except (TypeError, ValueError): self._cached_row.append(_('Unknown')) else: self._cached_row.append( util.timestamp_to_elapsed_string(float(creation_time))) try: size = int(metadata.get('filesize')) except (TypeError, ValueError): size = None self._cached_row.append(util.format_size(size)) try: progress = int(float(metadata.get('progress', 100))) except (TypeError, ValueError): progress = 100 self._cached_row.append(progress) buddies = [] if metadata.get('buddies'): try: buddies = json.loads(metadata['buddies']).values() except json.decoder.JSONDecodeError, exception: logging.warning('Cannot decode buddies for %r: %s', metadata['uid'], exception) if not isinstance(buddies, list): logging.warning('Content of buddies for %r is not a list: %r', metadata['uid'], buddies) buddies = [] for n_ in xrange(0, 3): if buddies: try: nick, color = buddies.pop(0) except (AttributeError, ValueError), exception: logging.warning('Malformed buddies for %r: %s', metadata['uid'], exception) else: self._cached_row.append([nick, XoColor(color)]) continue self._cached_row.append(None) return self._cached_row[column] def do_iter_nth_child(self, parent_iter, n): return (False, None) def do_get_path(self, iterator): treepath = Gtk.TreePath((iterator.user_data,)) return treepath def do_get_iter(self, path): idx = path.get_indices()[0] iterator = Gtk.TreeIter() iterator.user_data = idx return (True, iterator) def do_iter_next(self, iterator): idx = iterator.user_data + 1 if idx >= self._result_set.length: iterator.stamp = -1 return (False, iterator) else: iterator.user_data = idx return (True, iterator) def do_get_flags(self): return Gtk.TreeModelFlags.ITERS_PERSIST | Gtk.TreeModelFlags.LIST_ONLY def do_iter_children(self, iterator): return (False, iterator) def do_iter_has_child(self, iterator): return False def do_iter_parent(self, iterator): return (False, Gtk.TreeIter()) def do_drag_data_get(self, path, selection): uid = self[path][ListModel.COLUMN_UID] target_atom = selection.get_target() target_name = target_atom.name() if target_name == 'text/uri-list': # Only get a new temp path if we have a new file, the frame # requests a path many times and if we give it a new path it # ends up with a broken path if uid != self._temp_drag_file_uid: # Get hold of a reference so the temp file doesn't get deleted self._temp_drag_file_path = model.get_file(uid) self._temp_drag_file_uid = uid logging.debug('putting %r in selection', self._temp_drag_file_path) selection.set(target_atom, 8, self._temp_drag_file_path) return True elif target_name == 'journal-object-id': # uid is unicode but Gtk.SelectionData.set() needs str selection.set(target_atom, 8, str(uid)) return True return False def set_selected(self, uid, value): if value: self._selected.append(uid) else: self._selected.remove(uid) def is_selected(self, uid): return uid in self._selected def get_selected_items(self): return self._selected def restore_selection(self, selected): self._selected = selected def select_all(self): self._selected = self._all_ids[:] def select_none(self): self._selected = []
gpl-3.0
[ 3, 1898, 334, 35, 9, 8937, 12, 377, 1377, 85, 812, 565, 736, 79, 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, 199, 646, 2050, 199, 646, 900, 199, 199, 646, 2022, 199, 504, 18895, 14, 8421, 492, 31264, 199, 504, 18895, 14, 8421, 492, 11424, 199, 504, 9796, 492, 9796, 465, 485, 199, 199, 504, 308, 21922, 19, 14, 15707, 14, 15987, 2326, 492, 1323, 79, 4117, 199, 504, 308, 21922, 19, 14, 15707, 492, 3449, 199, 504, 308, 21922, 19, 492, 4884, 199, 199, 504, 16290, 7570, 14, 7067, 492, 1402, 199, 504, 16290, 7570, 14, 7067, 492, 18576, 421, 199, 3177, 63, 2846, 1668, 63, 10486, 275, 283, 1308, 14, 416, 541, 411, 14, 83, 21922, 14, 1451, 5502, 7, 199, 3177, 63, 2846, 1668, 63, 17598, 275, 283, 1308, 14, 416, 541, 411, 14, 83, 21922, 14, 1451, 5502, 7, 199, 3177, 63, 2846, 1668, 63, 3243, 275, 1994, 1308, 15, 416, 541, 411, 15, 83, 21922, 15, 1451, 5502, 7, 421, 199, 533, 3820, 1685, 8, 39, 1692, 14, 39, 1692, 12, 11424, 14, 3987, 1685, 12, 11424, 14, 3987, 20287, 2980, 304, 272, 636, 71, 466, 63, 354, 363, 275, 283, 25909, 1296, 1685, 7, 339, 636, 71, 10458, 363, 275, 469, 267, 283, 2179, 356, 334, 39, 1692, 14, 11274, 6381, 14, 9390, 63, 12903, 12, 488, 12, 7287, 12884, 267, 283, 5734, 356, 334, 39, 1692, 14, 11274, 6381, 14, 9390, 63, 12903, 12, 488, 12, 7287, 12884, 272, 789, 339, 29955, 63, 6685, 275, 378, 272, 29955, 63, 2078, 54, 726, 4427, 275, 413, 272, 29955, 63, 15903, 275, 499, 272, 29955, 63, 15903, 63, 7134, 275, 650, 272, 29955, 63, 19091, 275, 841, 272, 29955, 63, 20277, 275, 959, 272, 29955, 63, 5798, 2594, 63, 4961, 275, 1227, 272, 29955, 63, 9472, 11025, 275, 1520, 272, 29955, 63, 24547, 275, 1695, 272, 29955, 63, 2910, 5745, 57, 63, 17, 275, 1749, 272, 29955, 63, 2910, 5745, 57, 63, 18, 275, 1616, 272, 29955, 63, 2910, 5745, 57, 63, 19, 275, 4119, 272, 29955, 63, 4859, 275, 3144, 339, 485, 21436, 63, 7893, 275, 469, 267, 29955, 63, 6685, 26, 620, 12, 267, 29955, 63, 2078, 54, 726, 4427, 26, 2155, 12, 267, 29955, 63, 15903, 26, 620, 12, 267, 29955, 63, 15903, 63, 7134, 26, 909, 12, 267, 29955, 63, 19091, 26, 620, 12, 267, 29955, 63, 20277, 26, 620, 12, 267, 29955, 63, 5798, 2594, 63, 4961, 26, 620, 12, 267, 29955, 63, 9472, 11025, 26, 620, 12, 267, 29955, 63, 24547, 26, 1109, 12, 267, 29955, 63, 2910, 5745, 57, 63, 17, 26, 909, 12, 267, 29955, 63, 2910, 5745, 57, 63, 19, 26, 909, 12, 267, 29955, 63, 2910, 5745, 57, 63, 18, 26, 909, 12, 267, 29955, 63, 4859, 26, 2155, 12, 272, 789, 339, 485, 12898, 63, 4305, 275, 1616, 339, 347, 636, 826, 721, 277, 12, 1827, 304, 267, 31264, 14, 39, 1692, 855, 826, 721, 277, 9, 398, 291, 423, 2019, 63, 11151, 63, 1080, 275, 488, 267, 291, 423, 808, 63, 14479, 63, 493, 63, 1535, 275, 488, 267, 291, 423, 5245, 63, 1143, 275, 488, 267, 291, 423, 1131, 275, 1827, 267, 291, 423, 452, 63, 1580, 275, 942, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 1099, 63, 409, 275, 1402, 14, 1623, 8, 1131, 12, 3820, 1685, 423, 12898, 63, 4305, 9, 267, 2050, 14, 1757, 360, 826, 754, 409, 26, 450, 82, 297, 900, 14, 521, 342, 446, 307, 9, 267, 291, 423, 808, 63, 14479, 63, 493, 63, 515, 275, 488, 267, 291, 423, 5511, 275, 942, 398, 327, 31697, 26, 710, 2455, 911, 11480, 2739, 626, 652, 365, 295, 30639, 880, 314, 1402, 883, 267, 327, 5126, 9793, 1337, 577, 13, 12106, 436, 4543, 14, 267, 291, 14, 1345, 63, 374, 63, 264, 30639, 275, 756, 398, 327, 13874, 314, 4493, 6330, 972, 315, 314, 3123, 1345, 880, 781, 886, 440, 1929, 267, 327, 370, 30943, 314, 1402, 436, 8292, 1536, 314, 13704, 3421, 267, 291, 423, 5334, 63, 3189, 275, 1052, 398, 291, 423, 1099, 63, 409, 14, 2179, 14, 2242, 8, 277, 855, 1099, 63, 409, 63, 2179, 63, 2894, 9, 267, 291, 423, 1099, 63, 409, 14, 5734, 14, 2242, 8, 277, 855, 1099, 63, 409, 63, 5734, 63, 2894, 9, 339, 347, 664, 63, 452, 63, 1580, 8, 277, 304, 267, 372, 291, 423, 452, 63, 1580, 339, 347, 636, 1099, 63, 409, 63, 2179, 63, 2894, 8, 277, 12, 1011, 958, 304, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 452, 63, 1580, 275, 291, 423, 1099, 63, 409, 14, 1623, 63, 1580, 8, 277, 423, 1131, 9, 267, 2050, 14, 1757, 360, 362, 1006, 2762, 26, 450, 82, 297, 900, 14, 521, 342, 446, 307, 9, 267, 291, 14, 8159, 360, 2179, 358, 339, 347, 636, 1099, 63, 409, 63, 5734, 63, 2894, 8, 277, 12, 1011, 958, 304, 267, 291, 14, 8159, 360, 5734, 358, 339, 347, 3272, 8, 277, 12, 4588, 63, 3058, 29, 403, 304, 267, 291, 423, 1099, 63, 409, 14, 2758, 342, 267, 291, 423, 5334, 63, 3058, 275, 4588, 63, 3058, 339, 347, 3631, 8, 277, 304, 267, 291, 423, 1099, 63, 409, 14, 2379, 342, 339, 347, 664, 63 ]
[ 1898, 334, 35, 9, 8937, 12, 377, 1377, 85, 812, 565, 736, 79, 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, 199, 646, 2050, 199, 646, 900, 199, 199, 646, 2022, 199, 504, 18895, 14, 8421, 492, 31264, 199, 504, 18895, 14, 8421, 492, 11424, 199, 504, 9796, 492, 9796, 465, 485, 199, 199, 504, 308, 21922, 19, 14, 15707, 14, 15987, 2326, 492, 1323, 79, 4117, 199, 504, 308, 21922, 19, 14, 15707, 492, 3449, 199, 504, 308, 21922, 19, 492, 4884, 199, 199, 504, 16290, 7570, 14, 7067, 492, 1402, 199, 504, 16290, 7570, 14, 7067, 492, 18576, 421, 199, 3177, 63, 2846, 1668, 63, 10486, 275, 283, 1308, 14, 416, 541, 411, 14, 83, 21922, 14, 1451, 5502, 7, 199, 3177, 63, 2846, 1668, 63, 17598, 275, 283, 1308, 14, 416, 541, 411, 14, 83, 21922, 14, 1451, 5502, 7, 199, 3177, 63, 2846, 1668, 63, 3243, 275, 1994, 1308, 15, 416, 541, 411, 15, 83, 21922, 15, 1451, 5502, 7, 421, 199, 533, 3820, 1685, 8, 39, 1692, 14, 39, 1692, 12, 11424, 14, 3987, 1685, 12, 11424, 14, 3987, 20287, 2980, 304, 272, 636, 71, 466, 63, 354, 363, 275, 283, 25909, 1296, 1685, 7, 339, 636, 71, 10458, 363, 275, 469, 267, 283, 2179, 356, 334, 39, 1692, 14, 11274, 6381, 14, 9390, 63, 12903, 12, 488, 12, 7287, 12884, 267, 283, 5734, 356, 334, 39, 1692, 14, 11274, 6381, 14, 9390, 63, 12903, 12, 488, 12, 7287, 12884, 272, 789, 339, 29955, 63, 6685, 275, 378, 272, 29955, 63, 2078, 54, 726, 4427, 275, 413, 272, 29955, 63, 15903, 275, 499, 272, 29955, 63, 15903, 63, 7134, 275, 650, 272, 29955, 63, 19091, 275, 841, 272, 29955, 63, 20277, 275, 959, 272, 29955, 63, 5798, 2594, 63, 4961, 275, 1227, 272, 29955, 63, 9472, 11025, 275, 1520, 272, 29955, 63, 24547, 275, 1695, 272, 29955, 63, 2910, 5745, 57, 63, 17, 275, 1749, 272, 29955, 63, 2910, 5745, 57, 63, 18, 275, 1616, 272, 29955, 63, 2910, 5745, 57, 63, 19, 275, 4119, 272, 29955, 63, 4859, 275, 3144, 339, 485, 21436, 63, 7893, 275, 469, 267, 29955, 63, 6685, 26, 620, 12, 267, 29955, 63, 2078, 54, 726, 4427, 26, 2155, 12, 267, 29955, 63, 15903, 26, 620, 12, 267, 29955, 63, 15903, 63, 7134, 26, 909, 12, 267, 29955, 63, 19091, 26, 620, 12, 267, 29955, 63, 20277, 26, 620, 12, 267, 29955, 63, 5798, 2594, 63, 4961, 26, 620, 12, 267, 29955, 63, 9472, 11025, 26, 620, 12, 267, 29955, 63, 24547, 26, 1109, 12, 267, 29955, 63, 2910, 5745, 57, 63, 17, 26, 909, 12, 267, 29955, 63, 2910, 5745, 57, 63, 19, 26, 909, 12, 267, 29955, 63, 2910, 5745, 57, 63, 18, 26, 909, 12, 267, 29955, 63, 4859, 26, 2155, 12, 272, 789, 339, 485, 12898, 63, 4305, 275, 1616, 339, 347, 636, 826, 721, 277, 12, 1827, 304, 267, 31264, 14, 39, 1692, 855, 826, 721, 277, 9, 398, 291, 423, 2019, 63, 11151, 63, 1080, 275, 488, 267, 291, 423, 808, 63, 14479, 63, 493, 63, 1535, 275, 488, 267, 291, 423, 5245, 63, 1143, 275, 488, 267, 291, 423, 1131, 275, 1827, 267, 291, 423, 452, 63, 1580, 275, 942, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 1099, 63, 409, 275, 1402, 14, 1623, 8, 1131, 12, 3820, 1685, 423, 12898, 63, 4305, 9, 267, 2050, 14, 1757, 360, 826, 754, 409, 26, 450, 82, 297, 900, 14, 521, 342, 446, 307, 9, 267, 291, 423, 808, 63, 14479, 63, 493, 63, 515, 275, 488, 267, 291, 423, 5511, 275, 942, 398, 327, 31697, 26, 710, 2455, 911, 11480, 2739, 626, 652, 365, 295, 30639, 880, 314, 1402, 883, 267, 327, 5126, 9793, 1337, 577, 13, 12106, 436, 4543, 14, 267, 291, 14, 1345, 63, 374, 63, 264, 30639, 275, 756, 398, 327, 13874, 314, 4493, 6330, 972, 315, 314, 3123, 1345, 880, 781, 886, 440, 1929, 267, 327, 370, 30943, 314, 1402, 436, 8292, 1536, 314, 13704, 3421, 267, 291, 423, 5334, 63, 3189, 275, 1052, 398, 291, 423, 1099, 63, 409, 14, 2179, 14, 2242, 8, 277, 855, 1099, 63, 409, 63, 2179, 63, 2894, 9, 267, 291, 423, 1099, 63, 409, 14, 5734, 14, 2242, 8, 277, 855, 1099, 63, 409, 63, 5734, 63, 2894, 9, 339, 347, 664, 63, 452, 63, 1580, 8, 277, 304, 267, 372, 291, 423, 452, 63, 1580, 339, 347, 636, 1099, 63, 409, 63, 2179, 63, 2894, 8, 277, 12, 1011, 958, 304, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 452, 63, 1580, 275, 291, 423, 1099, 63, 409, 14, 1623, 63, 1580, 8, 277, 423, 1131, 9, 267, 2050, 14, 1757, 360, 362, 1006, 2762, 26, 450, 82, 297, 900, 14, 521, 342, 446, 307, 9, 267, 291, 14, 8159, 360, 2179, 358, 339, 347, 636, 1099, 63, 409, 63, 5734, 63, 2894, 8, 277, 12, 1011, 958, 304, 267, 291, 14, 8159, 360, 5734, 358, 339, 347, 3272, 8, 277, 12, 4588, 63, 3058,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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 ]
40223101/2015cda_g1
static/Brython3.1.1-20150328-091302/Lib/subprocess.py
728
67282
# subprocess - Subprocesses with accessible I/O streams # # For more information about this module, see PEP 324. # # Copyright (c) 2003-2005 by Peter Astrand <astrand@lysator.liu.se> # # Licensed to PSF under a Contributor Agreement. # See http://www.python.org/2.4/license for licensing details. r"""subprocess - Subprocesses with accessible I/O streams This module allows you to spawn processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace several other, older modules and functions, like: os.system os.spawn* Information about how the subprocess module can be used to replace these modules and functions can be found below. Using the subprocess module =========================== This module defines one class called Popen: class Popen(args, bufsize=-1, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=True, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, pass_fds=()): Arguments are: args should be a string, or a sequence of program arguments. The program to execute is normally the first item in the args sequence or string, but can be explicitly set by using the executable argument. On POSIX, with shell=False (default): In this case, the Popen class uses os.execvp() to execute the child program. args should normally be a sequence. A string will be treated as a sequence with the string as the only item (the program to execute). On POSIX, with shell=True: If args is a string, it specifies the command string to execute through the shell. If args is a sequence, the first item specifies the command string, and any additional items will be treated as additional shell arguments. On Windows: the Popen class uses CreateProcess() to execute the child program, which operates on strings. If args is a sequence, it will be converted to a string using the list2cmdline method. Please note that not all MS Windows applications interpret the command line the same way: The list2cmdline is designed for applications using the same rules as the MS C runtime. bufsize will be supplied as the corresponding argument to the io.open() function when creating the stdin/stdout/stderr pipe file objects: 0 means unbuffered (read & write are one system call and can return short), 1 means line buffered, any other positive value means use a buffer of approximately that size. A negative bufsize, the default, means the system default of io.DEFAULT_BUFFER_SIZE will be used. stdin, stdout and stderr specify the executed programs' standard input, standard output and standard error file handles, respectively. Valid values are PIPE, an existing file descriptor (a positive integer), an existing file object, and None. PIPE indicates that a new pipe to the child should be created. With None, no redirection will occur; the child's file handles will be inherited from the parent. Additionally, stderr can be STDOUT, which indicates that the stderr data from the applications should be captured into the same file handle as for stdout. On POSIX, if preexec_fn is set to a callable object, this object will be called in the child process just before the child is executed. The use of preexec_fn is not thread safe, using it in the presence of threads could lead to a deadlock in the child process before the new executable is executed. If close_fds is true, all file descriptors except 0, 1 and 2 will be closed before the child process is executed. The default for close_fds varies by platform: Always true on POSIX. True when stdin/stdout/stderr are None on Windows, false otherwise. pass_fds is an optional sequence of file descriptors to keep open between the parent and child. Providing any pass_fds implicitly sets close_fds to true. if shell is true, the specified command will be executed through the shell. If cwd is not None, the current directory will be changed to cwd before the child is executed. On POSIX, if restore_signals is True all signals that Python sets to SIG_IGN are restored to SIG_DFL in the child process before the exec. Currently this includes the SIGPIPE, SIGXFZ and SIGXFSZ signals. This parameter does nothing on Windows. On POSIX, if start_new_session is True, the setsid() system call will be made in the child process prior to executing the command. If env is not None, it defines the environment variables for the new process. If universal_newlines is false, the file objects stdin, stdout and stderr are opened as binary files, and no line ending conversion is done. If universal_newlines is true, the file objects stdout and stderr are opened as a text files, but lines may be terminated by any of '\n', the Unix end-of-line convention, '\r', the old Macintosh convention or '\r\n', the Windows convention. All of these external representations are seen as '\n' by the Python program. Also, the newlines attribute of the file objects stdout, stdin and stderr are not updated by the communicate() method. The startupinfo and creationflags, if given, will be passed to the underlying CreateProcess() function. They can specify things such as appearance of the main window and priority for the new process. (Windows only) This module also defines some shortcut functions: call(*popenargs, **kwargs): Run command with arguments. Wait for command to complete, then return the returncode attribute. The arguments are the same as for the Popen constructor. Example: >>> retcode = subprocess.call(["ls", "-l"]) check_call(*popenargs, **kwargs): Run command with arguments. Wait for command to complete. If the exit code was zero then return, otherwise raise CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute. The arguments are the same as for the Popen constructor. Example: >>> subprocess.check_call(["ls", "-l"]) 0 getstatusoutput(cmd): Return (status, output) of executing cmd in a shell. Execute the string 'cmd' in a shell with os.popen() and return a 2-tuple (status, output). cmd is actually run as '{ cmd ; } 2>&1', so that the returned output will contain output or error messages. A trailing newline is stripped from the output. The exit status for the command can be interpreted according to the rules for the C function wait(). Example: >>> subprocess.getstatusoutput('ls /bin/ls') (0, '/bin/ls') >>> subprocess.getstatusoutput('cat /bin/junk') (256, 'cat: /bin/junk: No such file or directory') >>> subprocess.getstatusoutput('/bin/junk') (256, 'sh: /bin/junk: not found') getoutput(cmd): Return output (stdout or stderr) of executing cmd in a shell. Like getstatusoutput(), except the exit status is ignored and the return value is a string containing the command's output. Example: >>> subprocess.getoutput('ls /bin/ls') '/bin/ls' check_output(*popenargs, **kwargs): Run command with arguments and return its output. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. The arguments are the same as for the Popen constructor. Example: >>> output = subprocess.check_output(["ls", "-l", "/dev/null"]) Exceptions ---------- Exceptions raised in the child process, before the new program has started to execute, will be re-raised in the parent. Additionally, the exception object will have one extra attribute called 'child_traceback', which is a string containing traceback information from the child's point of view. The most common exception raised is OSError. This occurs, for example, when trying to execute a non-existent file. Applications should prepare for OSErrors. A ValueError will be raised if Popen is called with invalid arguments. Exceptions defined within this module inherit from SubprocessError. check_call() and check_output() will raise CalledProcessError if the called process returns a non-zero return code. TimeoutExpired be raised if a timeout was specified and expired. Security -------- Unlike some other popen functions, this implementation will never call /bin/sh implicitly. This means that all characters, including shell metacharacters, can safely be passed to child processes. Popen objects ============= Instances of the Popen class have the following methods: poll() Check if child process has terminated. Returns returncode attribute. wait() Wait for child process to terminate. Returns returncode attribute. communicate(input=None) Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. communicate() returns a tuple (stdout, stderr). Note: The data read is buffered in memory, so do not use this method if the data size is large or unlimited. The following attributes are also available: stdin If the stdin argument is PIPE, this attribute is a file object that provides input to the child process. Otherwise, it is None. stdout If the stdout argument is PIPE, this attribute is a file object that provides output from the child process. Otherwise, it is None. stderr If the stderr argument is PIPE, this attribute is file object that provides error output from the child process. Otherwise, it is None. pid The process ID of the child process. returncode The child return code. A None value indicates that the process hasn't terminated yet. A negative value -N indicates that the child was terminated by signal N (POSIX only). Replacing older functions with the subprocess module ==================================================== In this section, "a ==> b" means that b can be used as a replacement for a. Note: All functions in this section fail (more or less) silently if the executed program cannot be found; this module raises an OSError exception. In the following examples, we assume that the subprocess module is imported with "from subprocess import *". Replacing /bin/sh shell backquote --------------------------------- output=`mycmd myarg` ==> output = Popen(["mycmd", "myarg"], stdout=PIPE).communicate()[0] Replacing shell pipe line ------------------------- output=`dmesg | grep hda` ==> p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE) output = p2.communicate()[0] Replacing os.system() --------------------- sts = os.system("mycmd" + " myarg") ==> p = Popen("mycmd" + " myarg", shell=True) pid, sts = os.waitpid(p.pid, 0) Note: * Calling the program through the shell is usually not required. * It's easier to look at the returncode attribute than the exitstatus. A more real-world example would look like this: try: retcode = call("mycmd" + " myarg", shell=True) if retcode < 0: print("Child was terminated by signal", -retcode, file=sys.stderr) else: print("Child returned", retcode, file=sys.stderr) except OSError as e: print("Execution failed:", e, file=sys.stderr) Replacing os.spawn* ------------------- P_NOWAIT example: pid = os.spawnlp(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg") ==> pid = Popen(["/bin/mycmd", "myarg"]).pid P_WAIT example: retcode = os.spawnlp(os.P_WAIT, "/bin/mycmd", "mycmd", "myarg") ==> retcode = call(["/bin/mycmd", "myarg"]) Vector example: os.spawnvp(os.P_NOWAIT, path, args) ==> Popen([path] + args[1:]) Environment example: os.spawnlpe(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg", env) ==> Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"}) """ import sys mswindows = (sys.platform == "win32") import io import os import time import traceback import gc import signal import builtins import warnings import errno try: from time import monotonic as _time except ImportError: from time import time as _time # Exception classes used by this module. class SubprocessError(Exception): pass class CalledProcessError(SubprocessError): """This exception is raised when a process run by check_call() or check_output() returns a non-zero exit status. The exit status will be stored in the returncode attribute; check_output() will also store the output in the output attribute. """ def __init__(self, returncode, cmd, output=None): self.returncode = returncode self.cmd = cmd self.output = output def __str__(self): return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode) class TimeoutExpired(SubprocessError): """This exception is raised when the timeout expires while waiting for a child process. """ def __init__(self, cmd, timeout, output=None): self.cmd = cmd self.timeout = timeout self.output = output def __str__(self): return ("Command '%s' timed out after %s seconds" % (self.cmd, self.timeout)) if mswindows: import threading import msvcrt import _winapi class STARTUPINFO: dwFlags = 0 hStdInput = None hStdOutput = None hStdError = None wShowWindow = 0 class pywintypes: error = IOError else: import select _has_poll = hasattr(select, 'poll') import _posixsubprocess _create_pipe = _posixsubprocess.cloexec_pipe # When select or poll has indicated that the file is writable, # we can write up to _PIPE_BUF bytes without risk of blocking. # POSIX defines PIPE_BUF as >= 512. _PIPE_BUF = getattr(select, 'PIPE_BUF', 512) __all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call", "getstatusoutput", "getoutput", "check_output", "CalledProcessError", "DEVNULL"] if mswindows: from _winapi import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP, STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, STD_ERROR_HANDLE, SW_HIDE, STARTF_USESTDHANDLES, STARTF_USESHOWWINDOW) __all__.extend(["CREATE_NEW_CONSOLE", "CREATE_NEW_PROCESS_GROUP", "STD_INPUT_HANDLE", "STD_OUTPUT_HANDLE", "STD_ERROR_HANDLE", "SW_HIDE", "STARTF_USESTDHANDLES", "STARTF_USESHOWWINDOW"]) class Handle(int): closed = False def Close(self, CloseHandle=_winapi.CloseHandle): if not self.closed: self.closed = True CloseHandle(self) def Detach(self): if not self.closed: self.closed = True return int(self) raise ValueError("already closed") def __repr__(self): return "Handle(%d)" % int(self) __del__ = Close __str__ = __repr__ try: MAXFD = os.sysconf("SC_OPEN_MAX") except: MAXFD = 256 # This lists holds Popen instances for which the underlying process had not # exited at the time its __del__ method got called: those processes are wait()ed # for synchronously from _cleanup() when a new Popen object is created, to avoid # zombie processes. _active = [] def _cleanup(): for inst in _active[:]: res = inst._internal_poll(_deadstate=sys.maxsize) if res is not None: try: _active.remove(inst) except ValueError: # This can happen if two threads create a new Popen instance. # It's harmless that it was already removed, so ignore. pass PIPE = -1 STDOUT = -2 DEVNULL = -3 def _eintr_retry_call(func, *args): while True: try: return func(*args) except InterruptedError: continue # XXX This function is only used by multiprocessing and the test suite, # but it's here so that it can be imported when Python is compiled without # threads. def _args_from_interpreter_flags(): """Return a list of command-line arguments reproducing the current settings in sys.flags and sys.warnoptions.""" flag_opt_map = { 'debug': 'd', # 'inspect': 'i', # 'interactive': 'i', 'optimize': 'O', 'dont_write_bytecode': 'B', 'no_user_site': 's', 'no_site': 'S', 'ignore_environment': 'E', 'verbose': 'v', 'bytes_warning': 'b', 'quiet': 'q', 'hash_randomization': 'R', } args = [] for flag, opt in flag_opt_map.items(): v = getattr(sys.flags, flag) if v > 0: args.append('-' + opt * v) for opt in sys.warnoptions: args.append('-W' + opt) return args def call(*popenargs, timeout=None, **kwargs): """Run command with arguments. Wait for command to complete or timeout, then return the returncode attribute. The arguments are the same as for the Popen constructor. Example: retcode = call(["ls", "-l"]) """ with Popen(*popenargs, **kwargs) as p: try: return p.wait(timeout=timeout) except: p.kill() p.wait() raise def check_call(*popenargs, **kwargs): """Run command with arguments. Wait for command to complete. If the exit code was zero then return, otherwise raise CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute. The arguments are the same as for the call function. Example: check_call(["ls", "-l"]) """ retcode = call(*popenargs, **kwargs) if retcode: cmd = kwargs.get("args") if cmd is None: cmd = popenargs[0] raise CalledProcessError(retcode, cmd) return 0 def check_output(*popenargs, timeout=None, **kwargs): r"""Run command with arguments and return its output. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. The arguments are the same as for the Popen constructor. Example: >>> check_output(["ls", "-l", "/dev/null"]) b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n' The stdout argument is not allowed as it is used internally. To capture standard error in the result, use stderr=STDOUT. >>> check_output(["/bin/sh", "-c", ... "ls -l non_existent_file ; exit 0"], ... stderr=STDOUT) b'ls: non_existent_file: No such file or directory\n' If universal_newlines=True is passed, the return value will be a string rather than bytes. """ if 'stdout' in kwargs: raise ValueError('stdout argument not allowed, it will be overridden.') with Popen(*popenargs, stdout=PIPE, **kwargs) as process: try: output, unused_err = process.communicate(timeout=timeout) except TimeoutExpired: process.kill() output, unused_err = process.communicate() raise TimeoutExpired(process.args, timeout, output=output) except: process.kill() process.wait() raise retcode = process.poll() if retcode: raise CalledProcessError(retcode, process.args, output=output) return output def list2cmdline(seq): """ Translate a sequence of arguments into a command line string, using the same rules as the MS C runtime: 1) Arguments are delimited by white space, which is either a space or a tab. 2) A string surrounded by double quotation marks is interpreted as a single argument, regardless of white space contained within. A quoted string can be embedded in an argument. 3) A double quotation mark preceded by a backslash is interpreted as a literal double quotation mark. 4) Backslashes are interpreted literally, unless they immediately precede a double quotation mark. 5) If backslashes immediately precede a double quotation mark, every pair of backslashes is interpreted as a literal backslash. If the number of backslashes is odd, the last backslash escapes the next double quotation mark as described in rule 3. """ # See # http://msdn.microsoft.com/en-us/library/17w5ykft.aspx # or search http://msdn.microsoft.com for # "Parsing C++ Command-Line Arguments" result = [] needquote = False for arg in seq: bs_buf = [] # Add a space to separate this argument from the others if result: result.append(' ') needquote = (" " in arg) or ("\t" in arg) or not arg if needquote: result.append('"') for c in arg: if c == '\\': # Don't know if we need to double yet. bs_buf.append(c) elif c == '"': # Double backslashes. result.append('\\' * len(bs_buf)*2) bs_buf = [] result.append('\\"') else: # Normal char if bs_buf: result.extend(bs_buf) bs_buf = [] result.append(c) # Add remaining backslashes, if any. if bs_buf: result.extend(bs_buf) if needquote: result.extend(bs_buf) result.append('"') return ''.join(result) # Various tools for executing commands and looking at their output and status. # # NB This only works (and is only relevant) for POSIX. def getstatusoutput(cmd): """Return (status, output) of executing cmd in a shell. Execute the string 'cmd' in a shell with os.popen() and return a 2-tuple (status, output). cmd is actually run as '{ cmd ; } 2>&1', so that the returned output will contain output or error messages. A trailing newline is stripped from the output. The exit status for the command can be interpreted according to the rules for the C function wait(). Example: >>> import subprocess >>> subprocess.getstatusoutput('ls /bin/ls') (0, '/bin/ls') >>> subprocess.getstatusoutput('cat /bin/junk') (256, 'cat: /bin/junk: No such file or directory') >>> subprocess.getstatusoutput('/bin/junk') (256, 'sh: /bin/junk: not found') """ with os.popen('{ ' + cmd + '; } 2>&1', 'r') as pipe: try: text = pipe.read() sts = pipe.close() except: process = pipe._proc process.kill() process.wait() raise if sts is None: sts = 0 if text[-1:] == '\n': text = text[:-1] return sts, text def getoutput(cmd): """Return output (stdout or stderr) of executing cmd in a shell. Like getstatusoutput(), except the exit status is ignored and the return value is a string containing the command's output. Example: >>> import subprocess >>> subprocess.getoutput('ls /bin/ls') '/bin/ls' """ return getstatusoutput(cmd)[1] _PLATFORM_DEFAULT_CLOSE_FDS = object() class Popen(object): def __init__(self, args, bufsize=-1, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=_PLATFORM_DEFAULT_CLOSE_FDS, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, pass_fds=()): """Create new Popen instance.""" _cleanup() self._child_created = False self._input = None self._communication_started = False if bufsize is None: bufsize = -1 # Restore default if not isinstance(bufsize, int): raise TypeError("bufsize must be an integer") if mswindows: if preexec_fn is not None: raise ValueError("preexec_fn is not supported on Windows " "platforms") any_stdio_set = (stdin is not None or stdout is not None or stderr is not None) if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS: if any_stdio_set: close_fds = False else: close_fds = True elif close_fds and any_stdio_set: raise ValueError( "close_fds is not supported on Windows platforms" " if you redirect stdin/stdout/stderr") else: # POSIX if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS: close_fds = True if pass_fds and not close_fds: warnings.warn("pass_fds overriding close_fds.", RuntimeWarning) close_fds = True if startupinfo is not None: raise ValueError("startupinfo is only supported on Windows " "platforms") if creationflags != 0: raise ValueError("creationflags is only supported on Windows " "platforms") self.args = args self.stdin = None self.stdout = None self.stderr = None self.pid = None self.returncode = None self.universal_newlines = universal_newlines # Input and output objects. The general principle is like # this: # # Parent Child # ------ ----- # p2cwrite ---stdin---> p2cread # c2pread <--stdout--- c2pwrite # errread <--stderr--- errwrite # # On POSIX, the child objects are file descriptors. On # Windows, these are Windows file handles. The parent objects # are file descriptors on both platforms. The parent objects # are -1 when not using PIPEs. The child objects are -1 # when not redirecting. (p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) = self._get_handles(stdin, stdout, stderr) # We wrap OS handles *before* launching the child, otherwise a # quickly terminating child could make our fds unwrappable # (see #8458). #fix me brython syntax error #if mswindows: # if p2cwrite != -1: # p2cwrite = msvcrt.open_osfhandle(p2cwrite.Detach(), 0) # if c2pread != -1: # c2pread = msvcrt.open_osfhandle(c2pread.Detach(), 0) # if errread != -1: # errread = msvcrt.open_osfhandle(errread.Detach(), 0) if p2cwrite != -1: self.stdin = io.open(p2cwrite, 'wb', bufsize) if universal_newlines: self.stdin = io.TextIOWrapper(self.stdin, write_through=True) if c2pread != -1: self.stdout = io.open(c2pread, 'rb', bufsize) if universal_newlines: self.stdout = io.TextIOWrapper(self.stdout) if errread != -1: self.stderr = io.open(errread, 'rb', bufsize) if universal_newlines: self.stderr = io.TextIOWrapper(self.stderr) self._closed_child_pipe_fds = False try: self._execute_child(args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session) except: # Cleanup if the child failed starting. for f in filter(None, (self.stdin, self.stdout, self.stderr)): try: f.close() except EnvironmentError: pass # Ignore EBADF or other errors. if not self._closed_child_pipe_fds: to_close = [] if stdin == PIPE: to_close.append(p2cread) if stdout == PIPE: to_close.append(c2pwrite) if stderr == PIPE: to_close.append(errwrite) if hasattr(self, '_devnull'): to_close.append(self._devnull) for fd in to_close: try: os.close(fd) except EnvironmentError: pass raise def _translate_newlines(self, data, encoding): data = data.decode(encoding) return data.replace("\r\n", "\n").replace("\r", "\n") def __enter__(self): return self def __exit__(self, type, value, traceback): if self.stdout: self.stdout.close() if self.stderr: self.stderr.close() if self.stdin: self.stdin.close() # Wait for the process to terminate, to avoid zombies. self.wait() def __del__(self, _maxsize=sys.maxsize, _active=_active): # If __init__ hasn't had a chance to execute (e.g. if it # was passed an undeclared keyword argument), we don't # have a _child_created attribute at all. if not getattr(self, '_child_created', False): # We didn't get to successfully create a child process. return # In case the child hasn't been waited on, check if it's done. self._internal_poll(_deadstate=_maxsize) if self.returncode is None and _active is not None: # Child is still running, keep us alive until we can wait on it. _active.append(self) def _get_devnull(self): if not hasattr(self, '_devnull'): self._devnull = os.open(os.devnull, os.O_RDWR) return self._devnull def communicate(self, input=None, timeout=None): """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be bytes to be sent to the child process, or None, if no data should be sent to the child. communicate() returns a tuple (stdout, stderr).""" if self._communication_started and input: raise ValueError("Cannot send input after starting communication") # Optimization: If we are not worried about timeouts, we haven't # started communicating, and we have one or zero pipes, using select() # or threads is unnecessary. if (timeout is None and not self._communication_started and [self.stdin, self.stdout, self.stderr].count(None) >= 2): stdout = None stderr = None if self.stdin: if input: try: self.stdin.write(input) except IOError as e: if e.errno != errno.EPIPE and e.errno != errno.EINVAL: raise self.stdin.close() elif self.stdout: stdout = _eintr_retry_call(self.stdout.read) self.stdout.close() elif self.stderr: stderr = _eintr_retry_call(self.stderr.read) self.stderr.close() self.wait() else: if timeout is not None: endtime = _time() + timeout else: endtime = None try: stdout, stderr = self._communicate(input, endtime, timeout) finally: self._communication_started = True sts = self.wait(timeout=self._remaining_time(endtime)) return (stdout, stderr) def poll(self): return self._internal_poll() def _remaining_time(self, endtime): """Convenience for _communicate when computing timeouts.""" if endtime is None: return None else: return endtime - _time() def _check_timeout(self, endtime, orig_timeout): """Convenience for checking if a timeout has expired.""" if endtime is None: return if _time() > endtime: raise TimeoutExpired(self.args, orig_timeout) if mswindows: # # Windows methods # def _get_handles(self, stdin, stdout, stderr): """Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ if stdin is None and stdout is None and stderr is None: return (-1, -1, -1, -1, -1, -1) p2cread, p2cwrite = -1, -1 c2pread, c2pwrite = -1, -1 errread, errwrite = -1, -1 if stdin is None: p2cread = _winapi.GetStdHandle(_winapi.STD_INPUT_HANDLE) if p2cread is None: p2cread, _ = _winapi.CreatePipe(None, 0) p2cread = Handle(p2cread) _winapi.CloseHandle(_) elif stdin == PIPE: p2cread, p2cwrite = _winapi.CreatePipe(None, 0) p2cread, p2cwrite = Handle(p2cread), Handle(p2cwrite) elif stdin == DEVNULL: p2cread = msvcrt.get_osfhandle(self._get_devnull()) elif isinstance(stdin, int): p2cread = msvcrt.get_osfhandle(stdin) else: # Assuming file-like object p2cread = msvcrt.get_osfhandle(stdin.fileno()) p2cread = self._make_inheritable(p2cread) if stdout is None: c2pwrite = _winapi.GetStdHandle(_winapi.STD_OUTPUT_HANDLE) if c2pwrite is None: _, c2pwrite = _winapi.CreatePipe(None, 0) c2pwrite = Handle(c2pwrite) _winapi.CloseHandle(_) elif stdout == PIPE: c2pread, c2pwrite = _winapi.CreatePipe(None, 0) c2pread, c2pwrite = Handle(c2pread), Handle(c2pwrite) elif stdout == DEVNULL: c2pwrite = msvcrt.get_osfhandle(self._get_devnull()) elif isinstance(stdout, int): c2pwrite = msvcrt.get_osfhandle(stdout) else: # Assuming file-like object c2pwrite = msvcrt.get_osfhandle(stdout.fileno()) c2pwrite = self._make_inheritable(c2pwrite) if stderr is None: errwrite = _winapi.GetStdHandle(_winapi.STD_ERROR_HANDLE) if errwrite is None: _, errwrite = _winapi.CreatePipe(None, 0) errwrite = Handle(errwrite) _winapi.CloseHandle(_) elif stderr == PIPE: errread, errwrite = _winapi.CreatePipe(None, 0) errread, errwrite = Handle(errread), Handle(errwrite) elif stderr == STDOUT: errwrite = c2pwrite elif stderr == DEVNULL: errwrite = msvcrt.get_osfhandle(self._get_devnull()) elif isinstance(stderr, int): errwrite = msvcrt.get_osfhandle(stderr) else: # Assuming file-like object errwrite = msvcrt.get_osfhandle(stderr.fileno()) errwrite = self._make_inheritable(errwrite) return (p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) def _make_inheritable(self, handle): """Return a duplicate of handle, which is inheritable""" h = _winapi.DuplicateHandle( _winapi.GetCurrentProcess(), handle, _winapi.GetCurrentProcess(), 0, 1, _winapi.DUPLICATE_SAME_ACCESS) return Handle(h) def _find_w9xpopen(self): """Find and return absolut path to w9xpopen.exe""" w9xpopen = os.path.join( os.path.dirname(_winapi.GetModuleFileName(0)), "w9xpopen.exe") if not os.path.exists(w9xpopen): # Eeek - file-not-found - possibly an embedding # situation - see if we can locate it in sys.exec_prefix w9xpopen = os.path.join(os.path.dirname(sys.base_exec_prefix), "w9xpopen.exe") if not os.path.exists(w9xpopen): raise RuntimeError("Cannot locate w9xpopen.exe, which is " "needed for Popen to work with your " "shell or platform.") return w9xpopen def _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session): """Execute program (MS Windows version)""" assert not pass_fds, "pass_fds not supported on Windows." if not isinstance(args, str): args = list2cmdline(args) # Process startup details if startupinfo is None: startupinfo = STARTUPINFO() if -1 not in (p2cread, c2pwrite, errwrite): startupinfo.dwFlags |= _winapi.STARTF_USESTDHANDLES startupinfo.hStdInput = p2cread startupinfo.hStdOutput = c2pwrite startupinfo.hStdError = errwrite if shell: startupinfo.dwFlags |= _winapi.STARTF_USESHOWWINDOW startupinfo.wShowWindow = _winapi.SW_HIDE comspec = os.environ.get("COMSPEC", "cmd.exe") args = '{} /c "{}"'.format (comspec, args) if (_winapi.GetVersion() >= 0x80000000 or os.path.basename(comspec).lower() == "command.com"): # Win9x, or using command.com on NT. We need to # use the w9xpopen intermediate program. For more # information, see KB Q150956 # (http://web.archive.org/web/20011105084002/http://support.microsoft.com/support/kb/articles/Q150/9/56.asp) w9xpopen = self._find_w9xpopen() args = '"%s" %s' % (w9xpopen, args) # Not passing CREATE_NEW_CONSOLE has been known to # cause random failures on win9x. Specifically a # dialog: "Your program accessed mem currently in # use at xxx" and a hopeful warning about the # stability of your system. Cost is Ctrl+C won't # kill children. creationflags |= _winapi.CREATE_NEW_CONSOLE # Start the process try: hp, ht, pid, tid = _winapi.CreateProcess(executable, args, # no special security None, None, int(not close_fds), creationflags, env, cwd, startupinfo) except pywintypes.error as e: # Translate pywintypes.error to WindowsError, which is # a subclass of OSError. FIXME: We should really # translate errno using _sys_errlist (or similar), but # how can this be done from Python? raise WindowsError(*e.args) finally: # Child is launched. Close the parent's copy of those pipe # handles that only the child should have open. You need # to make sure that no handles to the write end of the # output pipe are maintained in this process or else the # pipe will not close when the child process exits and the # ReadFile will hang. if p2cread != -1: p2cread.Close() if c2pwrite != -1: c2pwrite.Close() if errwrite != -1: errwrite.Close() if hasattr(self, '_devnull'): os.close(self._devnull) # Retain the process handle, but close the thread handle self._child_created = True self._handle = Handle(hp) self.pid = pid _winapi.CloseHandle(ht) def _internal_poll(self, _deadstate=None, _WaitForSingleObject=_winapi.WaitForSingleObject, _WAIT_OBJECT_0=_winapi.WAIT_OBJECT_0, _GetExitCodeProcess=_winapi.GetExitCodeProcess): """Check if child process has terminated. Returns returncode attribute. This method is called by __del__, so it can only refer to objects in its local scope. """ if self.returncode is None: if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0: self.returncode = _GetExitCodeProcess(self._handle) return self.returncode def wait(self, timeout=None, endtime=None): """Wait for child process to terminate. Returns returncode attribute.""" if endtime is not None: timeout = self._remaining_time(endtime) if timeout is None: timeout_millis = _winapi.INFINITE else: timeout_millis = int(timeout * 1000) if self.returncode is None: result = _winapi.WaitForSingleObject(self._handle, timeout_millis) if result == _winapi.WAIT_TIMEOUT: raise TimeoutExpired(self.args, timeout) self.returncode = _winapi.GetExitCodeProcess(self._handle) return self.returncode def _readerthread(self, fh, buffer): buffer.append(fh.read()) fh.close() def _communicate(self, input, endtime, orig_timeout): # Start reader threads feeding into a list hanging off of this # object, unless they've already been started. if self.stdout and not hasattr(self, "_stdout_buff"): self._stdout_buff = [] self.stdout_thread = \ threading.Thread(target=self._readerthread, args=(self.stdout, self._stdout_buff)) self.stdout_thread.daemon = True self.stdout_thread.start() if self.stderr and not hasattr(self, "_stderr_buff"): self._stderr_buff = [] self.stderr_thread = \ threading.Thread(target=self._readerthread, args=(self.stderr, self._stderr_buff)) self.stderr_thread.daemon = True self.stderr_thread.start() if self.stdin: if input is not None: try: self.stdin.write(input) except IOError as e: if e.errno != errno.EPIPE: raise self.stdin.close() # Wait for the reader threads, or time out. If we time out, the # threads remain reading and the fds left open in case the user # calls communicate again. if self.stdout is not None: self.stdout_thread.join(self._remaining_time(endtime)) if self.stdout_thread.is_alive(): raise TimeoutExpired(self.args, orig_timeout) if self.stderr is not None: self.stderr_thread.join(self._remaining_time(endtime)) if self.stderr_thread.is_alive(): raise TimeoutExpired(self.args, orig_timeout) # Collect the output from and close both pipes, now that we know # both have been read successfully. stdout = None stderr = None if self.stdout: stdout = self._stdout_buff self.stdout.close() if self.stderr: stderr = self._stderr_buff self.stderr.close() # All data exchanged. Translate lists into strings. if stdout is not None: stdout = stdout[0] if stderr is not None: stderr = stderr[0] return (stdout, stderr) def send_signal(self, sig): """Send a signal to the process """ if sig == signal.SIGTERM: self.terminate() elif sig == signal.CTRL_C_EVENT: os.kill(self.pid, signal.CTRL_C_EVENT) elif sig == signal.CTRL_BREAK_EVENT: os.kill(self.pid, signal.CTRL_BREAK_EVENT) else: raise ValueError("Unsupported signal: {}".format(sig)) def terminate(self): """Terminates the process """ try: _winapi.TerminateProcess(self._handle, 1) except PermissionError: # ERROR_ACCESS_DENIED (winerror 5) is received when the # process already died. rc = _winapi.GetExitCodeProcess(self._handle) if rc == _winapi.STILL_ACTIVE: raise self.returncode = rc kill = terminate else: # # POSIX methods # def _get_handles(self, stdin, stdout, stderr): """Construct and return tuple with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ p2cread, p2cwrite = -1, -1 c2pread, c2pwrite = -1, -1 errread, errwrite = -1, -1 if stdin is None: pass elif stdin == PIPE: p2cread, p2cwrite = _create_pipe() elif stdin == DEVNULL: p2cread = self._get_devnull() elif isinstance(stdin, int): p2cread = stdin else: # Assuming file-like object p2cread = stdin.fileno() if stdout is None: pass elif stdout == PIPE: c2pread, c2pwrite = _create_pipe() elif stdout == DEVNULL: c2pwrite = self._get_devnull() elif isinstance(stdout, int): c2pwrite = stdout else: # Assuming file-like object c2pwrite = stdout.fileno() if stderr is None: pass elif stderr == PIPE: errread, errwrite = _create_pipe() elif stderr == STDOUT: errwrite = c2pwrite elif stderr == DEVNULL: errwrite = self._get_devnull() elif isinstance(stderr, int): errwrite = stderr else: # Assuming file-like object errwrite = stderr.fileno() return (p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) def _close_fds(self, fds_to_keep): start_fd = 3 for fd in sorted(fds_to_keep): if fd >= start_fd: os.closerange(start_fd, fd) start_fd = fd + 1 if start_fd <= MAXFD: os.closerange(start_fd, MAXFD) def _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session): """Execute program (POSIX version)""" if isinstance(args, (str, bytes)): args = [args] else: args = list(args) if shell: args = ["/bin/sh", "-c"] + args if executable: args[0] = executable if executable is None: executable = args[0] orig_executable = executable # For transferring possible exec failure from child to parent. # Data format: "exception name:hex errno:description" # Pickle is not used; it is complex and involves memory allocation. errpipe_read, errpipe_write = _create_pipe() try: try: # We must avoid complex work that could involve # malloc or free in the child process to avoid # potential deadlocks, thus we do all this here. # and pass it to fork_exec() if env is not None: env_list = [os.fsencode(k) + b'=' + os.fsencode(v) for k, v in env.items()] else: env_list = None # Use execv instead of execve. executable = os.fsencode(executable) if os.path.dirname(executable): executable_list = (executable,) else: # This matches the behavior of os._execvpe(). executable_list = tuple( os.path.join(os.fsencode(dir), executable) for dir in os.get_exec_path(env)) fds_to_keep = set(pass_fds) fds_to_keep.add(errpipe_write) self.pid = _posixsubprocess.fork_exec( args, executable_list, close_fds, sorted(fds_to_keep), cwd, env_list, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, errpipe_read, errpipe_write, restore_signals, start_new_session, preexec_fn) self._child_created = True finally: # be sure the FD is closed no matter what os.close(errpipe_write) # self._devnull is not always defined. devnull_fd = getattr(self, '_devnull', None) if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd: os.close(p2cread) if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd: os.close(c2pwrite) if errwrite != -1 and errread != -1 and errwrite != devnull_fd: os.close(errwrite) if devnull_fd is not None: os.close(devnull_fd) # Prevent a double close of these fds from __init__ on error. self._closed_child_pipe_fds = True # Wait for exec to fail or succeed; possibly raising an # exception (limited in size) errpipe_data = bytearray() while True: part = _eintr_retry_call(os.read, errpipe_read, 50000) errpipe_data += part if not part or len(errpipe_data) > 50000: break finally: # be sure the FD is closed no matter what os.close(errpipe_read) if errpipe_data: try: _eintr_retry_call(os.waitpid, self.pid, 0) except OSError as e: if e.errno != errno.ECHILD: raise try: exception_name, hex_errno, err_msg = ( errpipe_data.split(b':', 2)) except ValueError: exception_name = b'RuntimeError' hex_errno = b'0' err_msg = (b'Bad exception data from child: ' + repr(errpipe_data)) child_exception_type = getattr( builtins, exception_name.decode('ascii'), RuntimeError) err_msg = err_msg.decode(errors="surrogatepass") if issubclass(child_exception_type, OSError) and hex_errno: errno_num = int(hex_errno, 16) child_exec_never_called = (err_msg == "noexec") if child_exec_never_called: err_msg = "" if errno_num != 0: err_msg = os.strerror(errno_num) if errno_num == errno.ENOENT: if child_exec_never_called: # The error must be from chdir(cwd). err_msg += ': ' + repr(cwd) else: err_msg += ': ' + repr(orig_executable) raise child_exception_type(errno_num, err_msg) raise child_exception_type(err_msg) def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED, _WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED, _WEXITSTATUS=os.WEXITSTATUS): # This method is called (indirectly) by __del__, so it cannot # refer to anything outside of its local scope.""" if _WIFSIGNALED(sts): self.returncode = -_WTERMSIG(sts) elif _WIFEXITED(sts): self.returncode = _WEXITSTATUS(sts) else: # Should never happen raise RuntimeError("Unknown child exit status!") def _internal_poll(self, _deadstate=None, _waitpid=os.waitpid, _WNOHANG=os.WNOHANG, _os_error=os.error, _ECHILD=errno.ECHILD): """Check if child process has terminated. Returns returncode attribute. This method is called by __del__, so it cannot reference anything outside of the local scope (nor can any methods it calls). """ if self.returncode is None: try: pid, sts = _waitpid(self.pid, _WNOHANG) if pid == self.pid: self._handle_exitstatus(sts) except _os_error as e: if _deadstate is not None: self.returncode = _deadstate elif e.errno == _ECHILD: # This happens if SIGCLD is set to be ignored or # waiting for child processes has otherwise been # disabled for our process. This child is dead, we # can't get the status. # http://bugs.python.org/issue15756 self.returncode = 0 return self.returncode def _try_wait(self, wait_flags): try: (pid, sts) = _eintr_retry_call(os.waitpid, self.pid, wait_flags) except OSError as e: if e.errno != errno.ECHILD: raise # This happens if SIGCLD is set to be ignored or waiting # for child processes has otherwise been disabled for our # process. This child is dead, we can't get the status. pid = self.pid sts = 0 return (pid, sts) def wait(self, timeout=None, endtime=None): """Wait for child process to terminate. Returns returncode attribute.""" if self.returncode is not None: return self.returncode # endtime is preferred to timeout. timeout is only used for # printing. if endtime is not None or timeout is not None: if endtime is None: endtime = _time() + timeout elif timeout is None: timeout = self._remaining_time(endtime) if endtime is not None: # Enter a busy loop if we have a timeout. This busy loop was # cribbed from Lib/threading.py in Thread.wait() at r71065. delay = 0.0005 # 500 us -> initial delay of 1 ms while True: (pid, sts) = self._try_wait(os.WNOHANG) assert pid == self.pid or pid == 0 if pid == self.pid: self._handle_exitstatus(sts) break remaining = self._remaining_time(endtime) if remaining <= 0: raise TimeoutExpired(self.args, timeout) delay = min(delay * 2, remaining, .05) time.sleep(delay) else: while self.returncode is None: (pid, sts) = self._try_wait(0) # Check the pid and loop as waitpid has been known to return # 0 even without WNOHANG in odd situations. issue14396. if pid == self.pid: self._handle_exitstatus(sts) return self.returncode def _communicate(self, input, endtime, orig_timeout): if self.stdin and not self._communication_started: # Flush stdio buffer. This might block, if the user has # been writing to .stdin in an uncontrolled fashion. self.stdin.flush() if not input: self.stdin.close() if _has_poll: stdout, stderr = self._communicate_with_poll(input, endtime, orig_timeout) else: stdout, stderr = self._communicate_with_select(input, endtime, orig_timeout) self.wait(timeout=self._remaining_time(endtime)) # All data exchanged. Translate lists into strings. if stdout is not None: stdout = b''.join(stdout) if stderr is not None: stderr = b''.join(stderr) # Translate newlines, if requested. # This also turns bytes into strings. if self.universal_newlines: if stdout is not None: stdout = self._translate_newlines(stdout, self.stdout.encoding) if stderr is not None: stderr = self._translate_newlines(stderr, self.stderr.encoding) return (stdout, stderr) def _save_input(self, input): # This method is called from the _communicate_with_*() methods # so that if we time out while communicating, we can continue # sending input if we retry. if self.stdin and self._input is None: self._input_offset = 0 self._input = input if self.universal_newlines and input is not None: self._input = self._input.encode(self.stdin.encoding) def _communicate_with_poll(self, input, endtime, orig_timeout): stdout = None # Return stderr = None # Return if not self._communication_started: self._fd2file = {} poller = select.poll() def register_and_append(file_obj, eventmask): poller.register(file_obj.fileno(), eventmask) self._fd2file[file_obj.fileno()] = file_obj def close_unregister_and_remove(fd): poller.unregister(fd) self._fd2file[fd].close() self._fd2file.pop(fd) if self.stdin and input: register_and_append(self.stdin, select.POLLOUT) # Only create this mapping if we haven't already. if not self._communication_started: self._fd2output = {} if self.stdout: self._fd2output[self.stdout.fileno()] = [] if self.stderr: self._fd2output[self.stderr.fileno()] = [] select_POLLIN_POLLPRI = select.POLLIN | select.POLLPRI if self.stdout: register_and_append(self.stdout, select_POLLIN_POLLPRI) stdout = self._fd2output[self.stdout.fileno()] if self.stderr: register_and_append(self.stderr, select_POLLIN_POLLPRI) stderr = self._fd2output[self.stderr.fileno()] self._save_input(input) while self._fd2file: timeout = self._remaining_time(endtime) if timeout is not None and timeout < 0: raise TimeoutExpired(self.args, orig_timeout) try: ready = poller.poll(timeout) except select.error as e: if e.args[0] == errno.EINTR: continue raise self._check_timeout(endtime, orig_timeout) # XXX Rewrite these to use non-blocking I/O on the # file objects; they are no longer using C stdio! for fd, mode in ready: if mode & select.POLLOUT: chunk = self._input[self._input_offset : self._input_offset + _PIPE_BUF] try: self._input_offset += os.write(fd, chunk) except OSError as e: if e.errno == errno.EPIPE: close_unregister_and_remove(fd) else: raise else: if self._input_offset >= len(self._input): close_unregister_and_remove(fd) elif mode & select_POLLIN_POLLPRI: data = os.read(fd, 4096) if not data: close_unregister_and_remove(fd) self._fd2output[fd].append(data) else: # Ignore hang up or errors. close_unregister_and_remove(fd) return (stdout, stderr) def _communicate_with_select(self, input, endtime, orig_timeout): if not self._communication_started: self._read_set = [] self._write_set = [] if self.stdin and input: self._write_set.append(self.stdin) if self.stdout: self._read_set.append(self.stdout) if self.stderr: self._read_set.append(self.stderr) self._save_input(input) stdout = None # Return stderr = None # Return if self.stdout: if not self._communication_started: self._stdout_buff = [] stdout = self._stdout_buff if self.stderr: if not self._communication_started: self._stderr_buff = [] stderr = self._stderr_buff while self._read_set or self._write_set: timeout = self._remaining_time(endtime) if timeout is not None and timeout < 0: raise TimeoutExpired(self.args, orig_timeout) try: (rlist, wlist, xlist) = \ select.select(self._read_set, self._write_set, [], timeout) except select.error as e: if e.args[0] == errno.EINTR: continue raise # According to the docs, returning three empty lists indicates # that the timeout expired. if not (rlist or wlist or xlist): raise TimeoutExpired(self.args, orig_timeout) # We also check what time it is ourselves for good measure. self._check_timeout(endtime, orig_timeout) # XXX Rewrite these to use non-blocking I/O on the # file objects; they are no longer using C stdio! if self.stdin in wlist: chunk = self._input[self._input_offset : self._input_offset + _PIPE_BUF] try: bytes_written = os.write(self.stdin.fileno(), chunk) except OSError as e: if e.errno == errno.EPIPE: self.stdin.close() self._write_set.remove(self.stdin) else: raise else: self._input_offset += bytes_written if self._input_offset >= len(self._input): self.stdin.close() self._write_set.remove(self.stdin) if self.stdout in rlist: data = os.read(self.stdout.fileno(), 1024) if not data: self.stdout.close() self._read_set.remove(self.stdout) stdout.append(data) if self.stderr in rlist: data = os.read(self.stderr.fileno(), 1024) if not data: self.stderr.close() self._read_set.remove(self.stderr) stderr.append(data) return (stdout, stderr) def send_signal(self, sig): """Send a signal to the process """ os.kill(self.pid, sig) def terminate(self): """Terminate the process with SIGTERM """ self.send_signal(signal.SIGTERM) def kill(self): """Kill the process with SIGKILL """ self.send_signal(signal.SIGKILL)
gpl-3.0
[ 3, 3873, 446, 4804, 11816, 543, 17909, 473, 15, 47, 13788, 199, 3, 199, 3, 2104, 1655, 2556, 3595, 642, 859, 12, 1937, 13663, 650, 1194, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 13004, 13, 9397, 701, 22912, 437, 30964, 665, 65, 30964, 32, 76, 588, 707, 14, 317, 85, 14, 261, 30, 199, 3, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 3, 1666, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 18, 14, 20, 15, 1682, 367, 32572, 2436, 14, 199, 199, 82, 624, 5781, 446, 4804, 11816, 543, 17909, 473, 15, 47, 13788, 199, 199, 2765, 859, 6127, 1265, 370, 15187, 10358, 12, 4907, 370, 3932, 199, 1210, 15, 1199, 15, 705, 20988, 12, 436, 3332, 3932, 372, 9479, 14, 221, 961, 859, 199, 262, 724, 795, 370, 3350, 9978, 1163, 12, 12731, 4621, 436, 3423, 12, 2839, 26, 199, 199, 736, 14, 2253, 199, 736, 14, 10212, 10, 199, 199, 4935, 3595, 4212, 314, 3873, 859, 883, 506, 1202, 370, 3350, 3520, 199, 3112, 436, 3423, 883, 506, 1911, 5084, 14, 4388, 199, 10369, 314, 3873, 859, 199, 1280, 21326, 199, 2765, 859, 7890, 1373, 1021, 2797, 13995, 26, 199, 199, 533, 13995, 8, 589, 12, 17080, 4022, 17, 12, 7286, 29, 403, 12, 288, 9009, 29, 403, 12, 3839, 29, 403, 12, 4635, 29, 403, 12, 288, 876, 1628, 63, 2324, 29, 403, 12, 4002, 63, 14240, 29, 549, 12, 5218, 29, 797, 12, 288, 8288, 29, 403, 12, 2589, 29, 403, 12, 17508, 63, 13839, 29, 797, 12, 288, 14210, 815, 29, 403, 12, 7143, 2469, 29, 16, 12, 288, 9066, 63, 10458, 29, 549, 12, 1343, 63, 1222, 63, 1730, 29, 797, 12, 986, 63, 14240, 23603, 421, 199, 14517, 787, 26, 199, 199, 589, 1077, 506, 282, 1059, 12, 503, 282, 3414, 402, 2240, 2368, 14, 221, 710, 199, 6815, 370, 5341, 365, 12252, 314, 1642, 1242, 315, 314, 1249, 3414, 503, 199, 875, 12, 1325, 883, 506, 7662, 663, 701, 1808, 314, 7286, 1423, 14, 199, 199, 3314, 18169, 12, 543, 5218, 29, 797, 334, 885, 304, 1010, 642, 1930, 12, 314, 13995, 1021, 199, 5589, 747, 14, 1628, 11702, 342, 370, 5341, 314, 1982, 2240, 14, 221, 1249, 1077, 12252, 199, 1235, 282, 3414, 14, 221, 437, 1059, 911, 506, 10184, 465, 282, 3414, 543, 314, 1059, 199, 305, 314, 1454, 1242, 334, 1589, 2240, 370, 5341, 680, 199, 199, 3314, 18169, 12, 543, 5218, 29, 549, 26, 982, 1249, 365, 282, 1059, 12, 652, 9314, 314, 199, 1531, 1059, 370, 5341, 4012, 314, 5218, 14, 221, 982, 1249, 365, 282, 3414, 12, 199, 1589, 1642, 1242, 9314, 314, 1414, 1059, 12, 436, 1263, 4722, 2974, 199, 14117, 506, 10184, 465, 4722, 5218, 2368, 14, 199, 199, 3314, 5417, 26, 314, 13995, 1021, 4440, 2790, 3498, 342, 370, 5341, 314, 1982, 199, 6815, 12, 1314, 1758, 2335, 641, 3326, 14, 221, 982, 1249, 365, 282, 3414, 12, 652, 911, 506, 199, 22818, 370, 282, 1059, 1808, 314, 769, 18, 15612, 1083, 14, 221, 7754, 5317, 626, 199, 1397, 1006, 14282, 5417, 13103, 15579, 314, 1414, 1004, 314, 2011, 199, 3316, 26, 710, 769, 18, 15612, 365, 19829, 367, 13103, 1808, 314, 2011, 199, 4423, 465, 314, 14282, 445, 8836, 14, 199, 199, 19146, 911, 506, 6841, 465, 314, 5226, 1423, 370, 314, 5890, 14, 1490, 342, 199, 1593, 1380, 6425, 314, 9009, 15, 2703, 15, 3083, 5200, 570, 2251, 26, 199, 16, 4910, 625, 17605, 334, 739, 1253, 2218, 787, 1373, 2656, 1240, 436, 883, 372, 3974, 395, 199, 17, 4910, 1004, 20224, 12, 1263, 1163, 7317, 574, 4910, 675, 282, 3335, 402, 199, 16815, 6897, 590, 626, 1568, 14, 221, 437, 6946, 17080, 12, 314, 849, 12, 4910, 314, 2656, 199, 885, 402, 5890, 14, 3472, 63, 10960, 63, 4305, 911, 506, 1202, 14, 199, 199, 6626, 12, 3839, 436, 4635, 4165, 314, 7934, 18572, 7, 4465, 199, 1210, 12, 4465, 1072, 436, 4465, 1125, 570, 10022, 12, 17342, 14, 199, 3490, 1338, 787, 22773, 12, 376, 3411, 570, 5872, 334, 65, 7317, 199, 4115, 395, 376, 3411, 570, 909, 12, 436, 488, 14, 221, 22773, 9126, 626, 282, 199, 1222, 5200, 370, 314, 1982, 1077, 506, 2737, 14, 221, 8777, 488, 12, 949, 23713, 199, 14117, 4781, 27, 314, 1982, 1159, 570, 10022, 911, 506, 12623, 687, 314, 199, 1708, 14, 221, 25448, 12, 4635, 883, 506, 4384, 12619, 12, 1314, 9126, 626, 314, 199, 3083, 666, 687, 314, 13103, 1077, 506, 17487, 1901, 314, 2011, 199, 493, 2429, 465, 367, 3839, 14, 199, 199, 3314, 18169, 12, 340, 876, 1628, 63, 2324, 365, 663, 370, 282, 4550, 909, 12, 642, 909, 911, 506, 199, 3527, 315, 314, 1982, 2112, 2951, 2544, 314, 1982, 365, 7934, 14, 221, 710, 675, 199, 1618, 876, 1628, 63, 2324, 365, 440, 2462, 5048, 12, 1808, 652, 315, 314, 20024, 402, 7183, 199, 15153, 12690, 370, 282, 12314, 831, 315, 314, 1982, 2112, 2544, 314, 892, 7286, 199, 374, 7934, 14, 199, 199, 3917, 4002, 63, 14240, 365, 2549, 12, 1006, 570, 15428, 871, 378, 12, 413, 436, 499, 911, 506, 199, 5938, 2544, 314, 1982, 2112, 365, 7934, 14, 221, 710, 849, 367, 4002, 63, 14240, 199, 86, 3433, 701, 4298, 26, 221, 16763, 2549, 641, 18169, 14, 221, 715, 1380, 9009, 15, 2703, 15, 3083, 199, 1530, 488, 641, 5417, 12, 3055, 4257, 14, 199, 199, 1529, 63, 14240, 365, 376, 2716, 3414, 402, 570, 15428, 370, 4215, 1551, 3382, 314, 199, 1708, 436, 1982, 14, 221, 2165, 11604, 1263, 986, 63, 14240, 19796, 5951, 4002, 63, 14240, 370, 2549, 14, 199, 199, 692, 5218, 365, 2549, 12, 314, 2013, 1414, 911, 506, 7934, 4012, 314, 199, 5641, 14, 199, 199, 3917, 8288, 365, 440, 488, 12, 314, 1453, 2082, 911, 506, 2896, 370, 8288, 199, 5182, 314, 1982, 365, 7934, 14, 199, 199, 3314, 18169, 12, 340, 9066, 63, 10458, 365, 715, 1006, 10166, 626, 2018, 5951, 370, 199, 7864, 63, 3203, 787, 14429, 370, 15522, 63, 36, 3143, 315, 314, 1982, 2112, 2544, 314, 2146, 14, 199, 31499, 642, 6952, 314, 15522, 6089, 12, 15522, 25145, 58 ]
[ 3873, 446, 4804, 11816, 543, 17909, 473, 15, 47, 13788, 199, 3, 199, 3, 2104, 1655, 2556, 3595, 642, 859, 12, 1937, 13663, 650, 1194, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 13004, 13, 9397, 701, 22912, 437, 30964, 665, 65, 30964, 32, 76, 588, 707, 14, 317, 85, 14, 261, 30, 199, 3, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 3, 1666, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 18, 14, 20, 15, 1682, 367, 32572, 2436, 14, 199, 199, 82, 624, 5781, 446, 4804, 11816, 543, 17909, 473, 15, 47, 13788, 199, 199, 2765, 859, 6127, 1265, 370, 15187, 10358, 12, 4907, 370, 3932, 199, 1210, 15, 1199, 15, 705, 20988, 12, 436, 3332, 3932, 372, 9479, 14, 221, 961, 859, 199, 262, 724, 795, 370, 3350, 9978, 1163, 12, 12731, 4621, 436, 3423, 12, 2839, 26, 199, 199, 736, 14, 2253, 199, 736, 14, 10212, 10, 199, 199, 4935, 3595, 4212, 314, 3873, 859, 883, 506, 1202, 370, 3350, 3520, 199, 3112, 436, 3423, 883, 506, 1911, 5084, 14, 4388, 199, 10369, 314, 3873, 859, 199, 1280, 21326, 199, 2765, 859, 7890, 1373, 1021, 2797, 13995, 26, 199, 199, 533, 13995, 8, 589, 12, 17080, 4022, 17, 12, 7286, 29, 403, 12, 288, 9009, 29, 403, 12, 3839, 29, 403, 12, 4635, 29, 403, 12, 288, 876, 1628, 63, 2324, 29, 403, 12, 4002, 63, 14240, 29, 549, 12, 5218, 29, 797, 12, 288, 8288, 29, 403, 12, 2589, 29, 403, 12, 17508, 63, 13839, 29, 797, 12, 288, 14210, 815, 29, 403, 12, 7143, 2469, 29, 16, 12, 288, 9066, 63, 10458, 29, 549, 12, 1343, 63, 1222, 63, 1730, 29, 797, 12, 986, 63, 14240, 23603, 421, 199, 14517, 787, 26, 199, 199, 589, 1077, 506, 282, 1059, 12, 503, 282, 3414, 402, 2240, 2368, 14, 221, 710, 199, 6815, 370, 5341, 365, 12252, 314, 1642, 1242, 315, 314, 1249, 3414, 503, 199, 875, 12, 1325, 883, 506, 7662, 663, 701, 1808, 314, 7286, 1423, 14, 199, 199, 3314, 18169, 12, 543, 5218, 29, 797, 334, 885, 304, 1010, 642, 1930, 12, 314, 13995, 1021, 199, 5589, 747, 14, 1628, 11702, 342, 370, 5341, 314, 1982, 2240, 14, 221, 1249, 1077, 12252, 199, 1235, 282, 3414, 14, 221, 437, 1059, 911, 506, 10184, 465, 282, 3414, 543, 314, 1059, 199, 305, 314, 1454, 1242, 334, 1589, 2240, 370, 5341, 680, 199, 199, 3314, 18169, 12, 543, 5218, 29, 549, 26, 982, 1249, 365, 282, 1059, 12, 652, 9314, 314, 199, 1531, 1059, 370, 5341, 4012, 314, 5218, 14, 221, 982, 1249, 365, 282, 3414, 12, 199, 1589, 1642, 1242, 9314, 314, 1414, 1059, 12, 436, 1263, 4722, 2974, 199, 14117, 506, 10184, 465, 4722, 5218, 2368, 14, 199, 199, 3314, 5417, 26, 314, 13995, 1021, 4440, 2790, 3498, 342, 370, 5341, 314, 1982, 199, 6815, 12, 1314, 1758, 2335, 641, 3326, 14, 221, 982, 1249, 365, 282, 3414, 12, 652, 911, 506, 199, 22818, 370, 282, 1059, 1808, 314, 769, 18, 15612, 1083, 14, 221, 7754, 5317, 626, 199, 1397, 1006, 14282, 5417, 13103, 15579, 314, 1414, 1004, 314, 2011, 199, 3316, 26, 710, 769, 18, 15612, 365, 19829, 367, 13103, 1808, 314, 2011, 199, 4423, 465, 314, 14282, 445, 8836, 14, 199, 199, 19146, 911, 506, 6841, 465, 314, 5226, 1423, 370, 314, 5890, 14, 1490, 342, 199, 1593, 1380, 6425, 314, 9009, 15, 2703, 15, 3083, 5200, 570, 2251, 26, 199, 16, 4910, 625, 17605, 334, 739, 1253, 2218, 787, 1373, 2656, 1240, 436, 883, 372, 3974, 395, 199, 17, 4910, 1004, 20224, 12, 1263, 1163, 7317, 574, 4910, 675, 282, 3335, 402, 199, 16815, 6897, 590, 626, 1568, 14, 221, 437, 6946, 17080, 12, 314, 849, 12, 4910, 314, 2656, 199, 885, 402, 5890, 14, 3472, 63, 10960, 63, 4305, 911, 506, 1202, 14, 199, 199, 6626, 12, 3839, 436, 4635, 4165, 314, 7934, 18572, 7, 4465, 199, 1210, 12, 4465, 1072, 436, 4465, 1125, 570, 10022, 12, 17342, 14, 199, 3490, 1338, 787, 22773, 12, 376, 3411, 570, 5872, 334, 65, 7317, 199, 4115, 395, 376, 3411, 570, 909, 12, 436, 488, 14, 221, 22773, 9126, 626, 282, 199, 1222, 5200, 370, 314, 1982, 1077, 506, 2737, 14, 221, 8777, 488, 12, 949, 23713, 199, 14117, 4781, 27, 314, 1982, 1159, 570, 10022, 911, 506, 12623, 687, 314, 199, 1708, 14, 221, 25448, 12, 4635, 883, 506, 4384, 12619, 12, 1314, 9126, 626, 314, 199, 3083, 666, 687, 314, 13103, 1077, 506, 17487, 1901, 314, 2011, 199, 493, 2429, 465, 367, 3839, 14, 199, 199, 3314, 18169, 12, 340, 876, 1628, 63, 2324, 365, 663, 370, 282, 4550, 909, 12, 642, 909, 911, 506, 199, 3527, 315, 314, 1982, 2112, 2951, 2544, 314, 1982, 365, 7934, 14, 221, 710, 675, 199, 1618, 876, 1628, 63, 2324, 365, 440, 2462, 5048, 12, 1808, 652, 315, 314, 20024, 402, 7183, 199, 15153, 12690, 370, 282, 12314, 831, 315, 314, 1982, 2112, 2544, 314, 892, 7286, 199, 374, 7934, 14, 199, 199, 3917, 4002, 63, 14240, 365, 2549, 12, 1006, 570, 15428, 871, 378, 12, 413, 436, 499, 911, 506, 199, 5938, 2544, 314, 1982, 2112, 365, 7934, 14, 221, 710, 849, 367, 4002, 63, 14240, 199, 86, 3433, 701, 4298, 26, 221, 16763, 2549, 641, 18169, 14, 221, 715, 1380, 9009, 15, 2703, 15, 3083, 199, 1530, 488, 641, 5417, 12, 3055, 4257, 14, 199, 199, 1529, 63, 14240, 365, 376, 2716, 3414, 402, 570, 15428, 370, 4215, 1551, 3382, 314, 199, 1708, 436, 1982, 14, 221, 2165, 11604, 1263, 986, 63, 14240, 19796, 5951, 4002, 63, 14240, 370, 2549, 14, 199, 199, 692, 5218, 365, 2549, 12, 314, 2013, 1414, 911, 506, 7934, 4012, 314, 199, 5641, 14, 199, 199, 3917, 8288, 365, 440, 488, 12, 314, 1453, 2082, 911, 506, 2896, 370, 8288, 199, 5182, 314, 1982, 365, 7934, 14, 199, 199, 3314, 18169, 12, 340, 9066, 63, 10458, 365, 715, 1006, 10166, 626, 2018, 5951, 370, 199, 7864, 63, 3203, 787, 14429, 370, 15522, 63, 36, 3143, 315, 314, 1982, 2112, 2544, 314, 2146, 14, 199, 31499, 642, 6952, 314, 15522, 6089, 12, 15522, 25145, 58, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
geodrinx/gearthview
ext-libs/twisted/python/test/test_fakepwd.py
43
14092
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Tests for L{twisted.python.fakepwd}. """ try: import pwd except ImportError: pwd = None try: import spwd except ImportError: spwd = None import os from operator import getitem from twisted.trial.unittest import TestCase from twisted.python.fakepwd import UserDatabase, ShadowDatabase SYSTEM_UID_MAX = 999 def findInvalidUID(): """ By convention, UIDs less than 1000 are reserved for the system. A system which allocated every single one of those UIDs would likely have practical problems with allocating new ones, so let's assume that we'll be able to find one. (If we don't, this will wrap around to negative values and I{eventually} find something.) @return: a user ID which does not exist on the local system. Or, on systems without a L{pwd} module, return C{SYSTEM_UID_MAX}. """ guess = SYSTEM_UID_MAX if pwd is not None: while True: try: pwd.getpwuid(guess) except KeyError: break else: guess -= 1 return guess INVALID_UID = findInvalidUID() class UserDatabaseTestsMixin: """ L{UserDatabaseTestsMixin} defines tests which apply to any user database implementation. Subclasses should mix it in, implement C{setUp} to create C{self.database} bound to a user database instance, and implement C{getExistingUserInfo} to return information about a user (such information should be unique per test method). """ def test_getpwuid(self): """ I{getpwuid} accepts a uid and returns the user record associated with it. """ for i in range(2): # Get some user which exists in the database. username, password, uid, gid, gecos, dir, shell = self.getExistingUserInfo() # Now try to look it up and make sure the result is correct. entry = self.database.getpwuid(uid) self.assertEqual(entry.pw_name, username) self.assertEqual(entry.pw_passwd, password) self.assertEqual(entry.pw_uid, uid) self.assertEqual(entry.pw_gid, gid) self.assertEqual(entry.pw_gecos, gecos) self.assertEqual(entry.pw_dir, dir) self.assertEqual(entry.pw_shell, shell) def test_noSuchUID(self): """ I{getpwuid} raises L{KeyError} when passed a uid which does not exist in the user database. """ self.assertRaises(KeyError, self.database.getpwuid, INVALID_UID) def test_getpwnam(self): """ I{getpwnam} accepts a username and returns the user record associated with it. """ for i in range(2): # Get some user which exists in the database. username, password, uid, gid, gecos, dir, shell = self.getExistingUserInfo() # Now try to look it up and make sure the result is correct. entry = self.database.getpwnam(username) self.assertEqual(entry.pw_name, username) self.assertEqual(entry.pw_passwd, password) self.assertEqual(entry.pw_uid, uid) self.assertEqual(entry.pw_gid, gid) self.assertEqual(entry.pw_gecos, gecos) self.assertEqual(entry.pw_dir, dir) self.assertEqual(entry.pw_shell, shell) def test_noSuchName(self): """ I{getpwnam} raises L{KeyError} when passed a username which does not exist in the user database. """ self.assertRaises( KeyError, self.database.getpwnam, 'no' 'such' 'user' 'exists' 'the' 'name' 'is' 'too' 'long' 'and' 'has' '\1' 'in' 'it' 'too') def test_recordLength(self): """ The user record returned by I{getpwuid}, I{getpwnam}, and I{getpwall} has a length. """ db = self.database username, password, uid, gid, gecos, dir, shell = self.getExistingUserInfo() for entry in [db.getpwuid(uid), db.getpwnam(username), db.getpwall()[0]]: self.assertIsInstance(len(entry), int) self.assertEqual(len(entry), 7) def test_recordIndexable(self): """ The user record returned by I{getpwuid}, I{getpwnam}, and I{getpwall} is indexable, with successive indexes starting from 0 corresponding to the values of the C{pw_name}, C{pw_passwd}, C{pw_uid}, C{pw_gid}, C{pw_gecos}, C{pw_dir}, and C{pw_shell} attributes, respectively. """ db = self.database username, password, uid, gid, gecos, dir, shell = self.getExistingUserInfo() for entry in [db.getpwuid(uid), db.getpwnam(username), db.getpwall()[0]]: self.assertEqual(entry[0], username) self.assertEqual(entry[1], password) self.assertEqual(entry[2], uid) self.assertEqual(entry[3], gid) self.assertEqual(entry[4], gecos) self.assertEqual(entry[5], dir) self.assertEqual(entry[6], shell) self.assertEqual(len(entry), len(list(entry))) self.assertRaises(IndexError, getitem, entry, 7) class UserDatabaseTests(TestCase, UserDatabaseTestsMixin): """ Tests for L{UserDatabase}. """ def setUp(self): """ Create a L{UserDatabase} with no user data in it. """ self.database = UserDatabase() self._counter = SYSTEM_UID_MAX + 1 def getExistingUserInfo(self): """ Add a new user to C{self.database} and return its information. """ self._counter += 1 suffix = '_' + str(self._counter) username = 'username' + suffix password = 'password' + suffix uid = self._counter gid = self._counter + 1000 gecos = 'gecos' + suffix dir = 'dir' + suffix shell = 'shell' + suffix self.database.addUser(username, password, uid, gid, gecos, dir, shell) return (username, password, uid, gid, gecos, dir, shell) def test_addUser(self): """ L{UserDatabase.addUser} accepts seven arguments, one for each field of a L{pwd.struct_passwd}, and makes the new record available via L{UserDatabase.getpwuid}, L{UserDatabase.getpwnam}, and L{UserDatabase.getpwall}. """ username = 'alice' password = 'secr3t' uid = 123 gid = 456 gecos = 'Alice,,,' home = '/users/alice' shell = '/usr/bin/foosh' db = self.database db.addUser(username, password, uid, gid, gecos, home, shell) for [entry] in [[db.getpwuid(uid)], [db.getpwnam(username)], db.getpwall()]: self.assertEqual(entry.pw_name, username) self.assertEqual(entry.pw_passwd, password) self.assertEqual(entry.pw_uid, uid) self.assertEqual(entry.pw_gid, gid) self.assertEqual(entry.pw_gecos, gecos) self.assertEqual(entry.pw_dir, home) self.assertEqual(entry.pw_shell, shell) class PwdModuleTests(TestCase, UserDatabaseTestsMixin): """ L{PwdModuleTests} runs the tests defined by L{UserDatabaseTestsMixin} against the built-in C{pwd} module. This serves to verify that L{UserDatabase} is really a fake of that API. """ if pwd is None: skip = "Cannot verify UserDatabase against pwd without pwd" else: database = pwd def setUp(self): self._users = iter(self.database.getpwall()) self._uids = set() def getExistingUserInfo(self): """ Read and return the next record from C{self._users}, filtering out any records with previously seen uid values (as these cannot be found with C{getpwuid} and only cause trouble). """ while True: entry = next(self._users) uid = entry.pw_uid if uid not in self._uids: self._uids.add(uid) return entry class ShadowDatabaseTestsMixin: """ L{ShadowDatabaseTestsMixin} defines tests which apply to any shadow user database implementation. Subclasses should mix it in, implement C{setUp} to create C{self.database} bound to a shadow user database instance, and implement C{getExistingUserInfo} to return information about a user (such information should be unique per test method). """ def test_getspnam(self): """ L{getspnam} accepts a username and returns the user record associated with it. """ for i in range(2): # Get some user which exists in the database. (username, password, lastChange, min, max, warn, inact, expire, flag) = self.getExistingUserInfo() entry = self.database.getspnam(username) self.assertEqual(entry.sp_nam, username) self.assertEqual(entry.sp_pwd, password) self.assertEqual(entry.sp_lstchg, lastChange) self.assertEqual(entry.sp_min, min) self.assertEqual(entry.sp_max, max) self.assertEqual(entry.sp_warn, warn) self.assertEqual(entry.sp_inact, inact) self.assertEqual(entry.sp_expire, expire) self.assertEqual(entry.sp_flag, flag) def test_noSuchName(self): """ I{getspnam} raises L{KeyError} when passed a username which does not exist in the user database. """ self.assertRaises(KeyError, self.database.getspnam, "alice") def test_recordLength(self): """ The shadow user record returned by I{getspnam} and I{getspall} has a length. """ db = self.database username = self.getExistingUserInfo()[0] for entry in [db.getspnam(username), db.getspall()[0]]: self.assertIsInstance(len(entry), int) self.assertEqual(len(entry), 9) def test_recordIndexable(self): """ The shadow user record returned by I{getpwnam} and I{getspall} is indexable, with successive indexes starting from 0 corresponding to the values of the C{sp_nam}, C{sp_pwd}, C{sp_lstchg}, C{sp_min}, C{sp_max}, C{sp_warn}, C{sp_inact}, C{sp_expire}, and C{sp_flag} attributes, respectively. """ db = self.database (username, password, lastChange, min, max, warn, inact, expire, flag) = self.getExistingUserInfo() for entry in [db.getspnam(username), db.getspall()[0]]: self.assertEqual(entry[0], username) self.assertEqual(entry[1], password) self.assertEqual(entry[2], lastChange) self.assertEqual(entry[3], min) self.assertEqual(entry[4], max) self.assertEqual(entry[5], warn) self.assertEqual(entry[6], inact) self.assertEqual(entry[7], expire) self.assertEqual(entry[8], flag) self.assertEqual(len(entry), len(list(entry))) self.assertRaises(IndexError, getitem, entry, 9) class ShadowDatabaseTests(TestCase, ShadowDatabaseTestsMixin): """ Tests for L{ShadowDatabase}. """ def setUp(self): """ Create a L{ShadowDatabase} with no user data in it. """ self.database = ShadowDatabase() self._counter = 0 def getExistingUserInfo(self): """ Add a new user to C{self.database} and return its information. """ self._counter += 1 suffix = '_' + str(self._counter) username = 'username' + suffix password = 'password' + suffix lastChange = self._counter + 1 min = self._counter + 2 max = self._counter + 3 warn = self._counter + 4 inact = self._counter + 5 expire = self._counter + 6 flag = self._counter + 7 self.database.addUser(username, password, lastChange, min, max, warn, inact, expire, flag) return (username, password, lastChange, min, max, warn, inact, expire, flag) def test_addUser(self): """ L{UserDatabase.addUser} accepts seven arguments, one for each field of a L{pwd.struct_passwd}, and makes the new record available via L{UserDatabase.getpwuid}, L{UserDatabase.getpwnam}, and L{UserDatabase.getpwall}. """ username = 'alice' password = 'secr3t' lastChange = 17 min = 42 max = 105 warn = 12 inact = 3 expire = 400 flag = 3 db = self.database db.addUser(username, password, lastChange, min, max, warn, inact, expire, flag) for [entry] in [[db.getspnam(username)], db.getspall()]: self.assertEqual(entry.sp_nam, username) self.assertEqual(entry.sp_pwd, password) self.assertEqual(entry.sp_lstchg, lastChange) self.assertEqual(entry.sp_min, min) self.assertEqual(entry.sp_max, max) self.assertEqual(entry.sp_warn, warn) self.assertEqual(entry.sp_inact, inact) self.assertEqual(entry.sp_expire, expire) self.assertEqual(entry.sp_flag, flag) class SPwdModuleTests(TestCase, ShadowDatabaseTestsMixin): """ L{SPwdModuleTests} runs the tests defined by L{ShadowDatabaseTestsMixin} against the built-in C{spwd} module. This serves to verify that L{ShadowDatabase} is really a fake of that API. """ if spwd is None: skip = "Cannot verify ShadowDatabase against spwd without spwd" elif os.getuid() != 0: skip = "Cannot access shadow user database except as root" else: database = spwd def setUp(self): self._users = iter(self.database.getspall()) def getExistingUserInfo(self): """ Read and return the next record from C{self._users}. """ return next(self._users)
gpl-3.0
[ 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 2925, 367, 491, 91, 12145, 14, 1548, 14, 3183, 14258, 5565, 199, 624, 199, 199, 893, 26, 272, 492, 14374, 199, 2590, 3545, 26, 272, 14374, 275, 488, 199, 199, 893, 26, 272, 492, 2249, 2989, 199, 2590, 3545, 26, 272, 2249, 2989, 275, 488, 199, 199, 646, 747, 199, 504, 4182, 492, 2312, 4484, 199, 199, 504, 7390, 14, 14443, 14, 2796, 492, 7640, 199, 504, 7390, 14, 1548, 14, 3183, 14258, 492, 2876, 7243, 12, 5244, 8369, 7243, 199, 199, 12711, 63, 6685, 63, 4283, 275, 22291, 199, 199, 318, 2342, 3364, 6685, 837, 272, 408, 272, 4885, 16129, 12, 738, 12818, 6656, 2419, 5198, 787, 4644, 367, 314, 2656, 14, 221, 437, 2656, 272, 1314, 17659, 4036, 2849, 1373, 402, 5204, 738, 12818, 3955, 12060, 1172, 20594, 3294, 272, 8826, 543, 29447, 1958, 892, 7869, 12, 880, 4691, 1159, 5534, 626, 781, 7171, 506, 7688, 370, 272, 2342, 1373, 14, 221, 334, 3917, 781, 2793, 1133, 12, 642, 911, 4816, 6818, 370, 6946, 1338, 436, 272, 473, 91, 1430, 3163, 93, 2342, 6020, 4959, 339, 768, 1107, 26, 282, 922, 2870, 1314, 1630, 440, 2187, 641, 314, 2257, 2656, 14, 221, 4236, 12, 641, 267, 10460, 1928, 282, 491, 91, 14258, 93, 859, 12, 372, 445, 91, 12711, 63, 6685, 63, 4283, 5565, 272, 408, 272, 9519, 275, 20859, 63, 6685, 63, 4283, 272, 340, 14374, 365, 440, 488, 26, 267, 1830, 715, 26, 288, 862, 26, 355, 14374, 14, 362, 8796, 1535, 8, 11636, 9, 288, 871, 4067, 26, 355, 2059, 288, 587, 26, 355, 9519, 4862, 413, 272, 372, 9519, 4388, 199, 9692, 63, 6685, 275, 2342, 3364, 6685, 342, 4388, 199, 533, 2876, 7243, 2925, 4256, 26, 272, 408, 272, 491, 91, 1899, 7243, 2925, 4256, 93, 7890, 2295, 1314, 4838, 370, 1263, 922, 3050, 272, 4514, 14, 221, 20196, 1077, 13667, 652, 315, 12, 5669, 445, 91, 5996, 93, 370, 1218, 272, 445, 91, 277, 14, 4659, 93, 3914, 370, 282, 922, 3050, 1256, 12, 436, 5669, 272, 445, 91, 362, 23490, 1899, 2354, 93, 370, 372, 2556, 3595, 282, 922, 334, 10180, 2556, 272, 1077, 506, 3747, 1126, 511, 1083, 680, 272, 408, 272, 347, 511, 63, 362, 8796, 1535, 8, 277, 304, 267, 408, 267, 473, 91, 362, 8796, 1535, 93, 11479, 282, 1747, 436, 2529, 314, 922, 2777, 4568, 543, 267, 652, 14, 267, 408, 267, 367, 284, 315, 1425, 8, 18, 304, 288, 327, 2372, 2005, 922, 1314, 3495, 315, 314, 3050, 14, 288, 3434, 12, 2505, 12, 1747, 12, 15122, 12, 2312, 5197, 12, 2935, 12, 5218, 275, 291, 14, 362, 23490, 1899, 2354, 342, 953, 327, 7356, 862, 370, 3648, 652, 1536, 436, 1852, 3238, 314, 754, 365, 3211, 14, 288, 2397, 275, 291, 14, 4659, 14, 362, 8796, 1535, 8, 1535, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 354, 12, 3434, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 12671, 12, 2505, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 1535, 12, 1747, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 8787, 12, 15122, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 303, 5197, 12, 2312, 5197, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 694, 12, 2935, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 5641, 12, 5218, 9, 2378, 347, 511, 63, 889, 16912, 6685, 8, 277, 304, 267, 408, 267, 473, 91, 362, 8796, 1535, 93, 6534, 491, 91, 10230, 93, 1380, 3032, 282, 1747, 1314, 1630, 440, 2187, 267, 315, 314, 922, 3050, 14, 267, 408, 267, 291, 14, 1855, 8, 10230, 12, 291, 14, 4659, 14, 362, 8796, 1535, 12, 29901, 63, 6685, 9, 2378, 347, 511, 63, 362, 80, 3501, 455, 8, 277, 304, 267, 408, 267, 473, 91, 362, 80, 3501, 455, 93, 11479, 282, 3434, 436, 2529, 314, 922, 2777, 4568, 267, 543, 652, 14, 267, 408, 267, 367, 284, 315, 1425, 8, 18, 304, 288, 327, 2372, 2005, 922, 1314, 3495, 315, 314, 3050, 14, 288, 3434, 12, 2505, 12, 1747, 12, 15122, 12, 2312, 5197, 12, 2935, 12, 5218, 275, 291, 14, 362, 23490, 1899, 2354, 342, 953, 327, 7356, 862, 370, 3648, 652, 1536, 436, 1852, 3238, 314, 754, 365, 3211, 14, 288, 2397, 275, 291, 14, 4659, 14, 362, 80, 3501, 455, 8, 2473, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 354, 12, 3434, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 12671, 12, 2505, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 1535, 12, 1747, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 8787, 12, 15122, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 303, 5197, 12, 2312, 5197, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 694, 12, 2935, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 5641, 12, 5218, 9, 2378, 347, 511, 63, 889, 16912, 985, 8, 277, 304, 267, 408, 267, 473, 91, 362, 80, 3501, 455, 93, 6534, 491, 91, 10230, 93, 1380, 3032, 282, 3434, 1314, 1630, 440, 267, 2187, 315, 314, 922, 3050, 14, 267, 408, 267, 291, 14, 1855, 8, 288, 4067, 12, 291, 14, 4659, 14, 362, 80, 3501, 455, 12, 288, 283, 889, 7, 283, 10180, 7, 283, 751, 7, 283, 2444, 7, 283, 1589, 7, 283, 354, 7, 283, 374, 7, 283, 7354, 7, 283, 2809, 7, 283, 460, 7, 283, 1989, 7, 288, 1557, 17, 7, 283, 262, 7, 283, 390, 7, 283, 7354, 358, 2378, 347, 511, 63, 3059, 4625, 8, 277, 304, 267, 408, 267, 710, 922, 2777, 2138, 701, 473, 91, 362, 8796, 1535, 1386, 473, 91, 362, 80, 3501, 455, 1386, 436, 473, 91, 362, 80, 7567, 93, 267, 965, 282, 2582, 14, 267, 408, 267, 1592, 275, 291, 14, 4659, 267, 3434, 12, 2505, 12, 1747, 12, 15122, 12, 2312, 5197, 12, 2935, 12, 5218, 275, 291, 14, 362, 23490, 1899, 2354, 342, 267, 367, 2397, 315, 359, 697, 14 ]
[ 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 2925, 367, 491, 91, 12145, 14, 1548, 14, 3183, 14258, 5565, 199, 624, 199, 199, 893, 26, 272, 492, 14374, 199, 2590, 3545, 26, 272, 14374, 275, 488, 199, 199, 893, 26, 272, 492, 2249, 2989, 199, 2590, 3545, 26, 272, 2249, 2989, 275, 488, 199, 199, 646, 747, 199, 504, 4182, 492, 2312, 4484, 199, 199, 504, 7390, 14, 14443, 14, 2796, 492, 7640, 199, 504, 7390, 14, 1548, 14, 3183, 14258, 492, 2876, 7243, 12, 5244, 8369, 7243, 199, 199, 12711, 63, 6685, 63, 4283, 275, 22291, 199, 199, 318, 2342, 3364, 6685, 837, 272, 408, 272, 4885, 16129, 12, 738, 12818, 6656, 2419, 5198, 787, 4644, 367, 314, 2656, 14, 221, 437, 2656, 272, 1314, 17659, 4036, 2849, 1373, 402, 5204, 738, 12818, 3955, 12060, 1172, 20594, 3294, 272, 8826, 543, 29447, 1958, 892, 7869, 12, 880, 4691, 1159, 5534, 626, 781, 7171, 506, 7688, 370, 272, 2342, 1373, 14, 221, 334, 3917, 781, 2793, 1133, 12, 642, 911, 4816, 6818, 370, 6946, 1338, 436, 272, 473, 91, 1430, 3163, 93, 2342, 6020, 4959, 339, 768, 1107, 26, 282, 922, 2870, 1314, 1630, 440, 2187, 641, 314, 2257, 2656, 14, 221, 4236, 12, 641, 267, 10460, 1928, 282, 491, 91, 14258, 93, 859, 12, 372, 445, 91, 12711, 63, 6685, 63, 4283, 5565, 272, 408, 272, 9519, 275, 20859, 63, 6685, 63, 4283, 272, 340, 14374, 365, 440, 488, 26, 267, 1830, 715, 26, 288, 862, 26, 355, 14374, 14, 362, 8796, 1535, 8, 11636, 9, 288, 871, 4067, 26, 355, 2059, 288, 587, 26, 355, 9519, 4862, 413, 272, 372, 9519, 4388, 199, 9692, 63, 6685, 275, 2342, 3364, 6685, 342, 4388, 199, 533, 2876, 7243, 2925, 4256, 26, 272, 408, 272, 491, 91, 1899, 7243, 2925, 4256, 93, 7890, 2295, 1314, 4838, 370, 1263, 922, 3050, 272, 4514, 14, 221, 20196, 1077, 13667, 652, 315, 12, 5669, 445, 91, 5996, 93, 370, 1218, 272, 445, 91, 277, 14, 4659, 93, 3914, 370, 282, 922, 3050, 1256, 12, 436, 5669, 272, 445, 91, 362, 23490, 1899, 2354, 93, 370, 372, 2556, 3595, 282, 922, 334, 10180, 2556, 272, 1077, 506, 3747, 1126, 511, 1083, 680, 272, 408, 272, 347, 511, 63, 362, 8796, 1535, 8, 277, 304, 267, 408, 267, 473, 91, 362, 8796, 1535, 93, 11479, 282, 1747, 436, 2529, 314, 922, 2777, 4568, 543, 267, 652, 14, 267, 408, 267, 367, 284, 315, 1425, 8, 18, 304, 288, 327, 2372, 2005, 922, 1314, 3495, 315, 314, 3050, 14, 288, 3434, 12, 2505, 12, 1747, 12, 15122, 12, 2312, 5197, 12, 2935, 12, 5218, 275, 291, 14, 362, 23490, 1899, 2354, 342, 953, 327, 7356, 862, 370, 3648, 652, 1536, 436, 1852, 3238, 314, 754, 365, 3211, 14, 288, 2397, 275, 291, 14, 4659, 14, 362, 8796, 1535, 8, 1535, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 354, 12, 3434, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 12671, 12, 2505, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 1535, 12, 1747, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 8787, 12, 15122, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 303, 5197, 12, 2312, 5197, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 694, 12, 2935, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 5641, 12, 5218, 9, 2378, 347, 511, 63, 889, 16912, 6685, 8, 277, 304, 267, 408, 267, 473, 91, 362, 8796, 1535, 93, 6534, 491, 91, 10230, 93, 1380, 3032, 282, 1747, 1314, 1630, 440, 2187, 267, 315, 314, 922, 3050, 14, 267, 408, 267, 291, 14, 1855, 8, 10230, 12, 291, 14, 4659, 14, 362, 8796, 1535, 12, 29901, 63, 6685, 9, 2378, 347, 511, 63, 362, 80, 3501, 455, 8, 277, 304, 267, 408, 267, 473, 91, 362, 80, 3501, 455, 93, 11479, 282, 3434, 436, 2529, 314, 922, 2777, 4568, 267, 543, 652, 14, 267, 408, 267, 367, 284, 315, 1425, 8, 18, 304, 288, 327, 2372, 2005, 922, 1314, 3495, 315, 314, 3050, 14, 288, 3434, 12, 2505, 12, 1747, 12, 15122, 12, 2312, 5197, 12, 2935, 12, 5218, 275, 291, 14, 362, 23490, 1899, 2354, 342, 953, 327, 7356, 862, 370, 3648, 652, 1536, 436, 1852, 3238, 314, 754, 365, 3211, 14, 288, 2397, 275, 291, 14, 4659, 14, 362, 80, 3501, 455, 8, 2473, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 354, 12, 3434, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 12671, 12, 2505, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 1535, 12, 1747, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 8787, 12, 15122, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 303, 5197, 12, 2312, 5197, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 694, 12, 2935, 9, 288, 291, 14, 629, 8, 2373, 14, 8796, 63, 5641, 12, 5218, 9, 2378, 347, 511, 63, 889, 16912, 985, 8, 277, 304, 267, 408, 267, 473, 91, 362, 80, 3501, 455, 93, 6534, 491, 91, 10230, 93, 1380, 3032, 282, 3434, 1314, 1630, 440, 267, 2187, 315, 314, 922, 3050, 14, 267, 408, 267, 291, 14, 1855, 8, 288, 4067, 12, 291, 14, 4659, 14, 362, 80, 3501, 455, 12, 288, 283, 889, 7, 283, 10180, 7, 283, 751, 7, 283, 2444, 7, 283, 1589, 7, 283, 354, 7, 283, 374, 7, 283, 7354, 7, 283, 2809, 7, 283, 460, 7, 283, 1989, 7, 288, 1557, 17, 7, 283, 262, 7, 283, 390, 7, 283, 7354, 358, 2378, 347, 511, 63, 3059, 4625, 8, 277, 304, 267, 408, 267, 710, 922, 2777, 2138, 701, 473, 91, 362, 8796, 1535, 1386, 473, 91, 362, 80, 3501, 455, 1386, 436, 473, 91, 362, 80, 7567, 93, 267, 965, 282, 2582, 14, 267, 408, 267, 1592, 275, 291, 14, 4659, 267, 3434, 12, 2505, 12, 1747, 12, 15122, 12, 2312, 5197, 12, 2935, 12, 5218, 275, 291, 14, 362, 23490, 1899, 2354, 342, 267, 367, 2397, 315, 359, 697, 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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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 ]
Schibum/sndlatr
gae/babel/messages/plurals.py
151
6696
# -*- coding: utf-8 -*- """ babel.messages.plurals ~~~~~~~~~~~~~~~~~~~~~~ Plural form definitions. :copyright: (c) 2013 by the Babel Team. :license: BSD, see LICENSE for more details. """ from babel.core import default_locale, Locale from operator import itemgetter # XXX: remove this file, duplication with babel.plural LC_CTYPE = default_locale('LC_CTYPE') PLURALS = { # Afar # 'aa': (), # Abkhazian # 'ab': (), # Avestan # 'ae': (), # Afrikaans - From Pootle's PO's 'af': (2, '(n != 1)'), # Akan # 'ak': (), # Amharic # 'am': (), # Aragonese # 'an': (), # Arabic - From Pootle's PO's 'ar': (6, '(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n>=3 && n<=10 ? 3 : n>=11 && n<=99 ? 4 : 5)'), # Assamese # 'as': (), # Avaric # 'av': (), # Aymara # 'ay': (), # Azerbaijani # 'az': (), # Bashkir # 'ba': (), # Belarusian # 'be': (), # Bulgarian - From Pootle's PO's 'bg': (2, '(n != 1)'), # Bihari # 'bh': (), # Bislama # 'bi': (), # Bambara # 'bm': (), # Bengali - From Pootle's PO's 'bn': (2, '(n != 1)'), # Tibetan - as discussed in private with Andrew West 'bo': (1, '0'), # Breton # 'br': (), # Bosnian # 'bs': (), # Catalan - From Pootle's PO's 'ca': (2, '(n != 1)'), # Chechen # 'ce': (), # Chamorro # 'ch': (), # Corsican # 'co': (), # Cree # 'cr': (), # Czech 'cs': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), # Church Slavic # 'cu': (), # Chuvash 'cv': (1, '0'), # Welsh 'cy': (5, '(n==1 ? 1 : n==2 ? 2 : n==3 ? 3 : n==6 ? 4 : 0)'), # Danish 'da': (2, '(n != 1)'), # German 'de': (2, '(n != 1)'), # Divehi # 'dv': (), # Dzongkha 'dz': (1, '0'), # Greek 'el': (2, '(n != 1)'), # English 'en': (2, '(n != 1)'), # Esperanto 'eo': (2, '(n != 1)'), # Spanish 'es': (2, '(n != 1)'), # Estonian 'et': (2, '(n != 1)'), # Basque - From Pootle's PO's 'eu': (2, '(n != 1)'), # Persian - From Pootle's PO's 'fa': (1, '0'), # Finnish 'fi': (2, '(n != 1)'), # French 'fr': (2, '(n > 1)'), # Friulian - From Pootle's PO's 'fur': (2, '(n > 1)'), # Irish 'ga': (3, '(n==1 ? 0 : n==2 ? 1 : 2)'), # Galician - From Pootle's PO's 'gl': (2, '(n != 1)'), # Hausa - From Pootle's PO's 'ha': (2, '(n != 1)'), # Hebrew 'he': (2, '(n != 1)'), # Hindi - From Pootle's PO's 'hi': (2, '(n != 1)'), # Croatian 'hr': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), # Hungarian 'hu': (1, '0'), # Armenian - From Pootle's PO's 'hy': (1, '0'), # Icelandic - From Pootle's PO's 'is': (2, '(n != 1)'), # Italian 'it': (2, '(n != 1)'), # Japanese 'ja': (1, '0'), # Georgian - From Pootle's PO's 'ka': (1, '0'), # Kongo - From Pootle's PO's 'kg': (2, '(n != 1)'), # Khmer - From Pootle's PO's 'km': (1, '0'), # Korean 'ko': (1, '0'), # Kurdish - From Pootle's PO's 'ku': (2, '(n != 1)'), # Lao - Another member of the Tai language family, like Thai. 'lo': (1, '0'), # Lithuanian 'lt': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2)'), # Latvian 'lv': (3, '(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2)'), # Maltese - From Pootle's PO's 'mt': (4, '(n==1 ? 0 : n==0 || ( n%100>1 && n%100<11) ? 1 : (n%100>10 && n%100<20 ) ? 2 : 3)'), # Norwegian Bokmål 'nb': (2, '(n != 1)'), # Dutch 'nl': (2, '(n != 1)'), # Norwegian Nynorsk 'nn': (2, '(n != 1)'), # Norwegian 'no': (2, '(n != 1)'), # Punjabi - From Pootle's PO's 'pa': (2, '(n != 1)'), # Polish 'pl': (3, '(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), # Portuguese 'pt': (2, '(n != 1)'), # Brazilian 'pt_BR': (2, '(n > 1)'), # Romanian - From Pootle's PO's 'ro': (3, '(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2)'), # Russian 'ru': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), # Slovak 'sk': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), # Slovenian 'sl': (4, '(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3)'), # Serbian - From Pootle's PO's 'sr': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), # Southern Sotho - From Pootle's PO's 'st': (2, '(n != 1)'), # Swedish 'sv': (2, '(n != 1)'), # Thai 'th': (1, '0'), # Turkish 'tr': (1, '0'), # Ukrainian 'uk': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'), # Venda - From Pootle's PO's 've': (2, '(n != 1)'), # Vietnamese - From Pootle's PO's 'vi': (1, '0'), # Xhosa - From Pootle's PO's 'xh': (2, '(n != 1)'), # Chinese - From Pootle's PO's 'zh_CN': (1, '0'), 'zh_HK': (1, '0'), 'zh_TW': (1, '0'), } DEFAULT_PLURAL = (2, '(n != 1)') class _PluralTuple(tuple): """A tuple with plural information.""" __slots__ = () num_plurals = property(itemgetter(0), doc=""" The number of plurals used by the locale.""") plural_expr = property(itemgetter(1), doc=""" The plural expression used by the locale.""") plural_forms = property(lambda x: 'npurals=%s; plural=%s' % x, doc=""" The plural expression used by the catalog or locale.""") def __str__(self): return self.plural_forms def get_plural(locale=LC_CTYPE): """A tuple with the information catalogs need to perform proper pluralization. The first item of the tuple is the number of plural forms, the second the plural expression. >>> get_plural(locale='en') (2, '(n != 1)') >>> get_plural(locale='ga') (3, '(n==1 ? 0 : n==2 ? 1 : 2)') The object returned is a special tuple with additional members: >>> tup = get_plural("ja") >>> tup.num_plurals 1 >>> tup.plural_expr '0' >>> tup.plural_forms 'npurals=1; plural=0' Converting the tuple into a string prints the plural forms for a gettext catalog: >>> str(tup) 'npurals=1; plural=0' """ locale = Locale.parse(locale) try: tup = PLURALS[str(locale)] except KeyError: try: tup = PLURALS[locale.language] except KeyError: tup = DEFAULT_PLURAL return _PluralTuple(tup)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 29178, 14, 3431, 14, 1168, 300, 2551, 272, 18294, 2878, 1714, 339, 7497, 4889, 1824, 10269, 14, 339, 520, 7307, 26, 334, 67, 9, 6171, 701, 314, 699, 902, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 29178, 14, 1018, 492, 849, 63, 5508, 12, 28298, 199, 504, 4182, 492, 1242, 7416, 421, 199, 3, 5787, 26, 2813, 642, 570, 12, 11866, 1863, 543, 29178, 14, 10019, 421, 199, 7027, 63, 7540, 275, 849, 63, 5508, 360, 7027, 63, 7540, 358, 421, 199, 2749, 1230, 748, 51, 275, 469, 272, 327, 437, 15315, 272, 327, 283, 2158, 356, 11969, 272, 327, 8351, 75, 22133, 5653, 272, 327, 283, 371, 356, 11969, 272, 327, 437, 432, 9746, 272, 327, 283, 3624, 356, 11969, 272, 327, 437, 25876, 7351, 796, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 2756, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 437, 29305, 272, 327, 283, 1151, 356, 11969, 272, 327, 437, 77, 8210, 530, 272, 327, 283, 455, 356, 11969, 272, 327, 437, 2527, 368, 261, 272, 327, 283, 290, 356, 11969, 272, 327, 437, 24176, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 285, 356, 334, 22, 12, 8189, 78, 389, 16, 5805, 378, 520, 302, 389, 17, 5805, 413, 520, 302, 389, 18, 5805, 499, 520, 302, 8119, 19, 10883, 302, 12932, 709, 5805, 650, 520, 302, 8119, 845, 10883, 302, 12932, 1020, 5805, 841, 520, 959, 11218, 272, 327, 10829, 313, 261, 272, 327, 283, 305, 356, 11969, 272, 327, 437, 1391, 530, 272, 327, 283, 1214, 356, 11969, 272, 327, 437, 89, 4584, 65, 272, 327, 283, 1187, 356, 11969, 272, 327, 437, 2282, 2470, 7879, 26455, 272, 327, 283, 4651, 356, 11969, 272, 327, 699, 1119, 75, 723, 272, 327, 283, 2470, 356, 11969, 272, 327, 699, 352, 285, 85, 6214, 272, 327, 283, 1235, 356, 11969, 272, 327, 699, 27092, 15289, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 6856, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 699, 24278, 759, 272, 327, 283, 26397, 356, 11969, 272, 327, 699, 374, 416, 391, 272, 327, 283, 4492, 356, 11969, 272, 327, 699, 455, 1700, 65, 272, 327, 283, 12648, 356, 11969, 272, 327, 699, 22329, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 10472, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 377, 1892, 386, 290, 446, 465, 4339, 527, 939, 315, 5726, 543, 6061, 5257, 644, 597, 272, 283, 656, 356, 334, 17, 12, 283, 16, 659, 272, 327, 699, 264, 1860, 272, 327, 283, 3289, 356, 11969, 272, 327, 699, 736, 78, 5653, 272, 327, 283, 1533, 356, 11969, 272, 327, 445, 7539, 290, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 696, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 445, 426, 24604, 272, 327, 283, 301, 356, 11969, 272, 327, 2799, 455, 269, 293, 272, 327, 283, 335, 356, 11969, 272, 327, 7499, 338, 2425, 272, 327, 283, 331, 356, 11969, 272, 327, 445, 850, 272, 327, 283, 1556, 356, 11969, 272, 327, 445, 806, 335, 272, 283, 1259, 356, 334, 19, 12, 8189, 78, 5, 709, 389, 17, 10883, 302, 5, 1960, 1111, 845, 5805, 378, 520, 302, 5, 709, 8119, 18, 10883, 302, 5, 709, 12932, 20, 10883, 334, 78, 5, 1960, 28, 709, 12208, 302, 5, 1960, 8119, 1165, 9, 5805, 413, 520, 499, 11218, 272, 327, 2799, 300, 335, 428, 416, 31629, 272, 327, 283, 15140, 356, 11969, 272, 327, 2799, 9154, 1119, 272, 283, 5107, 356, 334, 17, 12, 283, 16, 659, 272, 327, 644, 352, 609, 272, 283, 1480, 356, 334, 21, 12, 8189, 78, 389, 17, 5805, 413, 520, 302, 389, 18, 5805, 499, 520, 302, 389, 19, 5805, 650, 520, 302, 389, 22, 5805, 841, 520, 378, 11218, 272, 327, 24747, 2453, 272, 283, 983, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 22261, 1237, 272, 283, 271, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 577, 1912, 5812, 272, 327, 283, 8398, 356, 11969, 272, 327, 577, 90, 951, 75, 2411, 272, 283, 17019, 356, 334, 17, 12, 283, 16, 659, 272, 327, 598, 14291, 272, 283, 352, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 20144, 272, 283, 287, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 662, 83, 529, 290, 475, 272, 283, 20805, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 32091, 2453, 272, 283, 397, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 15896, 265, 5653, 272, 283, 386, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 699, 305, 544, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 16913, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 3492, 6214, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 667, 356, 334, 17, 12, 283, 16, 659, 272, 327, 11711, 78, 2453, 272, 283, 329, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 481, 15148, 272, 283, 4391, 356, 334, 18, 12, 8189, 78, 690, 413, 11218, 272, 327, 31712, 28325, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 70, 300, 356, 334, 18, 12, 8189, 78, 690, 413, 11218, 272, 327, 473, 322, 609, 272, 283, 5294, 356, 334, 19, 12, 8189, 78, 389, 17, 5805, 378, 520, 302, 389, 18, 5805, 413, 520, 499, 11218, 272, 327, 598, 17999, 5653, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 3528, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 869, 65, 527, 65, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 2411, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 19771, 272, 283, 426, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 869, 3558, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 5812, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 445, 293, 2159 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 29178, 14, 3431, 14, 1168, 300, 2551, 272, 18294, 2878, 1714, 339, 7497, 4889, 1824, 10269, 14, 339, 520, 7307, 26, 334, 67, 9, 6171, 701, 314, 699, 902, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 504, 29178, 14, 1018, 492, 849, 63, 5508, 12, 28298, 199, 504, 4182, 492, 1242, 7416, 421, 199, 3, 5787, 26, 2813, 642, 570, 12, 11866, 1863, 543, 29178, 14, 10019, 421, 199, 7027, 63, 7540, 275, 849, 63, 5508, 360, 7027, 63, 7540, 358, 421, 199, 2749, 1230, 748, 51, 275, 469, 272, 327, 437, 15315, 272, 327, 283, 2158, 356, 11969, 272, 327, 8351, 75, 22133, 5653, 272, 327, 283, 371, 356, 11969, 272, 327, 437, 432, 9746, 272, 327, 283, 3624, 356, 11969, 272, 327, 437, 25876, 7351, 796, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 2756, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 437, 29305, 272, 327, 283, 1151, 356, 11969, 272, 327, 437, 77, 8210, 530, 272, 327, 283, 455, 356, 11969, 272, 327, 437, 2527, 368, 261, 272, 327, 283, 290, 356, 11969, 272, 327, 437, 24176, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 285, 356, 334, 22, 12, 8189, 78, 389, 16, 5805, 378, 520, 302, 389, 17, 5805, 413, 520, 302, 389, 18, 5805, 499, 520, 302, 8119, 19, 10883, 302, 12932, 709, 5805, 650, 520, 302, 8119, 845, 10883, 302, 12932, 1020, 5805, 841, 520, 959, 11218, 272, 327, 10829, 313, 261, 272, 327, 283, 305, 356, 11969, 272, 327, 437, 1391, 530, 272, 327, 283, 1214, 356, 11969, 272, 327, 437, 89, 4584, 65, 272, 327, 283, 1187, 356, 11969, 272, 327, 437, 2282, 2470, 7879, 26455, 272, 327, 283, 4651, 356, 11969, 272, 327, 699, 1119, 75, 723, 272, 327, 283, 2470, 356, 11969, 272, 327, 699, 352, 285, 85, 6214, 272, 327, 283, 1235, 356, 11969, 272, 327, 699, 27092, 15289, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 6856, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 699, 24278, 759, 272, 327, 283, 26397, 356, 11969, 272, 327, 699, 374, 416, 391, 272, 327, 283, 4492, 356, 11969, 272, 327, 699, 455, 1700, 65, 272, 327, 283, 12648, 356, 11969, 272, 327, 699, 22329, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 10472, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 377, 1892, 386, 290, 446, 465, 4339, 527, 939, 315, 5726, 543, 6061, 5257, 644, 597, 272, 283, 656, 356, 334, 17, 12, 283, 16, 659, 272, 327, 699, 264, 1860, 272, 327, 283, 3289, 356, 11969, 272, 327, 699, 736, 78, 5653, 272, 327, 283, 1533, 356, 11969, 272, 327, 445, 7539, 290, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 696, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 445, 426, 24604, 272, 327, 283, 301, 356, 11969, 272, 327, 2799, 455, 269, 293, 272, 327, 283, 335, 356, 11969, 272, 327, 7499, 338, 2425, 272, 327, 283, 331, 356, 11969, 272, 327, 445, 850, 272, 327, 283, 1556, 356, 11969, 272, 327, 445, 806, 335, 272, 283, 1259, 356, 334, 19, 12, 8189, 78, 5, 709, 389, 17, 10883, 302, 5, 1960, 1111, 845, 5805, 378, 520, 302, 5, 709, 8119, 18, 10883, 302, 5, 709, 12932, 20, 10883, 334, 78, 5, 1960, 28, 709, 12208, 302, 5, 1960, 8119, 1165, 9, 5805, 413, 520, 499, 11218, 272, 327, 2799, 300, 335, 428, 416, 31629, 272, 327, 283, 15140, 356, 11969, 272, 327, 2799, 9154, 1119, 272, 283, 5107, 356, 334, 17, 12, 283, 16, 659, 272, 327, 644, 352, 609, 272, 283, 1480, 356, 334, 21, 12, 8189, 78, 389, 17, 5805, 413, 520, 302, 389, 18, 5805, 499, 520, 302, 389, 19, 5805, 650, 520, 302, 389, 22, 5805, 841, 520, 378, 11218, 272, 327, 24747, 2453, 272, 283, 983, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 22261, 1237, 272, 283, 271, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 577, 1912, 5812, 272, 327, 283, 8398, 356, 11969, 272, 327, 577, 90, 951, 75, 2411, 272, 283, 17019, 356, 334, 17, 12, 283, 16, 659, 272, 327, 598, 14291, 272, 283, 352, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 20144, 272, 283, 287, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 662, 83, 529, 290, 475, 272, 283, 20805, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 32091, 2453, 272, 283, 397, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 15896, 265, 5653, 272, 283, 386, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 699, 305, 544, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 16913, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 3492, 6214, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 667, 356, 334, 17, 12, 283, 16, 659, 272, 327, 11711, 78, 2453, 272, 283, 329, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 481, 15148, 272, 283, 4391, 356, 334, 18, 12, 8189, 78, 690, 413, 11218, 272, 327, 31712, 28325, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 70, 300, 356, 334, 18, 12, 8189, 78, 690, 413, 11218, 272, 327, 473, 322, 609, 272, 283, 5294, 356, 334, 19, 12, 8189, 78, 389, 17, 5805, 378, 520, 302, 389, 18, 5805, 413, 520, 499, 11218, 272, 327, 598, 17999, 5653, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 3528, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 869, 65, 527, 65, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 2411, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 19771, 272, 283, 426, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 869, 3558, 446, 11606, 4376, 24629, 1159, 3625, 1159, 272, 283, 5812, 356, 334, 18, 12, 8189, 78, 1137, 413, 11218, 272, 327, 445, 293, 2159, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
slagle/ansible-modules-extras
packaging/dpkg_selections.py
88
2405
#!/usr/bin/python # -*- coding: utf-8 -*- # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. DOCUMENTATION = ''' --- module: dpkg_selections short_description: Dpkg package selection selections description: - Change dpkg package selection state via --get-selections and --set-selections. version_added: "2.0" author: Brian Brazil <brian.brazil@boxever.com> options: name: description: - Name of the package required: true selection: description: - The selection state to set the package to. choices: [ 'install', 'hold', 'deinstall', 'purge' ] required: true notes: - This module won't cause any packages to be installed/removed/purged, use the C(apt) module for that. ''' EXAMPLES = ''' # Prevent python from being upgraded. - dpkg_selections: name=python selection=hold ''' def main(): module = AnsibleModule( argument_spec = dict( name = dict(required=True), selection = dict(choices=['install', 'hold', 'deinstall', 'purge']) ), supports_check_mode=True, ) dpkg = module.get_bin_path('dpkg', True) name = module.params['name'] selection = module.params['selection'] # Get current settings. rc, out, err = module.run_command([dpkg, '--get-selections', name], check_rc=True) if not out: current = 'not present' else: current = out.split()[1] changed = current != selection if module.check_mode or not changed: module.exit_json(changed=changed, before=current, after=selection) module.run_command([dpkg, '--set-selections'], data="%s %s" % (name, selection), check_rc=True) module.exit_json(changed=changed, before=current, after=selection) from ansible.module_utils.basic import * main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 366, 4600, 63, 5592, 83, 199, 3612, 63, 1802, 26, 577, 4600, 2559, 7267, 7267, 83, 199, 1802, 26, 272, 446, 7743, 366, 4600, 2559, 7267, 1174, 4799, 1553, 362, 13, 5592, 83, 436, 1553, 409, 13, 5592, 83, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 699, 18429, 32377, 90, 382, 665, 9660, 290, 14, 7828, 90, 382, 32, 656, 1845, 422, 14, 957, 30, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 2559, 267, 1415, 26, 2549, 272, 7267, 26, 267, 1369, 26, 288, 446, 710, 7267, 1174, 370, 663, 314, 2559, 370, 14, 267, 3415, 26, 359, 283, 3174, 297, 283, 12239, 297, 283, 271, 3174, 297, 283, 18254, 7, 1622, 267, 1415, 26, 2549, 199, 5983, 26, 272, 446, 961, 859, 7859, 1133, 7675, 1263, 6117, 370, 506, 4903, 15, 10649, 15, 6653, 3046, 12, 675, 314, 445, 8, 6182, 9, 859, 367, 626, 14, 199, 2344, 199, 8918, 275, 1449, 199, 3, 29861, 2366, 687, 3769, 1536, 13688, 14, 199, 13, 366, 4600, 63, 5592, 83, 26, 536, 29, 1548, 7267, 29, 12239, 199, 2344, 199, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 275, 1211, 8, 288, 536, 275, 1211, 8, 2427, 29, 549, 395, 288, 7267, 275, 1211, 8, 4577, 2968, 3174, 297, 283, 12239, 297, 283, 271, 3174, 297, 283, 18254, 1105, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 549, 12, 272, 776, 339, 366, 4600, 275, 859, 14, 362, 63, 1393, 63, 515, 360, 68, 4600, 297, 715, 9, 339, 536, 275, 859, 14, 1162, 459, 354, 418, 272, 7267, 275, 859, 14, 1162, 459, 5592, 418, 339, 327, 2372, 1453, 2202, 14, 272, 4819, 12, 734, 12, 2329, 275, 859, 14, 1065, 63, 1531, 779, 68, 4600, 12, 2850, 362, 13, 5592, 83, 297, 536, 467, 1104, 63, 1195, 29, 549, 9, 272, 340, 440, 734, 26, 267, 1453, 275, 283, 1397, 3451, 7, 272, 587, 26, 267, 1453, 275, 734, 14, 1294, 3430, 17, 61, 339, 2896, 275, 1453, 1137, 7267, 339, 340, 859, 14, 1074, 63, 632, 503, 440, 2896, 26, 489, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 12, 2544, 29, 1818, 12, 2410, 29, 5592, 9, 339, 859, 14, 1065, 63, 1531, 779, 68, 4600, 12, 2850, 409, 13, 5592, 83, 995, 666, 5961, 83, 450, 83, 2, 450, 334, 354, 12, 7267, 395, 1104, 63, 1195, 29, 549, 9, 272, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 12, 2544, 29, 1818, 12, 2410, 29, 5592, 9, 421, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 366, 4600, 63, 5592, 83, 199, 3612, 63, 1802, 26, 577, 4600, 2559, 7267, 7267, 83, 199, 1802, 26, 272, 446, 7743, 366, 4600, 2559, 7267, 1174, 4799, 1553, 362, 13, 5592, 83, 436, 1553, 409, 13, 5592, 83, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 699, 18429, 32377, 90, 382, 665, 9660, 290, 14, 7828, 90, 382, 32, 656, 1845, 422, 14, 957, 30, 199, 1419, 26, 272, 536, 26, 267, 1369, 26, 288, 446, 2812, 402, 314, 2559, 267, 1415, 26, 2549, 272, 7267, 26, 267, 1369, 26, 288, 446, 710, 7267, 1174, 370, 663, 314, 2559, 370, 14, 267, 3415, 26, 359, 283, 3174, 297, 283, 12239, 297, 283, 271, 3174, 297, 283, 18254, 7, 1622, 267, 1415, 26, 2549, 199, 5983, 26, 272, 446, 961, 859, 7859, 1133, 7675, 1263, 6117, 370, 506, 4903, 15, 10649, 15, 6653, 3046, 12, 675, 314, 445, 8, 6182, 9, 859, 367, 626, 14, 199, 2344, 199, 8918, 275, 1449, 199, 3, 29861, 2366, 687, 3769, 1536, 13688, 14, 199, 13, 366, 4600, 63, 5592, 83, 26, 536, 29, 1548, 7267, 29, 12239, 199, 2344, 199, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 275, 1211, 8, 288, 536, 275, 1211, 8, 2427, 29, 549, 395, 288, 7267, 275, 1211, 8, 4577, 2968, 3174, 297, 283, 12239, 297, 283, 271, 3174, 297, 283, 18254, 1105, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 549, 12, 272, 776, 339, 366, 4600, 275, 859, 14, 362, 63, 1393, 63, 515, 360, 68, 4600, 297, 715, 9, 339, 536, 275, 859, 14, 1162, 459, 354, 418, 272, 7267, 275, 859, 14, 1162, 459, 5592, 418, 339, 327, 2372, 1453, 2202, 14, 272, 4819, 12, 734, 12, 2329, 275, 859, 14, 1065, 63, 1531, 779, 68, 4600, 12, 2850, 362, 13, 5592, 83, 297, 536, 467, 1104, 63, 1195, 29, 549, 9, 272, 340, 440, 734, 26, 267, 1453, 275, 283, 1397, 3451, 7, 272, 587, 26, 267, 1453, 275, 734, 14, 1294, 3430, 17, 61, 339, 2896, 275, 1453, 1137, 7267, 339, 340, 859, 14, 1074, 63, 632, 503, 440, 2896, 26, 489, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 12, 2544, 29, 1818, 12, 2410, 29, 5592, 9, 339, 859, 14, 1065, 63, 1531, 779, 68, 4600, 12, 2850, 409, 13, 5592, 83, 995, 666, 5961, 83, 450, 83, 2, 450, 334, 354, 12, 7267, 395, 1104, 63, 1195, 29, 549, 9, 272, 859, 14, 2224, 63, 1001, 8, 2489, 29, 2489, 12, 2544, 29, 1818, 12, 2410, 29, 5592, 9, 421, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
MuffinMedic/znc-weblog
weblog.py
1
5161
import znc import os def is_safe_path(basedir, path): return os.path.abspath(path).startswith(basedir) class weblog(znc.Module): module_types = [znc.CModInfo.GlobalModule] description = "Allowings viewing of log files from the ZNC webadmin" wiki_page = "Weblog" def OnLoad(self, args, message): return True def WebRequiresLogin(self): return True def WebRequiresAdmin(self): return False def GetWebMenuTitle(self): return "Log Viewer" def OnWebRequest(self, sock, page, tmpl): user = sock.GetUser() dir = sock.GetParam('dir', False) if page == "index": if sock.GetRawParam('scope', True): scope = sock.GetRawParam('scope', True) self.setscope(scope, sock, tmpl) try: self.listdir(tmpl, dir, sock) except KeyError: row = tmpl.AddRow("ErrorLoop") row["error"] = "No scope set. Please set one above." elif page == "log" or page == "raw": self.viewlog(tmpl, dir, sock, page) self.getscopes(sock, tmpl) return True def listdir(self, tmpl, dir, sock): base = self.getbase(sock) try: dir_list = sorted(os.listdir(base + dir)) self.breadcrumbs(tmpl, dir, False) if len(dir_list) > 0: for item in dir_list: row = tmpl.AddRow("ListLoop") rel = dir + '/' + item if dir else item path = base + rel if os.path.isfile(path): url = 'log?dir=' + rel.replace('#', '%23') size = str(os.path.getsize(path) >> 10) + " KB" elif os.path.isdir(path): url = '?dir=' + rel.replace('#', '%23') size = len([name for name in os.listdir(path)]) row["scope"] = url row["item"] = item row["size"] = str(size) else: row = tmpl.AddRow("ErrorLoop") row["error"] = "Directory empty." except FileNotFoundError: row = tmpl.AddRow("ErrorLoop") row["error"] = "Directory does not exist. Please make sure you have the log module enabled and that you are attempting to access logs at the appropriate level (global, user, or network)." def viewlog(self, tmpl, dir, sock, page): base = self.getbase(sock) if not is_safe_path(base, base + dir): if page == "raw": row = tmpl.AddRow("LogLoop") row['log'] = "Error: invalid directory provided." return row = tmpl.AddRow("ErrorLoop") row["error"] = "Invalid directory provided." return path = base + dir row = tmpl.AddRow("LogLoop") with open(path, 'r', encoding='utf8') as log: log = log.read() if page == "raw": log = log.replace('<', '&lt;').replace('>', '&gt;') row['log'] = log if page == "log": self.breadcrumbs(tmpl, dir, True) row['raw'] = 'raw?dir=' + dir.replace('#', '%23') def breadcrumbs(self, tmpl, dir, islog): folders = dir.split('/') crumbs = ['<a href="">logs / </a>'] row = tmpl.AddRow("BreadcrumbLoop") row["crumbtext"] = "logs" row["crumburl"] = "" for i in range(0, len(folders)): if folders[i]: row = tmpl.AddRow("BreadcrumbLoop") row["crumbtext"] = folders[i] url = '/'.join(folders[0:i+1]) url = url.replace('#', '%23') row["crumburl"] = url if i == len(folders) - 1 and islog: row["islog"] = "True" def getbase(self, sock): base = znc.CZNC.Get().GetZNCPath() user = sock.GetUser() scope = self.nv[user] if scope == "Global": base = base + '/moddata/log/' + user + '/' elif scope == "User": base = base + '/users/' + user + '/moddata/log/' else: base = base + '/users/' + user + '/networks/' + self.nv[user] + '/moddata/log/' return base def getscopes(self, sock, tmpl): user_string = sock.GetUser() user = znc.CZNC.Get().FindUser(user_string) networks = user.GetNetworks() net_array = [] for network in networks: net_array.append(network.GetName()) net_array = sorted(net_array) net_array.insert(0, 'User'); net_array.insert(0, 'Global') for net in net_array: row = tmpl.AddRow("ScopeLoop") try: if net == self.nv[user_string]: row["active"] = "True" except KeyError: pass row["network"] = net def setscope(self, scope, sock, tmpl): user = sock.GetUser() self.nv[user] = scope row = tmpl.AddRow("MessageLoop") row["message"] = "Scope successfully set."
gpl-3.0
[ 646, 1315, 7966, 199, 646, 747, 199, 199, 318, 365, 63, 3489, 63, 515, 8, 12484, 12, 931, 304, 272, 372, 747, 14, 515, 14, 4832, 8, 515, 680, 2460, 8, 12484, 9, 199, 199, 533, 3330, 793, 8, 90, 7966, 14, 2377, 304, 272, 859, 63, 1313, 275, 359, 90, 7966, 14, 9249, 364, 2354, 14, 7025, 2377, 61, 272, 1369, 275, 298, 7852, 780, 2455, 316, 402, 943, 1584, 687, 314, 3107, 6389, 3330, 2113, 2, 272, 17195, 63, 1606, 275, 298, 5926, 793, 2, 339, 347, 4068, 6200, 8, 277, 12, 1249, 12, 1245, 304, 267, 372, 715, 339, 347, 6001, 18153, 8880, 8, 277, 304, 267, 372, 715, 339, 347, 6001, 18153, 4880, 8, 277, 304, 267, 372, 756, 339, 347, 2372, 5926, 5977, 6888, 8, 277, 304, 267, 372, 298, 2445, 10935, 281, 2, 339, 347, 4068, 5926, 2017, 8, 277, 12, 6771, 12, 2034, 12, 9675, 304, 267, 922, 275, 6771, 14, 1002, 1899, 342, 267, 2935, 275, 6771, 14, 1002, 4098, 360, 694, 297, 756, 9, 267, 340, 2034, 508, 298, 1080, 582, 288, 340, 6771, 14, 1002, 7963, 4098, 360, 2645, 297, 715, 304, 355, 4194, 275, 6771, 14, 1002, 7963, 4098, 360, 2645, 297, 715, 9, 355, 291, 14, 2193, 1859, 8, 2645, 12, 6771, 12, 9675, 9, 288, 862, 26, 355, 291, 14, 7374, 8, 11510, 12, 2935, 12, 6771, 9, 288, 871, 4067, 26, 355, 1962, 275, 9675, 14, 1123, 5810, 480, 547, 7382, 531, 355, 1962, 905, 705, 937, 275, 298, 1944, 4194, 663, 14, 7754, 663, 1373, 3432, 2122, 267, 916, 2034, 508, 298, 793, 2, 503, 2034, 508, 298, 1773, 582, 288, 291, 14, 1345, 793, 8, 11510, 12, 2935, 12, 6771, 12, 2034, 9, 267, 291, 14, 362, 14129, 8, 5096, 12, 9675, 9, 398, 372, 715, 339, 347, 27483, 8, 277, 12, 9675, 12, 2935, 12, 6771, 304, 267, 1300, 275, 291, 14, 362, 1095, 8, 5096, 9, 398, 862, 26, 288, 2935, 63, 513, 275, 3355, 8, 736, 14, 7374, 8, 1095, 435, 2935, 430, 953, 291, 14, 66, 25972, 23135, 8, 11510, 12, 2935, 12, 756, 9, 953, 340, 822, 8, 694, 63, 513, 9, 690, 378, 26, 355, 367, 1242, 315, 2935, 63, 513, 26, 490, 1962, 275, 9675, 14, 1123, 5810, 480, 1296, 7382, 531, 4951, 4668, 275, 2935, 435, 7324, 435, 1242, 340, 2935, 587, 1242, 4951, 931, 275, 1300, 435, 4668, 4951, 340, 747, 14, 515, 14, 6292, 8, 515, 304, 717, 1166, 275, 283, 793, 31, 694, 534, 435, 4668, 14, 1814, 7863, 297, 1543, 1789, 358, 717, 1568, 275, 620, 8, 736, 14, 515, 14, 20733, 8, 515, 9, 4331, 1616, 9, 435, 298, 27638, 2, 490, 916, 747, 14, 515, 14, 6027, 8, 515, 304, 717, 1166, 275, 8720, 694, 534, 435, 4668, 14, 1814, 7863, 297, 1543, 1789, 358, 717, 1568, 275, 822, 779, 354, 367, 536, 315, 747, 14, 7374, 8, 515, 3948, 4951, 1962, 905, 2645, 937, 275, 1166, 490, 1962, 905, 1053, 937, 275, 1242, 4951, 1962, 905, 890, 937, 275, 620, 8, 890, 9, 953, 587, 26, 355, 1962, 275, 9675, 14, 1123, 5810, 480, 547, 7382, 531, 355, 1962, 905, 705, 937, 275, 298, 6231, 2701, 2122, 398, 871, 3814, 10870, 26, 288, 1962, 275, 9675, 14, 1123, 5810, 480, 547, 7382, 531, 288, 1962, 905, 705, 937, 275, 298, 6231, 1630, 440, 2187, 14, 7754, 1852, 3238, 1265, 1172, 314, 943, 859, 5223, 436, 626, 1265, 787, 19595, 370, 2879, 9610, 737, 314, 5827, 2166, 334, 2966, 12, 922, 12, 503, 2784, 17617, 339, 347, 2455, 793, 8, 277, 12, 9675, 12, 2935, 12, 6771, 12, 2034, 304, 267, 1300, 275, 291, 14, 362, 1095, 8, 5096, 9, 398, 340, 440, 365, 63, 3489, 63, 515, 8, 1095, 12, 1300, 435, 2935, 304, 288, 340, 2034, 508, 298, 1773, 582, 355, 1962, 275, 9675, 14, 1123, 5810, 480, 2445, 7382, 531, 355, 1962, 459, 793, 418, 275, 298, 547, 26, 3866, 2082, 2741, 2122, 355, 372, 288, 1962, 275, 9675, 14, 1123, 5810, 480, 547, 7382, 531, 288, 1962, 905, 705, 937, 275, 298, 3364, 2082, 2741, 2122, 288, 372, 398, 931, 275, 1300, 435, 2935, 267, 1962, 275, 9675, 14, 1123, 5810, 480, 2445, 7382, 531, 267, 543, 1551, 8, 515, 12, 283, 82, 297, 2644, 534, 1624, 24, 358, 465, 943, 26, 288, 943, 275, 943, 14, 739, 342, 267, 340, 2034, 508, 298, 1773, 582, 288, 943, 275, 943, 14, 1814, 4827, 297, 7673, 4116, 27, 1959, 1814, 360, 4206, 7673, 3308, 10784, 267, 1962, 459, 793, 418, 275, 943, 267, 340, 2034, 508, 298, 793, 582, 288, 291, 14, 66, 25972, 23135, 8, 11510, 12, 2935, 12, 715, 9, 288, 1962, 459, 1773, 418, 275, 283, 1773, 31, 694, 534, 435, 2935, 14, 1814, 7863, 297, 1543, 1789, 358, 339, 347, 330, 25972, 23135, 8, 277, 12, 9675, 12, 2935, 12, 365, 793, 304, 267, 16533, 275, 2935, 14, 1294, 7825, 267, 2467, 23135, 275, 12329, 65, 4369, 9287, 30, 7270, 1182, 3068, 65, 18763, 398, 1962, 275, 9675, 14, 1123, 5810, 480, 34, 25972, 4295, 7382, 531, 267, 1962, 905, 1556, 4295, 505, 937, 275, 298, 7270, 2, 267, 1962, 905, 1556, 4295, 633, 937, 275, 3087, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 15171, 2298, 288, 340, 16533, 59, 73, 2189, 355, 1962, 275, 9675, 14, 1123, 5810, 480, 34, 25972, 4295, 7382, 531, 355, 1962, 905, 1556, 4295, 505, 937, 275, 16533, 59, 73, 61, 355, 1166, 275, 20538, 904, 8, 15171, 59, 16, 26, 73, 11, 17, 566, 355, 1166, 275, 1166, 14, 1814, 7863, 297, 1543, 1789, 358, 355, 1962, 905, 1556, 4295, 633, 937, 275, 1166, 355, 340, 284, 508, 822, 8, 15171, 9, 446, 413, 436, 365, 793, 26, 490, 1962, 905, 374, 793, 937, 275, 298, 549, 2, 339, 347, 664, 1095, 8, 277, 12, 6771, 304, 267, 1300, 275, 1315, 7966, 14, 27808, 6389, 14, 1002, 1252, 1002, 58, 6389, 2042, 342, 267, 922, 275, 6771, 14, 1002, 1899, 342, 267, 4194, 275, 291, 14, 15969, 59, 751, 61, 267, 340, 4194, 508, 298, 7025, 582 ]
[ 1315, 7966, 199, 646, 747, 199, 199, 318, 365, 63, 3489, 63, 515, 8, 12484, 12, 931, 304, 272, 372, 747, 14, 515, 14, 4832, 8, 515, 680, 2460, 8, 12484, 9, 199, 199, 533, 3330, 793, 8, 90, 7966, 14, 2377, 304, 272, 859, 63, 1313, 275, 359, 90, 7966, 14, 9249, 364, 2354, 14, 7025, 2377, 61, 272, 1369, 275, 298, 7852, 780, 2455, 316, 402, 943, 1584, 687, 314, 3107, 6389, 3330, 2113, 2, 272, 17195, 63, 1606, 275, 298, 5926, 793, 2, 339, 347, 4068, 6200, 8, 277, 12, 1249, 12, 1245, 304, 267, 372, 715, 339, 347, 6001, 18153, 8880, 8, 277, 304, 267, 372, 715, 339, 347, 6001, 18153, 4880, 8, 277, 304, 267, 372, 756, 339, 347, 2372, 5926, 5977, 6888, 8, 277, 304, 267, 372, 298, 2445, 10935, 281, 2, 339, 347, 4068, 5926, 2017, 8, 277, 12, 6771, 12, 2034, 12, 9675, 304, 267, 922, 275, 6771, 14, 1002, 1899, 342, 267, 2935, 275, 6771, 14, 1002, 4098, 360, 694, 297, 756, 9, 267, 340, 2034, 508, 298, 1080, 582, 288, 340, 6771, 14, 1002, 7963, 4098, 360, 2645, 297, 715, 304, 355, 4194, 275, 6771, 14, 1002, 7963, 4098, 360, 2645, 297, 715, 9, 355, 291, 14, 2193, 1859, 8, 2645, 12, 6771, 12, 9675, 9, 288, 862, 26, 355, 291, 14, 7374, 8, 11510, 12, 2935, 12, 6771, 9, 288, 871, 4067, 26, 355, 1962, 275, 9675, 14, 1123, 5810, 480, 547, 7382, 531, 355, 1962, 905, 705, 937, 275, 298, 1944, 4194, 663, 14, 7754, 663, 1373, 3432, 2122, 267, 916, 2034, 508, 298, 793, 2, 503, 2034, 508, 298, 1773, 582, 288, 291, 14, 1345, 793, 8, 11510, 12, 2935, 12, 6771, 12, 2034, 9, 267, 291, 14, 362, 14129, 8, 5096, 12, 9675, 9, 398, 372, 715, 339, 347, 27483, 8, 277, 12, 9675, 12, 2935, 12, 6771, 304, 267, 1300, 275, 291, 14, 362, 1095, 8, 5096, 9, 398, 862, 26, 288, 2935, 63, 513, 275, 3355, 8, 736, 14, 7374, 8, 1095, 435, 2935, 430, 953, 291, 14, 66, 25972, 23135, 8, 11510, 12, 2935, 12, 756, 9, 953, 340, 822, 8, 694, 63, 513, 9, 690, 378, 26, 355, 367, 1242, 315, 2935, 63, 513, 26, 490, 1962, 275, 9675, 14, 1123, 5810, 480, 1296, 7382, 531, 4951, 4668, 275, 2935, 435, 7324, 435, 1242, 340, 2935, 587, 1242, 4951, 931, 275, 1300, 435, 4668, 4951, 340, 747, 14, 515, 14, 6292, 8, 515, 304, 717, 1166, 275, 283, 793, 31, 694, 534, 435, 4668, 14, 1814, 7863, 297, 1543, 1789, 358, 717, 1568, 275, 620, 8, 736, 14, 515, 14, 20733, 8, 515, 9, 4331, 1616, 9, 435, 298, 27638, 2, 490, 916, 747, 14, 515, 14, 6027, 8, 515, 304, 717, 1166, 275, 8720, 694, 534, 435, 4668, 14, 1814, 7863, 297, 1543, 1789, 358, 717, 1568, 275, 822, 779, 354, 367, 536, 315, 747, 14, 7374, 8, 515, 3948, 4951, 1962, 905, 2645, 937, 275, 1166, 490, 1962, 905, 1053, 937, 275, 1242, 4951, 1962, 905, 890, 937, 275, 620, 8, 890, 9, 953, 587, 26, 355, 1962, 275, 9675, 14, 1123, 5810, 480, 547, 7382, 531, 355, 1962, 905, 705, 937, 275, 298, 6231, 2701, 2122, 398, 871, 3814, 10870, 26, 288, 1962, 275, 9675, 14, 1123, 5810, 480, 547, 7382, 531, 288, 1962, 905, 705, 937, 275, 298, 6231, 1630, 440, 2187, 14, 7754, 1852, 3238, 1265, 1172, 314, 943, 859, 5223, 436, 626, 1265, 787, 19595, 370, 2879, 9610, 737, 314, 5827, 2166, 334, 2966, 12, 922, 12, 503, 2784, 17617, 339, 347, 2455, 793, 8, 277, 12, 9675, 12, 2935, 12, 6771, 12, 2034, 304, 267, 1300, 275, 291, 14, 362, 1095, 8, 5096, 9, 398, 340, 440, 365, 63, 3489, 63, 515, 8, 1095, 12, 1300, 435, 2935, 304, 288, 340, 2034, 508, 298, 1773, 582, 355, 1962, 275, 9675, 14, 1123, 5810, 480, 2445, 7382, 531, 355, 1962, 459, 793, 418, 275, 298, 547, 26, 3866, 2082, 2741, 2122, 355, 372, 288, 1962, 275, 9675, 14, 1123, 5810, 480, 547, 7382, 531, 288, 1962, 905, 705, 937, 275, 298, 3364, 2082, 2741, 2122, 288, 372, 398, 931, 275, 1300, 435, 2935, 267, 1962, 275, 9675, 14, 1123, 5810, 480, 2445, 7382, 531, 267, 543, 1551, 8, 515, 12, 283, 82, 297, 2644, 534, 1624, 24, 358, 465, 943, 26, 288, 943, 275, 943, 14, 739, 342, 267, 340, 2034, 508, 298, 1773, 582, 288, 943, 275, 943, 14, 1814, 4827, 297, 7673, 4116, 27, 1959, 1814, 360, 4206, 7673, 3308, 10784, 267, 1962, 459, 793, 418, 275, 943, 267, 340, 2034, 508, 298, 793, 582, 288, 291, 14, 66, 25972, 23135, 8, 11510, 12, 2935, 12, 715, 9, 288, 1962, 459, 1773, 418, 275, 283, 1773, 31, 694, 534, 435, 2935, 14, 1814, 7863, 297, 1543, 1789, 358, 339, 347, 330, 25972, 23135, 8, 277, 12, 9675, 12, 2935, 12, 365, 793, 304, 267, 16533, 275, 2935, 14, 1294, 7825, 267, 2467, 23135, 275, 12329, 65, 4369, 9287, 30, 7270, 1182, 3068, 65, 18763, 398, 1962, 275, 9675, 14, 1123, 5810, 480, 34, 25972, 4295, 7382, 531, 267, 1962, 905, 1556, 4295, 505, 937, 275, 298, 7270, 2, 267, 1962, 905, 1556, 4295, 633, 937, 275, 3087, 267, 367, 284, 315, 1425, 8, 16, 12, 822, 8, 15171, 2298, 288, 340, 16533, 59, 73, 2189, 355, 1962, 275, 9675, 14, 1123, 5810, 480, 34, 25972, 4295, 7382, 531, 355, 1962, 905, 1556, 4295, 505, 937, 275, 16533, 59, 73, 61, 355, 1166, 275, 20538, 904, 8, 15171, 59, 16, 26, 73, 11, 17, 566, 355, 1166, 275, 1166, 14, 1814, 7863, 297, 1543, 1789, 358, 355, 1962, 905, 1556, 4295, 633, 937, 275, 1166, 355, 340, 284, 508, 822, 8, 15171, 9, 446, 413, 436, 365, 793, 26, 490, 1962, 905, 374, 793, 937, 275, 298, 549, 2, 339, 347, 664, 1095, 8, 277, 12, 6771, 304, 267, 1300, 275, 1315, 7966, 14, 27808, 6389, 14, 1002, 1252, 1002, 58, 6389, 2042, 342, 267, 922, 275, 6771, 14, 1002, 1899, 342, 267, 4194, 275, 291, 14, 15969, 59, 751, 61, 267, 340, 4194, 508, 298, 7025, 582, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hforge/itools
test/test_html.py
3
16999
# -*- coding: UTF-8 -*- # Copyright (C) 2004, 2006-2010 J. David Ibáñez <jdavid.ibp@gmail.com> # Copyright (C) 2006 Hervé Cauwelier <herve@oursours.net> # Copyright (C) 2008 David Versmisse <versmisse@lil.univ-littoral.fr> # Copyright (C) 2008 Romain Gauthier <romain.gauthier@itaapy.com> # Copyright (C) 2008 Sylvain Taverne <taverne.sylvain@gmail.com> # Copyright (C) 2008 Wynand Winterbach <wynand.winterbach@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # Import from the Standard Library from unittest import TestCase, main # Import from itools from itools.gettext import POFile from itools.html import HTMLFile, XHTMLFile, HTMLParser, sanitize_str from itools.html.xhtml import stream_to_html from itools.srx import TEXT, START_FORMAT, END_FORMAT from itools.xml import XMLParser, XMLError, START_ELEMENT, END_ELEMENT from itools.xml import TEXT as xml_TEXT, stream_to_str ########################################################################### # Test HTML ########################################################################### def parse_tags(data): return [ (type, value[1]) for type, value, line in HTMLParser(data) if type == START_ELEMENT or type == END_ELEMENT ] class HTMLParserTestCase(TestCase): def test_doctype(self): data = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">' stream = HTMLParser(data) self.assertEqual(stream_to_str(stream), data) def test_obvious(self): data = '<p></p>' expected = [(START_ELEMENT, 'p'), (END_ELEMENT, 'p')] self.assertEqual(parse_tags(data), expected) def test_empty(self): data = '<br>' expected = [(START_ELEMENT, 'br'), (END_ELEMENT, 'br')] self.assertEqual(parse_tags(data), expected) def test_ul(self): data = '<ul><li><li></li></ul>' expected = [ (START_ELEMENT, 'ul'), (START_ELEMENT, 'li'), (END_ELEMENT, 'li'), (START_ELEMENT, 'li'), (END_ELEMENT, 'li'), (END_ELEMENT, 'ul')] self.assertEqual(parse_tags(data), expected) def test_forbidden(self): data = '<html><body><title></title></body></html>' expected = [ (START_ELEMENT, 'html'), (START_ELEMENT, 'body'), (START_ELEMENT, 'title'), (END_ELEMENT, 'title'), (END_ELEMENT, 'body'), (END_ELEMENT, 'html')] self.assertEqual(parse_tags(data), expected) ####################################################################### # Broken HTML ####################################################################### def test_missing_end_element(self): data = '<div><span></div>' self.assertRaises(XMLError, HTMLParser, data) def test_missing_end_element2(self): data = '<div>' self.assertRaises(XMLError, HTMLParser, data) class i18nTestCase(TestCase): def test_case1(self): """Test element content.""" doc = HTMLFile(string='<p>hello world</p>') messages = [unit[0] for unit in doc.get_units()] self.assertEqual(messages, [((TEXT, u'hello world'),)]) def test_case2(self): """Test simple attribute.""" doc = HTMLFile(string='<img alt="The beach" src="beach.jpg">') messages = [unit[0] for unit in doc.get_units()] self.assertEqual(messages, [((TEXT, u'The beach'),)]) def test_case3(self): """Test complex attribute.""" doc = HTMLFile(string= '<html>\n' '<input type="text" name="id">\n' '<input type="submit" value="Change">\n' '</html>') messages = [unit[0] for unit in doc.get_units()] self.assertEqual(messages, [((TEXT, u'Change'),)]) def test_case4(self): """Test translation of an element content""" doc = HTMLFile(string='<p>hello world</p>') p = POFile(string= 'msgctxt "paragraph"\n' 'msgid "hello world"\n' 'msgstr "hola mundo"') self.assertEqual(doc.translate(p), '<p>hola mundo</p>') def test_case5(self): """Test translation of an element content""" doc = HTMLFile(string='<img alt="The beach" src="beach.jpg">') po = POFile(string= 'msgctxt "img[alt]"\n' 'msgid "The beach"\n' 'msgstr "La playa"') string = doc.translate(po) output = HTMLFile(string=string) expected = HTMLFile(string='<img alt="La playa" src="beach.jpg">') self.assertEqual(output, expected) def test_case6(self): """Test translation of an element content""" doc = HTMLFile(string= '<input type="text" name="id">' '<input type="submit" value="Change">') p = POFile(string= 'msgctxt "button"\n' 'msgid "Change"\n' 'msgstr "Cambiar"') output = HTMLFile(string=doc.translate(p)) expected = HTMLFile(string= '<input type="text" name="id">' '<input type="submit" value="Cambiar">') self.assertEqual(output.to_str(), expected.to_str()) def test_translation1(self): """Test translation with surrounding tags""" doc = HTMLFile(string='<em>hello world</em>') p = POFile(string= 'msgctxt "emphasis"\n' 'msgid "hello world"\n' 'msgstr "hola mundo"') self.assertEqual(doc.translate(p), '<em>hola mundo</em>') def test_translation2(self): """Test translation with surrounding tags (2)""" doc = HTMLFile(string = 'Say: <em>hello world. It\'s me.</em>') p = POFile(string= 'msgid "Say:"\n' 'msgstr "Dice:"\n\n' 'msgctxt "emphasis"\n' 'msgid "hello world."\n' 'msgstr "hola mundo."\n\n' 'msgctxt "emphasis"\n' 'msgid "It\'s me."\n' 'msgstr "Es me."') self.assertEqual(doc.translate(p), 'Dice: <em>hola mundo. Es me.</em>') def test_translation3(self): """Test translation with surrounding tags (3)""" doc = HTMLFile(string = 'Say: <em> hello world. It\'s me.</em> Do you remember me ?') p = POFile(string= 'msgid "Say:"\n' 'msgstr "Dites:"\n\n' 'msgctxt "emphasis"\n' 'msgid "hello world."\n' 'msgstr "Bonjour monde."\n\n' 'msgctxt "emphasis"\n' 'msgid "It\'s me."\n' 'msgstr "C\'est moi."\n\n' 'msgid "Do you remember me ?"\n' 'msgstr "Vous vous rappelez de moi ?"') self.assertEqual(doc.translate(p), 'Dites: <em> Bonjour monde. C\'est moi.</em> ' 'Vous vous rappelez de moi ?') def test_translation4(self): """Test translation with surrounding tags (4)""" doc = HTMLFile(string = 'Say: <em> hello world. It\'s me.</em>' ' Do you remember me ? ') p = POFile(string= 'msgid "Say:"\n' 'msgstr "Dites:"\n\n' 'msgctxt "emphasis"\n' 'msgid "hello world."\n' 'msgstr "Bonjour monde."\n\n' 'msgctxt "emphasis"\n' 'msgid "It\'s me."\n' 'msgstr "C\'est moi."\n\n' 'msgid "Do you remember me ?"\n' 'msgstr "Vous vous rappelez de moi ?"') self.assertEqual(doc.translate(p), 'Dites: ' '<em> Bonjour monde. C\'est moi.</em>' ' Vous vous rappelez de moi ? ') def test_pre(self): """Test raw content.""" doc = HTMLFile(string = '<pre> This is raw text, " \n"' ' </pre>') messages = [unit[0] for unit in doc.get_units()] expected = [((TEXT, u'This is raw text, " \n"'),)] self.assertEqual(messages, expected) ########################################################################### # Test XHTML ########################################################################### class SerializationTestCase(TestCase): def test_stream_to_html_escape(self): parser = XMLParser('<p xmlns="http://www.w3.org/1999/xhtml"></p>') events = list(parser) events.insert(1, (xml_TEXT, '<br/>', 0)) self.assertEqual( stream_to_html(events), '<p xmlns="http://www.w3.org/1999/xhtml">&lt;br/></p>') def test_html(self): parser = XMLParser( '<p xmlns="http://www.w3.org/1999/xhtml">Bed&amp;Breakfast</p>') out = stream_to_html(parser) # Assert self.assertEqual(out, '<p xmlns="http://www.w3.org/1999/xhtml">Bed&amp;Breakfast</p>') class SegmentationTestCase(TestCase): def test_paragraph(self): """Test formatted paragraph""" doc = XHTMLFile(string= '<p xmlns="http://www.w3.org/1999/xhtml">\n' 'The Mozilla project maintains <em>choice</em> and\n' '<em>innovation</em> on the Internet. Developing the\n' 'acclaimed, <em>open source</em>, <b>Mozilla 1.6</b>.\n' '</p>') messages = [unit[0] for unit in doc.get_units()] expected = [((TEXT, u'The Mozilla project maintains '), (START_FORMAT, 1), (TEXT, u'choice'), (END_FORMAT, 1), (TEXT, u' and '), (START_FORMAT, 2), (TEXT, u'innovation'), (END_FORMAT, 2), (TEXT, u' on the Internet.')), ((TEXT, u'Developing the acclaimed, '), (START_FORMAT, 3), (TEXT, u'open source'), (END_FORMAT, 3), (TEXT, u', '), (START_FORMAT, 4), (TEXT, u'Mozilla 1.6'), (END_FORMAT, 4), (TEXT, u'.'))] self.assertEqual(messages, expected) def test_table(self): doc = XHTMLFile(string= '<table xmlns="http://www.w3.org/1999/xhtml">\n' ' <tr>\n' ' <th>Title</th>\n' ' <th>Size</th>\n' ' </tr>\n' ' <tr>\n' ' <td>The good, the bad and the ugly</td>\n' ' <td>looong</td>\n' ' </tr>\n' ' <tr>\n' ' <td>Love story</td>\n' ' <td>even longer</td>\n' ' </tr>\n' '</table>') messages = [unit[0] for unit in doc.get_units()] expected = [((TEXT, u'Title'),), ((TEXT, u'Size'),), ((TEXT, u'The good, the bad and the ugly'),), ((TEXT, u'looong'),), ((TEXT, u'Love story'),), ((TEXT, u'even longer'),)] self.assertEqual(messages, expected) def test_random(self): """Test element content.""" # The document doc = XHTMLFile(string= '<body xmlns="http://www.w3.org/1999/xhtml">\n' ' <p>this <em>word</em> is nice</p>\n' ' <a href="/"><img src="logo.png" /></a>\n' ' <p><em>hello world</em></p><br/>' ' bye <em>J. David Ibanez Palomar</em>\n' '</body>') messages = [unit[0] for unit in doc.get_units()] expected = [((TEXT, u'this '), (START_FORMAT, 1), (TEXT, u'word'), (END_FORMAT, 1), (TEXT, u' is nice')), ((TEXT, u'hello world'),), ((TEXT, u'bye '), (START_FORMAT, 6), (TEXT, u'J. David Ibanez Palomar'), (END_FORMAT, 6))] self.assertEqual(messages, expected) def test_form(self): """Test complex attribute.""" # The document doc = XHTMLFile(string= '<form xmlns="http://www.w3.org/1999/xhtml">\n' ' <input type="text" name="id" />\n' ' <input type="submit" value="Change" />\n' '</form>') messages = [unit[0] for unit in doc.get_units()] self.assertEqual(messages, [((TEXT, u'Change'),)]) def test_inline(self): doc = XHTMLFile(string= '<p xmlns="http://www.w3.org/1999/xhtml">' 'Hi <b>everybody, </b><i>how are you ? </i>' '</p>') messages = [unit[0] for unit in doc.get_units()] expected = [((TEXT, u'Hi '), (START_FORMAT, 1), (TEXT, u'everybody, '), (END_FORMAT, 1), (START_FORMAT, 2), (TEXT, u'how are you ? '), (END_FORMAT, 2))] self.assertEqual(messages, expected) class TranslationTestCase(TestCase): def setUp(self): self.template = ( '<?xml version="1.0" encoding="UTF-8"?>\n' '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n' ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n' '<html xmlns="http://www.w3.org/1999/xhtml">\n' ' <head></head>\n' ' <body>%s</body>\n' '</html>\n') def test_case1(self): """Test element content.""" data = self.template % '<p>hello little world</p>' doc = XHTMLFile(string=data) messages = [unit[0] for unit in doc.get_units()] self.assertEqual(messages, [((TEXT, u'hello little world'),)]) def test_case2(self): """Test simple attribute.""" data = self.template % '<img alt="The beach" src="beach.jpg" />' doc = XHTMLFile(string=data) messages = [unit[0] for unit in doc.get_units()] self.assertEqual(messages, [((TEXT, u'The beach'),)]) def test_case3(self): """Test complex attribute.""" data = self.template % ('<input type="text" name="id" />\n' '<input type="submit" value="Change" />') doc = XHTMLFile(string=data) messages = [unit[0] for unit in doc.get_units()] self.assertEqual(messages, [((TEXT, u'Change'),)]) def test_case4(self): """Test translation of an element content""" string = ( 'msgctxt "paragraph"\n' 'msgid "hello world"\n' 'msgstr "hola mundo"\n') p = POFile(string=string) string = self.template % '<p>hello world</p>' source = XHTMLFile(string=string) string = source.translate(p) xhtml = XHTMLFile(string=string) messages = [unit[0] for unit in xhtml.get_units()] self.assertEqual(messages, [((TEXT, u'hola mundo'),)]) def test_case5(self): """Test translation of an element content""" po = POFile(string= 'msgctxt "img[alt]"\n' 'msgid "The beach"\n' 'msgstr "La playa"') xhtml = XHTMLFile(string= self.template % '<img alt="The beach" src="beach.jpg" />') html = xhtml.translate(po) xhtml = XHTMLFile(string=html) messages = [unit[0] for unit in xhtml.get_units()] self.assertEqual(messages, [((TEXT, u'La playa'),)]) class SanitizerTestCase(TestCase): def test_javascript(self): data = '<div><script>alert("Hello world")</script></div>' stream = sanitize_str(data) data_return = stream_to_html(stream) expected = '<div></div>' self.assertEqual(data_return, expected) def test_css(self): data = '<div style="background: url(javascript:void);"></div>' stream = sanitize_str(data) data_return = stream_to_html(stream) expected = '<div></div>' self.assertEqual(data_return, expected) def test_onmouseover(self): data = '<b onMouseOver="self.location.href=\'www.free.fr\'">Hello</b>' stream = sanitize_str(data) data_return = stream_to_html(stream) expected = '<b>Hello</b>' self.assertEqual(data_return, expected) def test_links(self): data = '<a href="javascript:alert(\'Hello\')">Hello World</a>' stream = sanitize_str(data) data_return = stream_to_html(stream) expected = '<a>Hello World</a>' self.assertEqual(data_return, expected) def test_comment(self): data = '<!-- javascript:alert("Hello"); -->' stream = sanitize_str(data) data_return = stream_to_html(stream) expected = '' self.assertEqual(data_return, expected) if __name__ == '__main__': main()
gpl-3.0
[ 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 3, 1898, 334, 35, 9, 8353, 12, 8315, 13, 6542, 1603, 14, 20232, 473, 66, 11302, 22692, 27263, 665, 74, 983, 5017, 14, 1892, 80, 32, 6799, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 8315, 18769, 86, 5741, 445, 3844, 1129, 5697, 665, 2523, 432, 32, 16363, 16363, 14, 846, 30, 199, 3, 1898, 334, 35, 9, 9079, 20232, 812, 1192, 1292, 261, 665, 14895, 1292, 261, 32, 317, 76, 14, 27516, 13, 1051, 8270, 279, 14, 4391, 30, 199, 3, 1898, 334, 35, 9, 9079, 6848, 973, 598, 1178, 4446, 665, 293, 973, 14, 71, 1178, 4446, 32, 21492, 439, 89, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 9079, 5515, 6371, 1581, 377, 28396, 685, 665, 502, 422, 685, 14, 1786, 6371, 1581, 32, 6799, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 9079, 644, 1236, 460, 644, 1058, 31983, 665, 87, 1236, 460, 14, 87, 1058, 31983, 32, 6799, 14, 957, 30, 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, 199, 3, 3161, 687, 314, 9739, 11243, 199, 504, 2882, 492, 7640, 12, 2446, 199, 199, 3, 3161, 687, 284, 2537, 199, 504, 284, 2537, 14, 5152, 492, 3625, 1173, 199, 504, 284, 2537, 14, 1360, 492, 4163, 1173, 12, 26223, 1173, 12, 24581, 12, 21077, 63, 495, 199, 504, 284, 2537, 14, 1360, 14, 12909, 492, 2547, 63, 475, 63, 1360, 199, 504, 284, 2537, 14, 5474, 88, 492, 11951, 12, 13910, 63, 4807, 12, 7729, 63, 4807, 199, 504, 284, 2537, 14, 1652, 492, 4692, 2842, 12, 4692, 547, 12, 13910, 63, 12535, 12, 7729, 63, 12535, 199, 504, 284, 2537, 14, 1652, 492, 11951, 465, 2748, 63, 3876, 12, 2547, 63, 475, 63, 495, 4388, 199, 3949, 5680, 199, 3, 1379, 4163, 199, 3949, 5680, 199, 318, 2198, 63, 2969, 8, 576, 304, 272, 372, 359, 334, 466, 12, 574, 59, 17, 566, 367, 730, 12, 574, 12, 1004, 315, 24581, 8, 576, 9, 1467, 340, 730, 508, 13910, 63, 12535, 503, 730, 508, 7729, 63, 12535, 1622, 421, 199, 533, 24581, 1746, 8, 1746, 304, 339, 347, 511, 63, 6356, 8, 277, 304, 267, 666, 275, 2650, 1, 16556, 3517, 21755, 21486, 55, 19, 35, 501, 21156, 4163, 650, 14, 18, 21789, 501, 742, 15603, 267, 2547, 275, 24581, 8, 576, 9, 267, 291, 14, 629, 8, 1745, 63, 475, 63, 495, 8, 1745, 395, 666, 9, 2378, 347, 511, 63, 2873, 2971, 8, 277, 304, 267, 666, 275, 2650, 80, 2957, 80, 3524, 267, 1420, 275, 3842, 7363, 63, 12535, 12, 283, 80, 659, 334, 3902, 63, 12535, 12, 283, 80, 5440, 267, 291, 14, 629, 8, 1122, 63, 2969, 8, 576, 395, 1420, 9, 2378, 347, 511, 63, 1667, 8, 277, 304, 267, 666, 275, 2650, 3289, 3524, 267, 1420, 275, 3842, 7363, 63, 12535, 12, 283, 3289, 659, 334, 3902, 63, 12535, 12, 283, 3289, 5440, 267, 291, 14, 629, 8, 1122, 63, 2969, 8, 576, 395, 1420, 9, 2378, 347, 511, 63, 348, 8, 277, 304, 267, 666, 275, 2650, 348, 2535, 317, 2535, 317, 2957, 317, 2957, 348, 3524, 267, 1420, 275, 359, 288, 334, 7363, 63, 12535, 12, 283, 348, 659, 334, 7363, 63, 12535, 12, 283, 317, 659, 334, 3902, 63, 12535, 12, 283, 317, 659, 288, 334, 7363, 63, 12535, 12, 283, 317, 659, 334, 3902, 63, 12535, 12, 283, 317, 659, 334, 3902, 63, 12535, 12, 283, 348, 5440, 267, 291, 14, 629, 8, 1122, 63, 2969, 8, 576, 395, 1420, 9, 2378, 347, 511, 63, 29293, 8, 277, 304, 267, 666, 275, 2650, 1360, 2535, 2030, 2535, 1213, 2957, 1213, 2957, 2030, 2957, 1360, 3524, 267, 1420, 275, 359, 288, 334, 7363, 63, 12535, 12, 283, 1360, 659, 334, 7363, 63, 12535, 12, 283, 2030, 659, 288, 334, 7363, 63, 12535, 12, 283, 1213, 659, 334, 3902, 63, 12535, 12, 283, 1213, 659, 288, 334, 3902, 63, 12535, 12, 283, 2030, 659, 334, 3902, 63, 12535, 12, 283, 1360, 5440, 267, 291, 14, 629, 8, 1122, 63, 2969, 8, 576, 395, 1420, 9, 16478, 15779, 14776, 272, 327, 23804, 4163, 272, 15779, 14776, 272, 347, 511, 63, 4752, 63, 500, 63, 2108, 8, 277, 304, 267, 666, 275, 2650, 3015, 2535, 3751, 2957, 3015, 3524, 267, 291, 14, 1855, 8, 4317, 547, 12, 24581, 12, 666, 9, 2378, 347, 511, 63, 4752, 63, 500, 63, 2108, 18, 8, 277, 304, 267, 666, 275, 2650, 3015, 3524, 267, 291, 14, 1855, 8, 4317, 547, 12, 24581, 12, 666, 9, 4388, 199, 533, 284, 1085, 78, 1746, 8, 1746, 304, 339, 347, 511, 63, 2546, 17, 8, 277, 304, 267, 408, 774, 1819, 1564, 1041, 267, 1382, 275, 4163, 1173, 8, 875, 15829, 80, 30, 5006, 6701, 1108, 80, 5971, 398, 3788, 275, 359, 3248, 59, 16, 61, 367, 4137, 315, 1382, 14, 362, 63, 5260, 5106, 267, 291, 14, 629, 8, 3431, 12, 359, 1332, 3876, 12, 399, 7, 5006, 6701, 659, 3948, 2378, 347, 511, 63, 2546, 18, 8, 277, 304, 267, 408, 774, 3486, 2225, 1041, 267, 1382, 275, 4163, 1173, 8, 875, 15829, 4060, 8791, 628, 1918, 506, 1225, 2, 2928, 628, 1235, 1225, 14, 8476, 1743, 358, 398, 3788, 275, 359, 3248, 59, 16, 61, 367, 4137 ]
[ 1882, 2803, 26, 9094, 13, 24, 1882, 199, 3, 1898, 334, 35, 9, 8353, 12, 8315, 13, 6542, 1603, 14, 20232, 473, 66, 11302, 22692, 27263, 665, 74, 983, 5017, 14, 1892, 80, 32, 6799, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 8315, 18769, 86, 5741, 445, 3844, 1129, 5697, 665, 2523, 432, 32, 16363, 16363, 14, 846, 30, 199, 3, 1898, 334, 35, 9, 9079, 20232, 812, 1192, 1292, 261, 665, 14895, 1292, 261, 32, 317, 76, 14, 27516, 13, 1051, 8270, 279, 14, 4391, 30, 199, 3, 1898, 334, 35, 9, 9079, 6848, 973, 598, 1178, 4446, 665, 293, 973, 14, 71, 1178, 4446, 32, 21492, 439, 89, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 9079, 5515, 6371, 1581, 377, 28396, 685, 665, 502, 422, 685, 14, 1786, 6371, 1581, 32, 6799, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 9079, 644, 1236, 460, 644, 1058, 31983, 665, 87, 1236, 460, 14, 87, 1058, 31983, 32, 6799, 14, 957, 30, 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, 199, 3, 3161, 687, 314, 9739, 11243, 199, 504, 2882, 492, 7640, 12, 2446, 199, 199, 3, 3161, 687, 284, 2537, 199, 504, 284, 2537, 14, 5152, 492, 3625, 1173, 199, 504, 284, 2537, 14, 1360, 492, 4163, 1173, 12, 26223, 1173, 12, 24581, 12, 21077, 63, 495, 199, 504, 284, 2537, 14, 1360, 14, 12909, 492, 2547, 63, 475, 63, 1360, 199, 504, 284, 2537, 14, 5474, 88, 492, 11951, 12, 13910, 63, 4807, 12, 7729, 63, 4807, 199, 504, 284, 2537, 14, 1652, 492, 4692, 2842, 12, 4692, 547, 12, 13910, 63, 12535, 12, 7729, 63, 12535, 199, 504, 284, 2537, 14, 1652, 492, 11951, 465, 2748, 63, 3876, 12, 2547, 63, 475, 63, 495, 4388, 199, 3949, 5680, 199, 3, 1379, 4163, 199, 3949, 5680, 199, 318, 2198, 63, 2969, 8, 576, 304, 272, 372, 359, 334, 466, 12, 574, 59, 17, 566, 367, 730, 12, 574, 12, 1004, 315, 24581, 8, 576, 9, 1467, 340, 730, 508, 13910, 63, 12535, 503, 730, 508, 7729, 63, 12535, 1622, 421, 199, 533, 24581, 1746, 8, 1746, 304, 339, 347, 511, 63, 6356, 8, 277, 304, 267, 666, 275, 2650, 1, 16556, 3517, 21755, 21486, 55, 19, 35, 501, 21156, 4163, 650, 14, 18, 21789, 501, 742, 15603, 267, 2547, 275, 24581, 8, 576, 9, 267, 291, 14, 629, 8, 1745, 63, 475, 63, 495, 8, 1745, 395, 666, 9, 2378, 347, 511, 63, 2873, 2971, 8, 277, 304, 267, 666, 275, 2650, 80, 2957, 80, 3524, 267, 1420, 275, 3842, 7363, 63, 12535, 12, 283, 80, 659, 334, 3902, 63, 12535, 12, 283, 80, 5440, 267, 291, 14, 629, 8, 1122, 63, 2969, 8, 576, 395, 1420, 9, 2378, 347, 511, 63, 1667, 8, 277, 304, 267, 666, 275, 2650, 3289, 3524, 267, 1420, 275, 3842, 7363, 63, 12535, 12, 283, 3289, 659, 334, 3902, 63, 12535, 12, 283, 3289, 5440, 267, 291, 14, 629, 8, 1122, 63, 2969, 8, 576, 395, 1420, 9, 2378, 347, 511, 63, 348, 8, 277, 304, 267, 666, 275, 2650, 348, 2535, 317, 2535, 317, 2957, 317, 2957, 348, 3524, 267, 1420, 275, 359, 288, 334, 7363, 63, 12535, 12, 283, 348, 659, 334, 7363, 63, 12535, 12, 283, 317, 659, 334, 3902, 63, 12535, 12, 283, 317, 659, 288, 334, 7363, 63, 12535, 12, 283, 317, 659, 334, 3902, 63, 12535, 12, 283, 317, 659, 334, 3902, 63, 12535, 12, 283, 348, 5440, 267, 291, 14, 629, 8, 1122, 63, 2969, 8, 576, 395, 1420, 9, 2378, 347, 511, 63, 29293, 8, 277, 304, 267, 666, 275, 2650, 1360, 2535, 2030, 2535, 1213, 2957, 1213, 2957, 2030, 2957, 1360, 3524, 267, 1420, 275, 359, 288, 334, 7363, 63, 12535, 12, 283, 1360, 659, 334, 7363, 63, 12535, 12, 283, 2030, 659, 288, 334, 7363, 63, 12535, 12, 283, 1213, 659, 334, 3902, 63, 12535, 12, 283, 1213, 659, 288, 334, 3902, 63, 12535, 12, 283, 2030, 659, 334, 3902, 63, 12535, 12, 283, 1360, 5440, 267, 291, 14, 629, 8, 1122, 63, 2969, 8, 576, 395, 1420, 9, 16478, 15779, 14776, 272, 327, 23804, 4163, 272, 15779, 14776, 272, 347, 511, 63, 4752, 63, 500, 63, 2108, 8, 277, 304, 267, 666, 275, 2650, 3015, 2535, 3751, 2957, 3015, 3524, 267, 291, 14, 1855, 8, 4317, 547, 12, 24581, 12, 666, 9, 2378, 347, 511, 63, 4752, 63, 500, 63, 2108, 18, 8, 277, 304, 267, 666, 275, 2650, 3015, 3524, 267, 291, 14, 1855, 8, 4317, 547, 12, 24581, 12, 666, 9, 4388, 199, 533, 284, 1085, 78, 1746, 8, 1746, 304, 339, 347, 511, 63, 2546, 17, 8, 277, 304, 267, 408, 774, 1819, 1564, 1041, 267, 1382, 275, 4163, 1173, 8, 875, 15829, 80, 30, 5006, 6701, 1108, 80, 5971, 398, 3788, 275, 359, 3248, 59, 16, 61, 367, 4137, 315, 1382, 14, 362, 63, 5260, 5106, 267, 291, 14, 629, 8, 3431, 12, 359, 1332, 3876, 12, 399, 7, 5006, 6701, 659, 3948, 2378, 347, 511, 63, 2546, 18, 8, 277, 304, 267, 408, 774, 3486, 2225, 1041, 267, 1382, 275, 4163, 1173, 8, 875, 15829, 4060, 8791, 628, 1918, 506, 1225, 2, 2928, 628, 1235, 1225, 14, 8476, 1743, 358, 398, 3788, 275, 359, 3248, 59, 16, 61, 367, 4137, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
40123148/w17b
static/Brython3.1.3-20150514-095342/Lib/test/regrtest.py
718
65317
#! /usr/bin/python3.3 """ Usage: python -m test [options] [test_name1 [test_name2 ...]] python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]] If no arguments or options are provided, finds all files matching the pattern "test_*" in the Lib/test subdirectory and runs them in alphabetical order (but see -M and -u, below, for exceptions). For more rigorous testing, it is useful to use the following command line: python -E -Wd -m test [options] [test_name1 ...] Options: -h/--help -- print this text and exit --timeout TIMEOUT -- dump the traceback and exit if a test takes more than TIMEOUT seconds; disabled if TIMEOUT is negative or equals to zero --wait -- wait for user input, e.g., allow a debugger to be attached Verbosity -v/--verbose -- run tests in verbose mode with output to stdout -w/--verbose2 -- re-run failed tests in verbose mode -W/--verbose3 -- display test output on failure -d/--debug -- print traceback for failed tests -q/--quiet -- no output unless one or more tests fail -o/--slow -- print the slowest 10 tests --header -- print header with interpreter info Selecting tests -r/--randomize -- randomize test execution order (see below) --randseed -- pass a random seed to reproduce a previous random run -f/--fromfile -- read names of tests to run from a file (see below) -x/--exclude -- arguments are tests to *exclude* -s/--single -- single step through a set of tests (see below) -m/--match PAT -- match test cases and methods with glob pattern PAT -G/--failfast -- fail as soon as a test fails (only with -v or -W) -u/--use RES1,RES2,... -- specify which special resource intensive tests to run -M/--memlimit LIMIT -- run very large memory-consuming tests --testdir DIR -- execute test files in the specified directory (instead of the Python stdlib test suite) Special runs -l/--findleaks -- if GC is available detect tests that leak memory -L/--runleaks -- run the leaks(1) command just before exit -R/--huntrleaks RUNCOUNTS -- search for reference leaks (needs debug build, v. slow) -j/--multiprocess PROCESSES -- run PROCESSES processes at once -T/--coverage -- turn on code coverage tracing using the trace module -D/--coverdir DIRECTORY -- Directory where coverage files are put -N/--nocoverdir -- Put coverage files alongside modules -t/--threshold THRESHOLD -- call gc.set_threshold(THRESHOLD) -n/--nowindows -- suppress error message boxes on Windows -F/--forever -- run the specified tests in a loop, until an error happens Additional Option Details: -r randomizes test execution order. You can use --randseed=int to provide a int seed value for the randomizer; this is useful for reproducing troublesome test orders. -s On the first invocation of regrtest using -s, the first test file found or the first test file given on the command line is run, and the name of the next test is recorded in a file named pynexttest. If run from the Python build directory, pynexttest is located in the 'build' subdirectory, otherwise it is located in tempfile.gettempdir(). On subsequent runs, the test in pynexttest is run, and the next test is written to pynexttest. When the last test has been run, pynexttest is deleted. In this way it is possible to single step through the test files. This is useful when doing memory analysis on the Python interpreter, which process tends to consume too many resources to run the full regression test non-stop. -S is used to continue running tests after an aborted run. It will maintain the order a standard run (ie, this assumes -r is not used). This is useful after the tests have prematurely stopped for some external reason and you want to start running from where you left off rather than starting from the beginning. -f reads the names of tests from the file given as f's argument, one or more test names per line. Whitespace is ignored. Blank lines and lines beginning with '#' are ignored. This is especially useful for whittling down failures involving interactions among tests. -L causes the leaks(1) command to be run just before exit if it exists. leaks(1) is available on Mac OS X and presumably on some other FreeBSD-derived systems. -R runs each test several times and examines sys.gettotalrefcount() to see if the test appears to be leaking references. The argument should be of the form stab:run:fname where 'stab' is the number of times the test is run to let gettotalrefcount settle down, 'run' is the number of times further it is run and 'fname' is the name of the file the reports are written to. These parameters all have defaults (5, 4 and "reflog.txt" respectively), and the minimal invocation is '-R :'. -M runs tests that require an exorbitant amount of memory. These tests typically try to ascertain containers keep working when containing more than 2 billion objects, which only works on 64-bit systems. There are also some tests that try to exhaust the address space of the process, which only makes sense on 32-bit systems with at least 2Gb of memory. The passed-in memlimit, which is a string in the form of '2.5Gb', determines howmuch memory the tests will limit themselves to (but they may go slightly over.) The number shouldn't be more memory than the machine has (including swap memory). You should also keep in mind that swap memory is generally much, much slower than RAM, and setting memlimit to all available RAM or higher will heavily tax the machine. On the other hand, it is no use running these tests with a limit of less than 2.5Gb, and many require more than 20Gb. Tests that expect to use more than memlimit memory will be skipped. The big-memory tests generally run very, very long. -u is used to specify which special resource intensive tests to run, such as those requiring large file support or network connectivity. The argument is a comma-separated list of words indicating the resources to test. Currently only the following are defined: all - Enable all special resources. none - Disable all special resources (this is the default). audio - Tests that use the audio device. (There are known cases of broken audio drivers that can crash Python or even the Linux kernel.) curses - Tests that use curses and will modify the terminal's state and output modes. largefile - It is okay to run some test that may create huge files. These tests can take a long time and may consume >2GB of disk space temporarily. network - It is okay to run tests that use external network resource, e.g. testing SSL support for sockets. decimal - Test the decimal module against a large suite that verifies compliance with standards. cpu - Used for certain CPU-heavy tests. subprocess Run all tests for the subprocess module. urlfetch - It is okay to download files required on testing. gui - Run tests that require a running GUI. To enable all resources except one, use '-uall,-<resource>'. For example, to run all the tests except for the gui tests, give the option '-uall,-gui'. """ # We import importlib *ASAP* in order to test #15386 import importlib import builtins import faulthandler import getopt import io import json import logging import os import platform import random import re import shutil import signal import sys import sysconfig import tempfile import time import traceback import unittest import warnings from inspect import isabstract try: import threading except ImportError: threading = None try: import multiprocessing.process except ImportError: multiprocessing = None # Some times __path__ and __file__ are not absolute (e.g. while running from # Lib/) and, if we change the CWD to run the tests in a temporary dir, some # imports might fail. This affects only the modules imported before os.chdir(). # These modules are searched first in sys.path[0] (so '' -- the CWD) and if # they are found in the CWD their __file__ and __path__ will be relative (this # happens before the chdir). All the modules imported after the chdir, are # not found in the CWD, and since the other paths in sys.path[1:] are absolute # (site.py absolutize them), the __file__ and __path__ will be absolute too. # Therefore it is necessary to absolutize manually the __file__ and __path__ of # the packages to prevent later imports to fail when the CWD is different. for module in sys.modules.values(): if hasattr(module, '__path__'): module.__path__ = [os.path.abspath(path) for path in module.__path__] if hasattr(module, '__file__'): module.__file__ = os.path.abspath(module.__file__) # MacOSX (a.k.a. Darwin) has a default stack size that is too small # for deeply recursive regular expressions. We see this as crashes in # the Python test suite when running test_re.py and test_sre.py. The # fix is to set the stack limit to 2048. # This approach may also be useful for other Unixy platforms that # suffer from small default stack limits. if sys.platform == 'darwin': try: import resource except ImportError: pass else: soft, hard = resource.getrlimit(resource.RLIMIT_STACK) newsoft = min(hard, max(soft, 1024*2048)) resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard)) # Test result constants. PASSED = 1 FAILED = 0 ENV_CHANGED = -1 SKIPPED = -2 RESOURCE_DENIED = -3 INTERRUPTED = -4 CHILD_ERROR = -5 # error in a child process from test import support RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui') TEMPDIR = os.path.abspath(tempfile.gettempdir()) def usage(msg): print(msg, file=sys.stderr) print("Use --help for usage", file=sys.stderr) sys.exit(2) def main(tests=None, testdir=None, verbose=0, quiet=False, exclude=False, single=0, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False, coverdir='coverage', runleaks=False, huntrleaks=False, verbose2=False, print_slow=False, random_seed=None, use_mp=None, verbose3=False, forever=False, header=False, failfast=False, match_tests=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other default arguments (verbose, quiet, exclude, single, randomize, findleaks, use_resources, trace, coverdir, print_slow, and random_seed) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ # Display the Python traceback on fatal errors (e.g. segfault) faulthandler.enable(all_threads=True) # Display the Python traceback on SIGALRM or SIGUSR1 signal signals = [] if hasattr(signal, 'SIGALRM'): signals.append(signal.SIGALRM) if hasattr(signal, 'SIGUSR1'): signals.append(signal.SIGUSR1) for signum in signals: faulthandler.register(signum, chain=True) replace_stdout() support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvqxsoS:rf:lu:t:TD:NLR:FdwWM:nj:Gm:', ['help', 'verbose', 'verbose2', 'verbose3', 'quiet', 'exclude', 'single', 'slow', 'randomize', 'fromfile=', 'findleaks', 'use=', 'threshold=', 'coverdir=', 'nocoverdir', 'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=', 'multiprocess=', 'coverage', 'slaveargs=', 'forever', 'debug', 'start=', 'nowindows', 'header', 'testdir=', 'timeout=', 'wait', 'failfast', 'match=', 'next=']) except getopt.error as msg: usage(msg) # Defaults if random_seed is None: random_seed = random.randrange(10000000) if use_resources is None: use_resources = [] debug = False start = None timeout = None for o, a in opts: if o in ('-h', '--help'): print(__doc__) return elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-w', '--verbose2'): verbose2 = True elif o in ('-d', '--debug'): debug = True elif o in ('-W', '--verbose3'): verbose3 = True elif o in ('-G', '--failfast'): failfast = True elif o in ('-q', '--quiet'): quiet = True; verbose = 0 elif o in ('-x', '--exclude'): exclude = True elif o in ('-S', '--start'): start = a elif o in ('-s', '--single'): single = 1 elif o == '--next': single = int(a) elif o in ('-o', '--slow'): print_slow = True elif o in ('-r', '--randomize'): randomize = True elif o == '--randseed': random_seed = int(a) elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-m', '--match'): match_tests = a elif o in ('-l', '--findleaks'): findleaks = True elif o in ('-L', '--runleaks'): runleaks = True elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-T', '--coverage'): trace = True elif o in ('-D', '--coverdir'): # CWD is replaced with a temporary dir before calling main(), so we # need join it with the saved CWD so it goes where the user expects. coverdir = os.path.join(support.SAVEDCWD, a) elif o in ('-N', '--nocoverdir'): coverdir = None elif o in ('-R', '--huntrleaks'): huntrleaks = a.split(':') if len(huntrleaks) not in (2, 3): print(a, huntrleaks) usage('-R takes 2 or 3 colon-separated arguments') if not huntrleaks[0]: huntrleaks[0] = 5 else: huntrleaks[0] = int(huntrleaks[0]) if not huntrleaks[1]: huntrleaks[1] = 4 else: huntrleaks[1] = int(huntrleaks[1]) if len(huntrleaks) == 2 or not huntrleaks[2]: huntrleaks[2:] = ["reflog.txt"] # Avoid false positives due to various caches # filling slowly with random data: warm_caches() elif o in ('-M', '--memlimit'): support.set_memlimit(a) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue if r == 'none': del use_resources[:] continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage('Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) elif o in ('-n', '--nowindows'): import msvcrt msvcrt.SetErrorMode(msvcrt.SEM_FAILCRITICALERRORS| msvcrt.SEM_NOALIGNMENTFAULTEXCEPT| msvcrt.SEM_NOGPFAULTERRORBOX| msvcrt.SEM_NOOPENFILEERRORBOX) try: msvcrt.CrtSetReportMode except AttributeError: # release build pass else: for m in [msvcrt.CRT_WARN, msvcrt.CRT_ERROR, msvcrt.CRT_ASSERT]: msvcrt.CrtSetReportMode(m, msvcrt.CRTDBG_MODE_FILE) msvcrt.CrtSetReportFile(m, msvcrt.CRTDBG_FILE_STDERR) elif o in ('-F', '--forever'): forever = True elif o in ('-j', '--multiprocess'): use_mp = int(a) if use_mp <= 0: try: import multiprocessing # Use all cores + extras for tests that like to sleep use_mp = 2 + multiprocessing.cpu_count() except (ImportError, NotImplementedError): use_mp = 3 if use_mp == 1: use_mp = None elif o == '--header': header = True elif o == '--slaveargs': args, kwargs = json.loads(a) try: result = runtest(*args, **kwargs) except KeyboardInterrupt: result = INTERRUPTED, '' except BaseException as e: traceback.print_exc() result = CHILD_ERROR, str(e) sys.stdout.flush() print() # Force a newline (just in case) print(json.dumps(result)) sys.exit(0) elif o == '--testdir': # CWD is replaced with a temporary dir before calling main(), so we # join it with the saved CWD so it ends up where the user expects. testdir = os.path.join(support.SAVEDCWD, a) elif o == '--timeout': if hasattr(faulthandler, 'dump_tracebacks_later'): timeout = float(a) if timeout <= 0: timeout = None else: print("Warning: The timeout option requires " "faulthandler.dump_tracebacks_later") timeout = None elif o == '--wait': input("Press any key to continue...") else: print(("No handler for option {}. Please report this as a bug " "at http://bugs.python.org.").format(o), file=sys.stderr) sys.exit(1) if single and fromfile: usage("-s and -f don't go together!") if use_mp and trace: usage("-T and -j don't go together!") if use_mp and findleaks: usage("-l and -j don't go together!") if use_mp and support.max_memuse: usage("-M and -j don't go together!") if failfast and not (verbose or verbose3): usage("-G/--failfast needs either -v or -W") good = [] bad = [] skipped = [] resource_denieds = [] environment_changed = [] interrupted = False if findleaks: try: import gc except ImportError: print('No GC available, disabling findleaks.') findleaks = False else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: filename = os.path.join(TEMPDIR, 'pynexttest') try: fp = open(filename, 'r') next_test = fp.read().strip() tests = [next_test] fp.close() except IOError: pass if fromfile: tests = [] fp = open(os.path.join(support.SAVEDCWD, fromfile)) count_pat = re.compile(r'\[\s*\d+/\s*\d+\]') for line in fp: line = count_pat.sub('', line) guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. removepy(args) removepy(tests) stdtests = STDTESTS[:] nottests = NOTTESTS.copy() if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests.add(arg) args = [] # For a partial run, we do not need to clutter the output. if verbose or header or not (quiet or single != 1 or tests or args): # Print basic platform information print("==", platform.python_implementation(), *sys.version.split()) print("== ", platform.platform(aliased=True), "%s-endian" % sys.byteorder) print("== ", os.getcwd()) print("Testing with flags:", sys.flags) # if testdir is set, then we are not running the python tests suite, so # don't add default tests to be executed or skipped (pass empty values) if testdir: alltests = findtests(testdir, list(), set()) else: alltests = findtests(testdir, stdtests, nottests) selected = tests or args or alltests if single: first_selected = selected[0] index_selected = alltests.index(first_selected) if index_selected + single > len(alltests): single = len(alltests) - index_selected selected = alltests[index_selected:index_selected+single] try: next_single_test = alltests[index_selected+single] except IndexError: next_single_test = None # Remove all the selected tests that precede start if it's set. if start: try: del selected[:selected.index(start)] except ValueError: print("Couldn't find starting test (%s), using all tests" % start) if randomize: random.seed(random_seed) print("Using random seed", random_seed) random.shuffle(selected) if trace: import trace, tempfile tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix, tempfile.gettempdir()], trace=False, count=True) test_times = [] support.verbose = verbose # Tell tests to be moderately quiet support.use_resources = use_resources save_modules = sys.modules.keys() def accumulate_result(test, result): ok, test_time = result test_times.append((test_time, test)) if ok == PASSED: good.append(test) elif ok == FAILED: bad.append(test) elif ok == ENV_CHANGED: environment_changed.append(test) elif ok == SKIPPED: skipped.append(test) elif ok == RESOURCE_DENIED: skipped.append(test) resource_denieds.append(test) if forever: def test_forever(tests=list(selected)): while True: for test in tests: yield test if bad: return tests = test_forever() test_count = '' test_count_width = 3 else: tests = iter(selected) test_count = '/{}'.format(len(selected)) test_count_width = len(test_count) - 1 if use_mp: try: from threading import Thread except ImportError: print("Multiprocess option requires thread support") sys.exit(2) from queue import Queue from subprocess import Popen, PIPE debug_output_pat = re.compile(r"\[\d+ refs\]$") output = Queue() pending = MultiprocessTests(tests) opt_args = support.args_from_interpreter_flags() base_cmd = [sys.executable] + opt_args + ['-m', 'test.regrtest'] def work(): # A worker thread. try: while True: try: test = next(pending) except StopIteration: output.put((None, None, None, None)) return args_tuple = ( (test, verbose, quiet), dict(huntrleaks=huntrleaks, use_resources=use_resources, debug=debug, output_on_failure=verbose3, timeout=timeout, failfast=failfast, match_tests=match_tests) ) # -E is needed by some tests, e.g. test_import # Running the child from the same working directory ensures # that TEMPDIR for the child is the same when # sysconfig.is_python_build() is true. See issue 15300. popen = Popen(base_cmd + ['--slaveargs', json.dumps(args_tuple)], stdout=PIPE, stderr=PIPE, universal_newlines=True, close_fds=(os.name != 'nt'), cwd=support.SAVEDCWD) stdout, stderr = popen.communicate() retcode = popen.wait() # Strip last refcount output line if it exists, since it # comes from the shutdown of the interpreter in the subcommand. stderr = debug_output_pat.sub("", stderr) stdout, _, result = stdout.strip().rpartition("\n") if retcode != 0: result = (CHILD_ERROR, "Exit code %s" % retcode) output.put((test, stdout.rstrip(), stderr.rstrip(), result)) return if not result: output.put((None, None, None, None)) return result = json.loads(result) output.put((test, stdout.rstrip(), stderr.rstrip(), result)) except BaseException: output.put((None, None, None, None)) raise workers = [Thread(target=work) for i in range(use_mp)] for worker in workers: worker.start() finished = 0 test_index = 1 try: while finished < use_mp: test, stdout, stderr, result = output.get() if test is None: finished += 1 continue accumulate_result(test, result) if not quiet: fmt = "[{1:{0}}{2}/{3}] {4}" if bad else "[{1:{0}}{2}] {4}" print(fmt.format( test_count_width, test_index, test_count, len(bad), test)) if stdout: print(stdout) if stderr: print(stderr, file=sys.stderr) sys.stdout.flush() sys.stderr.flush() if result[0] == INTERRUPTED: raise KeyboardInterrupt if result[0] == CHILD_ERROR: raise Exception("Child error on {}: {}".format(test, result[1])) test_index += 1 except KeyboardInterrupt: interrupted = True pending.interrupted = True for worker in workers: worker.join() else: for test_index, test in enumerate(tests, 1): if not quiet: fmt = "[{1:{0}}{2}/{3}] {4}" if bad else "[{1:{0}}{2}] {4}" print(fmt.format( test_count_width, test_index, test_count, len(bad), test)) sys.stdout.flush() if trace: # If we're tracing code coverage, then we don't exit with status # if on a false return value from main. tracer.runctx('runtest(test, verbose, quiet, timeout=timeout)', globals=globals(), locals=vars()) else: try: result = runtest(test, verbose, quiet, huntrleaks, debug, output_on_failure=verbose3, timeout=timeout, failfast=failfast, match_tests=match_tests) accumulate_result(test, result) except KeyboardInterrupt: interrupted = True break except: raise if findleaks: gc.collect() if gc.garbage: print("Warning: test created", len(gc.garbage), end=' ') print("uncollectable object(s).") # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): support.unload(module) if interrupted: # print a newline after ^C print() print("Test suite interrupted by signal SIGINT.") omitted = set(selected) - set(good) - set(bad) - set(skipped) print(count(len(omitted), "test"), "omitted:") printlist(omitted) if good and not quiet: if not bad and not skipped and not interrupted and len(good) > 1: print("All", end=' ') print(count(len(good), "test"), "OK.") if print_slow: test_times.sort(reverse=True) print("10 slowest tests:") for time, test in test_times[:10]: print("%s: %.1fs" % (test, time)) if bad: bad = sorted(set(bad) - set(environment_changed)) if bad: print(count(len(bad), "test"), "failed:") printlist(bad) if environment_changed: print("{} altered the execution environment:".format( count(len(environment_changed), "test"))) printlist(environment_changed) if skipped and not quiet: print(count(len(skipped), "test"), "skipped:") printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print(count(len(surprise), "skip"), \ "unexpected on", plat + ":") printlist(surprise) else: print("Those skips are all expected on", plat + ".") else: print("Ask someone to teach regrtest.py about which tests are") print("expected to get skipped on", plat + ".") if verbose2 and bad: print("Re-running failed tests in verbose mode") for test in bad: print("Re-running test %r in verbose mode" % test) sys.stdout.flush() try: verbose = True ok = runtest(test, True, quiet, huntrleaks, debug, timeout=timeout) except KeyboardInterrupt: # print a newline separate from the ^C print() break except: raise if single: if next_single_test: with open(filename, 'w') as fp: fp.write(next_single_test + '\n') else: os.unlink(filename) if trace: r = tracer.results() r.write_results(show_missing=True, summary=True, coverdir=coverdir) if runleaks: os.system("leaks %d" % os.getpid()) sys.exit(len(bad) > 0 or interrupted) # small set of tests to determine if we have a basically functioning interpreter # (i.e. if any of these fail, then anything else is likely to follow) STDTESTS = [ 'test_grammar', 'test_opcodes', 'test_dict', 'test_builtin', 'test_exceptions', 'test_types', 'test_unittest', 'test_doctest', 'test_doctest2', 'test_support' ] # set of tests that we don't want to be executed when using regrtest NOTTESTS = set() def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS): """Return a list of all applicable test modules.""" testdir = findtestdir(testdir) names = os.listdir(testdir) tests = [] others = set(stdtests) | nottests for name in names: mod, ext = os.path.splitext(name) if mod[:5] == "test_" and ext in (".py", "") and mod not in others: tests.append(mod) return stdtests + sorted(tests) # We do not use a generator so multiple threads can call next(). class MultiprocessTests(object): """A thread-safe iterator over tests for multiprocess mode.""" def __init__(self, tests): self.interrupted = False self.lock = threading.Lock() self.tests = tests def __iter__(self): return self def __next__(self): with self.lock: if self.interrupted: raise StopIteration('tests interrupted') return next(self.tests) def replace_stdout(): """Set stdout encoder error handler to backslashreplace (as stderr error handler) to avoid UnicodeEncodeError when printing a traceback""" import atexit stdout = sys.stdout sys.stdout = open(stdout.fileno(), 'w', encoding=stdout.encoding, errors="backslashreplace", closefd=False, newline='\n') def restore_stdout(): sys.stdout.close() sys.stdout = stdout atexit.register(restore_stdout) def runtest(test, verbose, quiet, huntrleaks=False, debug=False, use_resources=None, output_on_failure=False, failfast=False, match_tests=None, timeout=None): """Run a single test. test -- the name of the test verbose -- if true, print more messages quiet -- if true, don't print 'skipped' messages (probably redundant) test_times -- a list of (time, test_name) pairs huntrleaks -- run multiple times to test for leaks; requires a debug build; a triple corresponding to -R's three arguments output_on_failure -- if true, display test output on failure timeout -- dump the traceback and exit if a test takes more than timeout seconds Returns one of the test result constants: INTERRUPTED KeyboardInterrupt when run under -j RESOURCE_DENIED test skipped because resource denied SKIPPED test skipped for some other reason ENV_CHANGED test failed because it changed the execution environment FAILED test failed PASSED test passed """ if use_resources is not None: support.use_resources = use_resources use_timeout = (timeout is not None) if use_timeout: faulthandler.dump_tracebacks_later(timeout, exit=True) try: support.match_tests = match_tests if failfast: support.failfast = True if output_on_failure: support.verbose = True # Reuse the same instance to all calls to runtest(). Some # tests keep a reference to sys.stdout or sys.stderr # (eg. test_argparse). if runtest.stringio is None: stream = io.StringIO() runtest.stringio = stream else: stream = runtest.stringio stream.seek(0) stream.truncate() orig_stdout = sys.stdout orig_stderr = sys.stderr try: sys.stdout = stream sys.stderr = stream result = runtest_inner(test, verbose, quiet, huntrleaks, debug, display_failure=False) if result[0] == FAILED: output = stream.getvalue() orig_stderr.write(output) orig_stderr.flush() finally: sys.stdout = orig_stdout sys.stderr = orig_stderr else: support.verbose = verbose # Tell tests to be moderately quiet result = runtest_inner(test, verbose, quiet, huntrleaks, debug, display_failure=not verbose) return result finally: if use_timeout: faulthandler.cancel_dump_tracebacks_later() cleanup_test_droppings(test, verbose) runtest.stringio = None # Unit tests are supposed to leave the execution environment unchanged # once they complete. But sometimes tests have bugs, especially when # tests fail, and the changes to environment go on to mess up other # tests. This can cause issues with buildbot stability, since tests # are run in random order and so problems may appear to come and go. # There are a few things we can save and restore to mitigate this, and # the following context manager handles this task. class saved_test_environment: """Save bits of the test environment and restore them at block exit. with saved_test_environment(testname, verbose, quiet): #stuff Unless quiet is True, a warning is printed to stderr if any of the saved items was changed by the test. The attribute 'changed' is initially False, but is set to True if a change is detected. If verbose is more than 1, the before and after state of changed items is also printed. """ changed = False def __init__(self, testname, verbose=0, quiet=False): self.testname = testname self.verbose = verbose self.quiet = quiet # To add things to save and restore, add a name XXX to the resources list # and add corresponding get_XXX/restore_XXX functions. get_XXX should # return the value to be saved and compared against a second call to the # get function when test execution completes. restore_XXX should accept # the saved value and restore the resource using it. It will be called if # and only if a change in the value is detected. # # Note: XXX will have any '.' replaced with '_' characters when determining # the corresponding method names. resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr', 'os.environ', 'sys.path', 'sys.path_hooks', '__import__', 'warnings.filters', 'asyncore.socket_map', 'logging._handlers', 'logging._handlerList', 'sys.gettrace', 'sys.warnoptions', 'threading._dangling', 'multiprocessing.process._dangling', 'sysconfig._CONFIG_VARS', 'sysconfig._INSTALL_SCHEMES', 'support.TESTFN', ) def get_sys_argv(self): return id(sys.argv), sys.argv, sys.argv[:] def restore_sys_argv(self, saved_argv): sys.argv = saved_argv[1] sys.argv[:] = saved_argv[2] def get_cwd(self): return os.getcwd() def restore_cwd(self, saved_cwd): os.chdir(saved_cwd) def get_sys_stdout(self): return sys.stdout def restore_sys_stdout(self, saved_stdout): sys.stdout = saved_stdout def get_sys_stderr(self): return sys.stderr def restore_sys_stderr(self, saved_stderr): sys.stderr = saved_stderr def get_sys_stdin(self): return sys.stdin def restore_sys_stdin(self, saved_stdin): sys.stdin = saved_stdin def get_os_environ(self): return id(os.environ), os.environ, dict(os.environ) def restore_os_environ(self, saved_environ): os.environ = saved_environ[1] os.environ.clear() os.environ.update(saved_environ[2]) def get_sys_path(self): return id(sys.path), sys.path, sys.path[:] def restore_sys_path(self, saved_path): sys.path = saved_path[1] sys.path[:] = saved_path[2] def get_sys_path_hooks(self): return id(sys.path_hooks), sys.path_hooks, sys.path_hooks[:] def restore_sys_path_hooks(self, saved_hooks): sys.path_hooks = saved_hooks[1] sys.path_hooks[:] = saved_hooks[2] def get_sys_gettrace(self): return sys.gettrace() def restore_sys_gettrace(self, trace_fxn): sys.settrace(trace_fxn) def get___import__(self): return builtins.__import__ def restore___import__(self, import_): builtins.__import__ = import_ def get_warnings_filters(self): return id(warnings.filters), warnings.filters, warnings.filters[:] def restore_warnings_filters(self, saved_filters): warnings.filters = saved_filters[1] warnings.filters[:] = saved_filters[2] def get_asyncore_socket_map(self): asyncore = sys.modules.get('asyncore') # XXX Making a copy keeps objects alive until __exit__ gets called. return asyncore and asyncore.socket_map.copy() or {} def restore_asyncore_socket_map(self, saved_map): asyncore = sys.modules.get('asyncore') if asyncore is not None: asyncore.close_all(ignore_all=True) asyncore.socket_map.update(saved_map) def get_shutil_archive_formats(self): # we could call get_archives_formats() but that only returns the # registry keys; we want to check the values too (the functions that # are registered) return shutil._ARCHIVE_FORMATS, shutil._ARCHIVE_FORMATS.copy() def restore_shutil_archive_formats(self, saved): shutil._ARCHIVE_FORMATS = saved[0] shutil._ARCHIVE_FORMATS.clear() shutil._ARCHIVE_FORMATS.update(saved[1]) def get_shutil_unpack_formats(self): return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy() def restore_shutil_unpack_formats(self, saved): shutil._UNPACK_FORMATS = saved[0] shutil._UNPACK_FORMATS.clear() shutil._UNPACK_FORMATS.update(saved[1]) def get_logging__handlers(self): # _handlers is a WeakValueDictionary return id(logging._handlers), logging._handlers, logging._handlers.copy() def restore_logging__handlers(self, saved_handlers): # Can't easily revert the logging state pass def get_logging__handlerList(self): # _handlerList is a list of weakrefs to handlers return id(logging._handlerList), logging._handlerList, logging._handlerList[:] def restore_logging__handlerList(self, saved_handlerList): # Can't easily revert the logging state pass def get_sys_warnoptions(self): return id(sys.warnoptions), sys.warnoptions, sys.warnoptions[:] def restore_sys_warnoptions(self, saved_options): sys.warnoptions = saved_options[1] sys.warnoptions[:] = saved_options[2] # Controlling dangling references to Thread objects can make it easier # to track reference leaks. def get_threading__dangling(self): if not threading: return None # This copies the weakrefs without making any strong reference return threading._dangling.copy() def restore_threading__dangling(self, saved): if not threading: return threading._dangling.clear() threading._dangling.update(saved) # Same for Process objects def get_multiprocessing_process__dangling(self): if not multiprocessing: return None # This copies the weakrefs without making any strong reference return multiprocessing.process._dangling.copy() def restore_multiprocessing_process__dangling(self, saved): if not multiprocessing: return multiprocessing.process._dangling.clear() multiprocessing.process._dangling.update(saved) def get_sysconfig__CONFIG_VARS(self): # make sure the dict is initialized sysconfig.get_config_var('prefix') return (id(sysconfig._CONFIG_VARS), sysconfig._CONFIG_VARS, dict(sysconfig._CONFIG_VARS)) def restore_sysconfig__CONFIG_VARS(self, saved): sysconfig._CONFIG_VARS = saved[1] sysconfig._CONFIG_VARS.clear() sysconfig._CONFIG_VARS.update(saved[2]) def get_sysconfig__INSTALL_SCHEMES(self): return (id(sysconfig._INSTALL_SCHEMES), sysconfig._INSTALL_SCHEMES, sysconfig._INSTALL_SCHEMES.copy()) def restore_sysconfig__INSTALL_SCHEMES(self, saved): sysconfig._INSTALL_SCHEMES = saved[1] sysconfig._INSTALL_SCHEMES.clear() sysconfig._INSTALL_SCHEMES.update(saved[2]) def get_support_TESTFN(self): if os.path.isfile(support.TESTFN): result = 'f' elif os.path.isdir(support.TESTFN): result = 'd' else: result = None return result def restore_support_TESTFN(self, saved_value): if saved_value is None: if os.path.isfile(support.TESTFN): os.unlink(support.TESTFN) elif os.path.isdir(support.TESTFN): shutil.rmtree(support.TESTFN) def resource_info(self): for name in self.resources: method_suffix = name.replace('.', '_') get_name = 'get_' + method_suffix restore_name = 'restore_' + method_suffix yield name, getattr(self, get_name), getattr(self, restore_name) def __enter__(self): self.saved_values = dict((name, get()) for name, get, restore in self.resource_info()) return self def __exit__(self, exc_type, exc_val, exc_tb): saved_values = self.saved_values del self.saved_values for name, get, restore in self.resource_info(): current = get() original = saved_values.pop(name) # Check for changes to the resource's value if current != original: self.changed = True restore(original) if not self.quiet: print("Warning -- {} was modified by {}".format( name, self.testname), file=sys.stderr) if self.verbose > 1: print(" Before: {}\n After: {} ".format( original, current), file=sys.stderr) return False def runtest_inner(test, verbose, quiet, huntrleaks=False, debug=False, display_failure=True): support.unload(test) test_time = 0.0 refleak = False # True if the test leaked references. try: if test.startswith('test.'): abstest = test else: # Always import it from the test package abstest = 'test.' + test with saved_test_environment(test, verbose, quiet) as environment: start_time = time.time() the_package = __import__(abstest, globals(), locals(), []) the_module = getattr(the_package, test) # If the test has a test_main, that will run the appropriate # tests. If not, use normal unittest test loading. test_runner = getattr(the_module, "test_main", None) if test_runner is None: tests = unittest.TestLoader().loadTestsFromModule(the_module) test_runner = lambda: support.run_unittest(tests) test_runner() if huntrleaks: refleak = dash_R(the_module, test, test_runner, huntrleaks) test_time = time.time() - start_time except support.ResourceDenied as msg: if not quiet: print(test, "skipped --", msg) sys.stdout.flush() return RESOURCE_DENIED, test_time except unittest.SkipTest as msg: if not quiet: print(test, "skipped --", msg) sys.stdout.flush() return SKIPPED, test_time except KeyboardInterrupt: raise except support.TestFailed as msg: if display_failure: print("test", test, "failed --", msg, file=sys.stderr) else: print("test", test, "failed", file=sys.stderr) sys.stderr.flush() return FAILED, test_time except: msg = traceback.format_exc() print("test", test, "crashed --", msg, file=sys.stderr) sys.stderr.flush() return FAILED, test_time else: if refleak: return FAILED, test_time if environment.changed: return ENV_CHANGED, test_time return PASSED, test_time def cleanup_test_droppings(testname, verbose): import shutil import stat import gc # First kill any dangling references to open files etc. # This can also issue some ResourceWarnings which would otherwise get # triggered during the following test run, and possibly produce failures. gc.collect() # Try to clean up junk commonly left behind. While tests shouldn't leave # any files or directories behind, when a test fails that can be tedious # for it to arrange. The consequences can be especially nasty on Windows, # since if a test leaves a file open, it cannot be deleted by name (while # there's nothing we can do about that here either, we can display the # name of the offending test, which is a real help). for name in (support.TESTFN, "db_home", ): if not os.path.exists(name): continue if os.path.isdir(name): kind, nuker = "directory", shutil.rmtree elif os.path.isfile(name): kind, nuker = "file", os.unlink else: raise SystemError("os.path says %r exists but is neither " "directory nor file" % name) if verbose: print("%r left behind %s %r" % (testname, kind, name)) try: # if we have chmod, fix possible permissions problems # that might prevent cleanup if (hasattr(os, 'chmod')): os.chmod(name, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) nuker(name) except Exception as msg: print(("%r left behind %s %r and it couldn't be " "removed: %s" % (testname, kind, name, msg)), file=sys.stderr) def dash_R(the_module, test, indirect_test, huntrleaks): """Run a test multiple times, looking for reference leaks. Returns: False if the test didn't leak references; True if we detected refleaks. """ # This code is hackish and inelegant, but it seems to do the job. import copyreg import collections.abc if not hasattr(sys, 'gettotalrefcount'): raise Exception("Tracking reference leaks requires a debug build " "of Python") # Save current values for dash_R_cleanup() to restore. fs = warnings.filters[:] ps = copyreg.dispatch_table.copy() pic = sys.path_importer_cache.copy() try: import zipimport except ImportError: zdc = None # Run unmodified on platforms without zipimport support else: zdc = zipimport._zip_directory_cache.copy() abcs = {} for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]: if not isabstract(abc): continue for obj in abc.__subclasses__() + [abc]: abcs[obj] = obj._abc_registry.copy() if indirect_test: def run_the_test(): indirect_test() else: def run_the_test(): del sys.modules[the_module.__name__] exec('import ' + the_module.__name__) deltas = [] nwarmup, ntracked, fname = huntrleaks fname = os.path.join(support.SAVEDCWD, fname) repcount = nwarmup + ntracked print("beginning", repcount, "repetitions", file=sys.stderr) print(("1234567890"*(repcount//10 + 1))[:repcount], file=sys.stderr) sys.stderr.flush() dash_R_cleanup(fs, ps, pic, zdc, abcs) for i in range(repcount): rc_before = sys.gettotalrefcount() run_the_test() sys.stderr.write('.') sys.stderr.flush() dash_R_cleanup(fs, ps, pic, zdc, abcs) rc_after = sys.gettotalrefcount() if i >= nwarmup: deltas.append(rc_after - rc_before) print(file=sys.stderr) if any(deltas): msg = '%s leaked %s references, sum=%s' % (test, deltas, sum(deltas)) print(msg, file=sys.stderr) sys.stderr.flush() with open(fname, "a") as refrep: print(msg, file=refrep) refrep.flush() return True return False def dash_R_cleanup(fs, ps, pic, zdc, abcs): import gc, copyreg import _strptime, linecache import urllib.parse, urllib.request, mimetypes, doctest import struct, filecmp, collections.abc from distutils.dir_util import _path_created from weakref import WeakSet # Clear the warnings registry, so they can be displayed again for mod in sys.modules.values(): if hasattr(mod, '__warningregistry__'): del mod.__warningregistry__ # Restore some original values. warnings.filters[:] = fs copyreg.dispatch_table.clear() copyreg.dispatch_table.update(ps) sys.path_importer_cache.clear() sys.path_importer_cache.update(pic) try: import zipimport except ImportError: pass # Run unmodified on platforms without zipimport support else: zipimport._zip_directory_cache.clear() zipimport._zip_directory_cache.update(zdc) # clear type cache sys._clear_type_cache() # Clear ABC registries, restoring previously saved ABC registries. for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]: if not isabstract(abc): continue for obj in abc.__subclasses__() + [abc]: obj._abc_registry = abcs.get(obj, WeakSet()).copy() obj._abc_cache.clear() obj._abc_negative_cache.clear() # Flush standard output, so that buffered data is sent to the OS and # associated Python objects are reclaimed. for stream in (sys.stdout, sys.stderr, sys.__stdout__, sys.__stderr__): if stream is not None: stream.flush() # Clear assorted module caches. _path_created.clear() re.purge() _strptime._regex_cache.clear() urllib.parse.clear_cache() urllib.request.urlcleanup() linecache.clearcache() mimetypes._default_mime_types() filecmp._cache.clear() struct._clearcache() doctest.master = None try: import ctypes except ImportError: # Don't worry about resetting the cache if ctypes is not supported pass else: ctypes._reset_cache() # Collect cyclic trash. gc.collect() def warm_caches(): # char cache s = bytes(range(256)) for i in range(256): s[i:i+1] # unicode cache x = [chr(i) for i in range(256)] # int cache x = list(range(-5, 257)) def findtestdir(path=None): return path or os.path.dirname(__file__) or os.curdir def removepy(names): if not names: return for idx, name in enumerate(names): basename, ext = os.path.splitext(name) if ext == '.py': names[idx] = basename def count(n, word): if n == 1: return "%d %s" % (n, word) else: return "%d %ss" % (n, word) def printlist(x, width=70, indent=4): """Print the elements of iterable x to stdout. Optional arg width (default 70) is the maximum line length. Optional arg indent (default 4) is the number of blanks with which to begin each line. """ from textwrap import fill blanks = ' ' * indent # Print the sorted list: 'x' may be a '--random' list or a set() print(fill(' '.join(str(elt) for elt in sorted(x)), width, initial_indent=blanks, subsequent_indent=blanks)) # Map sys.platform to a string containing the basenames of tests # expected to be skipped on that platform. # # Special cases: # test_pep277 # The _ExpectedSkips constructor adds this to the set of expected # skips if not os.path.supports_unicode_filenames. # test_timeout # Controlled by test_timeout.skip_expected. Requires the network # resource and a socket module. # # Tests that are expected to be skipped everywhere except on one platform # are also handled separately. _expectations = ( ('win32', """ test__locale test_crypt test_curses test_dbm test_devpoll test_fcntl test_fork1 test_epoll test_dbm_gnu test_dbm_ndbm test_grp test_ioctl test_largefile test_kqueue test_openpty test_ossaudiodev test_pipes test_poll test_posix test_pty test_pwd test_resource test_signal test_syslog test_threadsignals test_wait3 test_wait4 """), ('linux', """ test_curses test_devpoll test_largefile test_kqueue test_ossaudiodev """), ('unixware', """ test_epoll test_largefile test_kqueue test_minidom test_openpty test_pyexpat test_sax test_sundry """), ('openunix', """ test_epoll test_largefile test_kqueue test_minidom test_openpty test_pyexpat test_sax test_sundry """), ('sco_sv', """ test_asynchat test_fork1 test_epoll test_gettext test_largefile test_locale test_kqueue test_minidom test_openpty test_pyexpat test_queue test_sax test_sundry test_thread test_threaded_import test_threadedtempfile test_threading """), ('darwin', """ test__locale test_curses test_devpoll test_epoll test_dbm_gnu test_gdb test_largefile test_locale test_minidom test_ossaudiodev test_poll """), ('sunos', """ test_curses test_dbm test_epoll test_kqueue test_dbm_gnu test_gzip test_openpty test_zipfile test_zlib """), ('hp-ux', """ test_curses test_epoll test_dbm_gnu test_gzip test_largefile test_locale test_kqueue test_minidom test_openpty test_pyexpat test_sax test_zipfile test_zlib """), ('cygwin', """ test_curses test_dbm test_devpoll test_epoll test_ioctl test_kqueue test_largefile test_locale test_ossaudiodev test_socketserver """), ('os2emx', """ test_audioop test_curses test_epoll test_kqueue test_largefile test_mmap test_openpty test_ossaudiodev test_pty test_resource test_signal """), ('freebsd', """ test_devpoll test_epoll test_dbm_gnu test_locale test_ossaudiodev test_pep277 test_pty test_socketserver test_tcl test_tk test_ttk_guionly test_ttk_textonly test_timeout test_urllibnet test_multiprocessing """), ('aix', """ test_bz2 test_epoll test_dbm_gnu test_gzip test_kqueue test_ossaudiodev test_tcl test_tk test_ttk_guionly test_ttk_textonly test_zipimport test_zlib """), ('openbsd', """ test_ctypes test_devpoll test_epoll test_dbm_gnu test_locale test_normalization test_ossaudiodev test_pep277 test_tcl test_tk test_ttk_guionly test_ttk_textonly test_multiprocessing """), ('netbsd', """ test_ctypes test_curses test_devpoll test_epoll test_dbm_gnu test_locale test_ossaudiodev test_pep277 test_tcl test_tk test_ttk_guionly test_ttk_textonly test_multiprocessing """), ) class _ExpectedSkips: def __init__(self): import os.path from test import test_timeout self.valid = False expected = None for item in _expectations: if sys.platform.startswith(item[0]): expected = item[1] break if expected is not None: self.expected = set(expected.split()) # These are broken tests, for now skipped on every platform. # XXX Fix these! self.expected.add('test_nis') # expected to be skipped on every platform, even Linux if not os.path.supports_unicode_filenames: self.expected.add('test_pep277') # doctest, profile and cProfile tests fail when the codec for the # fs encoding isn't built in because PyUnicode_Decode() adds two # calls into Python. encs = ("utf-8", "latin-1", "ascii", "mbcs", "utf-16", "utf-32") if sys.getfilesystemencoding().lower() not in encs: self.expected.add('test_profile') self.expected.add('test_cProfile') self.expected.add('test_doctest') if test_timeout.skip_expected: self.expected.add('test_timeout') if sys.platform != "win32": # test_sqlite is only reliable on Windows where the library # is distributed with Python WIN_ONLY = {"test_unicode_file", "test_winreg", "test_winsound", "test_startfile", "test_sqlite", "test_msilib"} self.expected |= WIN_ONLY if sys.platform != 'sunos5': self.expected.add('test_nis') if support.python_is_optimized(): self.expected.add("test_gdb") self.valid = True def isvalid(self): "Return true iff _ExpectedSkips knows about the current platform." return self.valid def getexpected(self): """Return set of test names we expect to skip on current platform. self.isvalid() must be true. """ assert self.isvalid() return self.expected def _make_temp_dir_for_build(TEMPDIR): # When tests are run from the Python build directory, it is best practice # to keep the test files in a subfolder. It eases the cleanup of leftover # files using command "make distclean". if sysconfig.is_python_build(): TEMPDIR = os.path.join(sysconfig.get_config_var('srcdir'), 'build') TEMPDIR = os.path.abspath(TEMPDIR) try: os.mkdir(TEMPDIR) except FileExistsError: pass # Define a writable temp dir that will be used as cwd while running # the tests. The name of the dir includes the pid to allow parallel # testing (see the -j option). TESTCWD = 'test_python_{}'.format(os.getpid()) TESTCWD = os.path.join(TEMPDIR, TESTCWD) return TEMPDIR, TESTCWD if __name__ == '__main__': # Remove regrtest.py's own directory from the module search path. Despite # the elimination of implicit relative imports, this is still needed to # ensure that submodules of the test package do not inappropriately appear # as top-level modules even when people (or buildbots!) invoke regrtest.py # directly instead of using the -m switch mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0]))) i = len(sys.path) while i >= 0: i -= 1 if os.path.abspath(os.path.normpath(sys.path[i])) == mydir: del sys.path[i] # findtestdir() gets the dirname out of __file__, so we have to make it # absolute before changing the working directory. # For example __file__ may be relative when running trace or profile. # See issue #9323. __file__ = os.path.abspath(__file__) # sanity check assert __file__ == os.path.abspath(sys.argv[0]) TEMPDIR, TESTCWD = _make_temp_dir_for_build(TEMPDIR) # Run the tests in a context manager that temporary changes the CWD to a # temporary and writable directory. If it's not possible to create or # change the CWD, the original CWD will be used. The original CWD is # available from support.SAVEDCWD. with support.temp_cwd(TESTCWD, quiet=True): main()
agpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1548, 19, 14, 19, 199, 199, 624, 199, 7692, 26, 199, 199, 1548, 446, 77, 511, 359, 1419, 61, 359, 396, 63, 354, 17, 359, 396, 63, 354, 18, 2263, 2677, 199, 1548, 931, 15, 475, 15, 4728, 15, 396, 15, 1135, 82, 396, 14, 647, 359, 1419, 61, 359, 396, 63, 354, 17, 359, 396, 63, 354, 18, 2263, 2677, 421, 199, 3917, 949, 2368, 503, 1511, 787, 2741, 12, 17651, 1006, 1584, 4877, 199, 1589, 3851, 298, 396, 63, 12469, 315, 314, 8003, 15, 396, 25094, 436, 7858, 199, 1589, 77, 315, 23331, 3294, 1865, 334, 7911, 1937, 446, 45, 436, 446, 85, 12, 5084, 12, 367, 4967, 680, 199, 199, 1858, 1655, 8012, 2904, 1785, 5343, 12, 652, 365, 2997, 370, 675, 314, 2569, 199, 1531, 1004, 26, 199, 199, 1548, 446, 37, 446, 55, 68, 446, 77, 511, 359, 1419, 61, 359, 396, 63, 354, 17, 21214, 421, 199, 4558, 26, 199, 199, 13, 72, 25695, 3437, 755, 1553, 870, 642, 1318, 436, 4458, 199, 306, 2593, 29998, 355, 1553, 5461, 314, 5190, 436, 4458, 340, 282, 511, 6181, 1655, 673, 2419, 29998, 4696, 27, 6980, 340, 29998, 365, 6946, 673, 503, 18527, 370, 4697, 199, 306, 2573, 3515, 1553, 3618, 367, 922, 1324, 12, 325, 14, 71, 2020, 2040, 282, 14958, 370, 506, 10102, 199, 199, 3673, 5947, 199, 199, 13, 86, 25695, 3832, 259, 1553, 1255, 2295, 315, 3376, 818, 543, 1072, 370, 3839, 199, 13, 87, 25695, 3832, 18, 257, 1553, 295, 13, 1065, 3405, 2295, 315, 3376, 818, 199, 13, 55, 25695, 3832, 19, 257, 1553, 2929, 511, 1072, 641, 5988, 199, 13, 68, 25695, 1757, 420, 1553, 870, 5190, 367, 3405, 2295, 199, 13, 81, 25695, 10243, 420, 1553, 949, 1072, 7444, 1373, 503, 1655, 2295, 2449, 199, 13, 79, 25695, 14362, 755, 1553, 870, 314, 11999, 597, 1616, 2295, 2043, 1553, 1291, 258, 1553, 870, 1406, 543, 12693, 2256, 199, 199, 5446, 316, 2295, 199, 199, 13, 82, 25695, 28610, 221, 1553, 2196, 794, 511, 6451, 1865, 334, 3239, 5084, 9, 2043, 1553, 3759, 5176, 257, 1553, 986, 282, 2196, 6347, 370, 9172, 282, 4136, 2196, 1255, 199, 13, 70, 25695, 30717, 257, 1553, 1586, 1561, 402, 2295, 370, 1255, 687, 282, 570, 334, 3239, 5084, 9, 199, 13, 88, 25695, 5473, 259, 1553, 2368, 787, 2295, 370, 627, 5473, 10, 199, 13, 83, 25695, 4780, 258, 1553, 2849, 3650, 4012, 282, 663, 402, 2295, 334, 3239, 5084, 9, 199, 13, 77, 25695, 1431, 31467, 221, 1553, 1336, 511, 5560, 436, 3102, 543, 5739, 3851, 31467, 199, 13, 39, 25695, 25829, 257, 1553, 2449, 465, 18930, 465, 282, 511, 6918, 334, 2118, 543, 446, 86, 503, 446, 55, 9, 199, 13, 85, 25695, 1180, 12565, 17, 12, 3830, 18, 12, 1396, 355, 1553, 4165, 1314, 4539, 2073, 315, 724, 3398, 2295, 370, 1255, 199, 13, 45, 25695, 5286, 3097, 5138, 355, 1553, 1255, 7437, 7031, 4402, 13, 388, 26745, 2295, 2043, 1553, 16634, 19253, 355, 1553, 5341, 511, 1584, 315, 314, 2013, 2082, 334, 23145, 673, 402, 314, 2018, 26678, 511, 5241, 9, 199, 199, 12246, 7858, 199, 199, 13, 76, 25695, 1623, 28477, 221, 1553, 340, 31555, 365, 2808, 9696, 2295, 626, 25831, 4402, 199, 13, 44, 25695, 1065, 28477, 257, 1553, 1255, 314, 1026, 14631, 8, 17, 9, 1414, 2951, 2544, 4458, 199, 13, 50, 25695, 72, 324, 454, 28477, 21277, 8760, 51, 355, 1553, 2754, 367, 3659, 1026, 14631, 334, 10065, 3105, 1900, 12, 373, 14, 11999, 9, 199, 13, 74, 25695, 3029, 1412, 3611, 35, 1608, 654, 355, 1553, 1255, 3611, 35, 1608, 654, 10358, 737, 5403, 199, 13, 52, 25695, 10828, 257, 1553, 7485, 641, 1233, 11745, 23465, 1808, 314, 3307, 859, 199, 13, 36, 25695, 5899, 694, 8703, 5347, 355, 1553, 15191, 2382, 11745, 1584, 787, 5324, 199, 13, 46, 25695, 889, 5899, 694, 1553, 16280, 11745, 1584, 3180, 2441, 4621, 199, 13, 84, 25695, 7227, 4221, 15098, 5104, 355, 1553, 1240, 9486, 14, 409, 63, 7227, 8, 19307, 9, 199, 13, 78, 25695, 2131, 3206, 221, 1553, 15678, 1125, 1245, 17193, 641, 5417, 199, 13, 38, 25695, 21327, 259, 1553, 1255, 314, 2013, 2295, 315, 282, 4438, 12, 5133, 376, 1125, 10986, 421, 199, 8824, 3207, 15621, 26, 199, 199, 13, 82, 2196, 6491, 511, 6451, 1865, 14, 2047, 883, 675, 1553, 3759, 5176, 29, 442, 370, 5647, 282, 199, 442, 6347, 574, 367, 314, 2196, 1793, 27, 642, 365, 2997, 367, 295, 496, 14713, 29616, 3972, 199, 396, 15460, 14, 199, 199, 13, 83, 4068, 314, 1642, 19569, 402, 1295, 82, 396, 1808, 446, 83, 12, 314, 1642, 511, 570, 1911, 199, 269, 314, 1642, 511, 570, 1627, 641, 314, 1414, 1004, 365, 1255, 12, 436, 314, 536, 402, 199, 1589, 2163, 511, 365, 18894, 315, 282, 570, 4310, 1134, 2184, 396, 14, 221, 982, 1255, 687, 314, 199, 4718, 1900, 2082, 12, 1134, 2184, 396, 365, 16180, 315, 314, 283, 1506, 7, 25094, 12, 199, 26617, 652, 365, 16180, 315, 5549, 14, 31572, 1252, 221, 4068, 13372, 7858, 12, 199, 1589, 511, 315, 1134, 2184, 396, 365, 1255, 12, 436, 314, 2163, 511, 365, 5313, 370, 1134, 2184, 396, 14, 199, 11423, 314, 2061, 511, 965, 2757, 1255, 12, 1134, 2184, 396, 365, 5463, 14, 221, 1010, 642, 4340, 652, 199, 374, 3962, 370, 2849, 3650, 4012, 314, 511, 1584, 14, 221, 961, 365, 2997, 1380, 199, 1117, 316, 4402, 11284, 641, 314, 2018, 12693, 12, 1314, 2112, 16685, 795, 370, 199, 10235, 4634, 5002, 5944, 370, 1255, 314, 2615, 10864, 511, 2222, 13, 2379, 14, 199, 199, 13, 51, 365, 1202, 370, 1980, 3879, 2295, 2410, 376, 26815, 1255, 14, 221, 2779, 911, 199, 20180, 314, 1865, 282, 4465, 1255, 334, 1873, 12, 642, 15194, 446, 82, 365, 440, 1202, 680, 199, 2765, 365, 2997, 2410, 314, 2295, 1172, 876, 19925, 590, 15248, 367, 2005, 5957, 199, 5764, 436, 1265, 2934, 370, 1343, 3879, 687, 2382, 1265, 3602, 2331, 7830, 199, 13797, 6617, 687, 314, 9608, 14, 199, 199, 13, 70, 11597, 314, 1561, 402, 2295, 687, 314, 570, 1627, 465, 289, 1159, 1423, 12, 1373, 199, 269 ]
[ 1182, 2647, 15, 1393, 15, 1548, 19, 14, 19, 199, 199, 624, 199, 7692, 26, 199, 199, 1548, 446, 77, 511, 359, 1419, 61, 359, 396, 63, 354, 17, 359, 396, 63, 354, 18, 2263, 2677, 199, 1548, 931, 15, 475, 15, 4728, 15, 396, 15, 1135, 82, 396, 14, 647, 359, 1419, 61, 359, 396, 63, 354, 17, 359, 396, 63, 354, 18, 2263, 2677, 421, 199, 3917, 949, 2368, 503, 1511, 787, 2741, 12, 17651, 1006, 1584, 4877, 199, 1589, 3851, 298, 396, 63, 12469, 315, 314, 8003, 15, 396, 25094, 436, 7858, 199, 1589, 77, 315, 23331, 3294, 1865, 334, 7911, 1937, 446, 45, 436, 446, 85, 12, 5084, 12, 367, 4967, 680, 199, 199, 1858, 1655, 8012, 2904, 1785, 5343, 12, 652, 365, 2997, 370, 675, 314, 2569, 199, 1531, 1004, 26, 199, 199, 1548, 446, 37, 446, 55, 68, 446, 77, 511, 359, 1419, 61, 359, 396, 63, 354, 17, 21214, 421, 199, 4558, 26, 199, 199, 13, 72, 25695, 3437, 755, 1553, 870, 642, 1318, 436, 4458, 199, 306, 2593, 29998, 355, 1553, 5461, 314, 5190, 436, 4458, 340, 282, 511, 6181, 1655, 673, 2419, 29998, 4696, 27, 6980, 340, 29998, 365, 6946, 673, 503, 18527, 370, 4697, 199, 306, 2573, 3515, 1553, 3618, 367, 922, 1324, 12, 325, 14, 71, 2020, 2040, 282, 14958, 370, 506, 10102, 199, 199, 3673, 5947, 199, 199, 13, 86, 25695, 3832, 259, 1553, 1255, 2295, 315, 3376, 818, 543, 1072, 370, 3839, 199, 13, 87, 25695, 3832, 18, 257, 1553, 295, 13, 1065, 3405, 2295, 315, 3376, 818, 199, 13, 55, 25695, 3832, 19, 257, 1553, 2929, 511, 1072, 641, 5988, 199, 13, 68, 25695, 1757, 420, 1553, 870, 5190, 367, 3405, 2295, 199, 13, 81, 25695, 10243, 420, 1553, 949, 1072, 7444, 1373, 503, 1655, 2295, 2449, 199, 13, 79, 25695, 14362, 755, 1553, 870, 314, 11999, 597, 1616, 2295, 2043, 1553, 1291, 258, 1553, 870, 1406, 543, 12693, 2256, 199, 199, 5446, 316, 2295, 199, 199, 13, 82, 25695, 28610, 221, 1553, 2196, 794, 511, 6451, 1865, 334, 3239, 5084, 9, 2043, 1553, 3759, 5176, 257, 1553, 986, 282, 2196, 6347, 370, 9172, 282, 4136, 2196, 1255, 199, 13, 70, 25695, 30717, 257, 1553, 1586, 1561, 402, 2295, 370, 1255, 687, 282, 570, 334, 3239, 5084, 9, 199, 13, 88, 25695, 5473, 259, 1553, 2368, 787, 2295, 370, 627, 5473, 10, 199, 13, 83, 25695, 4780, 258, 1553, 2849, 3650, 4012, 282, 663, 402, 2295, 334, 3239, 5084, 9, 199, 13, 77, 25695, 1431, 31467, 221, 1553, 1336, 511, 5560, 436, 3102, 543, 5739, 3851, 31467, 199, 13, 39, 25695, 25829, 257, 1553, 2449, 465, 18930, 465, 282, 511, 6918, 334, 2118, 543, 446, 86, 503, 446, 55, 9, 199, 13, 85, 25695, 1180, 12565, 17, 12, 3830, 18, 12, 1396, 355, 1553, 4165, 1314, 4539, 2073, 315, 724, 3398, 2295, 370, 1255, 199, 13, 45, 25695, 5286, 3097, 5138, 355, 1553, 1255, 7437, 7031, 4402, 13, 388, 26745, 2295, 2043, 1553, 16634, 19253, 355, 1553, 5341, 511, 1584, 315, 314, 2013, 2082, 334, 23145, 673, 402, 314, 2018, 26678, 511, 5241, 9, 199, 199, 12246, 7858, 199, 199, 13, 76, 25695, 1623, 28477, 221, 1553, 340, 31555, 365, 2808, 9696, 2295, 626, 25831, 4402, 199, 13, 44, 25695, 1065, 28477, 257, 1553, 1255, 314, 1026, 14631, 8, 17, 9, 1414, 2951, 2544, 4458, 199, 13, 50, 25695, 72, 324, 454, 28477, 21277, 8760, 51, 355, 1553, 2754, 367, 3659, 1026, 14631, 334, 10065, 3105, 1900, 12, 373, 14, 11999, 9, 199, 13, 74, 25695, 3029, 1412, 3611, 35, 1608, 654, 355, 1553, 1255, 3611, 35, 1608, 654, 10358, 737, 5403, 199, 13, 52, 25695, 10828, 257, 1553, 7485, 641, 1233, 11745, 23465, 1808, 314, 3307, 859, 199, 13, 36, 25695, 5899, 694, 8703, 5347, 355, 1553, 15191, 2382, 11745, 1584, 787, 5324, 199, 13, 46, 25695, 889, 5899, 694, 1553, 16280, 11745, 1584, 3180, 2441, 4621, 199, 13, 84, 25695, 7227, 4221, 15098, 5104, 355, 1553, 1240, 9486, 14, 409, 63, 7227, 8, 19307, 9, 199, 13, 78, 25695, 2131, 3206, 221, 1553, 15678, 1125, 1245, 17193, 641, 5417, 199, 13, 38, 25695, 21327, 259, 1553, 1255, 314, 2013, 2295, 315, 282, 4438, 12, 5133, 376, 1125, 10986, 421, 199, 8824, 3207, 15621, 26, 199, 199, 13, 82, 2196, 6491, 511, 6451, 1865, 14, 2047, 883, 675, 1553, 3759, 5176, 29, 442, 370, 5647, 282, 199, 442, 6347, 574, 367, 314, 2196, 1793, 27, 642, 365, 2997, 367, 295, 496, 14713, 29616, 3972, 199, 396, 15460, 14, 199, 199, 13, 83, 4068, 314, 1642, 19569, 402, 1295, 82, 396, 1808, 446, 83, 12, 314, 1642, 511, 570, 1911, 199, 269, 314, 1642, 511, 570, 1627, 641, 314, 1414, 1004, 365, 1255, 12, 436, 314, 536, 402, 199, 1589, 2163, 511, 365, 18894, 315, 282, 570, 4310, 1134, 2184, 396, 14, 221, 982, 1255, 687, 314, 199, 4718, 1900, 2082, 12, 1134, 2184, 396, 365, 16180, 315, 314, 283, 1506, 7, 25094, 12, 199, 26617, 652, 365, 16180, 315, 5549, 14, 31572, 1252, 221, 4068, 13372, 7858, 12, 199, 1589, 511, 315, 1134, 2184, 396, 365, 1255, 12, 436, 314, 2163, 511, 365, 5313, 370, 1134, 2184, 396, 14, 199, 11423, 314, 2061, 511, 965, 2757, 1255, 12, 1134, 2184, 396, 365, 5463, 14, 221, 1010, 642, 4340, 652, 199, 374, 3962, 370, 2849, 3650, 4012, 314, 511, 1584, 14, 221, 961, 365, 2997, 1380, 199, 1117, 316, 4402, 11284, 641, 314, 2018, 12693, 12, 1314, 2112, 16685, 795, 370, 199, 10235, 4634, 5002, 5944, 370, 1255, 314, 2615, 10864, 511, 2222, 13, 2379, 14, 199, 199, 13, 51, 365, 1202, 370, 1980, 3879, 2295, 2410, 376, 26815, 1255, 14, 221, 2779, 911, 199, 20180, 314, 1865, 282, 4465, 1255, 334, 1873, 12, 642, 15194, 446, 82, 365, 440, 1202, 680, 199, 2765, 365, 2997, 2410, 314, 2295, 1172, 876, 19925, 590, 15248, 367, 2005, 5957, 199, 5764, 436, 1265, 2934, 370, 1343, 3879, 687, 2382, 1265,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